Merge "Move ApplicationInfo.usesNonSdkApi to private flags"
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;
|
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 */
|
/** @hide */
|
||||||
@IntDef(flag = true, prefix = { "PRIVATE_FLAG_" }, value = {
|
@IntDef(flag = true, prefix = { "PRIVATE_FLAG_" }, value = {
|
||||||
PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE,
|
PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE,
|
||||||
@@ -1000,13 +1007,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public String appComponentFactory;
|
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
|
* The category of this app. Categories are used to cluster multiple apps
|
||||||
* together into meaningful groups, such as when summarizing battery,
|
* together into meaningful groups, such as when summarizing battery,
|
||||||
@@ -1283,6 +1283,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
|
|||||||
pw.println(prefix + "category=" + category);
|
pw.println(prefix + "category=" + category);
|
||||||
}
|
}
|
||||||
pw.println(prefix + "HiddenApiEnforcementPolicy=" + getHiddenApiEnforcementPolicy());
|
pw.println(prefix + "HiddenApiEnforcementPolicy=" + getHiddenApiEnforcementPolicy());
|
||||||
|
pw.println(prefix + "usesNonSdkApi=" + usesNonSdkApi());
|
||||||
}
|
}
|
||||||
super.dumpBack(pw, prefix);
|
super.dumpBack(pw, prefix);
|
||||||
}
|
}
|
||||||
@@ -1704,11 +1705,18 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
|
|||||||
return SystemConfig.getInstance().getHiddenApiWhitelistedApps().contains(packageName);
|
return SystemConfig.getInstance().getHiddenApiWhitelistedApps().contains(packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public boolean usesNonSdkApi() {
|
||||||
|
return (privateFlags & PRIVATE_FLAG_USES_NON_SDK_API) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isAllowedToUseHiddenApis() {
|
private boolean isAllowedToUseHiddenApis() {
|
||||||
if (isSignedWithPlatformKey()) {
|
if (isSignedWithPlatformKey()) {
|
||||||
return true;
|
return true;
|
||||||
} else if (isSystemApp() || isUpdatedSystemApp()) {
|
} else if (isSystemApp() || isUpdatedSystemApp()) {
|
||||||
return usesNonSdkApi || isPackageWhitelistedForHiddenApis();
|
return usesNonSdkApi() || isPackageWhitelistedForHiddenApis();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3580,8 +3580,10 @@ public class PackageParser {
|
|||||||
ai.appComponentFactory = buildClassName(ai.packageName, factory, outError);
|
ai.appComponentFactory = buildClassName(ai.packageName, factory, outError);
|
||||||
}
|
}
|
||||||
|
|
||||||
ai.usesNonSdkApi = sa.getBoolean(
|
if (sa.getBoolean(
|
||||||
com.android.internal.R.styleable.AndroidManifestApplication_usesNonSdkApi, false);
|
com.android.internal.R.styleable.AndroidManifestApplication_usesNonSdkApi, false)) {
|
||||||
|
ai.privateFlags |= ApplicationInfo.PRIVATE_FLAG_USES_NON_SDK_API;
|
||||||
|
}
|
||||||
|
|
||||||
if (outError[0] == null) {
|
if (outError[0] == null) {
|
||||||
CharSequence pname;
|
CharSequence pname;
|
||||||
|
|||||||
@@ -21996,7 +21996,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
activeInstr.mUiAutomationConnection = uiAutomationConnection;
|
activeInstr.mUiAutomationConnection = uiAutomationConnection;
|
||||||
activeInstr.mResultClass = className;
|
activeInstr.mResultClass = className;
|
||||||
|
|
||||||
boolean disableHiddenApiChecks = ai.usesNonSdkApi
|
boolean disableHiddenApiChecks = ai.usesNonSdkApi()
|
||||||
|| (flags & INSTRUMENTATION_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0;
|
|| (flags & INSTRUMENTATION_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0;
|
||||||
if (disableHiddenApiChecks) {
|
if (disableHiddenApiChecks) {
|
||||||
enforceCallingPermission(android.Manifest.permission.DISABLE_HIDDEN_API_CHECKS,
|
enforceCallingPermission(android.Manifest.permission.DISABLE_HIDDEN_API_CHECKS,
|
||||||
|
|||||||
Reference in New Issue
Block a user