Loading src/com/android/settings/bluetooth/BluetoothPairingRequest.java +1 −3 Original line number Diff line number Diff line Loading @@ -50,10 +50,8 @@ public final class BluetoothPairingRequest extends BroadcastReceiver { PowerManager powerManager = context.getSystemService(PowerManager.class); int pairingVariant = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.ERROR); String deviceAddress = device != null ? device.getAddress() : null; String deviceName = device != null ? device.getName() : null; boolean shouldShowDialog = LocalBluetoothPreferences.shouldShowDialogInForeground( context, deviceAddress, deviceName); context, device); // Skips consent pairing dialog if the device was recently associated with CDM if (pairingVariant == BluetoothDevice.PAIRING_VARIANT_CONSENT Loading src/com/android/settings/bluetooth/BluetoothPermissionRequest.java +1 −3 Original line number Diff line number Diff line Loading @@ -108,8 +108,6 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { mRequestType); connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice); String deviceAddress = mDevice != null ? mDevice.getAddress() : null; String deviceName = mDevice != null ? mDevice.getName() : null; String title = null; String message = null; PowerManager powerManager = Loading @@ -117,7 +115,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { if (powerManager.isScreenOn() && LocalBluetoothPreferences.shouldShowDialogInForeground( context, deviceAddress, deviceName)) { context, mDevice)) { context.startActivity(connectionAccessIntent); } else { // Put up a notification that leads to the dialog Loading src/com/android/settings/bluetooth/LocalBluetoothPreferences.java +20 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,10 @@ package com.android.settings.bluetooth; import android.annotation.Nullable; import android.app.ActivityManager; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; Loading Loading @@ -57,8 +60,9 @@ final class LocalBluetoothPreferences { KEY_DISCOVERABLE_END_TIMESTAMP, 0); } static boolean shouldShowDialogInForeground(Context context, String deviceAddress, String deviceName) { static boolean shouldShowDialogInForeground(Context context, @Nullable BluetoothDevice device) { String deviceAddress = device != null ? device.getAddress() : null; String deviceName = device != null ? device.getName() : null; LocalBluetoothManager manager = Utils.getLocalBtManager(context); if (manager == null) { if (DEBUG) Log.v(TAG, "manager == null - do not show dialog."); Loading Loading @@ -126,6 +130,20 @@ final class LocalBluetoothPreferences { } } if (device != null) { ActivityManager activityManager = context.getSystemService(ActivityManager.class); String packageName = device.getCreateBondCaller(); if (packageName != null && activityManager.getPackageImportance(packageName) == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { if (DEBUG) { Log.v(TAG, "showing dialog because the initiating application " + "is in foreground"); } return true; } } if (DEBUG) Log.v(TAG, "Found no reason to show the dialog - do not show dialog."); return false; } Loading Loading
src/com/android/settings/bluetooth/BluetoothPairingRequest.java +1 −3 Original line number Diff line number Diff line Loading @@ -50,10 +50,8 @@ public final class BluetoothPairingRequest extends BroadcastReceiver { PowerManager powerManager = context.getSystemService(PowerManager.class); int pairingVariant = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.ERROR); String deviceAddress = device != null ? device.getAddress() : null; String deviceName = device != null ? device.getName() : null; boolean shouldShowDialog = LocalBluetoothPreferences.shouldShowDialogInForeground( context, deviceAddress, deviceName); context, device); // Skips consent pairing dialog if the device was recently associated with CDM if (pairingVariant == BluetoothDevice.PAIRING_VARIANT_CONSENT Loading
src/com/android/settings/bluetooth/BluetoothPermissionRequest.java +1 −3 Original line number Diff line number Diff line Loading @@ -108,8 +108,6 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { mRequestType); connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice); String deviceAddress = mDevice != null ? mDevice.getAddress() : null; String deviceName = mDevice != null ? mDevice.getName() : null; String title = null; String message = null; PowerManager powerManager = Loading @@ -117,7 +115,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { if (powerManager.isScreenOn() && LocalBluetoothPreferences.shouldShowDialogInForeground( context, deviceAddress, deviceName)) { context, mDevice)) { context.startActivity(connectionAccessIntent); } else { // Put up a notification that leads to the dialog Loading
src/com/android/settings/bluetooth/LocalBluetoothPreferences.java +20 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,10 @@ package com.android.settings.bluetooth; import android.annotation.Nullable; import android.app.ActivityManager; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; Loading Loading @@ -57,8 +60,9 @@ final class LocalBluetoothPreferences { KEY_DISCOVERABLE_END_TIMESTAMP, 0); } static boolean shouldShowDialogInForeground(Context context, String deviceAddress, String deviceName) { static boolean shouldShowDialogInForeground(Context context, @Nullable BluetoothDevice device) { String deviceAddress = device != null ? device.getAddress() : null; String deviceName = device != null ? device.getName() : null; LocalBluetoothManager manager = Utils.getLocalBtManager(context); if (manager == null) { if (DEBUG) Log.v(TAG, "manager == null - do not show dialog."); Loading Loading @@ -126,6 +130,20 @@ final class LocalBluetoothPreferences { } } if (device != null) { ActivityManager activityManager = context.getSystemService(ActivityManager.class); String packageName = device.getCreateBondCaller(); if (packageName != null && activityManager.getPackageImportance(packageName) == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { if (DEBUG) { Log.v(TAG, "showing dialog because the initiating application " + "is in foreground"); } return true; } } if (DEBUG) Log.v(TAG, "Found no reason to show the dialog - do not show dialog."); return false; } Loading