Create a global registry for system message IDs
Port all system UI notifications to use the registry. Retain stable integer IDs where they exist. Assign new stable IDs where resource IDs were previously used. Using "message" rather than "notification" since we may eventually want to include dialogs and toasts. Bug: 32584866 Bug: 30995038 Test: runtest systemui Change-Id: Iec4d7cebbd88683e339ada29a279315222699942
This commit is contained in:
@@ -39,6 +39,7 @@ import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -283,8 +284,6 @@ public class PluginInstanceManager<T extends Plugin> {
|
||||
Class<?> pluginClass = Class.forName(cls, true, classLoader);
|
||||
T plugin = (T) pluginClass.newInstance();
|
||||
if (plugin.getVersion() != mVersion) {
|
||||
final int id = mContext.getResources().getIdentifier("notification_plugin",
|
||||
"id", mContext.getPackageName());
|
||||
final int icon = mContext.getResources().getIdentifier("tuner", "drawable",
|
||||
mContext.getPackageName());
|
||||
final int color = Resources.getSystem().getIdentifier(
|
||||
@@ -320,7 +319,8 @@ public class PluginInstanceManager<T extends Plugin> {
|
||||
PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, i, 0);
|
||||
nb.addAction(new Action.Builder(null, "Disable plugin", pi).build());
|
||||
mContext.getSystemService(NotificationManager.class)
|
||||
.notifyAsUser(cls, id, nb.build(), UserHandle.ALL);
|
||||
.notifyAsUser(cls, SystemMessage.NOTE_PLUGIN, nb.build(),
|
||||
UserHandle.ALL);
|
||||
// TODO: Warn user.
|
||||
Log.w(TAG, "Plugin has invalid interface version " + plugin.getVersion()
|
||||
+ ", expected " + mVersion);
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.os.SystemProperties;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.systemui.plugins.PluginInstanceManager.PluginContextWrapper;
|
||||
|
||||
import dalvik.system.PathClassLoader;
|
||||
@@ -141,10 +142,8 @@ public class PluginManager extends BroadcastReceiver {
|
||||
mContext.getPackageManager().setComponentEnabledSetting(component,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
int id = mContext.getResources().getIdentifier("notification_plugin", "id",
|
||||
mContext.getPackageName());
|
||||
mContext.getSystemService(NotificationManager.class).cancel(component.getClassName(),
|
||||
id);
|
||||
SystemMessage.NOTE_PLUGIN);
|
||||
} else {
|
||||
Uri data = intent.getData();
|
||||
String pkg = data.getEncodedSchemeSpecificPart();
|
||||
|
||||
@@ -49,12 +49,7 @@
|
||||
<item type="id" name="scrim_target"/>
|
||||
<item type="id" name="scrim_alpha_start"/>
|
||||
<item type="id" name="scrim_alpha_end"/>
|
||||
<item type="id" name="notification_power"/>
|
||||
<item type="id" name="notification_screenshot"/>
|
||||
<item type="id" name="notification_hidden"/>
|
||||
<item type="id" name="notification_volumeui"/>
|
||||
<item type="id" name="notification_temperature"/>
|
||||
<item type="id" name="notification_plugin"/>
|
||||
<item type="id" name="transformation_start_x_tag"/>
|
||||
<item type="id" name="transformation_start_y_tag"/>
|
||||
<item type="id" name="transformation_start_scale_x_tag"/>
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SystemUI;
|
||||
import com.android.systemui.statusbar.phone.PhoneStatusBar;
|
||||
@@ -50,8 +51,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
|
||||
private static final String TAG = PowerUI.TAG + ".Notification";
|
||||
private static final boolean DEBUG = PowerUI.DEBUG;
|
||||
|
||||
private static final String TAG_NOTIFICATION_BATTERY = "low_battery";
|
||||
private static final String TAG_NOTIFICATION_TEMPERATURE = "high_temp";
|
||||
private static final String TAG_BATTERY = "low_battery";
|
||||
private static final String TAG_TEMPERATURE = "high_temp";
|
||||
|
||||
private static final int SHOWING_NOTHING = 0;
|
||||
private static final int SHOWING_WARNING = 1;
|
||||
@@ -136,7 +137,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
|
||||
showWarningNotification();
|
||||
mShowing = SHOWING_WARNING;
|
||||
} else {
|
||||
mNoMan.cancelAsUser(TAG_NOTIFICATION_BATTERY, R.id.notification_power, UserHandle.ALL);
|
||||
mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_BAD_CHARGER, UserHandle.ALL);
|
||||
mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_POWER_LOW, UserHandle.ALL);
|
||||
mShowing = SHOWING_NOTHING;
|
||||
}
|
||||
}
|
||||
@@ -155,7 +157,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
|
||||
com.android.internal.R.color.system_notification_accent_color));
|
||||
SystemUI.overrideNotificationAppName(mContext, nb);
|
||||
final Notification n = nb.build();
|
||||
mNoMan.notifyAsUser(TAG_NOTIFICATION_BATTERY, R.id.notification_power, n, UserHandle.ALL);
|
||||
mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_POWER_LOW, UserHandle.ALL);
|
||||
mNoMan.notifyAsUser(TAG_BATTERY, SystemMessage.NOTE_BAD_CHARGER, n, UserHandle.ALL);
|
||||
}
|
||||
|
||||
private void showWarningNotification() {
|
||||
@@ -185,8 +188,9 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
|
||||
mPlaySound = false;
|
||||
}
|
||||
SystemUI.overrideNotificationAppName(mContext, nb);
|
||||
mNoMan.notifyAsUser(
|
||||
TAG_NOTIFICATION_BATTERY, R.id.notification_power, nb.build(), UserHandle.ALL);
|
||||
final Notification n = nb.build();
|
||||
mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_BAD_CHARGER, UserHandle.ALL);
|
||||
mNoMan.notifyAsUser(TAG_BATTERY, SystemMessage.NOTE_POWER_LOW, n, UserHandle.ALL);
|
||||
}
|
||||
|
||||
private PendingIntent pendingBroadcast(String action) {
|
||||
@@ -213,8 +217,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
|
||||
return;
|
||||
}
|
||||
mTempWarning = false;
|
||||
mNoMan.cancelAsUser(
|
||||
TAG_NOTIFICATION_TEMPERATURE, R.id.notification_temperature, UserHandle.ALL);
|
||||
mNoMan.cancelAsUser(TAG_TEMPERATURE, SystemMessage.NOTE_HIGH_TEMP,
|
||||
UserHandle.ALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -237,8 +241,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
|
||||
com.android.internal.R.color.battery_saver_mode_color));
|
||||
SystemUI.overrideNotificationAppName(mContext, nb);
|
||||
final Notification n = nb.build();
|
||||
mNoMan.notifyAsUser(
|
||||
TAG_NOTIFICATION_TEMPERATURE, R.id.notification_temperature, n, UserHandle.ALL);
|
||||
mNoMan.notifyAsUser(TAG_TEMPERATURE, SystemMessage.NOTE_HIGH_TEMP, n, UserHandle.ALL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ import android.view.WindowManager;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SystemUI;
|
||||
|
||||
@@ -201,7 +202,8 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
|
||||
mNotificationBuilder.setFlag(Notification.FLAG_NO_CLEAR, true);
|
||||
SystemUI.overrideNotificationAppName(context, mNotificationBuilder);
|
||||
|
||||
mNotificationManager.notify(R.id.notification_screenshot, mNotificationBuilder.build());
|
||||
mNotificationManager.notify(SystemMessage.NOTE_GLOBAL_SCREENSHOT,
|
||||
mNotificationBuilder.build());
|
||||
|
||||
/**
|
||||
* NOTE: The following code prepares the notification builder for updating the notification
|
||||
@@ -348,7 +350,8 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
|
||||
.setPublicVersion(mPublicNotificationBuilder.build())
|
||||
.setFlag(Notification.FLAG_NO_CLEAR, false);
|
||||
|
||||
mNotificationManager.notify(R.id.notification_screenshot, mNotificationBuilder.build());
|
||||
mNotificationManager.notify(SystemMessage.NOTE_GLOBAL_SCREENSHOT,
|
||||
mNotificationBuilder.build());
|
||||
}
|
||||
mParams.finisher.run();
|
||||
mParams.clearContext();
|
||||
@@ -364,7 +367,7 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
|
||||
mParams.clearContext();
|
||||
|
||||
// Cancel the posted notification
|
||||
mNotificationManager.cancel(R.id.notification_screenshot);
|
||||
mNotificationManager.cancel(SystemMessage.NOTE_GLOBAL_SCREENSHOT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -866,7 +869,7 @@ class GlobalScreenshot {
|
||||
Notification n = new Notification.BigTextStyle(b)
|
||||
.bigText(errorMsg)
|
||||
.build();
|
||||
nManager.notify(R.id.notification_screenshot, n);
|
||||
nManager.notify(SystemMessage.NOTE_GLOBAL_SCREENSHOT, n);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -878,7 +881,7 @@ class GlobalScreenshot {
|
||||
// Clear the notification
|
||||
final NotificationManager nm =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.cancel(R.id.notification_screenshot);
|
||||
nm.cancel(SystemMessage.NOTE_GLOBAL_SCREENSHOT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -896,7 +899,7 @@ class GlobalScreenshot {
|
||||
final NotificationManager nm =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
final Uri uri = Uri.parse(intent.getStringExtra(SCREENSHOT_URI_ID));
|
||||
nm.cancel(R.id.notification_screenshot);
|
||||
nm.cancel(SystemMessage.NOTE_GLOBAL_SCREENSHOT);
|
||||
|
||||
// And delete the image from the media store
|
||||
new DeleteImageInBackgroundTask(context).execute(uri);
|
||||
|
||||
@@ -87,6 +87,7 @@ import android.widget.Toast;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.internal.statusbar.IStatusBarService;
|
||||
import com.android.internal.statusbar.StatusBarIcon;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
@@ -544,7 +545,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
} else if (BANNER_ACTION_CANCEL.equals(action) || BANNER_ACTION_SETUP.equals(action)) {
|
||||
NotificationManager noMan = (NotificationManager)
|
||||
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
noMan.cancel(R.id.notification_hidden);
|
||||
noMan.cancel(SystemMessage.NOTE_HIDDEN_NOTIFICATIONS);
|
||||
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0);
|
||||
@@ -885,7 +886,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
|
||||
NotificationManager noMan =
|
||||
(NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
noMan.notify(R.id.notification_hidden, note.build());
|
||||
noMan.notify(SystemMessage.NOTE_HIDDEN_NOTIFICATIONS, note.build());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ import android.widget.BaseAdapter;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.internal.util.UserIcons;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.systemui.GuestResumeSessionReceiver;
|
||||
@@ -79,8 +80,6 @@ public class UserSwitcherController {
|
||||
private static final String ACTION_LOGOUT_USER = "com.android.systemui.LOGOUT_USER";
|
||||
private static final int PAUSE_REFRESH_USERS_TIMEOUT_MS = 3000;
|
||||
|
||||
private static final int ID_REMOVE_GUEST = 1010;
|
||||
private static final int ID_LOGOUT_USER = 1011;
|
||||
private static final String TAG_REMOVE_GUEST = "remove_guest";
|
||||
private static final String TAG_LOGOUT_USER = "logout_user";
|
||||
|
||||
@@ -572,8 +571,8 @@ public class UserSwitcherController {
|
||||
mContext.getString(R.string.user_logout_notification_action),
|
||||
logoutPI);
|
||||
SystemUI.overrideNotificationAppName(mContext, builder);
|
||||
NotificationManager.from(mContext).notifyAsUser(TAG_LOGOUT_USER, ID_LOGOUT_USER,
|
||||
builder.build(), new UserHandle(userId));
|
||||
NotificationManager.from(mContext).notifyAsUser(TAG_LOGOUT_USER,
|
||||
SystemMessage.NOTE_LOGOUT_USER, builder.build(), new UserHandle(userId));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -595,8 +594,8 @@ public class UserSwitcherController {
|
||||
mContext.getString(R.string.guest_notification_remove_action),
|
||||
removeGuestPI);
|
||||
SystemUI.overrideNotificationAppName(mContext, builder);
|
||||
NotificationManager.from(mContext).notifyAsUser(TAG_REMOVE_GUEST, ID_REMOVE_GUEST,
|
||||
builder.build(), new UserHandle(guestUserId));
|
||||
NotificationManager.from(mContext).notifyAsUser(TAG_REMOVE_GUEST,
|
||||
SystemMessage.NOTE_REMOVE_GUEST, builder.build(), new UserHandle(guestUserId));
|
||||
}
|
||||
|
||||
private final Runnable mUnpauseRefreshUsers = new Runnable() {
|
||||
|
||||
@@ -41,6 +41,7 @@ import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.systemui.SystemUI;
|
||||
|
||||
import java.util.List;
|
||||
@@ -48,11 +49,6 @@ import java.util.List;
|
||||
public class StorageNotification extends SystemUI {
|
||||
private static final String TAG = "StorageNotification";
|
||||
|
||||
private static final int PUBLIC_ID = 0x53505542; // SPUB
|
||||
private static final int PRIVATE_ID = 0x53505256; // SPRV
|
||||
private static final int DISK_ID = 0x5344534b; // SDSK
|
||||
private static final int MOVE_ID = 0x534d4f56; // SMOV
|
||||
|
||||
private static final String ACTION_SNOOZE_VOLUME = "com.android.systemui.action.SNOOZE_VOLUME";
|
||||
private static final String ACTION_FINISH_WIZARD = "com.android.systemui.action.FINISH_WIZARD";
|
||||
|
||||
@@ -91,7 +87,8 @@ public class StorageNotification extends SystemUI {
|
||||
@Override
|
||||
public void onVolumeForgotten(String fsUuid) {
|
||||
// Stop annoying the user
|
||||
mNotificationManager.cancelAsUser(fsUuid, PRIVATE_ID, UserHandle.ALL);
|
||||
mNotificationManager.cancelAsUser(fsUuid, SystemMessage.NOTE_STORAGE_PRIVATE,
|
||||
UserHandle.ALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,7 +116,8 @@ public class StorageNotification extends SystemUI {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
// When finishing the adoption wizard, clean up any notifications
|
||||
// for moving primary storage
|
||||
mNotificationManager.cancelAsUser(null, MOVE_ID, UserHandle.ALL);
|
||||
mNotificationManager.cancelAsUser(null, SystemMessage.NOTE_STORAGE_MOVE,
|
||||
UserHandle.ALL);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -190,7 +188,8 @@ public class StorageNotification extends SystemUI {
|
||||
final VolumeInfo info = mStorageManager.findVolumeByUuid(fsUuid);
|
||||
if ((info != null && info.isMountedWritable()) || rec.isSnoozed()) {
|
||||
// Yay, private volume is here, or user snoozed
|
||||
mNotificationManager.cancelAsUser(fsUuid, PRIVATE_ID, UserHandle.ALL);
|
||||
mNotificationManager.cancelAsUser(fsUuid, SystemMessage.NOTE_STORAGE_PRIVATE,
|
||||
UserHandle.ALL);
|
||||
|
||||
} else {
|
||||
// Boo, annoy the user to reinsert the private volume
|
||||
@@ -211,8 +210,8 @@ public class StorageNotification extends SystemUI {
|
||||
.setDeleteIntent(buildSnoozeIntent(fsUuid));
|
||||
SystemUI.overrideNotificationAppName(mContext, builder);
|
||||
|
||||
mNotificationManager.notifyAsUser(fsUuid, PRIVATE_ID, builder
|
||||
.build(), UserHandle.ALL);
|
||||
mNotificationManager.notifyAsUser(fsUuid, SystemMessage.NOTE_STORAGE_PRIVATE,
|
||||
builder.build(), UserHandle.ALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,12 +236,13 @@ public class StorageNotification extends SystemUI {
|
||||
.setCategory(Notification.CATEGORY_ERROR);
|
||||
SystemUI.overrideNotificationAppName(mContext, builder);
|
||||
|
||||
mNotificationManager.notifyAsUser(disk.getId(), DISK_ID, builder.build(),
|
||||
UserHandle.ALL);
|
||||
mNotificationManager.notifyAsUser(disk.getId(), SystemMessage.NOTE_STORAGE_DISK,
|
||||
builder.build(), UserHandle.ALL);
|
||||
|
||||
} else {
|
||||
// Yay, we have volumes!
|
||||
mNotificationManager.cancelAsUser(disk.getId(), DISK_ID, UserHandle.ALL);
|
||||
mNotificationManager.cancelAsUser(disk.getId(), SystemMessage.NOTE_STORAGE_DISK,
|
||||
UserHandle.ALL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +252,8 @@ public class StorageNotification extends SystemUI {
|
||||
* @param disk The disk that went away.
|
||||
*/
|
||||
private void onDiskDestroyedInternal(@NonNull DiskInfo disk) {
|
||||
mNotificationManager.cancelAsUser(disk.getId(), DISK_ID, UserHandle.ALL);
|
||||
mNotificationManager.cancelAsUser(disk.getId(), SystemMessage.NOTE_STORAGE_DISK,
|
||||
UserHandle.ALL);
|
||||
}
|
||||
|
||||
private void onVolumeStateChangedInternal(VolumeInfo vol) {
|
||||
@@ -308,9 +309,11 @@ public class StorageNotification extends SystemUI {
|
||||
}
|
||||
|
||||
if (notif != null) {
|
||||
mNotificationManager.notifyAsUser(vol.getId(), PUBLIC_ID, notif, UserHandle.ALL);
|
||||
mNotificationManager.notifyAsUser(vol.getId(), SystemMessage.NOTE_STORAGE_PUBLIC,
|
||||
notif, UserHandle.ALL);
|
||||
} else {
|
||||
mNotificationManager.cancelAsUser(vol.getId(), PUBLIC_ID, UserHandle.ALL);
|
||||
mNotificationManager.cancelAsUser(vol.getId(), SystemMessage.NOTE_STORAGE_PUBLIC,
|
||||
UserHandle.ALL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,7 +491,7 @@ public class StorageNotification extends SystemUI {
|
||||
.setOngoing(true);
|
||||
SystemUI.overrideNotificationAppName(mContext, builder);
|
||||
|
||||
mNotificationManager.notifyAsUser(move.packageName, MOVE_ID,
|
||||
mNotificationManager.notifyAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE,
|
||||
builder.build(), UserHandle.ALL);
|
||||
}
|
||||
|
||||
@@ -496,7 +499,8 @@ public class StorageNotification extends SystemUI {
|
||||
if (move.packageName != null) {
|
||||
// We currently ignore finished app moves; just clear the last
|
||||
// published progress
|
||||
mNotificationManager.cancelAsUser(move.packageName, MOVE_ID, UserHandle.ALL);
|
||||
mNotificationManager.cancelAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE,
|
||||
UserHandle.ALL);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -537,8 +541,8 @@ public class StorageNotification extends SystemUI {
|
||||
.setAutoCancel(true);
|
||||
SystemUI.overrideNotificationAppName(mContext, builder);
|
||||
|
||||
mNotificationManager.notifyAsUser(move.packageName, MOVE_ID, builder.build(),
|
||||
UserHandle.ALL);
|
||||
mNotificationManager.notifyAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE,
|
||||
builder.build(), UserHandle.ALL);
|
||||
}
|
||||
|
||||
private int getSmallIcon(DiskInfo disk, int state) {
|
||||
|
||||
@@ -42,6 +42,7 @@ import android.os.UserHandle;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -143,8 +144,8 @@ public class PluginInstanceManagerTest extends SysuiTestCase {
|
||||
// Plugin shouldn't be connected because it is the wrong version.
|
||||
verify(mMockListener, Mockito.never()).onPluginConnected(
|
||||
ArgumentCaptor.forClass(Plugin.class).capture());
|
||||
verify(nm).notifyAsUser(eq(TestPlugin.class.getName()), eq(R.id.notification_plugin), any(),
|
||||
eq(UserHandle.ALL));
|
||||
verify(nm).notifyAsUser(eq(TestPlugin.class.getName()), eq(SystemMessage.NOTE_PLUGIN),
|
||||
any(), eq(UserHandle.ALL));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.net.Uri;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.plugins.PluginManager.PluginInstanceManagerFactory;
|
||||
|
||||
@@ -132,7 +133,7 @@ public class PluginManagerTest extends SysuiTestCase {
|
||||
Intent intent = new Intent(PluginManager.DISABLE_PLUGIN);
|
||||
intent.setData(Uri.parse("package://" + testComponent.flattenToString()));
|
||||
mPluginManager.onReceive(mContext, intent);
|
||||
verify(nm).cancel(eq(testComponent.getClassName()), eq(R.id.notification_plugin));
|
||||
verify(nm).cancel(eq(testComponent.getClassName()), eq(SystemMessage.NOTE_PLUGIN));
|
||||
verify(pm).setComponentEnabledSetting(eq(testComponent),
|
||||
eq(PackageManager.COMPONENT_ENABLED_STATE_DISABLED),
|
||||
eq(PackageManager.DONT_KILL_APP));
|
||||
|
||||
@@ -22,6 +22,7 @@ import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.anyString;
|
||||
@@ -34,6 +35,7 @@ import android.app.NotificationManager;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -76,28 +78,34 @@ public class PowerNotificationWarningsTest extends SysuiTestCase {
|
||||
public void testShowInvalidChargerNotification_NotifyAsUser() {
|
||||
mPowerNotificationWarnings.showInvalidChargerWarning();
|
||||
verify(mMockNotificationManager, times(1))
|
||||
.notifyAsUser(anyString(), anyInt(), any(), any());
|
||||
.notifyAsUser(anyString(), eq(SystemMessage.NOTE_BAD_CHARGER), any(), any());
|
||||
verify(mMockNotificationManager, times(1)).cancelAsUser(anyString(),
|
||||
eq(SystemMessage.NOTE_POWER_LOW), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDismissInvalidChargerNotification_CancelAsUser() {
|
||||
mPowerNotificationWarnings.showInvalidChargerWarning();
|
||||
mPowerNotificationWarnings.dismissInvalidChargerWarning();
|
||||
verify(mMockNotificationManager, times(1)).cancelAsUser(anyString(), anyInt(), any());
|
||||
verify(mMockNotificationManager, times(1)).cancelAsUser(anyString(),
|
||||
eq(SystemMessage.NOTE_BAD_CHARGER), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowLowBatteryNotification_NotifyAsUser() {
|
||||
mPowerNotificationWarnings.showLowBatteryWarning(false);
|
||||
verify(mMockNotificationManager, times(1))
|
||||
.notifyAsUser(anyString(), anyInt(), any(), any());
|
||||
.notifyAsUser(anyString(), eq(SystemMessage.NOTE_POWER_LOW), any(), any());
|
||||
verify(mMockNotificationManager, times(1)).cancelAsUser(anyString(),
|
||||
eq(SystemMessage.NOTE_BAD_CHARGER), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDismissLowBatteryNotification_CancelAsUser() {
|
||||
mPowerNotificationWarnings.showLowBatteryWarning(false);
|
||||
mPowerNotificationWarnings.dismissLowBatteryWarning();
|
||||
verify(mMockNotificationManager, times(1)).cancelAsUser(anyString(), anyInt(), any());
|
||||
verify(mMockNotificationManager, times(1)).cancelAsUser(anyString(),
|
||||
eq(SystemMessage.NOTE_POWER_LOW), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -105,7 +113,8 @@ public class PowerNotificationWarningsTest extends SysuiTestCase {
|
||||
mPowerNotificationWarnings.showLowBatteryWarning(false);
|
||||
ArgumentCaptor<Notification> captor = ArgumentCaptor.forClass(Notification.class);
|
||||
verify(mMockNotificationManager)
|
||||
.notifyAsUser(anyString(), anyInt(), captor.capture(), any());
|
||||
.notifyAsUser(anyString(), eq(SystemMessage.NOTE_POWER_LOW),
|
||||
captor.capture(), any());
|
||||
assertEquals(null, captor.getValue().sound);
|
||||
}
|
||||
|
||||
@@ -114,7 +123,8 @@ public class PowerNotificationWarningsTest extends SysuiTestCase {
|
||||
mPowerNotificationWarnings.showLowBatteryWarning(true);
|
||||
ArgumentCaptor<Notification> captor = ArgumentCaptor.forClass(Notification.class);
|
||||
verify(mMockNotificationManager)
|
||||
.notifyAsUser(anyString(), anyInt(), captor.capture(), any());
|
||||
.notifyAsUser(anyString(), eq(SystemMessage.NOTE_POWER_LOW),
|
||||
captor.capture(), any());
|
||||
assertNotEqual(null, captor.getValue().sound);
|
||||
}
|
||||
|
||||
@@ -122,13 +132,14 @@ public class PowerNotificationWarningsTest extends SysuiTestCase {
|
||||
public void testShowTemperatureWarning_NotifyAsUser() {
|
||||
mPowerNotificationWarnings.showTemperatureWarning();
|
||||
verify(mMockNotificationManager, times(1))
|
||||
.notifyAsUser(anyString(), anyInt(), any(), any());
|
||||
.notifyAsUser(anyString(), eq(SystemMessage.NOTE_HIGH_TEMP), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDismissTemperatureWarning_CancelAsUser() {
|
||||
mPowerNotificationWarnings.showTemperatureWarning();
|
||||
mPowerNotificationWarnings.dismissTemperatureWarning();
|
||||
verify(mMockNotificationManager, times(1)).cancelAsUser(anyString(), anyInt(), any());
|
||||
verify(mMockNotificationManager, times(1)).cancelAsUser(anyString(),
|
||||
eq(SystemMessage.NOTE_HIGH_TEMP), any());
|
||||
}
|
||||
}
|
||||
|
||||
79
proto/src/system_messages.proto
Normal file
79
proto/src/system_messages.proto
Normal file
@@ -0,0 +1,79 @@
|
||||
// Copyright (C) 2017 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
option java_package = "com.android.internal.messages";
|
||||
option java_outer_classname = "SystemMessageProto";
|
||||
|
||||
package com_android_notifications;
|
||||
|
||||
// Descriptors for system messages: notifications, dialogs, toasts, etc.
|
||||
message SystemMessage {
|
||||
|
||||
// System message IDs
|
||||
// These are non-consecutive in order to preserve some existing, ad hoc IDs.
|
||||
enum ID {
|
||||
// Unknown
|
||||
NOTE_UNKNOWN = 0;
|
||||
|
||||
// Notify the user that a screenshot was captured.
|
||||
// Package: com.android.systemui
|
||||
NOTE_GLOBAL_SCREENSHOT = 1;
|
||||
|
||||
// Warn the user about an invalid charger.
|
||||
// Package: com.android.systemui
|
||||
NOTE_BAD_CHARGER = 2;
|
||||
|
||||
// Warn the user about low battery.
|
||||
// Package: com.android.systemui
|
||||
NOTE_POWER_LOW = 3;
|
||||
|
||||
// Warn the user that the device has gotten warm.
|
||||
// Package: com.android.systemui
|
||||
NOTE_HIGH_TEMP = 4;
|
||||
|
||||
// Warn the user that some notifications are hidden.
|
||||
// Package: com.android.systemui
|
||||
NOTE_HIDDEN_NOTIFICATIONS = 5;
|
||||
|
||||
// Notify the user of a problem with a plugin (dev devices only).
|
||||
// Package: com.android.systemui
|
||||
NOTE_PLUGIN = 6;
|
||||
|
||||
// Confirm that the user wants to remove the guest account.
|
||||
// Package: com.android.systemui
|
||||
NOTE_REMOVE_GUEST = 1010;
|
||||
|
||||
// Confirm that the user wants to log out of the device.
|
||||
// Package: com.android.systemui
|
||||
NOTE_LOGOUT_USER = 1011;
|
||||
|
||||
// Notify the user about public volume state changes..
|
||||
// Package: com.android.systemui
|
||||
NOTE_STORAGE_PUBLIC = 0x53505542;
|
||||
|
||||
// Notify the user about private volume state changes.
|
||||
// Package: com.android.systemui
|
||||
NOTE_STORAGE_PRIVATE = 0x53505256;
|
||||
|
||||
// Notify the user about an unsupported storage device..
|
||||
// Package: com.android.systemui
|
||||
NOTE_STORAGE_DISK = 0x5344534b;
|
||||
|
||||
// Notify the user that data or apps are being moved to external storage.
|
||||
// Package: com.android.systemui
|
||||
NOTE_STORAGE_MOVE = 0x534d4f56;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user