Merge changes I68868b7f,I092d1385
* changes: Do not cache wildcard users (UserManager) Do not cache wildcard users (PackageManager)
This commit is contained in:
@@ -27,6 +27,7 @@ import android.annotation.Size;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.SystemService;
|
||||
import android.annotation.UserHandleAware;
|
||||
import android.annotation.UserIdInt;
|
||||
import android.app.Activity;
|
||||
import android.app.PropertyInvalidatedCache;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
@@ -349,6 +350,7 @@ public class AccountManager {
|
||||
|
||||
private static final class UserIdPackage
|
||||
{
|
||||
@UserIdInt
|
||||
public int userId;
|
||||
public String packageName;
|
||||
|
||||
@@ -379,7 +381,8 @@ public class AccountManager {
|
||||
}
|
||||
|
||||
PropertyInvalidatedCache<UserIdPackage, Account[]> mAccountsForUserCache =
|
||||
new PropertyInvalidatedCache<UserIdPackage, Account[]>(CACHE_ACCOUNTS_DATA_SIZE, CACHE_KEY_ACCOUNTS_DATA_PROPERTY) {
|
||||
new PropertyInvalidatedCache<UserIdPackage, Account[]>(
|
||||
CACHE_ACCOUNTS_DATA_SIZE, CACHE_KEY_ACCOUNTS_DATA_PROPERTY) {
|
||||
@Override
|
||||
protected Account[] recompute(UserIdPackage userAndPackage) {
|
||||
try {
|
||||
@@ -389,6 +392,10 @@ public class AccountManager {
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected boolean bypass(UserIdPackage query) {
|
||||
return query.userId < 0;
|
||||
}
|
||||
@Override
|
||||
protected boolean debugCompareQueryResults(Account[] l, Account[] r) {
|
||||
if (l == r) {
|
||||
return true;
|
||||
|
||||
@@ -1014,13 +1014,17 @@ public class ApplicationPackageManager extends PackageManager {
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected boolean bypass(Integer uid) {
|
||||
return uid < 0;
|
||||
}
|
||||
@Override
|
||||
public String queryToString(Integer uid) {
|
||||
return String.format("uid=%d", uid.intValue());
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public String[] getPackagesForUid(int uid) {
|
||||
public String[] getPackagesForUid(@UserIdInt int uid) {
|
||||
return mGetPackagesForUidCache.query(uid).value();
|
||||
}
|
||||
|
||||
@@ -1035,7 +1039,7 @@ public class ApplicationPackageManager extends PackageManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameForUid(int uid) {
|
||||
public String getNameForUid(@UserIdInt int uid) {
|
||||
try {
|
||||
return mPM.getNameForUid(uid);
|
||||
} catch (RemoteException e) {
|
||||
|
||||
@@ -9085,6 +9085,7 @@ public abstract class PackageManager {
|
||||
private static final class ApplicationInfoQuery {
|
||||
final String packageName;
|
||||
final int flags;
|
||||
@UserIdInt
|
||||
final int userId;
|
||||
|
||||
ApplicationInfoQuery(@Nullable String packageName, int flags, int userId) {
|
||||
@@ -9146,6 +9147,10 @@ public abstract class PackageManager {
|
||||
query.packageName, query.flags, query.userId);
|
||||
}
|
||||
@Override
|
||||
protected boolean bypass(ApplicationInfoQuery query) {
|
||||
return query.userId < 0;
|
||||
}
|
||||
@Override
|
||||
protected ApplicationInfo maybeCheckConsistency(
|
||||
ApplicationInfoQuery query, ApplicationInfo proposedResult) {
|
||||
// Implementing this debug check for ApplicationInfo would require a
|
||||
@@ -9156,7 +9161,7 @@ public abstract class PackageManager {
|
||||
|
||||
/** @hide */
|
||||
public static ApplicationInfo getApplicationInfoAsUserCached(
|
||||
String packageName, int flags, int userId) {
|
||||
String packageName, int flags, @UserIdInt int userId) {
|
||||
return sApplicationInfoCache.query(
|
||||
new ApplicationInfoQuery(packageName, flags, userId));
|
||||
}
|
||||
@@ -9188,6 +9193,7 @@ public abstract class PackageManager {
|
||||
private static final class PackageInfoQuery {
|
||||
final String packageName;
|
||||
final int flags;
|
||||
@UserIdInt
|
||||
final int userId;
|
||||
|
||||
PackageInfoQuery(@Nullable String packageName, int flags, int userId) {
|
||||
@@ -9248,6 +9254,10 @@ public abstract class PackageManager {
|
||||
query.packageName, query.flags, query.userId);
|
||||
}
|
||||
@Override
|
||||
protected boolean bypass(PackageInfoQuery query) {
|
||||
return query.userId < 0;
|
||||
}
|
||||
@Override
|
||||
protected PackageInfo maybeCheckConsistency(
|
||||
PackageInfoQuery query, PackageInfo proposedResult) {
|
||||
// Implementing this debug check for PackageInfo would require a
|
||||
@@ -9258,7 +9268,7 @@ public abstract class PackageManager {
|
||||
|
||||
/** @hide */
|
||||
public static PackageInfo getPackageInfoAsUserCached(
|
||||
String packageName, int flags, int userId) {
|
||||
String packageName, int flags, @UserIdInt int userId) {
|
||||
return sPackageInfoCache.query(new PackageInfoQuery(packageName, flags, userId));
|
||||
}
|
||||
|
||||
|
||||
@@ -2491,6 +2491,10 @@ public class UserManager {
|
||||
throw re.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected boolean bypass(Integer query) {
|
||||
return query < 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Uses IS_USER_UNLOCKED_PROPERTY for invalidation as the APIs have the same dependencies.
|
||||
@@ -2505,6 +2509,10 @@ public class UserManager {
|
||||
throw re.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected boolean bypass(Integer query) {
|
||||
return query < 0;
|
||||
}
|
||||
};
|
||||
|
||||
/** {@hide} */
|
||||
|
||||
Reference in New Issue
Block a user