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

Commit ea82335c authored by Hai Zhang's avatar Hai Zhang
Browse files

Add knownCerts to system API and copy constructor.

PermissionInfo.PROTECTION_FLAG_KNOWN_SIGNER is already @SystemApi, and
we need system API for accessing the actual certs in the modularized
permission subsystem.

The copy constructor missed knownCerts in ag/13504004 and is fixed now.
knownCerts isn't deep copied in the copy constructor because
PackageItemInfo.metaData isn't deep copied either.

Bug: 182523293
Test: atest CtsContentTestCases:PermissionInfoTest
Change-Id: I784764fdf7238f6b10455ff40c693de0823a94cb
parent 84d43a7e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3617,6 +3617,7 @@ package android.content.pm {
    field public static final int PROTECTION_FLAG_SYSTEM_TEXT_CLASSIFIER = 65536; // 0x10000
    field @Deprecated public static final int PROTECTION_FLAG_WELLBEING = 131072; // 0x20000
    field @Nullable public final String backgroundPermission;
    field @NonNull public java.util.Set<java.lang.String> knownCerts;
    field @StringRes public int requestRes;
  }
+8 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StringRes;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
@@ -33,6 +34,7 @@ import com.android.internal.util.Parcelling.BuiltIn.ForStringSet;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Collections;
import java.util.Set;

/**
@@ -486,7 +488,10 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
     *
     * @hide
     */
    public @Nullable Set<String> knownCerts;
    // Already being used as mutable and most other fields in this class are also mutable.
    @SuppressLint("MutableBareField")
    @SystemApi
    public @NonNull Set<String> knownCerts = Collections.emptySet();

    /** @hide */
    public static int fixProtectionLevel(int level) {
@@ -620,6 +625,8 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable {
        descriptionRes = orig.descriptionRes;
        requestRes = orig.requestRes;
        nonLocalizedDescription = orig.nonLocalizedDescription;
        // Note that knownCerts wasn't properly copied before Android U.
        knownCerts = orig.knownCerts;
    }

    /**