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

Commit 7c7fbf6f authored by Makoto Onuki's avatar Makoto Onuki
Browse files

getApplicationInfo() should throw NameNotFoundException

... instead of returning null.

Bug: 37324177

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: I7f9f3729ee0eef6b342e4711379e02516559472c
parent d2b368a6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10306,7 +10306,7 @@ package android.content.pm {
  public class LauncherApps {
    method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle);
    method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle);
    method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle) throws android.content.pm.PackageManager.NameNotFoundException;
    method public android.content.pm.LauncherApps.PinItemRequest getPinItemRequest(android.content.Intent);
    method public java.util.List<android.os.UserHandle> getProfiles();
    method public android.graphics.drawable.Drawable getShortcutBadgedIconDrawable(android.content.pm.ShortcutInfo, int);
+1 −1
Original line number Diff line number Diff line
@@ -10965,7 +10965,7 @@ package android.content.pm {
  public class LauncherApps {
    method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle);
    method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle);
    method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle) throws android.content.pm.PackageManager.NameNotFoundException;
    method public android.content.pm.LauncherApps.PinItemRequest getPinItemRequest(android.content.Intent);
    method public java.util.List<android.os.UserHandle> getProfiles();
    method public android.graphics.drawable.Drawable getShortcutBadgedIconDrawable(android.content.pm.ShortcutInfo, int);
+1 −1
Original line number Diff line number Diff line
@@ -10343,7 +10343,7 @@ package android.content.pm {
  public class LauncherApps {
    ctor public LauncherApps(android.content.Context);
    method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle);
    method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle);
    method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle) throws android.content.pm.PackageManager.NameNotFoundException;
    method public android.content.pm.LauncherApps.PinItemRequest getPinItemRequest(android.content.Intent);
    method public java.util.List<android.os.UserHandle> getProfiles();
    method public android.graphics.drawable.Drawable getShortcutBadgedIconDrawable(android.content.pm.ShortcutInfo, int);
+7 −2
Original line number Diff line number Diff line
@@ -498,8 +498,13 @@ public class AppWidgetHostView extends FrameLayout {
    private void updateContentDescription(AppWidgetProviderInfo info) {
        if (info != null) {
            LauncherApps launcherApps = getContext().getSystemService(LauncherApps.class);
            ApplicationInfo appInfo = launcherApps.getApplicationInfo(
            ApplicationInfo appInfo = null;
            try {
                appInfo = launcherApps.getApplicationInfo(
                        info.provider.getPackageName(), 0, info.getProfile());
            } catch (NameNotFoundException e) {
                // ignore -- use null.
            }
            if (appInfo != null &&
                    (appInfo.flags & ApplicationInfo.FLAG_SUSPENDED) != 0) {
                setContentDescription(
+14 −3
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ import android.os.UserManager;
import android.util.DisplayMetrics;
import android.util.Log;

import com.android.internal.util.Preconditions;

import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -622,11 +624,20 @@ public class LauncherApps {
     *         null if the package isn't installed for the given user, or the target user
     *         is not enabled.
     */
    public ApplicationInfo getApplicationInfo(String packageName, @ApplicationInfoFlags int flags,
            UserHandle user) {
    public ApplicationInfo getApplicationInfo(@NonNull String packageName,
            @ApplicationInfoFlags int flags, @NonNull UserHandle user)
            throws PackageManager.NameNotFoundException {
        Preconditions.checkNotNull(packageName, "packageName");
        Preconditions.checkNotNull(packageName, "user");
        logErrorForInvalidProfileAccess(user);
        try {
            return mService.getApplicationInfo(mContext.getPackageName(), packageName, flags, user);
            final ApplicationInfo ai = mService
                    .getApplicationInfo(mContext.getPackageName(), packageName, flags, user);
            if (ai == null) {
                throw new NameNotFoundException("Package " + packageName + " not found for user "
                        + user.getIdentifier());
            }
            return ai;
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }