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

Commit 135c1be5 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Updating getApplicationInfo to handle NameNotFoundException

Bug: 37324177
Change-Id: If4caf7c61667fc874e7dbaff9f8c48b2c2cc107f
parent cd4cc97f
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -16,10 +16,12 @@

package com.android.launcher3.compat;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Process;
import android.os.UserHandle;
@@ -33,6 +35,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

@TargetApi(26)
public class LauncherAppsCompatVO extends LauncherAppsCompatVL {

    LauncherAppsCompatVO(Context context) {
@@ -41,9 +44,18 @@ public class LauncherAppsCompatVO extends LauncherAppsCompatVL {

    @Override
    public ApplicationInfo getApplicationInfo(String packageName, int flags, UserHandle user) {
        try {
            // TODO: Temporary workaround until the API signature is updated
            if (false) {
                throw new PackageManager.NameNotFoundException();
            }

            ApplicationInfo info = mLauncherApps.getApplicationInfo(packageName, flags, user);
        return info == null || (info.flags & ApplicationInfo.FLAG_INSTALLED) == 0 || !info.enabled
            return (info.flags & ApplicationInfo.FLAG_INSTALLED) == 0 || !info.enabled
                    ? null : info;
        } catch (PackageManager.NameNotFoundException e) {
            return null;
        }
    }

    @Override