diff options
author | Wei Wang <wvw@google.com> | 2019-09-24 20:55:15 -0700 |
---|---|---|
committer | Wei Wang <wvw@google.com> | 2019-09-25 21:41:37 +0000 |
commit | 69df1cf48967c4d3c6090a7648b700213d6868c6 (patch) | |
tree | c8f1660ca1d519ad4e46de9128d8c1a891f2f3a8 | |
parent | a904e8d2083f4ca1fc7f2a89f7bc745404d218f0 (diff) |
Add a notification when console is active
Performance is largely impacted when console is running, and device
should not ship with that configuration. Moreover, we have seen cases,
when performance of new features was tested with UART on. This CL adds a
notification when console service is active indicating UART is on.
Fixes: 119623211
Test: Enable UART and see warning after boot
Test: Disable UART and no warning
Change-Id: Ie60f763088a15608027986ac855466eb7fc97264
-rw-r--r-- | core/res/res/values/strings.xml | 5 | ||||
-rw-r--r-- | core/res/res/values/symbols.xml | 2 | ||||
-rw-r--r-- | proto/src/system_messages.proto | 4 | ||||
-rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 32 |
4 files changed, 43 insertions, 0 deletions
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 56e1fed5bcec..b53a399f0c8a 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -3634,6 +3634,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 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] --> + <string name="console_running_notification_message">Performance is impacted. To disable, check bootloader.</string> + <!-- Title of notification shown when contaminant is detected on the USB port. [CHAR LIMIT=NONE] --> <string name="usb_contaminant_detected_title">Liquid or debris in USB port</string> <!-- Message of notification shown when contaminant is detected on the USB port. [CHAR LIMIT=NONE] --> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 3fe907c3b665..3d0a3b309720 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2094,6 +2094,8 @@ <java-symbol type="string" name="adb_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="console_running_notification_title" /> + <java-symbol type="string" name="console_running_notification_message" /> <java-symbol type="string" name="taking_remote_bugreport_notification_title" /> <java-symbol type="string" name="share_remote_bugreport_notification_title" /> <java-symbol type="string" name="sharing_remote_bugreport_notification_title" /> diff --git a/proto/src/system_messages.proto b/proto/src/system_messages.proto index ffbf1ae38635..5d6d1c993cd3 100644 --- a/proto/src/system_messages.proto +++ b/proto/src/system_messages.proto @@ -230,6 +230,10 @@ message SystemMessage { // Package: android NOTE_TEST_HARNESS_MODE_ENABLED = 54; + // Inform the user that Serial Console is active. + // Package: android + NOTE_SERIAL_CONSOLE_ENABLED = 55; + // 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/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index d7a68a1015a8..c46738df1f52 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -5320,10 +5320,42 @@ public class ActivityManagerService extends IActivityManager.Stub }); mUserController.scheduleStartProfiles(); } + // UART is on if init's console service is running, send a warning notification. + showConsoleNotificationIfActive(); t.traceEnd(); } + private void showConsoleNotificationIfActive() { + if (!SystemProperties.get("init.svc.console").equals("running")) { + return; + } + String title = mContext + .getString(com.android.internal.R.string.console_running_notification_title); + String message = mContext + .getString(com.android.internal.R.string.console_running_notification_message); + Notification notification = + new Notification.Builder(mContext, SystemNotificationChannels.DEVELOPER) + .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) + .setWhen(0) + .setOngoing(true) + .setTicker(title) + .setDefaults(0) // please be quiet + .setColor(mContext.getColor( + com.android.internal.R.color + .system_notification_accent_color)) + .setContentTitle(title) + .setContentText(message) + .setVisibility(Notification.VISIBILITY_PUBLIC) + .build(); + + NotificationManager notificationManager = + mContext.getSystemService(NotificationManager.class); + notificationManager.notifyAsUser( + null, SystemMessage.NOTE_SERIAL_CONSOLE_ENABLED, notification, UserHandle.ALL); + + } + @Override public void bootAnimationComplete() { final boolean callFinishBooting; |