Merge "Add getTargetSdkVersion without AppInfo" am: f8ab9c895b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1599639 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Iab7f841edba1f96b5b8248bdee88d9165f4d644e
This commit is contained in:
@@ -12039,6 +12039,7 @@ package android.content.pm {
|
|||||||
method public boolean getSyntheticAppDetailsActivityEnabled(@NonNull String);
|
method public boolean getSyntheticAppDetailsActivityEnabled(@NonNull String);
|
||||||
method @NonNull public abstract android.content.pm.FeatureInfo[] getSystemAvailableFeatures();
|
method @NonNull public abstract android.content.pm.FeatureInfo[] getSystemAvailableFeatures();
|
||||||
method @Nullable public abstract String[] getSystemSharedLibraryNames();
|
method @Nullable public abstract String[] getSystemSharedLibraryNames();
|
||||||
|
method @IntRange(from=0) public int getTargetSdkVersion(@NonNull String) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||||
method @Nullable public abstract CharSequence getText(@NonNull String, @StringRes int, @Nullable android.content.pm.ApplicationInfo);
|
method @Nullable public abstract CharSequence getText(@NonNull String, @StringRes int, @Nullable android.content.pm.ApplicationInfo);
|
||||||
method @NonNull public abstract android.graphics.drawable.Drawable getUserBadgedDrawableForDensity(@NonNull android.graphics.drawable.Drawable, @NonNull android.os.UserHandle, @Nullable android.graphics.Rect, int);
|
method @NonNull public abstract android.graphics.drawable.Drawable getUserBadgedDrawableForDensity(@NonNull android.graphics.drawable.Drawable, @NonNull android.os.UserHandle, @Nullable android.graphics.Rect, int);
|
||||||
method @NonNull public abstract android.graphics.drawable.Drawable getUserBadgedIcon(@NonNull android.graphics.drawable.Drawable, @NonNull android.os.UserHandle);
|
method @NonNull public abstract android.graphics.drawable.Drawable getUserBadgedIcon(@NonNull android.graphics.drawable.Drawable, @NonNull android.os.UserHandle);
|
||||||
|
|||||||
@@ -450,6 +450,19 @@ public class ApplicationPackageManager extends PackageManager {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTargetSdkVersion(@NonNull String packageName) throws NameNotFoundException {
|
||||||
|
try {
|
||||||
|
int version = mPM.getTargetSdkVersion(packageName);
|
||||||
|
if (version != -1) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw e.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
|
throw new PackageManager.NameNotFoundException(packageName);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActivityInfo getActivityInfo(ComponentName className, int flags)
|
public ActivityInfo getActivityInfo(ComponentName className, int flags)
|
||||||
throws NameNotFoundException {
|
throws NameNotFoundException {
|
||||||
|
|||||||
@@ -82,6 +82,11 @@ interface IPackageManager {
|
|||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
ApplicationInfo getApplicationInfo(String packageName, int flags ,int userId);
|
ApplicationInfo getApplicationInfo(String packageName, int flags ,int userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the target SDK for the given package name, or -1 if it cannot be retrieved
|
||||||
|
*/
|
||||||
|
int getTargetSdkVersion(String packageName);
|
||||||
|
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
ActivityInfo getActivityInfo(in ComponentName className, int flags, int userId);
|
ActivityInfo getActivityInfo(in ComponentName className, int flags, int userId);
|
||||||
|
|
||||||
|
|||||||
@@ -4269,6 +4269,15 @@ public abstract class PackageManager {
|
|||||||
return getApplicationInfoAsUser(packageName, flags, user.getIdentifier());
|
return getApplicationInfoAsUser(packageName, flags, user.getIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The target SDK version for the given package name.
|
||||||
|
* @throws NameNotFoundException if a package with the given name cannot be found on the system.
|
||||||
|
*/
|
||||||
|
@IntRange(from = 0)
|
||||||
|
public int getTargetSdkVersion(@NonNull String packageName) throws NameNotFoundException {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve all of the information we know about a particular activity
|
* Retrieve all of the information we know about a particular activity
|
||||||
* class.
|
* class.
|
||||||
|
|||||||
@@ -5349,6 +5349,23 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
return updateFlagsForComponent(flags, userId);
|
return updateFlagsForComponent(flags, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTargetSdkVersion(String packageName) {
|
||||||
|
synchronized (mLock) {
|
||||||
|
final AndroidPackage pkg = mPackages.get(packageName);
|
||||||
|
if (pkg == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
final PackageSetting ps = getPackageSetting(pkg.getPackageName());
|
||||||
|
if (shouldFilterApplicationLocked(ps, Binder.getCallingUid(),
|
||||||
|
UserHandle.getCallingUserId())) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return pkg.getTargetSdkVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActivityInfo getActivityInfo(ComponentName component, int flags, int userId) {
|
public ActivityInfo getActivityInfo(ComponentName component, int flags, int userId) {
|
||||||
return getActivityInfoInternal(component, flags, Binder.getCallingUid(), userId);
|
return getActivityInfoInternal(component, flags, Binder.getCallingUid(), userId);
|
||||||
@@ -24038,15 +24055,13 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTargetSdkVersionForPackage(String packageName)
|
public int getTargetSdkVersionForPackage(String packageName) throws RemoteException {
|
||||||
throws RemoteException {
|
int targetSdk = getTargetSdkVersion(packageName);
|
||||||
int callingUser = UserHandle.getUserId(Binder.getCallingUid());
|
if (targetSdk != -1) {
|
||||||
ApplicationInfo info = getApplicationInfo(packageName, 0, callingUser);
|
return targetSdk;
|
||||||
if (info == null) {
|
|
||||||
throw new RemoteException(
|
|
||||||
"Couldn't get ApplicationInfo for package " + packageName);
|
|
||||||
}
|
}
|
||||||
return info.targetSdkVersion;
|
|
||||||
|
throw new RemoteException("Couldn't get targetSdkVersion for package " + packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user