Merge "Move ApplicationInfo.usesNonSdkApi to private flags" am: fdd378c594
am: de5cc1ff5b
Change-Id: I8849fab757c732ab600e243c187f9acd0aa2c9d7
This commit is contained in:
@@ -621,6 +621,13 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
|
||||
*/
|
||||
public static final int PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY = 1 << 20;
|
||||
|
||||
/**
|
||||
* Indicates whether this package requires access to non-SDK APIs.
|
||||
* Only system apps and tests are allowed to use this property.
|
||||
* @hide
|
||||
*/
|
||||
public static final int PRIVATE_FLAG_USES_NON_SDK_API = 1 << 22;
|
||||
|
||||
/** @hide */
|
||||
@IntDef(flag = true, prefix = { "PRIVATE_FLAG_" }, value = {
|
||||
PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE,
|
||||
@@ -1000,13 +1007,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
|
||||
*/
|
||||
public String appComponentFactory;
|
||||
|
||||
/**
|
||||
* Indicates whether this package requires access to non-SDK APIs. Only system apps
|
||||
* and tests are allowed to use this property.
|
||||
* @hide
|
||||
*/
|
||||
public boolean usesNonSdkApi;
|
||||
|
||||
/**
|
||||
* The category of this app. Categories are used to cluster multiple apps
|
||||
* together into meaningful groups, such as when summarizing battery,
|
||||
@@ -1286,6 +1286,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
|
||||
pw.println(prefix + "category=" + category);
|
||||
}
|
||||
pw.println(prefix + "HiddenApiEnforcementPolicy=" + getHiddenApiEnforcementPolicy());
|
||||
pw.println(prefix + "usesNonSdkApi=" + usesNonSdkApi());
|
||||
}
|
||||
super.dumpBack(pw, prefix);
|
||||
}
|
||||
@@ -1710,11 +1711,18 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
|
||||
return SystemConfig.getInstance().getHiddenApiWhitelistedApps().contains(packageName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public boolean usesNonSdkApi() {
|
||||
return (privateFlags & PRIVATE_FLAG_USES_NON_SDK_API) != 0;
|
||||
}
|
||||
|
||||
private boolean isAllowedToUseHiddenApis() {
|
||||
if (isSignedWithPlatformKey()) {
|
||||
return true;
|
||||
} else if (isSystemApp() || isUpdatedSystemApp()) {
|
||||
return usesNonSdkApi || isPackageWhitelistedForHiddenApis();
|
||||
return usesNonSdkApi() || isPackageWhitelistedForHiddenApis();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3588,8 +3588,10 @@ public class PackageParser {
|
||||
ai.appComponentFactory = buildClassName(ai.packageName, factory, outError);
|
||||
}
|
||||
|
||||
ai.usesNonSdkApi = sa.getBoolean(
|
||||
com.android.internal.R.styleable.AndroidManifestApplication_usesNonSdkApi, false);
|
||||
if (sa.getBoolean(
|
||||
com.android.internal.R.styleable.AndroidManifestApplication_usesNonSdkApi, false)) {
|
||||
ai.privateFlags |= ApplicationInfo.PRIVATE_FLAG_USES_NON_SDK_API;
|
||||
}
|
||||
|
||||
if (outError[0] == null) {
|
||||
CharSequence pname;
|
||||
|
||||
@@ -22034,7 +22034,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
activeInstr.mUiAutomationConnection = uiAutomationConnection;
|
||||
activeInstr.mResultClass = className;
|
||||
|
||||
boolean disableHiddenApiChecks = ai.usesNonSdkApi
|
||||
boolean disableHiddenApiChecks = ai.usesNonSdkApi()
|
||||
|| (flags & INSTRUMENTATION_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0;
|
||||
if (disableHiddenApiChecks) {
|
||||
enforceCallingPermission(android.Manifest.permission.DISABLE_HIDDEN_API_CHECKS,
|
||||
|
||||
Reference in New Issue
Block a user