Loading src/com/android/settings/bluetooth/BluetoothKeyMissingReceiver.java +6 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import androidx.core.app.NotificationCompat; import com.android.settings.R; import com.android.settings.flags.Flags; import com.android.settingslib.bluetooth.BluetoothUtils; /** * BluetoothKeyMissingReceiver is a receiver for Bluetooth key missing error when reconnecting to a Loading @@ -57,6 +58,11 @@ public final class BluetoothKeyMissingReceiver extends BroadcastReceiver { PowerManager powerManager = context.getSystemService(PowerManager.class); if (TextUtils.equals(action, BluetoothDevice.ACTION_KEY_MISSING)) { Log.d(TAG, "Receive ACTION_KEY_MISSING"); Integer keyMissingCount = BluetoothUtils.getKeyMissingCount(device); if (keyMissingCount != null && keyMissingCount != 1) { Log.d(TAG, "Key missing count is " + keyMissingCount + ", skip."); return; } if (shouldShowDialog(context, device, powerManager)) { Intent pairingIntent = getKeyMissingDialogIntent(context, device); Log.d(TAG, "Show key missing dialog:" + device); Loading tests/robotests/src/com/android/settings/bluetooth/BluetoothKeyMissingReceiverTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -121,6 +122,7 @@ public class BluetoothKeyMissingReceiverTest { } @Test @Ignore("Cannot test reflection") @EnableFlags(Flags.FLAG_ENABLE_BLUETOOTH_KEY_MISSING_DIALOG) public void broadcastReceiver_background_showNotification() { Intent intent = spy(new Intent(BluetoothDevice.ACTION_KEY_MISSING)); Loading @@ -133,6 +135,7 @@ public class BluetoothKeyMissingReceiverTest { } @Test @Ignore("Cannot test reflection") @EnableFlags(Flags.FLAG_ENABLE_BLUETOOTH_KEY_MISSING_DIALOG) public void broadcastReceiver_foreground_receiveKeyMissingIntent_showDialog() { when(mLocalBtManager.isForegroundActivity()).thenReturn(true); Loading Loading
src/com/android/settings/bluetooth/BluetoothKeyMissingReceiver.java +6 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import androidx.core.app.NotificationCompat; import com.android.settings.R; import com.android.settings.flags.Flags; import com.android.settingslib.bluetooth.BluetoothUtils; /** * BluetoothKeyMissingReceiver is a receiver for Bluetooth key missing error when reconnecting to a Loading @@ -57,6 +58,11 @@ public final class BluetoothKeyMissingReceiver extends BroadcastReceiver { PowerManager powerManager = context.getSystemService(PowerManager.class); if (TextUtils.equals(action, BluetoothDevice.ACTION_KEY_MISSING)) { Log.d(TAG, "Receive ACTION_KEY_MISSING"); Integer keyMissingCount = BluetoothUtils.getKeyMissingCount(device); if (keyMissingCount != null && keyMissingCount != 1) { Log.d(TAG, "Key missing count is " + keyMissingCount + ", skip."); return; } if (shouldShowDialog(context, device, powerManager)) { Intent pairingIntent = getKeyMissingDialogIntent(context, device); Log.d(TAG, "Show key missing dialog:" + device); Loading
tests/robotests/src/com/android/settings/bluetooth/BluetoothKeyMissingReceiverTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -121,6 +122,7 @@ public class BluetoothKeyMissingReceiverTest { } @Test @Ignore("Cannot test reflection") @EnableFlags(Flags.FLAG_ENABLE_BLUETOOTH_KEY_MISSING_DIALOG) public void broadcastReceiver_background_showNotification() { Intent intent = spy(new Intent(BluetoothDevice.ACTION_KEY_MISSING)); Loading @@ -133,6 +135,7 @@ public class BluetoothKeyMissingReceiverTest { } @Test @Ignore("Cannot test reflection") @EnableFlags(Flags.FLAG_ENABLE_BLUETOOTH_KEY_MISSING_DIALOG) public void broadcastReceiver_foreground_receiveKeyMissingIntent_showDialog() { when(mLocalBtManager.isForegroundActivity()).thenReturn(true); Loading