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

Commit 5b734e17 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Update language to comply with Android’s inclusive language guidance.

See https://source.android.com/setup/contribute/respectful-code for reference

Test: atest --test-mapping apex/blobstore
Change-Id: Ic1db6fadab90667b0c3a383caa9ad60fab7d1f1b
parent 35fe926d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -89,8 +89,8 @@ import java.util.function.Consumer;
 * <p> Before committing the session, apps can indicate which apps are allowed to access the
 * contributed data using one or more of the following access modes:
 * <ul>
 *     <li> {@link Session#allowPackageAccess(String, byte[])} which will allow whitelisting
 *          specific packages to access the blobs.
 *     <li> {@link Session#allowPackageAccess(String, byte[])} which will allow specific packages
 *          to access the blobs.
 *     <li> {@link Session#allowSameSignatureAccess()} which will allow only apps which are signed
 *          with the same certificate as the app which contributed the blob to access it.
 *     <li> {@link Session#allowPublicAccess()} which will allow any app on the device to access
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ public final class XmlTags {
    // For BlobAccessMode
    public static final String TAG_ACCESS_MODE = "am";
    public static final String ATTR_TYPE = "t";
    public static final String TAG_WHITELISTED_PACKAGE = "wl";
    public static final String TAG_ALLOWED_PACKAGE = "wl";
    public static final String ATTR_CERTIFICATE = "ct";

    // For BlobHandle
+24 −24
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package com.android.server.blob;
import static android.app.blob.XmlTags.ATTR_CERTIFICATE;
import static android.app.blob.XmlTags.ATTR_PACKAGE;
import static android.app.blob.XmlTags.ATTR_TYPE;
import static android.app.blob.XmlTags.TAG_WHITELISTED_PACKAGE;
import static android.app.blob.XmlTags.TAG_ALLOWED_PACKAGE;

import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -52,21 +52,21 @@ class BlobAccessMode {
            ACCESS_TYPE_PRIVATE,
            ACCESS_TYPE_PUBLIC,
            ACCESS_TYPE_SAME_SIGNATURE,
            ACCESS_TYPE_WHITELIST,
            ACCESS_TYPE_ALLOWLIST,
    })
    @interface AccessType {}
    public static final int ACCESS_TYPE_PRIVATE = 1 << 0;
    public static final int ACCESS_TYPE_PUBLIC = 1 << 1;
    public static final int ACCESS_TYPE_SAME_SIGNATURE = 1 << 2;
    public static final int ACCESS_TYPE_WHITELIST = 1 << 3;
    public static final int ACCESS_TYPE_ALLOWLIST = 1 << 3;

    private int mAccessType = ACCESS_TYPE_PRIVATE;

    private final ArraySet<PackageIdentifier> mWhitelistedPackages = new ArraySet<>();
    private final ArraySet<PackageIdentifier> mAllowedPackages = new ArraySet<>();

    void allow(BlobAccessMode other) {
        if ((other.mAccessType & ACCESS_TYPE_WHITELIST) != 0) {
            mWhitelistedPackages.addAll(other.mWhitelistedPackages);
        if ((other.mAccessType & ACCESS_TYPE_ALLOWLIST) != 0) {
            mAllowedPackages.addAll(other.mAllowedPackages);
        }
        mAccessType |= other.mAccessType;
    }
@@ -80,8 +80,8 @@ class BlobAccessMode {
    }

    void allowPackageAccess(@NonNull String packageName, @NonNull byte[] certificate) {
        mAccessType |= ACCESS_TYPE_WHITELIST;
        mWhitelistedPackages.add(PackageIdentifier.create(packageName, certificate));
        mAccessType |= ACCESS_TYPE_ALLOWLIST;
        mAllowedPackages.add(PackageIdentifier.create(packageName, certificate));
    }

    boolean isPublicAccessAllowed() {
@@ -93,10 +93,10 @@ class BlobAccessMode {
    }

    boolean isPackageAccessAllowed(@NonNull String packageName, @NonNull byte[] certificate) {
        if ((mAccessType & ACCESS_TYPE_WHITELIST) == 0) {
        if ((mAccessType & ACCESS_TYPE_ALLOWLIST) == 0) {
            return false;
        }
        return mWhitelistedPackages.contains(PackageIdentifier.create(packageName, certificate));
        return mAllowedPackages.contains(PackageIdentifier.create(packageName, certificate));
    }

    boolean isAccessAllowedForCaller(Context context,
@@ -113,9 +113,9 @@ class BlobAccessMode {
            }
        }

        if ((mAccessType & ACCESS_TYPE_WHITELIST) != 0) {
            for (int i = 0; i < mWhitelistedPackages.size(); ++i) {
                final PackageIdentifier packageIdentifier = mWhitelistedPackages.valueAt(i);
        if ((mAccessType & ACCESS_TYPE_ALLOWLIST) != 0) {
            for (int i = 0; i < mAllowedPackages.size(); ++i) {
                final PackageIdentifier packageIdentifier = mAllowedPackages.valueAt(i);
                if (packageIdentifier.packageName.equals(callingPackage)
                        && pm.hasSigningCertificate(callingPackage, packageIdentifier.certificate,
                                PackageManager.CERT_INPUT_SHA256)) {
@@ -131,20 +131,20 @@ class BlobAccessMode {
        return mAccessType;
    }

    int getNumWhitelistedPackages() {
        return mWhitelistedPackages.size();
    int getAllowedPackagesCount() {
        return mAllowedPackages.size();
    }

    void dump(IndentingPrintWriter fout) {
        fout.println("accessType: " + DebugUtils.flagsToString(
                BlobAccessMode.class, "ACCESS_TYPE_", mAccessType));
        fout.print("Whitelisted pkgs:");
        if (mWhitelistedPackages.isEmpty()) {
        fout.print("Explicitly allowed pkgs:");
        if (mAllowedPackages.isEmpty()) {
            fout.println(" (Empty)");
        } else {
            fout.increaseIndent();
            for (int i = 0, count = mWhitelistedPackages.size(); i < count; ++i) {
                fout.println(mWhitelistedPackages.valueAt(i).toString());
            for (int i = 0, count = mAllowedPackages.size(); i < count; ++i) {
                fout.println(mAllowedPackages.valueAt(i).toString());
            }
            fout.decreaseIndent();
        }
@@ -152,12 +152,12 @@ class BlobAccessMode {

    void writeToXml(@NonNull XmlSerializer out) throws IOException {
        XmlUtils.writeIntAttribute(out, ATTR_TYPE, mAccessType);
        for (int i = 0, count = mWhitelistedPackages.size(); i < count; ++i) {
            out.startTag(null, TAG_WHITELISTED_PACKAGE);
            final PackageIdentifier packageIdentifier = mWhitelistedPackages.valueAt(i);
        for (int i = 0, count = mAllowedPackages.size(); i < count; ++i) {
            out.startTag(null, TAG_ALLOWED_PACKAGE);
            final PackageIdentifier packageIdentifier = mAllowedPackages.valueAt(i);
            XmlUtils.writeStringAttribute(out, ATTR_PACKAGE, packageIdentifier.packageName);
            XmlUtils.writeByteArrayAttribute(out, ATTR_CERTIFICATE, packageIdentifier.certificate);
            out.endTag(null, TAG_WHITELISTED_PACKAGE);
            out.endTag(null, TAG_ALLOWED_PACKAGE);
        }
    }

@@ -171,7 +171,7 @@ class BlobAccessMode {

        final int depth = in.getDepth();
        while (XmlUtils.nextElementWithin(in, depth)) {
            if (TAG_WHITELISTED_PACKAGE.equals(in.getName())) {
            if (TAG_ALLOWED_PACKAGE.equals(in.getName())) {
                final String packageName = XmlUtils.readStringAttribute(in, ATTR_PACKAGE);
                final byte[] certificate = XmlUtils.readByteArrayAttribute(in, ATTR_CERTIFICATE);
                blobAccessMode.allowPackageAccess(packageName, certificate);
+1 −1
Original line number Diff line number Diff line
@@ -478,7 +478,7 @@ class BlobMetadata {
                proto.write(BlobStatsEventProto.BlobCommitterProto.ACCESS_MODE,
                        committer.blobAccessMode.getAccessType());
                proto.write(BlobStatsEventProto.BlobCommitterProto.NUM_WHITELISTED_PACKAGE,
                        committer.blobAccessMode.getNumWhitelistedPackages());
                        committer.blobAccessMode.getAllowedPackagesCount());
                proto.end(token);
            }
            final byte[] committersBytes = proto.getBytes();
+2 −2
Original line number Diff line number Diff line
@@ -332,10 +332,10 @@ class BlobStoreSession extends IBlobStoreSession.Stub {
                throw new IllegalStateException("Not allowed to change access type in state: "
                        + stateToString(mState));
            }
            if (mBlobAccessMode.getNumWhitelistedPackages() >= getMaxPermittedPackages()) {
            if (mBlobAccessMode.getAllowedPackagesCount() >= getMaxPermittedPackages()) {
                throw new ParcelableException(new LimitExceededException(
                        "Too many packages permitted to access the blob: "
                                + mBlobAccessMode.getNumWhitelistedPackages()));
                                + mBlobAccessMode.getAllowedPackagesCount()));
            }
            mBlobAccessMode.allowPackageAccess(packageName, certificate);
        }