Merge "Add new API to retrieve app names in a batch" into oc-mr1-dev
am: 5e049eb884
Change-Id: I27542404b197a9d11d611d95f271660856271d40
This commit is contained in:
@@ -41116,6 +41116,7 @@ package android.test.mock {
|
||||
method public android.content.Intent getLaunchIntentForPackage(java.lang.String);
|
||||
method public android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
|
||||
method public java.lang.String getNameForUid(int);
|
||||
method public java.lang.String[] getNamesForUids(int[]);
|
||||
method public int[] getPackageGids(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public int[] getPackageGids(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public android.content.pm.PackageInfo getPackageInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
|
||||
@@ -44817,6 +44817,7 @@ package android.test.mock {
|
||||
method public android.content.Intent getLaunchIntentForPackage(java.lang.String);
|
||||
method public android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
|
||||
method public java.lang.String getNameForUid(int);
|
||||
method public java.lang.String[] getNamesForUids(int[]);
|
||||
method public int[] getPackageGids(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public int[] getPackageGids(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public android.content.pm.PackageInfo getPackageInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
|
||||
@@ -41370,6 +41370,7 @@ package android.test.mock {
|
||||
method public android.content.Intent getLaunchIntentForPackage(java.lang.String);
|
||||
method public android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
|
||||
method public java.lang.String getNameForUid(int);
|
||||
method public java.lang.String[] getNamesForUids(int[]);
|
||||
method public int[] getPackageGids(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public int[] getPackageGids(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public android.content.pm.PackageInfo getPackageInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
|
||||
@@ -31,7 +31,6 @@ import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.ChangedPackages;
|
||||
import android.content.pm.ComponentInfo;
|
||||
import android.content.pm.InstantAppInfo;
|
||||
import android.content.pm.FeatureInfo;
|
||||
import android.content.pm.IOnPermissionsChangeListener;
|
||||
import android.content.pm.IPackageDataObserver;
|
||||
@@ -40,6 +39,7 @@ import android.content.pm.IPackageInstallObserver;
|
||||
import android.content.pm.IPackageManager;
|
||||
import android.content.pm.IPackageMoveObserver;
|
||||
import android.content.pm.IPackageStatsObserver;
|
||||
import android.content.pm.InstantAppInfo;
|
||||
import android.content.pm.InstrumentationInfo;
|
||||
import android.content.pm.IntentFilterVerificationInfo;
|
||||
import android.content.pm.KeySet;
|
||||
@@ -88,13 +88,14 @@ import android.util.LauncherIcons;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
|
||||
import dalvik.system.VMRuntime;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.os.SomeArgs;
|
||||
import com.android.internal.util.Preconditions;
|
||||
import com.android.internal.util.UserIcons;
|
||||
|
||||
import dalvik.system.VMRuntime;
|
||||
|
||||
import libcore.util.EmptyArray;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
@@ -705,6 +706,15 @@ public class ApplicationPackageManager extends PackageManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getNamesForUids(int[] uids) {
|
||||
try {
|
||||
return mPM.getNamesForUids(uids);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUidForSharedUser(String sharedUserName)
|
||||
throws NameNotFoundException {
|
||||
|
||||
@@ -61,6 +61,12 @@ import android.content.IntentSender;
|
||||
* {@hide}
|
||||
*/
|
||||
interface IPackageManager {
|
||||
// Since these transactions are also called from native code, these must be kept in sync with
|
||||
// the ones in frameworks/native/include/binder/IPackageManager.h
|
||||
// =============== Beginning of transactions used on native side as well ======================
|
||||
String[] getNamesForUids(in int[] uids);
|
||||
// =============== End of transactions used on native side as well ============================
|
||||
|
||||
void checkPackageStartable(String packageName, int userId);
|
||||
boolean isPackageAvailable(String packageName, int userId);
|
||||
PackageInfo getPackageInfo(String packageName, int flags, int userId);
|
||||
|
||||
@@ -3589,6 +3589,14 @@ public abstract class PackageManager {
|
||||
*/
|
||||
public abstract @Nullable String getNameForUid(int uid);
|
||||
|
||||
/**
|
||||
* Retrieves the official names associated with each given uid.
|
||||
* @see #getNameForUid(int)
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public abstract @Nullable String[] getNamesForUids(int[] uids);
|
||||
|
||||
/**
|
||||
* Return the user id associated with a shared user name. Multiple
|
||||
* applications can specify a shared user name in their manifest and thus
|
||||
|
||||
@@ -6402,18 +6402,41 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
return null;
|
||||
}
|
||||
synchronized (mPackages) {
|
||||
Object obj = mSettings.getUserIdLPr(UserHandle.getAppId(uid));
|
||||
if (obj instanceof SharedUserSetting) {
|
||||
final SharedUserSetting sus = (SharedUserSetting) obj;
|
||||
return sus.name + ":" + sus.userId;
|
||||
} else if (obj instanceof PackageSetting) {
|
||||
final PackageSetting ps = (PackageSetting) obj;
|
||||
if (filterAppAccessLPr(ps, callingUid, UserHandle.getUserId(callingUid))) {
|
||||
return null;
|
||||
}
|
||||
return ps.name;
|
||||
return getNameForUidLocked(callingUid, uid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getNamesForUids(int[] uids) {
|
||||
if (uids == null || uids.length == 0) {
|
||||
return null;
|
||||
}
|
||||
final int callingUid = Binder.getCallingUid();
|
||||
if (getInstantAppPackageName(callingUid) != null) {
|
||||
return null;
|
||||
}
|
||||
final String[] names = new String[uids.length];
|
||||
synchronized (mPackages) {
|
||||
for (int i = uids.length - 1; i >= 0; i--) {
|
||||
final int uid = uids[i];
|
||||
names[i] = getNameForUidLocked(callingUid, uid);
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
private String getNameForUidLocked(int callingUid, int uid) {
|
||||
Object obj = mSettings.getUserIdLPr(UserHandle.getAppId(uid));
|
||||
if (obj instanceof SharedUserSetting) {
|
||||
final SharedUserSetting sus = (SharedUserSetting) obj;
|
||||
return sus.name + ":" + sus.userId;
|
||||
} else if (obj instanceof PackageSetting) {
|
||||
final PackageSetting ps = (PackageSetting) obj;
|
||||
if (filterAppAccessLPr(ps, callingUid, UserHandle.getUserId(callingUid))) {
|
||||
return null;
|
||||
}
|
||||
return ps.name;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -274,6 +274,11 @@ public class PackageManagerStub extends PackageManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getNamesForUids(int uid[]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUidForSharedUser(String sharedUserName)
|
||||
throws NameNotFoundException {
|
||||
|
||||
@@ -292,6 +292,7 @@ package android.test.mock {
|
||||
method public android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
|
||||
method public int getMoveStatus(int);
|
||||
method public java.lang.String getNameForUid(int);
|
||||
method public java.lang.String[] getNamesForUids(int[]);
|
||||
method public java.util.List<android.os.storage.VolumeInfo> getPackageCandidateVolumes(android.content.pm.ApplicationInfo);
|
||||
method public android.os.storage.VolumeInfo getPackageCurrentVolume(android.content.pm.ApplicationInfo);
|
||||
method public int[] getPackageGids(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
|
||||
@@ -321,6 +321,11 @@ public class MockPackageManager extends PackageManager {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getNamesForUids(int uid[]) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide - to match hiding in superclass
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user