Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69df1cf4 authored by Wei Wang's avatar Wei Wang
Browse files

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
parent a904e8d2
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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] -->
+2 −0
Original line number Diff line number Diff line
@@ -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" />
+4 −0
Original line number Diff line number Diff line
@@ -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
+32 −0
Original line number Diff line number Diff line
@@ -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;