Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qti-bt #8

Open
wants to merge 92 commits into
base: S
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
110c76a
core: jni: Switch to -O3
Nov 18, 2021
e628373
os: Process: Fix wrong code in isThreadInProcess
Mar 4, 2020
1c43054
SettingLib: Add deep sleep info to uptime preference
maxwen Sep 14, 2019
d39d6a3
Backport 'Add ability to disable GL draws'.
brettchabot May 21, 2021
6697506
Lazy load Properties::isDrawingEnabled.
brettchabot Jul 16, 2021
0d21909
display: Don't spam log when display state changes
adithya2306 Apr 14, 2021
d84d9ea
Updates to various icons:
dsandler Sep 13, 2019
38e9ce6
view: add null check for dispatch touch view
Oct 9, 2018
d598cde
frameworks: Fix null pointer Issue
Jun 4, 2017
3722150
Crash occured due to null pointer exception.
Oct 6, 2017
b84d6c3
ParcelFileDescriptor: Stop the panic
Nov 22, 2016
1331de6
Turn off some debugs
AndroidRul3z Nov 9, 2014
bb135cb
SystemUI: Redraw display cutout on overlay changes
adithya2306 Mar 4, 2021
01f9f4f
PowerUI: Mute logcat spam.
spezi77 Aug 24, 2021
882c7aa
Use new gradient dialog also for recovery/factory reset action
maxwen Dec 10, 2017
808ba14
SystemUI: Fix SystemUI Crash
Jul 7, 2017
a2934f8
base: Disable Remaining Debug
techyminati Mar 17, 2022
852f901
SystemUI: Show Bolt icon while charging.
imjyotiraditya Dec 17, 2020
c11eee7
base: PSSSSST! disable some DEBUG logspill
maxwen Oct 16, 2021
6d10e73
GpsNetInitiatedHandler: Disable more debugging
Cl3Kener Nov 19, 2014
1bf3492
SystemUI: PeopleSpaceWidgetManager: don't spam logcat
jhonboy121 Jan 22, 2022
f837d56
core: Give fresh look for Action Bar back arrow
herobuxx Mar 4, 2021
df0347d
SystemUI: Stop building NotoSerif font.
imjyotiraditya Dec 13, 2020
5c094c4
Fix daveys when latch_unsignaled is used
jreck Oct 18, 2021
42a4a41
Revert "hwui: JankTracer: Silence Davey logs for now"
adithya2306 May 30, 2022
a9b361f
Revert "base: Don't send interaction hint for unnecessary events"
adithya2306 May 27, 2022
8899ce4
SystemUI: Always refresh power menu on UI mode change
kdrag0n Mar 9, 2022
7e3e1aa
base: Fix location privacy indicator getting stuck
neobuddy89 Jan 17, 2022
fb5d472
core: Wipe package cache on upgrade even on user build
krasCGQ Apr 8, 2022
43882fb
SystemUI: fix MediaProjection cast crash
pawitp Dec 20, 2014
8089d39
Add BluetoothQualityReport class(1/2)
Jun 20, 2019
f9d0b9b
BT: Adding aptX-Adaptive codec entry to Framework
Jul 6, 2018
a578431
TWS-A2DP: Add TWS+ codec to DevUI support
Oct 4, 2018
3ebd903
Revert the change: AudioService: remove dead BT code.
Jun 19, 2019
03297d9
Bluetooth: Add SDK API support for TWS feature (2)
Mar 31, 2018
cea05bf
Bluetooth: Unpair both earbuds on unpair.
Apr 5, 2018
504378f
Bluetooth: Rename bluetooth property to support new P Treble rules
Jul 5, 2018
c516ffc
Bluetooth-TWS: Disable outgoing connection for 2nd earbud.
Aug 22, 2018
79aa546
Bluetooth-TWS: Disable outgoing connection to 2nd earbud
Oct 5, 2018
883848e
GAP: Reset bondingInitiatedLocally flag(1/3)
Jun 27, 2019
a3e54a9
BT: Send info if call is CS type from telecomm service to BT apps.
Feb 22, 2016
6c4ace7
Bluetooth: TWSP: Support Battery Status information display
May 3, 2019
3583f26
Add support for Transport discovery AD type (1/2)
Jun 24, 2018
201cd9e
Support CALLBACK_TYPE_SENSOR_ROUTING
May 10, 2018
687058d
Add scan filter for Transport Discovery data
Mar 1, 2019
da221d9
Obex: Squashed commit of the following
Feb 1, 2018
74ffc2a
GAP: Handle the race condition cases in auto connect logic
Mar 2, 2020
7e1cc75
Use BluetoothUtils instead of Utils
Aug 13, 2018
572a251
audio: Add support for audio extended codecs
Mar 20, 2019
06b06af
audio: Add support for APTX TWSP audio codec
Apr 18, 2019
096deba
TWS_A2DP: Handle active device change between TWS+ earbuds
May 9, 2019
f573374
BT_Audio: Updated Check for TWS+ switch
Jan 30, 2020
4512ab1
BT: Add new intent to broadcast IOT device details
Sep 6, 2017
0b9dbec
Bluetooth: Fix for Global reference table overflow issue[1/2]
Nov 8, 2017
7e60e48
BT Dev: Increase array size for codec selection in Dev Op
Sep 25, 2018
e41146c
Bluetooth: Fix for out of bound exception
Jul 24, 2019
baabb16
Keep a null check before accessing the BluetoothA2dpWrapper APIs.
Nov 6, 2018
1c70a6a
Enable codec change request when mode changes in aptX-adaptive
Aug 1, 2019
917c0ed
BT: Relocate A2DP codec strings for translation
moetayuko Jun 5, 2020
fae30aa
Fix BLE transport discovery scan filter
Mar 27, 2019
4d8736a
BLE: Fix NPE during start advertising
Aug 30, 2018
2729cc9
BT-Audio: Keep track of Active TWS+ EB device in BTHelper
Jul 3, 2020
508ff0a
Audio: Update current active bt device of mApmConnectedDevices.
Apr 2, 2020
3dfbd5f
Audio: use cached BT codec info during disconnecting
Feb 13, 2020
28ac1a9
Audio: Do not disconnect profiles till Bluetooth Off
Aug 28, 2019
b959dcf
Add callback onA2dpCodecConfigChanged
Aug 9, 2020
a3a7a2d
Bluetooth: Add APTX-Adaptive and APTX-TWS+ entries.
Sep 16, 2020
c9e0db7
Audio: Add support for lc3 codec.
Jul 20, 2020
c31cda5
Add LC3 codec type.
Oct 7, 2020
8cce8af
DeviceGroup: Framework changes for Group Device operations.
Jun 25, 2020
a5e385f
DeviceGroup: UI frameworks changes
Dec 3, 2020
32d6e96
DeviceGroup: Frameworks changes (for dual mode devices).
Oct 22, 2020
440a961
BT: API to update quiet mode status in Adapter service [2/3]
Oct 16, 2018
8c02afa
Bluetooth: Update Bluetooth permissions for internal APIS. (2/4)
Aug 24, 2021
32fc0cd
Periodic Advertisment Sync Transfer feature support
May 27, 2020
6db7e70
Revert "Matching codec index between frameworks and stack"
Mar 31, 2021
fd695f1
A2dpSrc: Align legacy codec enumeration with AOSP(4/7)
May 13, 2020
5c1696a
Add Broadcast profile id
Jan 11, 2021
c6fe92e
Bluetooth: Add BC profile entry
Dec 23, 2020
4a2d4ec
Bluetooth: Broadcast UI: Changes to existing files
Jan 15, 2021
8fb812f
Group-UI: UI frameworks changes
Oct 29, 2020
324d852
VCP: frameworks and settingsLib changes for VCP Profile
Nov 6, 2020
6861a6d
Update Bluetooth permissions for VCP APIS (1/3)
Sep 23, 2021
69b9b5e
BT: Add APIs to dynamically control Active profile
Sep 17, 2021
06600a7
hfp: define STATE_AUDIO_DISCONNECTING audio state
Jan 31, 2020
2384f60
Bluetooth: Add constructor for sending address type
Dec 10, 2020
2b5bafb
BLE: Add support for Group AD Type based scan filtering.
Sep 15, 2020
445cff9
BT: Add entry for MCP Service in Frameworks
Sep 22, 2021
a6a0f9b
Use BLUETOOTH_CONNECT permission instead of legacy permission
Sep 24, 2021
bb712de
AudioService: Music resumed to speaker after call
Jul 7, 2021
8a0dbfa
Check for a2dp profile when removing stale connection events
May 11, 2021
9d59e23
audio: Discard QTI only codecs when AOSP BT stack is in use
luk1337 Dec 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 203 additions & 0 deletions core/java/android/bluetooth/BluetoothAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
import java.util.concurrent.Executor;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.lang.reflect.Method;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
* Represents the local device Bluetooth adapter. The {@link BluetoothAdapter}
Expand Down Expand Up @@ -2004,6 +2007,22 @@ public boolean setActiveDevice(@NonNull BluetoothDevice device,
return false;
}

