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

Commit fa5e8361 authored by David Brazdil's avatar David Brazdil
Browse files

Move ApplicationInfo.usesNonSdkApi to private flags

No need to create an extra field for a boolean flag. Move the recently
added ApplicationInfo.usesNonSdkApi to one bit in privateFlags.

This also solves an issue where the field was not propagated during
copying of the data structure.

Bug: 113315999
Test: phone boots
Merged-In: I09f8f39454c013a84893ac304904a4412fc542bf
Change-Id: I09f8f39454c013a84893ac304904a4412fc542bf
(cherry picked from commit a5b4df2a)
parent 08d7a208
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,