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

Commit 282cfefe authored by Chris Wren's avatar Chris Wren
Browse files

standardize system notification IDs

All the trivial cases, plus some fixes to try to
mitigate collisions with the complex ones.

Complex services to follow in another CL,

Bug: 32584866
Test: make framework services
Change-Id: Ie9663600171d8ede11676e9d66f009dbb06def03
parent 474662da
Loading
Loading
Loading
Loading
+118 −1
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ message SystemMessage {

  // System message IDs
  // These are non-consecutive in order to preserve some existing, ad hoc IDs.
  // It is OK to use skipped IDs.
  // Prefer to add new IDs consecutively from zero, search for ADD_NEW_IDS_ABOVE_THIS_LINE.
  // Most of these IDs only became meaningful with the O release.
  enum ID {
    // Unknown
    NOTE_UNKNOWN = 0;
@@ -56,6 +59,112 @@ message SystemMessage {
    // Package: com.android.systemui
    NOTE_INSTANT_APPS = 7;

    // Notify the user that they should select an input method
    // Package: android
    NOTE_SELECT_INPUT_METHOD = 8;

    // Notify the user about limited functionality before decryption
    // Package: android
    NOTE_FBE_ENCRYPTED_NOTIFICATION = 9;

    // Give the user a way out of car mode
    // Package: android
    NOTE_CAR_MODE_DISABLE = 10;

    // Notification to tell the user that a heavy-weight application is running.
    // Package: android
    NOTE_HEAVY_WEIGHT_NOTIFICATION = 11;

    // Notification to tell the user that a process has exceeded its memory limit.
    // Package: android
    NOTE_DUMP_HEAP_NOTIFICATION = 12;

    // Notification that is shown when finishing a system upgrade
    // Package: android
    NOTE_SYSTEM_UPGRADING = 13;

    // Notify the user that tethering is active.
    // Package: android
    NOTE_TETHER_GENERAL = 14;
    NOTE_TETHER_USB = 15;
    NOTE_TETHER_BLUETOOTH = 16;

    // Notify the user that always-on VPN has disconnected.
    // Package: android
    NOTE_VPN_DISCONNECTED = 17;

    // Notify the user about a sync error.
    // Package: android
    NOTE_SYNC_ERROR = 18;

    // Ask the user to select a keyboard language and layout
    // Package: android
    NOTE_SELECT_KEYBOARD_LAYOUT = 19;

    // Update the user about the status of the VPN
    // Package: android
    NOTE_VPN_STATUS = 20;

    // Package manager either installed or deleted a package
    // Package: android
    NOTE_PACKAGE_STATE = 21;

    // Tell the user that storage space is low
    // Package: android
    NOTE_LOW_STORAGE = 23;

    // Confirm that the user wants to reset out of retail demo mode
    // Package: android
    NOTE_RETAIL_RESET = 24;

    // Entice the use to tap to share files
    // Package: android
    NOTE_USB_MTP_TAP = 25;

    // Display the Android Debug Protocol status
    // Package: android
    NOTE_ADB_ACTIVE = 26;

    // Inform that USB is configured for Media Transfer Protocol
    // Package: android
    NOTE_USB_MTP = 27;

    // Inform that USB is configured for Picture Transfer Protocol
    // Package: android
    NOTE_USB_PTP = 28;

    // Inform that USB is configured as a Musical Instrument Digital Interface
    // Package: android
    NOTE_USB_MIDI = 29;

    // Inform that USB is configured in host mode
    // Package: android
    NOTE_USB_ACCESSORY = 30;

    // Inform the user that the device is supplying power to another device.
    // Package: android
    NOTE_USB_SUPPLYING = 31;

    // Inform the user that the device is consuming power from another device.
    // Package: android
    NOTE_USB_CHARGING = 32;

    // Inform the user that a certificate authority is managing SSL
    // Package: android
    NOTE_SSL_CERT_INFO = 33;

    // 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

    // Notify the user that their work profile has been deleted
    // Package: android
    NOTE_PROFILE_WIPED = 1001;

    // Warn the user that their org can monitor the network
    // Package: android
    NOTE_NETWORK_LOGGING = 1002;

    // Confirm that the user wants to remove the guest account.
    // Package: com.android.systemui
    NOTE_REMOVE_GUEST = 1010;
@@ -64,9 +173,13 @@ message SystemMessage {
    // Package: com.android.systemui
    NOTE_LOGOUT_USER = 1011;

    // Communicate to the user about remote bugreports.
    // Package: android
    NOTE_REMOTE_BUGREPORT = 678432343;

    // Notify the user about public volume state changes..
    // Package: com.android.systemui
    NOTE_STORAGE_PUBLIC = 0x53505542;
    NOTE_STORAGE_PUBLIC = 0x53505542;  // 1397773634

    // Notify the user about private volume state changes.
    // Package: com.android.systemui
@@ -79,5 +192,9 @@ message SystemMessage {
    // Notify the user that data or apps are being moved to external storage.
    // Package: com.android.systemui
    NOTE_STORAGE_MOVE = 0x534d4f56;

    // Account Manager allocates IDs sequentially, starting here.
    // Package: android
    ACCOUNT_MANAGER_BASE = 0x70000000;
  }
}
+3 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.internal.inputmethod.InputMethodSubtypeSwitchingController;
import com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem;
import com.android.internal.inputmethod.InputMethodUtils;
import com.android.internal.inputmethod.InputMethodUtils.InputMethodSettings;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.os.HandlerCaller;
import com.android.internal.os.SomeArgs;
@@ -2192,7 +2193,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                            Slog.d(TAG, "--- show notification: label =  " + summary);
                        }
                        mNotificationManager.notifyAsUser(null,
                                com.android.internal.R.string.select_input_method,
                                SystemMessage.NOTE_SELECT_INPUT_METHOD,
                                mImeSwitcherNotification.build(), UserHandle.ALL);
                        mNotificationShown = true;
                    }
@@ -2204,7 +2205,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                        Slog.d(TAG, "--- hide notification");
                    }
                    mNotificationManager.cancelAsUser(null,
                            com.android.internal.R.string.select_input_method, UserHandle.ALL);
                            SystemMessage.NOTE_SELECT_INPUT_METHOD, UserHandle.ALL);
                    mNotificationShown = false;
                }
            }
