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

Commit 60c43b5f authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Adapt to change in behavior of MATCH_UNINSTALLED_PACKAGES

Don't use the PM flag to reach out across users

Bug: 31000380
Test: Manual
Change-Id: I2c59e30d69cbb4a9ac8710c88fab72cb7b89ef29
parent 7e9dd425
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -370,7 +370,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
            // apps, but this may include apps with just data, and if it is just
            // data we still want to count it as "installed".
            mAppInfo = mPm.getApplicationInfo(pkgName,
                    PackageManager.GET_UNINSTALLED_PACKAGES);
                    PackageManager.MATCH_UNINSTALLED_PACKAGES);
            if ((mAppInfo.flags&ApplicationInfo.FLAG_INSTALLED) == 0) {
                mAppInfo = null;
            }
@@ -525,7 +525,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
                try {
                    mPkgInfo = mPm.getPackageInfo(packageUri.getSchemeSpecificPart(),
                            PackageManager.GET_PERMISSIONS
                                    | PackageManager.GET_UNINSTALLED_PACKAGES);
                                    | PackageManager.MATCH_UNINSTALLED_PACKAGES);
                } catch (NameNotFoundException e) {
                }
                if (mPkgInfo == null) {
+0 −15
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ package com.android.packageinstaller;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageParser;
import android.content.pm.PackageParser.PackageParserException;
@@ -36,7 +35,6 @@ import android.widget.ImageView;
import android.widget.TextView;

import java.io.File;
import java.util.List;

/**
 * This is a utility class for defining some utility methods and constants
@@ -129,19 +127,6 @@ public class PackageUtil {
        return appSnippet;
    }

    public static boolean isPackageAlreadyInstalled(Activity context, String pkgName) {
        List<PackageInfo> installedList = context.getPackageManager().getInstalledPackages(
                PackageManager.GET_UNINSTALLED_PACKAGES);
        int installedListSize = installedList.size();
        for(int i = 0; i < installedListSize; i++) {
            PackageInfo tmp = installedList.get(i);
            if(pkgName.equalsIgnoreCase(tmp.packageName)) {
                return true;
            }
        }
        return false;
    }

    static public class AppSnippet {
        @NonNull public CharSequence label;
        @Nullable public Drawable icon;
+3 −3
Original line number Diff line number Diff line
@@ -214,7 +214,7 @@ public class WearPackageInstallerService extends Service {
            PackageInfo existingPkgInfo = null;
            try {
                existingPkgInfo = pm.getPackageInfo(packageName,
                        PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_PERMISSIONS);
                        PackageManager.MATCH_ANY_USER | PackageManager.GET_PERMISSIONS);
                if (existingPkgInfo != null) {
                    installFlags |= PackageManager.INSTALL_REPLACE_EXISTING;
                }