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

Commit 71ab6f65 authored by Ray Essick's avatar Ray Essick Committed by Android (Google) Code Review
Browse files

Merge "packagemanager_native access to package installer, version" into oc-mr1-dev

parents 8e84dfec 42a65abd
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -25141,6 +25141,37 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
            }
            return results;
        }
        // NB: this differentiates between preloads and sideloads
        @Override
        public String getInstallerForPackage(String packageName) throws RemoteException {
            final String installerName = getInstallerPackageName(packageName);
            if (!TextUtils.isEmpty(installerName)) {
                return installerName;
            }
            // differentiate between preload and sideload
            int callingUser = UserHandle.getUserId(Binder.getCallingUid());
            ApplicationInfo appInfo = getApplicationInfo(packageName,
                                    /*flags*/ 0,
                                    /*userId*/ callingUser);
            if (appInfo != null && (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                return "preload";
            }
            return "";
        }
        @Override
        public int getVersionCodeForPackage(String packageName) throws RemoteException {
            try {
                int callingUser = UserHandle.getUserId(Binder.getCallingUid());
                PackageInfo pInfo = getPackageInfo(packageName, 0, callingUser);
                if (pInfo != null) {
                    return pInfo.versionCode;
                }
            } catch (Exception e) {
            }
            return 0;
        }
    }
    private class PackageManagerInternalImpl extends PackageManagerInternal {