Dynamic shortcuts must have target activities, but somehow the invariant
was broken.
Bug:
36228253
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest1 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest2 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest3 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest4 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest5 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest6 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest7 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest8 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest9 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest10 -w com.android.frameworks.servicestests
Change-Id: I9163d57121f102d88baa3e34791877412719da50
// Disable dynamic shortcuts whose target activity is gone.
if (si.isDynamic()) {
- if (!s.injectIsMainActivity(si.getActivity(), getPackageUserId())) {
+ if (si.getActivity() == null) {
+ // Note if it's dynamic, it must have a target activity, but b/36228253.
+ s.wtf("null activity detected.");
+ // TODO Maybe remove it?
+ } else if (!s.injectIsMainActivity(si.getActivity(), getPackageUserId())) {
Slog.w(TAG, String.format(
"%s is no longer main activity. Disabling shorcut %s.",
getPackageName(), si.getId()));
}
final ComponentName activity = si.getActivity();
+ if (activity == null) {
+ mShortcutUser.mService.wtf("null activity detected.");
+ continue;
+ }
ArrayList<ShortcutInfo> list = activitiesToShortcuts.get(activity);
if (list == null) {
boolean injectIsMainActivity(@NonNull ComponentName activity, int userId) {
final long start = injectElapsedRealtime();
try {
+ if (activity == null) {
+ wtf("null activity detected");
+ return false;
+ }
if (DUMMY_MAIN_ACTIVITY.equals(activity.getClassName())) {
return true;
}