summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/content/pm/IPackageManager.aidl2
-rw-r--r--services/core/java/com/android/server/AppOpsService.java9
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java39
3 files changed, 33 insertions, 17 deletions
diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl
index a5e9faf..fec2c44 100644
--- a/core/java/android/content/pm/IPackageManager.aidl
+++ b/core/java/android/content/pm/IPackageManager.aidl
@@ -63,7 +63,9 @@ interface IPackageManager {
boolean isPackageAvailable(String packageName, int userId);
PackageInfo getPackageInfo(String packageName, int flags, int userId);
int getPackageUid(String packageName, int userId);
+ int getPackageUidEtc(String packageName, int flags, int userId);
int[] getPackageGids(String packageName, int userId);
+ int[] getPackageGidsEtc(String packageName, int flags, int userId);
String[] currentToCanonicalPackageNames(in String[] names);
String[] canonicalToCurrentPackageNames(in String[] names);
diff --git a/services/core/java/com/android/server/AppOpsService.java b/services/core/java/com/android/server/AppOpsService.java
index c373fb8..96c1e2a 100644
--- a/services/core/java/com/android/server/AppOpsService.java
+++ b/services/core/java/com/android/server/AppOpsService.java
@@ -39,7 +39,6 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
import android.media.AudioAttributes;
import android.os.AsyncTask;
import android.os.Binder;
@@ -263,12 +262,12 @@ public class AppOpsService extends IAppOpsService.Stub {
Iterator<Ops> it = pkgs.values().iterator();
while (it.hasNext()) {
Ops ops = it.next();
- int curUid;
+ int curUid = -1;
try {
- curUid = mContext.getPackageManager().getPackageUid(ops.packageName,
+ curUid = AppGlobals.getPackageManager().getPackageUidEtc(ops.packageName,
+ PackageManager.GET_UNINSTALLED_PACKAGES,
UserHandle.getUserId(ops.uidState.uid));
- } catch (NameNotFoundException e) {
- curUid = -1;
+ } catch (RemoteException ignored) {
}
if (curUid != ops.uidState.uid) {
Slog.i(TAG, "Pruning old package " + ops.packageName
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 5977a1b..cf15334 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -2733,26 +2733,38 @@ public class PackageManagerService extends IPackageManager.Stub {
@Override
public int getPackageUid(String packageName, int userId) {
+ return getPackageUidEtc(packageName, 0, userId);
+ }
+
+ @Override
+ public int getPackageUidEtc(String packageName, int flags, int userId) {
if (!sUserManager.exists(userId)) return -1;
enforceCrossUserPermission(Binder.getCallingUid(), userId, false, false, "get package uid");
// reader
synchronized (mPackages) {
- PackageParser.Package p = mPackages.get(packageName);
- if(p != null) {
+ final PackageParser.Package p = mPackages.get(packageName);
+ if (p != null) {
return UserHandle.getUid(userId, p.applicationInfo.uid);
}
- PackageSetting ps = mSettings.mPackages.get(packageName);
- if((ps == null) || (ps.pkg == null) || (ps.pkg.applicationInfo == null)) {
- return -1;
+ if ((flags & PackageManager.GET_UNINSTALLED_PACKAGES) != 0) {
+ final PackageSetting ps = mSettings.mPackages.get(packageName);
+ if (ps != null) {
+ return UserHandle.getUid(userId, ps.appId);
+ }
}
- p = ps.pkg;
- return p != null ? UserHandle.getUid(userId, p.applicationInfo.uid) : -1;
}
+
+ return -1;
+ }
+
+ @Override
+ public int[] getPackageGids(String packageName, int userId) {
+ return getPackageGidsEtc(packageName, 0, userId);
}
@Override
- public int[] getPackageGids(String packageName, int userId) throws RemoteException {
+ public int[] getPackageGidsEtc(String packageName, int flags, int userId) {
if (!sUserManager.exists(userId)) {
return null;
}
@@ -2762,14 +2774,17 @@ public class PackageManagerService extends IPackageManager.Stub {
// reader
synchronized (mPackages) {
- PackageParser.Package p = mPackages.get(packageName);
- if (DEBUG_PACKAGE_INFO) {
- Log.v(TAG, "getPackageGids" + packageName + ": " + p);
- }
+ final PackageParser.Package p = mPackages.get(packageName);
if (p != null) {
PackageSetting ps = (PackageSetting) p.mExtras;
return ps.getPermissionsState().computeGids(userId);
}
+ if ((flags & PackageManager.GET_UNINSTALLED_PACKAGES) != 0) {
+ final PackageSetting ps = mSettings.mPackages.get(packageName);
+ if (ps != null) {
+ return ps.getPermissionsState().computeGids(userId);
+ }
+ }
}
return null;