add null check when accessing target component from iteminfo
Bug: 139540363 Change-Id: I25d0100077de67b085c27b5ef91e22c6ac1ad959 Merged-In: I25d0100077de67b085c27b5ef91e22c6ac1ad959
This commit is contained in:
@@ -22,6 +22,8 @@ import android.content.Intent;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.util.ContentWriter;
|
||||
|
||||
/**
|
||||
@@ -134,6 +136,7 @@ public class ItemInfo {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ComponentName getTargetComponent() {
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
|
||||
@@ -131,6 +131,7 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite
|
||||
@Override
|
||||
public View.OnClickListener getOnClickListener(final Launcher launcher,
|
||||
final ItemInfo itemInfo) {
|
||||
if (itemInfo.getTargetComponent() == null) return null;
|
||||
final List<WidgetItem> widgets =
|
||||
launcher.getPopupDataProvider().getWidgetsForPackageUser(new PackageUserKey(
|
||||
itemInfo.getTargetComponent().getPackageName(), itemInfo.user));
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.android.launcher3.util;
|
||||
import android.os.UserHandle;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.ItemInfo;
|
||||
import com.android.launcher3.shortcuts.DeepShortcutManager;
|
||||
|
||||
@@ -15,7 +17,9 @@ public class PackageUserKey {
|
||||
public UserHandle mUser;
|
||||
private int mHashCode;
|
||||
|
||||
@Nullable
|
||||
public static PackageUserKey fromItemInfo(ItemInfo info) {
|
||||
if (info.getTargetComponent() == null) return null;
|
||||
return new PackageUserKey(info.getTargetComponent().getPackageName(), info.user);
|
||||
}
|
||||
|
||||
@@ -38,6 +42,7 @@ public class PackageUserKey {
|
||||
* @return Whether this PackageUserKey was successfully updated - it shouldn't be used if not.
|
||||
*/
|
||||
public boolean updateFromItemInfo(ItemInfo info) {
|
||||
if (info.getTargetComponent() == null) return false;
|
||||
if (ShortcutUtil.supportsShortcuts(info)) {
|
||||
update(info.getTargetComponent().getPackageName(), info.user);
|
||||
return true;
|
||||
|
||||
@@ -27,6 +27,8 @@ import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -78,8 +80,9 @@ public class DeepShortcutManager {
|
||||
* Gets all the manifest and dynamic shortcuts associated with the given package and user,
|
||||
* to be displayed in the shortcuts container on long press.
|
||||
*/
|
||||
public List<ShortcutInfo> queryForShortcutsContainer(ComponentName activity,
|
||||
public List<ShortcutInfo> queryForShortcutsContainer(@Nullable ComponentName activity,
|
||||
UserHandle user) {
|
||||
if (activity == null) return Collections.EMPTY_LIST;
|
||||
return query(ShortcutQuery.FLAG_MATCH_MANIFEST | ShortcutQuery.FLAG_MATCH_DYNAMIC,
|
||||
activity.getPackageName(), activity, null, user);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user