Loading core/java/android/bluetooth/BluetoothHeadset.java +10 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.compat.annotation.UnsupportedAppUsage; import android.content.AttributionSource; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.os.Binder; import android.os.Build; import android.os.Handler; Loading Loading @@ -365,6 +366,15 @@ public final class BluetoothHeadset implements BluetoothProfile { mAdapter = adapter; mAttributionSource = adapter.getAttributionSource(); // Preserve legacy compatibility where apps were depending on // registerStateChangeCallback() performing a permissions check which // has been relaxed in modern platform versions if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.R && context.checkSelfPermission(android.Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Need BLUETOOTH permission"); } IBluetoothManager mgr = mAdapter.getBluetoothManager(); if (mgr != null) { try { Loading core/java/android/bluetooth/BluetoothPbap.java +11 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.os.Build; import android.os.IBinder; import android.os.RemoteException; Loading Loading @@ -136,6 +137,16 @@ public class BluetoothPbap implements BluetoothProfile { mServiceListener = l; mAdapter = adapter; mAttributionSource = adapter.getAttributionSource(); // Preserve legacy compatibility where apps were depending on // registerStateChangeCallback() performing a permissions check which // has been relaxed in modern platform versions if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.R && context.checkSelfPermission(android.Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Need BLUETOOTH permission"); } IBluetoothManager mgr = mAdapter.getBluetoothManager(); if (mgr != null) { try { Loading core/java/android/bluetooth/BluetoothProfileConnector.java +12 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.os.Build; import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; Loading Loading @@ -123,6 +125,16 @@ public abstract class BluetoothProfileConnector<T> { mContext = context; mServiceListener = listener; IBluetoothManager mgr = BluetoothAdapter.getDefaultAdapter().getBluetoothManager(); // Preserve legacy compatibility where apps were depending on // registerStateChangeCallback() performing a permissions check which // has been relaxed in modern platform versions if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.R && context.checkSelfPermission(android.Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Need BLUETOOTH permission"); } if (mgr != null) { try { mgr.registerStateChangeCallback(mBluetoothStateChangeCallback); Loading Loading
core/java/android/bluetooth/BluetoothHeadset.java +10 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.compat.annotation.UnsupportedAppUsage; import android.content.AttributionSource; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.os.Binder; import android.os.Build; import android.os.Handler; Loading Loading @@ -365,6 +366,15 @@ public final class BluetoothHeadset implements BluetoothProfile { mAdapter = adapter; mAttributionSource = adapter.getAttributionSource(); // Preserve legacy compatibility where apps were depending on // registerStateChangeCallback() performing a permissions check which // has been relaxed in modern platform versions if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.R && context.checkSelfPermission(android.Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Need BLUETOOTH permission"); } IBluetoothManager mgr = mAdapter.getBluetoothManager(); if (mgr != null) { try { Loading
core/java/android/bluetooth/BluetoothPbap.java +11 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.os.Build; import android.os.IBinder; import android.os.RemoteException; Loading Loading @@ -136,6 +137,16 @@ public class BluetoothPbap implements BluetoothProfile { mServiceListener = l; mAdapter = adapter; mAttributionSource = adapter.getAttributionSource(); // Preserve legacy compatibility where apps were depending on // registerStateChangeCallback() performing a permissions check which // has been relaxed in modern platform versions if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.R && context.checkSelfPermission(android.Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Need BLUETOOTH permission"); } IBluetoothManager mgr = mAdapter.getBluetoothManager(); if (mgr != null) { try { Loading
core/java/android/bluetooth/BluetoothProfileConnector.java +12 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.os.Build; import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; Loading Loading @@ -123,6 +125,16 @@ public abstract class BluetoothProfileConnector<T> { mContext = context; mServiceListener = listener; IBluetoothManager mgr = BluetoothAdapter.getDefaultAdapter().getBluetoothManager(); // Preserve legacy compatibility where apps were depending on // registerStateChangeCallback() performing a permissions check which // has been relaxed in modern platform versions if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.R && context.checkSelfPermission(android.Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Need BLUETOOTH permission"); } if (mgr != null) { try { mgr.registerStateChangeCallback(mBluetoothStateChangeCallback); Loading