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

Commit c3d0e6a8 authored by Florian Mayer's avatar Florian Mayer
Browse files

[MTE] show notification if using MTE bootloader switch.

ro.arm64.memtag.bootctl_supported can be set by OEMs that do not want to
enable MTE by default yet but want to offer users a preview that can be
enabled in the Developer Options. This developer option will reboot the
phone and enable MTE. In that case we want to show a notification to
make sure the user does not forget that it is enabled.

Bug: 206895651
Change-Id: Iaebc16d4b8d0da302f18709e23062f4a5bd58fe3
parent 595a1480
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3838,6 +3838,11 @@
    <!-- 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 MTE status override is enabled. [CHAR LIMIT=NONE] -->
    <string name="mte_override_notification_title">Experimental MTE enabled</string>
    <!-- Message of notification shown when MTE status override is enabled. [CHAR LIMIT=NONE] -->
    <string name="mte_override_notification_message">Performance and stability might be impacted. Reboot to disable. If enabled using arm64.memtag.bootctl, set it to "none" beforehand.</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
@@ -2091,6 +2091,8 @@
  <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="mte_override_notification_title" />
  <java-symbol type="string" name="mte_override_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
@@ -282,6 +282,10 @@ message SystemMessage {
    // Notify the user to set up dream
    NOTE_SETUP_DREAM = 68;

    // Inform the user that MTE override is active.
    // Package: android
    NOTE_MTE_OVERRIDE_ENABLED = 69;

    // 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
+30 −0
Original line number Diff line number Diff line
@@ -4948,6 +4948,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        // UART is on if init's console service is running, send a warning notification.
        showConsoleNotificationIfActive();
        showMteOverrideNotificationIfActive();
        t.traceEnd();
    }
@@ -4982,6 +4983,35 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    private void showMteOverrideNotificationIfActive() {
        if (!SystemProperties.getBoolean("ro.arm64.memtag.bootctl_supported", false)
            || !com.android.internal.os.Zygote.nativeSupportsMemoryTagging()) {
            return;
        }
        String title = mContext
                .getString(com.android.internal.R.string.mte_override_notification_title);
        String message = mContext
                .getString(com.android.internal.R.string.mte_override_notification_message);
        Notification notification =
                new Notification.Builder(mContext, SystemNotificationChannels.DEVELOPER)
                        .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
                        .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_MTE_OVERRIDE_ENABLED, notification, UserHandle.ALL);
    }
    @Override
    public void bootAnimationComplete() {
        if (DEBUG_ALL) Slog.d(TAG, "bootAnimationComplete: Callers=" + Debug.getCallers(4));