summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/res/res/values/strings.xml5
-rw-r--r--core/res/res/values/symbols.xml2
-rw-r--r--proto/src/system_messages.proto4
-rw-r--r--services/core/java/com/android/server/pm/UserManagerService.java48
4 files changed, 59 insertions, 0 deletions
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 7a166dac046e..9d1e86b7ecb9 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -3833,6 +3833,11 @@
<!-- Message of notification shown when Test Harness Mode is enabled. [CHAR LIMIT=NONE] -->
<string name="test_harness_mode_notification_message">Perform a factory reset to disable Test Harness Mode.</string>
+ <!-- Title of notification shown when device is in the wrong Headless System User Mode configuration. [CHAR LIMIT=NONE] -->
+ <string name="wrong_hsum_configuration_notification_title">Wrong HSUM build configuration</string>
+ <!-- Message of notification shown when device is in the wrong Headless System User Mode configuration. [CHAR LIMIT=NONE] -->
+ <string name="wrong_hsum_configuration_notification_message">The Headless System User Mode state of this device differs from its build configuration. Please factory reset the device.</string>
+
<!-- Title of notification shown when serial console is enabled. [CHAR LIMIT=NONE] -->
<string name="console_running_notification_title">Serial console enabled</string>
<!-- Message of notification shown when serial console is enabled. [CHAR LIMIT=NONE] -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 0f54d89e49c0..8823894e18c8 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2153,6 +2153,8 @@
<java-symbol type="string" name="adbwifi_active_notification_title" />
<java-symbol type="string" name="test_harness_mode_notification_title" />
<java-symbol type="string" name="test_harness_mode_notification_message" />
+ <java-symbol type="string" name="wrong_hsum_configuration_notification_title" />
+ <java-symbol type="string" name="wrong_hsum_configuration_notification_message" />
<java-symbol type="string" name="console_running_notification_title" />
<java-symbol type="string" name="console_running_notification_message" />
<java-symbol type="string" name="mte_override_notification_title" />
diff --git a/proto/src/system_messages.proto b/proto/src/system_messages.proto
index e8db80a36f5b..994bdb58f543 100644
--- a/proto/src/system_messages.proto
+++ b/proto/src/system_messages.proto
@@ -314,6 +314,10 @@ message SystemMessage {
// Package: com.android.systemui
NOTE_ADAPTIVE_NOTIFICATIONS = 76;
+ // Warn the user that the device's Headless System User Mode status doesn't match the build's.
+ // Package: android
+ NOTE_WRONG_HSUM_STATUS = 77;
+
// ADD_NEW_IDS_ABOVE_THIS_LINE
// Legacy IDs with arbitrary values appear below
// Legacy IDs existed as stable non-conflicting constants prior to the O release
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index d1d8993168c9..7f4a5cb7cf8f 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -62,6 +62,8 @@ import android.app.BroadcastOptions;
import android.app.IActivityManager;
import android.app.IStopUserCallback;
import android.app.KeyguardManager;
+import android.app.Notification;
+import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.StatsManager;
import android.app.admin.DevicePolicyEventLogger;
@@ -147,6 +149,8 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.IAppOpsService;
import com.android.internal.app.SetScreenLockDialogActivity;
import com.android.internal.logging.MetricsLogger;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
+import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.os.BackgroundThread;
import com.android.internal.os.RoSystemProperties;
import com.android.internal.util.DumpUtils;
@@ -1070,6 +1074,8 @@ public class UserManagerService extends IUserManager.Stub {
if (isAutoLockingPrivateSpaceOnRestartsEnabled()) {
autoLockPrivateSpace();
}
+
+ showHsumNotificationIfNeeded();
}
private boolean isAutoLockingPrivateSpaceOnRestartsEnabled() {
@@ -4163,6 +4169,48 @@ public class UserManagerService extends IUserManager.Stub {
mUpdatingSystemUserMode = true;
}
+ /**
+ * If the device's actual HSUM status differs from that which is defined by its build
+ * configuration, warn the user. Ignores HSUM emulated status, since that isn't relevant.
+ *
+ * The goal is to inform dogfooders that they need to factory reset the device to align their
+ * device with its build configuration.
+ */
+ private void showHsumNotificationIfNeeded() {
+ if (RoSystemProperties.MULTIUSER_HEADLESS_SYSTEM_USER == isHeadlessSystemUserMode()) {
+ // Actual state does match the configuration. Great!
+ return;
+ }
+ if (Build.isDebuggable()
+ && !TextUtils.isEmpty(SystemProperties.get(SYSTEM_USER_MODE_EMULATION_PROPERTY))) {
+ // Ignore any device that has been playing around with HSUM emulation.
+ return;
+ }
+ Slogf.w(LOG_TAG, "Posting warning that device's HSUM status doesn't match the build's.");
+
+ final String title = mContext
+ .getString(R.string.wrong_hsum_configuration_notification_title);
+ final String message = mContext
+ .getString(R.string.wrong_hsum_configuration_notification_message);
+
+ final Notification notification =
+ new Notification.Builder(mContext, SystemNotificationChannels.DEVELOPER)
+ .setSmallIcon(R.drawable.stat_sys_adb)
+ .setWhen(0)
+ .setOngoing(true)
+ .setTicker(title)
+ .setDefaults(0)
+ .setColor(mContext.getColor(R.color.system_notification_accent_color))
+ .setContentTitle(title)
+ .setContentText(message)
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
+ .build();
+
+ final NotificationManager notificationManager =
+ mContext.getSystemService(NotificationManager.class);
+ notificationManager.notifyAsUser(
+ null, SystemMessage.NOTE_WRONG_HSUM_STATUS, notification, UserHandle.ALL);
+ }
private ResilientAtomicFile getUserListFile() {
File tempBackup = new File(mUserListFile.getParent(), mUserListFile.getName() + ".backup");