dragon: DragonKeyboardFirmwareUpdater: Exclude the service other than the primary user
This CL adds a check to exclude the users other than the primary user from
invoking the update service and makes notification title navigate to the update
confirmation page.
Bug: 25831955, 26226972
TEST= build, check if the update notification pop up on the work profile, and
click on notification to see if it proceeds to the update confirmation page
Change-Id: I2667343ec666420e3d766d19393104d84e5c9f89
diff --git a/DragonKeyboardFirmwareUpdater/keyboard_firmware_updater/src/com/android/dragonkeyboardfirmwareupdater/BluetoothConnectionBroadcastReceiver.java b/DragonKeyboardFirmwareUpdater/keyboard_firmware_updater/src/com/android/dragonkeyboardfirmwareupdater/BluetoothConnectionBroadcastReceiver.java
index 7ea3b48..9f6f078 100644
--- a/DragonKeyboardFirmwareUpdater/keyboard_firmware_updater/src/com/android/dragonkeyboardfirmwareupdater/BluetoothConnectionBroadcastReceiver.java
+++ b/DragonKeyboardFirmwareUpdater/keyboard_firmware_updater/src/com/android/dragonkeyboardfirmwareupdater/BluetoothConnectionBroadcastReceiver.java
@@ -30,6 +30,12 @@
@Override
public void onReceive(Context context, Intent intent) {
+ // Only process if the current user is the primary user in order to avoid starting the
+ // update process on the work profile.
+ UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ if (!userManager.isSystemUser()) {
+ return;
+ }
if (!BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED.equals(intent.getAction())) return;
diff --git a/DragonKeyboardFirmwareUpdater/keyboard_firmware_updater/src/com/android/dragonkeyboardfirmwareupdater/KeyboardFirmwareUpdateService.java b/DragonKeyboardFirmwareUpdater/keyboard_firmware_updater/src/com/android/dragonkeyboardfirmwareupdater/KeyboardFirmwareUpdateService.java
index acaab9c..d286cf1 100644
--- a/DragonKeyboardFirmwareUpdater/keyboard_firmware_updater/src/com/android/dragonkeyboardfirmwareupdater/KeyboardFirmwareUpdateService.java
+++ b/DragonKeyboardFirmwareUpdater/keyboard_firmware_updater/src/com/android/dragonkeyboardfirmwareupdater/KeyboardFirmwareUpdateService.java
@@ -698,6 +698,7 @@
.setCategory(Notification.CATEGORY_SYSTEM)
.setContentTitle(getString(R.string.notification_update_title))
.setContentText(getString(R.string.notification_update_text))
+ .setContentIntent(installIntent)
.setSmallIcon(R.drawable.ic_keyboard)
.addAction(new NotificationCompat.Action.Builder(
R.drawable.ic_later, getString(R.string.notification_update_later),