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

Commit fdd378c5 authored by David Brazdil's avatar David Brazdil Committed by Gerrit Code Review
Browse files

Merge "Move ApplicationInfo.usesNonSdkApi to private flags"

parents 3d93d8f3 fa5e8361
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -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,
@@ -1283,6 +1283,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);
    }
@@ -1704,11 +1705,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
@@ -3580,8 +3580,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
@@ -21996,7 +21996,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,