+5 −3
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ import android.util.Log;
import android.util.Slog;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.util.ArrayUtils;
import com.android.internal.widget.ICheckCredentialProgressCallback;
@@ -127,7 +128,6 @@ import javax.crypto.spec.GCMParameterSpec;
public class LockSettingsService extends ILockSettings.Stub {
    private static final String TAG = "LockSettingsService";
    private static final String PERMISSION = ACCESS_KEYGUARD_SECURE_STORAGE;
    private static final int FBE_ENCRYPTED_NOTIFICATION = 0;
    private static final boolean DEBUG = false;

    private static final int PROFILE_KEY_IV_SIZE = 12;
@@ -461,12 +461,14 @@ public class LockSettingsService extends ILockSettings.Stub {
                        .setVisibility(Notification.VISIBILITY_PUBLIC)
                        .setContentIntent(intent)
                        .build();
        mNotificationManager.notifyAsUser(null, FBE_ENCRYPTED_NOTIFICATION, notification, user);
        mNotificationManager.notifyAsUser(null, SystemMessage.NOTE_FBE_ENCRYPTED_NOTIFICATION,
            notification, user);
    }

    private void hideEncryptionNotification(UserHandle userHandle) {
        if (DEBUG) Slog.v(TAG, "hide encryption notification, user: " + userHandle.getIdentifier());
        mNotificationManager.cancelAsUser(null, FBE_ENCRYPTED_NOTIFICATION, userHandle);
        mNotificationManager.cancelAsUser(null, SystemMessage.NOTE_FBE_ENCRYPTED_NOTIFICATION,
            userHandle);
    }

    public void onCleanupUser(int userId) {
+3 −2
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import java.util.Collections;

import com.android.internal.R;
import com.android.internal.app.DisableCarModeActivity;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.server.power.ShutdownThread;
import com.android.server.twilight.TwilightListener;
@@ -710,10 +711,10 @@ final class UiModeManagerService extends SystemService {
                                PendingIntent.getActivityAsUser(context, 0, carModeOffIntent, 0,
                                        null, UserHandle.CURRENT));
                mNotificationManager.notifyAsUser(null,
                        R.string.car_mode_disable_notification_title, n.build(), UserHandle.ALL);
                        SystemMessage.NOTE_CAR_MODE_DISABLE, n.build(), UserHandle.ALL);
            } else {
                mNotificationManager.cancelAsUser(null,
                        R.string.car_mode_disable_notification_title, UserHandle.ALL);
                        SystemMessage.NOTE_CAR_MODE_DISABLE, UserHandle.ALL);
            }
        }
    }
+3 −1
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.content.PackageMonitor;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.IndentingPrintWriter;
@@ -189,7 +190,8 @@ public class AccountManagerService
    }

    private final LinkedHashMap<String, Session> mSessions = new LinkedHashMap<String, Session>();
    private final AtomicInteger mNotificationIds = new AtomicInteger(1);
    private final AtomicInteger mNotificationIds =
            new AtomicInteger(SystemMessage.ACCOUNT_MANAGER_BASE);

    static class UserAccounts {
        private final int userId;
Loading