/** @hide */
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
public boolean isBroadcastActive() {
try {
mServiceLock.readLock().lock();
if (mService != null) {
return mService.isBroadcastActive(mAttributionSource);
}
} catch (RemoteException e) {
Log.e(TAG, "", e);
} finally {
mServiceLock.readLock().unlock();
}
return false;
}

/**
* Connects all enabled and supported bluetooth profiles between the local and remote device.
* Connection is asynchronous and you should listen to each profile's broadcast intent
Expand Down Expand Up @@ -2987,6 +3006,92 @@ public Pair<byte[], byte[]> readOutOfBandData() {
return null;
}

private void closeBCProfile(BluetoothProfile proxy) {
Class<?> bshClass = null;
Method bshClose = null;
try {
bshClass = Class.forName("android.bluetooth.BluetoothSyncHelper");
} catch (ClassNotFoundException ex) {
Log.e(TAG, "no BSH: exists");
bshClass = null;
}
if (bshClass != null) {
Log.d(TAG, "Able to get BSH class handle");
try {
bshClose = bshClass.getDeclaredMethod("close", null);
} catch (NoSuchMethodException e) {
Log.e(TAG, "no BSH:isSupported method exists");
}
if (bshClose != null) {
try {
bshClose.invoke(proxy, null);
} catch(IllegalAccessException e) {
Log.e(TAG, "bshClose IllegalAccessException");
} catch (InvocationTargetException e) {
Log.e(TAG, "bshClose InvocationTargetException");
}
}
}
Log.d(TAG, "CloseBCProfile returns");
}

private boolean getBCProfile(Context context, BluetoothProfile.ServiceListener sl) {
boolean ret = true;
boolean isProfileSupported = false;
Class<?> bshClass = null;
Method bshSupported = null;
Constructor bshCons = null;
Object bshObj = null;
try {
bshClass = Class.forName("android.bluetooth.BluetoothSyncHelper");
} catch (ClassNotFoundException ex) {
Log.e(TAG, "no BSH: exists");
bshClass = null;
}
if (bshClass != null) {
Log.d(TAG, "Able to get BSH class handle");
try {
bshSupported = bshClass.getDeclaredMethod("isSupported", null);
} catch (NoSuchMethodException e) {
Log.e(TAG, "no BSH:isSupported method exists: gdm");
}
try {
bshCons =
bshClass.getDeclaredConstructor(
new Class[]{Context.class,
BluetoothProfile.ServiceListener.class});
} catch (NoSuchMethodException ex) {
Log.e(TAG, "bshCons: NoSuchMethodException: gdm" + ex);
}
}
if (bshClass != null && bshSupported != null && bshCons != null) {
try {
isProfileSupported = (boolean)bshSupported.invoke(null, null);
} catch(IllegalAccessException e) {
Log.e(TAG, "BSH:isSupported IllegalAccessException");
} catch (InvocationTargetException e) {
Log.e(TAG, "BSH:isSupported InvocationTargetException");
}
if (isProfileSupported) {
try {
bshObj = bshCons.newInstance(
context, sl);
} catch (InstantiationException ex) {
Log.e(TAG, "bshCons InstantiationException:" + ex);
} catch (IllegalAccessException ex) {
Log.e(TAG, "bshCons InstantiationException:" + ex);
} catch (InvocationTargetException ex) {
Log.e(TAG, "bshCons InvocationTargetException:" + ex);
}
}
}
if (bshObj == null) {
ret = false;
}
Log.d(TAG, "getBCService returns" + ret);
return ret;
}

/**
* Get the profile proxy object associated with the profile.
*
Expand Down Expand Up @@ -3056,6 +3161,10 @@ public boolean getProfileProxy(Context context, BluetoothProfile.ServiceListener
} else if (profile == BluetoothProfile.HID_DEVICE) {
BluetoothHidDevice hidDevice = new BluetoothHidDevice(context, listener, this);
return true;
} else if (profile == BluetoothProfile.BROADCAST) {
return getBroadcastProfile(context, listener);
} else if (profile == BluetoothProfile.BC_PROFILE) {
return getBCProfile(context, listener);
} else if (profile == BluetoothProfile.HEARING_AID) {
if (isHearingAidProfileSupported()) {
BluetoothHearingAid hearingAid = new BluetoothHearingAid(context, listener, this);
Expand All @@ -3065,6 +3174,12 @@ public boolean getProfileProxy(Context context, BluetoothProfile.ServiceListener
} else if (profile == BluetoothProfile.LE_AUDIO) {
BluetoothLeAudio leAudio = new BluetoothLeAudio(context, listener, this);
return true;
} else if (profile == BluetoothProfile.GROUP_CLIENT) {
BluetoothDeviceGroup groupClient = new BluetoothDeviceGroup(context, listener);
return true;
} else if (profile == BluetoothProfile.VCP) {
BluetoothVcp vcp = new BluetoothVcp(context, listener);
return true;
} else {
return false;
}
Expand Down Expand Up @@ -3150,13 +3265,85 @@ public void closeProfileProxy(int profile, BluetoothProfile proxy) {
BluetoothHidDevice hidDevice = (BluetoothHidDevice) proxy;
hidDevice.close();
break;
case BluetoothProfile.BROADCAST:
closeBroadcastProfile(proxy);
break;
case BluetoothProfile.BC_PROFILE:
closeBCProfile(proxy);
break;
case BluetoothProfile.HEARING_AID:
BluetoothHearingAid hearingAid = (BluetoothHearingAid) proxy;
hearingAid.close();
break;
case BluetoothProfile.LE_AUDIO:
BluetoothLeAudio leAudio = (BluetoothLeAudio) proxy;
leAudio.close();
case BluetoothProfile.GROUP_CLIENT:
BluetoothDeviceGroup groupClient = (BluetoothDeviceGroup) proxy;
groupClient.close();
break;
case BluetoothProfile.VCP:
BluetoothVcp vcp = (BluetoothVcp) proxy;
vcp.close();
break;
}
}

private boolean getBroadcastProfile(Context context,
BluetoothProfile.ServiceListener listener) {
boolean ret = true;
Class<?> broadcastClass = null;
Constructor bcastConstructor = null;
Object broadcastObj = null;
try {
broadcastClass = Class.forName("android.bluetooth.BluetoothBroadcast");
} catch (ClassNotFoundException ex) {
Log.e(TAG, "no BluetoothBroadcast: exists");
}
if (broadcastClass != null) {
try {
bcastConstructor =
broadcastClass.getDeclaredConstructor(new Class[]{Context.class,
BluetoothProfile.ServiceListener.class});
} catch (NoSuchMethodException ex) {
Log.e(TAG, "bcastConstructor: NoSuchMethodException: gdm" + ex);
}
}
if (bcastConstructor != null) {
try {
broadcastObj = bcastConstructor.newInstance(context, listener);
} catch (InstantiationException | IllegalAccessException |
InvocationTargetException ex) {
ex.printStackTrace();
}
}
if (broadcastObj == null) {
return false;
}
return true;
}

private void closeBroadcastProfile(BluetoothProfile proxy) {
Class<?> broadcastClass = null;
Method broadcastClose = null;
try {
broadcastClass = Class.forName("android.bluetooth.BluetootBroadcast");
} catch (ClassNotFoundException ex) {
Log.e(TAG, "no BluetoothBroadcast: exists");
}
if (broadcastClass != null) {
try {
broadcastClose = broadcastClass.getDeclaredMethod("close", null);
} catch (NoSuchMethodException e) {
Log.e(TAG, "no Broadcast:close method exists");
}
if (broadcastClose != null) {
try {
broadcastClose.invoke(proxy, null);
} catch(IllegalAccessException | InvocationTargetException ex) {
ex.printStackTrace();
}
}
}
}

Expand Down Expand Up @@ -3497,6 +3684,22 @@ public void onBluetoothStateChange(boolean on) {
}
}

/**
* @hide
*/
public void unregisterAdapter() {
try {
//mServiceLock.writeLock().lock();
if (mManagerService != null){
mManagerService.unregisterAdapter(mManagerCallback);
}
} catch (RemoteException e) {
Log.e(TAG, "", e);
} finally {
//mServiceLock.writeLock().unlock();
}
}

