Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b19f26e7 authored by David Brazdil's avatar David Brazdil Committed by Android (Google) Code Review
Browse files

Merge "Move ApplicationInfo.usesNonSdkApi to private flags"

parents 3b37d4d8 a5b4df2a
Loading
Loading
Loading
Loading
+19 −11
Original line number Diff line number Diff line
@@ -614,6 +614,13 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public static final int PRIVATE_FLAG_PRODUCT = 1 << 19;

    /**
     * Value for {@link #privateFlags}: whether this app is signed with the
     * platform key.
     * @hide
     */
    public static final int PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY = 1 << 20;

    /**
     * Value for {@link #privateFlags}: whether this app is pre-installed on the
     * google partition of the system image.
@@ -622,11 +629,11 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
    public static final int PRIVATE_FLAG_PRODUCT_SERVICES = 1 << 21;

    /**
     * Value for {@link #privateFlags}: whether this app is signed with the
     * platform key.
     * 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_SIGNED_WITH_PLATFORM_KEY = 1 << 20;
    public static final int PRIVATE_FLAG_USES_NON_SDK_API = 1 << 22;

    /** @hide */
    @IntDef(flag = true, prefix = { "PRIVATE_FLAG_" }, value = {
@@ -1008,13 +1015,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,
@@ -1294,6 +1294,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);
    }
@@ -1718,11 +1719,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;
        }
+4 −2
Original line number Diff line number Diff line
@@ -3659,8 +3659,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;
+1 −1
Original line number Diff line number Diff line
@@ -17061,7 +17061,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,