Make BluetoothAdapter#disable(boolean persist) a @SystemApi am: 8dafa60a2f am: 7db301321d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15960228 Change-Id: Ib97e835bdb2be865f26c1f63d68e25b204e12aa0
This commit is contained in:
@@ -1937,6 +1937,7 @@ package android.bluetooth {
|
|||||||
|
|
||||||
public final class BluetoothAdapter {
|
public final class BluetoothAdapter {
|
||||||
method @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public boolean addOnMetadataChangedListener(@NonNull android.bluetooth.BluetoothDevice, @NonNull java.util.concurrent.Executor, @NonNull android.bluetooth.BluetoothAdapter.OnMetadataChangedListener);
|
method @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public boolean addOnMetadataChangedListener(@NonNull android.bluetooth.BluetoothDevice, @NonNull java.util.concurrent.Executor, @NonNull android.bluetooth.BluetoothAdapter.OnMetadataChangedListener);
|
||||||
|
method @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public boolean disable(boolean);
|
||||||
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean disableBLE();
|
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean disableBLE();
|
||||||
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean enableBLE();
|
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean enableBLE();
|
||||||
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean enableNoAutoConnect();
|
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean enableNoAutoConnect();
|
||||||
|
|||||||
@@ -1245,13 +1245,17 @@ public final class BluetoothAdapter {
|
|||||||
/**
|
/**
|
||||||
* Turn off the local Bluetooth adapter and don't persist the setting.
|
* Turn off the local Bluetooth adapter and don't persist the setting.
|
||||||
*
|
*
|
||||||
|
* @param persist Indicate whether the off state should be persisted following the next reboot
|
||||||
* @return true to indicate adapter shutdown has begun, or false on immediate error
|
* @return true to indicate adapter shutdown has begun, or false on immediate error
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@UnsupportedAppUsage(trackingBug = 171933273)
|
@SystemApi
|
||||||
@RequiresLegacyBluetoothAdminPermission
|
@RequiresLegacyBluetoothAdminPermission
|
||||||
@RequiresBluetoothConnectPermission
|
@RequiresBluetoothConnectPermission
|
||||||
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
|
@RequiresPermission(allOf = {
|
||||||
|
android.Manifest.permission.BLUETOOTH_CONNECT,
|
||||||
|
android.Manifest.permission.BLUETOOTH_PRIVILEGED,
|
||||||
|
})
|
||||||
public boolean disable(boolean persist) {
|
public boolean disable(boolean persist) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1154,6 +1154,11 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
|
|
||||||
public boolean disable(AttributionSource attributionSource, boolean persist)
|
public boolean disable(AttributionSource attributionSource, boolean persist)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
if (!persist) {
|
||||||
|
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED,
|
||||||
|
"Need BLUETOOTH_PRIVILEGED permission");
|
||||||
|
}
|
||||||
|
|
||||||
final String packageName = attributionSource.getPackageName();
|
final String packageName = attributionSource.getPackageName();
|
||||||
if (!checkBluetoothPermissions(attributionSource, "disable", true)) {
|
if (!checkBluetoothPermissions(attributionSource, "disable", true)) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
@@ -2599,7 +2604,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
intent.putExtra(BluetoothAdapter.EXTRA_PREVIOUS_STATE, prevState);
|
intent.putExtra(BluetoothAdapter.EXTRA_PREVIOUS_STATE, prevState);
|
||||||
intent.putExtra(BluetoothAdapter.EXTRA_STATE, newState);
|
intent.putExtra(BluetoothAdapter.EXTRA_STATE, newState);
|
||||||
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
||||||
mContext.sendBroadcastAsUser(intent, UserHandle.ALL, null,
|
mContext.sendBroadcastAsUser(intent, UserHandle.ALL, null,
|
||||||
getTempAllowlistBroadcastOptions());
|
getTempAllowlistBroadcastOptions());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user