private Set<BluetoothDevice> toDeviceSet(List<BluetoothDevice> devices) {
Set<BluetoothDevice> deviceSet = new HashSet<BluetoothDevice>(devices);
return Collections.unmodifiableSet(deviceSet);
Expand Down
5 changes: 5 additions & 0 deletions core/java/android/bluetooth/BluetoothClass.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ public static final class Service {
private static final int BITMASK = 0xFFE000;

public static final int LIMITED_DISCOVERABILITY = 0x002000;
/**
* @hide
*/
public static final int GROUP = 0x004000;

public static final int POSITIONING = 0x010000;
public static final int NETWORKING = 0x020000;
public static final int RENDER = 0x040000;
Expand Down
44 changes: 43 additions & 1 deletion core/java/android/bluetooth/BluetoothCodecConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public final class BluetoothCodecConfig implements Parcelable {
SOURCE_CODEC_TYPE_APTX,
SOURCE_CODEC_TYPE_APTX_HD,
SOURCE_CODEC_TYPE_LDAC,
SOURCE_CODEC_TYPE_MAX,
SOURCE_CODEC_TYPE_APTX_ADAPTIVE,
SOURCE_CODEC_TYPE_APTX_TWSP,
SOURCE_QVA_CODEC_TYPE_MAX,
SOURCE_CODEC_TYPE_INVALID
})
@Retention(RetentionPolicy.SOURCE)
Expand All @@ -70,6 +72,24 @@ public final class BluetoothCodecConfig implements Parcelable {
@UnsupportedAppUsage
public static final int SOURCE_CODEC_TYPE_MAX = 5;

@UnsupportedAppUsage
public static final int SOURCE_CODEC_TYPE_APTX_ADAPTIVE = SOURCE_CODEC_TYPE_MAX;

@UnsupportedAppUsage
public static final int SOURCE_CODEC_TYPE_APTX_TWSP = SOURCE_CODEC_TYPE_MAX + 1;

@UnsupportedAppUsage
public static final int SOURCE_QVA_CODEC_TYPE_MAX = SOURCE_CODEC_TYPE_MAX + 2;

/* CELT is not an A2DP Codec and only used to fetch encoder
** format for BA usecase, moving out of a2dp codec value list
*/
@UnsupportedAppUsage
public static final int SOURCE_CODEC_TYPE_CELT = 8;

@UnsupportedAppUsage
public static final int SOURCE_CODEC_TYPE_LC3 = 9;

@UnsupportedAppUsage
public static final int SOURCE_CODEC_TYPE_INVALID = 1000 * 1000;

Expand Down Expand Up @@ -126,6 +146,17 @@ public final class BluetoothCodecConfig implements Parcelable {
@UnsupportedAppUsage
public static final int SAMPLE_RATE_192000 = 0x1 << 5;

@UnsupportedAppUsage
public static final int SAMPLE_RATE_16000 = 0x1 << 6;

@UnsupportedAppUsage
public static final int SAMPLE_RATE_24000 = 0x1 << 7;

@UnsupportedAppUsage
public static final int SAMPLE_RATE_32000 = 0x1 << 8;

@UnsupportedAppUsage
public static final int SAMPLE_RATE_8000 = 0x1 << 9;

/** @hide */
@IntDef(prefix = "BITS_PER_SAMPLE_", value = {
Expand Down Expand Up @@ -168,6 +199,9 @@ public final class BluetoothCodecConfig implements Parcelable {
@UnsupportedAppUsage
public static final int CHANNEL_MODE_STEREO = 0x1 << 1;

@UnsupportedAppUsage
public static final int CHANNEL_MODE_JOINT_STEREO = 0x1 << 2;

private final @SourceCodecType int mCodecType;
private @CodecPriority int mCodecPriority;
private final @SampleRate int mSampleRate;
Expand Down Expand Up @@ -403,6 +437,10 @@ public void writeToParcel(Parcel out, int flags) {
return "aptX HD";
case SOURCE_CODEC_TYPE_LDAC:
return "LDAC";
case SOURCE_CODEC_TYPE_APTX_ADAPTIVE:
return "aptX Adaptive";
case SOURCE_CODEC_TYPE_APTX_TWSP:
return "aptX TWS+";
case SOURCE_CODEC_TYPE_INVALID:
return "INVALID CODEC";
default:
Expand Down Expand Up @@ -652,6 +690,10 @@ public boolean sameCodecSpecificParameters(BluetoothCodecConfig other) {
if (mCodecSpecific1 != other.mCodecSpecific1) {
return false;
}
case SOURCE_CODEC_TYPE_APTX_ADAPTIVE:
if (other.mCodecSpecific4 > 0) {
return false;
}
// fall through
default:
return true;
Expand Down
Loading