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

Commit 8890becc authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Automerger Merge Worker
Browse files

Merge "Updated DisplayHash APIs" into sc-dev am: 8570e52d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14100524

Change-Id: Ia49e144989dbb341dcc2e10cc26a093520e5453f
parents 0e7439a3 8570e52d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -48518,7 +48518,7 @@ package android.view {
    method public android.view.View focusSearch(int);
    method public void forceHasOverlappingRendering(boolean);
    method public void forceLayout();
    method @Nullable public void generateDisplayHash(@NonNull String, @Nullable android.graphics.Rect, @NonNull java.util.concurrent.Executor, @NonNull android.view.displayhash.DisplayHashResultCallback);
    method public void generateDisplayHash(@NonNull String, @Nullable android.graphics.Rect, @NonNull java.util.concurrent.Executor, @NonNull android.view.displayhash.DisplayHashResultCallback);
    method public static int generateViewId();
    method public CharSequence getAccessibilityClassName();
    method public android.view.View.AccessibilityDelegate getAccessibilityDelegate();
+8 −7
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ package android {
    field public static final String BIND_CONTENT_CAPTURE_SERVICE = "android.permission.BIND_CONTENT_CAPTURE_SERVICE";
    field public static final String BIND_CONTENT_SUGGESTIONS_SERVICE = "android.permission.BIND_CONTENT_SUGGESTIONS_SERVICE";
    field public static final String BIND_DIRECTORY_SEARCH = "android.permission.BIND_DIRECTORY_SEARCH";
    field public static final String BIND_DISPLAY_HASHING_SERVICE = "android.permission.BIND_DISPLAY_HASHING_SERVICE";
    field public static final String BIND_DOMAIN_VERIFICATION_AGENT = "android.permission.BIND_DOMAIN_VERIFICATION_AGENT";
    field public static final String BIND_EUICC_SERVICE = "android.permission.BIND_EUICC_SERVICE";
    field public static final String BIND_EXTERNAL_STORAGE_SERVICE = "android.permission.BIND_EXTERNAL_STORAGE_SERVICE";
@@ -9864,7 +9865,7 @@ package android.service.displayhash {
  public final class DisplayHashParams implements android.os.Parcelable {
    method public int describeContents();
    method @Nullable public android.util.Size getBufferSize();
    method public boolean isGrayscaleBuffer();
    method public boolean isUseGrayscale();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.service.displayhash.DisplayHashParams> CREATOR;
  }
@@ -9873,17 +9874,17 @@ package android.service.displayhash {
    ctor public DisplayHashParams.Builder();
    method @NonNull public android.service.displayhash.DisplayHashParams build();
    method @NonNull public android.service.displayhash.DisplayHashParams.Builder setBufferSize(int, int);
    method @NonNull public android.service.displayhash.DisplayHashParams.Builder setGrayscaleBuffer(boolean);
    method @NonNull public android.service.displayhash.DisplayHashParams.Builder setUseGrayscale(boolean);
  }
  public abstract class DisplayHasherService extends android.app.Service {
    ctor public DisplayHasherService();
  public abstract class DisplayHashingService extends android.app.Service {
    ctor public DisplayHashingService();
    method @NonNull public final android.os.IBinder onBind(@NonNull android.content.Intent);
    method @Nullable public abstract void onGenerateDisplayHash(@NonNull byte[], @NonNull android.hardware.HardwareBuffer, @NonNull android.graphics.Rect, @NonNull String, @NonNull android.view.displayhash.DisplayHashResultCallback);
    method public abstract void onGenerateDisplayHash(@NonNull byte[], @NonNull android.hardware.HardwareBuffer, @NonNull android.graphics.Rect, @NonNull String, @NonNull android.view.displayhash.DisplayHashResultCallback);
    method @NonNull public abstract java.util.Map<java.lang.String,android.service.displayhash.DisplayHashParams> onGetDisplayHashAlgorithms();
    method @Nullable public abstract android.view.displayhash.VerifiedDisplayHash onVerifyDisplayHash(@NonNull byte[], @NonNull android.view.displayhash.DisplayHash);
    field public static final String SERVICE_INTERFACE = "android.service.displayhash.DisplayHasherService";
    field public static final String SERVICE_META_DATA = "android.displayhash.display_hasher_service";
    field public static final String SERVICE_INTERFACE = "android.service.displayhash.DisplayHashingService";
    field public static final String SERVICE_META_DATA = "android.displayhash.display_hashing_service";
  }
}
+28 −28
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import android.view.displayhash.DisplayHashResultCallback;
import com.android.internal.util.DataClass;

/**
 * Information passed from the {@link DisplayHasherService} to system server about how to get the
 * Information passed from the {@link DisplayHashingService} to system server about how to get the
 * display data that will be used to generate the {@link android.view.displayhash.DisplayHash}
 *
 * @hide
@@ -38,9 +38,9 @@ import com.android.internal.util.DataClass;
public final class DisplayHashParams implements Parcelable {
    /**
     * The size to scale the buffer to so the hash algorithm can properly generate the hash. The
     * buffer given to the {@link DisplayHasherService#onGenerateDisplayHash(byte[], HardwareBuffer,
     * Rect, String, DisplayHashResultCallback)} will be stretched based on the value set here.
     * If {@code null}, the buffer size will not be changed.
     * buffer given to the {@link DisplayHashingService#onGenerateDisplayHash(byte[],
     * HardwareBuffer, Rect, String, DisplayHashResultCallback)} will be stretched based on the
     * value set here. If {@code null}, the buffer size will not be changed.
     */
    @Nullable
    private final Size mBufferSize;
@@ -48,7 +48,7 @@ public final class DisplayHashParams implements Parcelable {
    /**
     * Whether the content will be captured in grayscale or color.
     */
    private final boolean mGrayscaleBuffer;
    private final boolean mUseGrayscale;

    /**
     * A builder for {@link DisplayHashParams}
@@ -56,7 +56,7 @@ public final class DisplayHashParams implements Parcelable {
    public static final class Builder {
        @Nullable
        private Size mBufferSize;
        private boolean mGrayscaleBuffer;
        private boolean mUseGrayscale;

        /**
         * Creates a new Builder.
@@ -68,8 +68,8 @@ public final class DisplayHashParams implements Parcelable {
         * The size to scale the buffer to so the hash algorithm can properly generate the hash.
         */
        @NonNull
        public Builder setBufferSize(int w, int h) {
            mBufferSize = new Size(w, h);
        public Builder setBufferSize(int width, int height) {
            mBufferSize = new Size(width, height);
            return this;
        }

@@ -77,15 +77,15 @@ public final class DisplayHashParams implements Parcelable {
         * Whether the content will be captured in grayscale or color.
         */
        @NonNull
        public Builder setGrayscaleBuffer(boolean value) {
            mGrayscaleBuffer = value;
        public Builder setUseGrayscale(boolean useGrayscale) {
            mUseGrayscale = useGrayscale;
            return this;
        }

        /** Builds the instance. This builder should not be touched after calling this! */
        @NonNull
        public DisplayHashParams build() {
            return new DisplayHashParams(mBufferSize, mGrayscaleBuffer);
            return new DisplayHashParams(mBufferSize, mUseGrayscale);
        }
    }

@@ -109,28 +109,28 @@ public final class DisplayHashParams implements Parcelable {
     *
     * @param bufferSize
     *   The size to scale the buffer to so the hash algorithm can properly generate the hash. The
     *   buffer given to the {@link DisplayHasherService#onGenerateDisplayHash(byte[], HardwareBuffer,
     *   Rect, String, DisplayHashResultCallback)} will be stretched based on the value set here.
     *   If {@code null}, the buffer size will not be changed.
     * @param grayscaleBuffer
     *   buffer given to the {@link DisplayHashingService#onGenerateDisplayHash(byte[],
     *   HardwareBuffer, Rect, String, DisplayHashResultCallback)} will be stretched based on the
     *   value set here. If {@code null}, the buffer size will not be changed.
     * @param useGrayscale
     *   Whether the content will be captured in grayscale or color.
     * @hide
     */
    @DataClass.Generated.Member
    public DisplayHashParams(
            @Nullable Size bufferSize,
            boolean grayscaleBuffer) {
            boolean useGrayscale) {
        this.mBufferSize = bufferSize;
        this.mGrayscaleBuffer = grayscaleBuffer;
        this.mUseGrayscale = useGrayscale;

        // onConstructed(); // You can define this method to get a callback
    }

    /**
     * The size to scale the buffer to so the hash algorithm can properly generate the hash. The
     * buffer given to the {@link DisplayHasherService#onGenerateDisplayHash(byte[], HardwareBuffer,
     * Rect, String, DisplayHashResultCallback)} will be stretched based on the value set here.
     * If {@code null}, the buffer size will not be changed.
     * buffer given to the {@link DisplayHashingService#onGenerateDisplayHash(byte[],
     * HardwareBuffer, Rect, String, DisplayHashResultCallback)} will be stretched based on the
     * value set here. If {@code null}, the buffer size will not be changed.
     */
    @DataClass.Generated.Member
    public @Nullable Size getBufferSize() {
@@ -141,8 +141,8 @@ public final class DisplayHashParams implements Parcelable {
     * Whether the content will be captured in grayscale or color.
     */
    @DataClass.Generated.Member
    public boolean isGrayscaleBuffer() {
        return mGrayscaleBuffer;
    public boolean isUseGrayscale() {
        return mUseGrayscale;
    }

    @Override
@@ -153,7 +153,7 @@ public final class DisplayHashParams implements Parcelable {

        return "DisplayHashParams { " +
                "bufferSize = " + mBufferSize + ", " +
                "grayscaleBuffer = " + mGrayscaleBuffer +
                "useGrayscale = " + mUseGrayscale +
        " }";
    }

@@ -164,7 +164,7 @@ public final class DisplayHashParams implements Parcelable {
        // void parcelFieldName(Parcel dest, int flags) { ... }

        byte flg = 0;
        if (mGrayscaleBuffer) flg |= 0x2;
        if (mUseGrayscale) flg |= 0x2;
        if (mBufferSize != null) flg |= 0x1;
        dest.writeByte(flg);
        if (mBufferSize != null) dest.writeSize(mBufferSize);
@@ -182,11 +182,11 @@ public final class DisplayHashParams implements Parcelable {
        // static FieldType unparcelFieldName(Parcel in) { ... }

        byte flg = in.readByte();
        boolean grayscaleBuffer = (flg & 0x2) != 0;
        boolean useGrayscale = (flg & 0x2) != 0;
        Size bufferSize = (flg & 0x1) == 0 ? null : (Size) in.readSize();

        this.mBufferSize = bufferSize;
        this.mGrayscaleBuffer = grayscaleBuffer;
        this.mUseGrayscale = useGrayscale;

        // onConstructed(); // You can define this method to get a callback
    }
@@ -206,10 +206,10 @@ public final class DisplayHashParams implements Parcelable {
    };

    @DataClass.Generated(
            time = 1617735166254L,
            time = 1618436855096L,
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/core/java/android/service/displayhash/DisplayHashParams.java",
            inputSignatures = "private final @android.annotation.Nullable android.util.Size mBufferSize\nprivate final  boolean mGrayscaleBuffer\nclass DisplayHashParams extends java.lang.Object implements [android.os.Parcelable]\nprivate @android.annotation.Nullable android.util.Size mBufferSize\nprivate  boolean mGrayscaleBuffer\npublic @android.annotation.NonNull android.service.displayhash.DisplayHashParams.Builder setBufferSize(int,int)\npublic @android.annotation.NonNull android.service.displayhash.DisplayHashParams.Builder setGrayscaleBuffer(boolean)\npublic @android.annotation.NonNull android.service.displayhash.DisplayHashParams build()\nclass Builder extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genAidl=true, genToString=true, genParcelable=true, genHiddenConstructor=true)")
            inputSignatures = "private final @android.annotation.Nullable android.util.Size mBufferSize\nprivate final  boolean mUseGrayscale\nclass DisplayHashParams extends java.lang.Object implements [android.os.Parcelable]\nprivate @android.annotation.Nullable android.util.Size mBufferSize\nprivate  boolean mUseGrayscale\npublic @android.annotation.NonNull android.service.displayhash.DisplayHashParams.Builder setBufferSize(int,int)\npublic @android.annotation.NonNull android.service.displayhash.DisplayHashParams.Builder setUseGrayscale(boolean)\npublic @android.annotation.NonNull android.service.displayhash.DisplayHashParams build()\nclass Builder extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genAidl=true, genToString=true, genParcelable=true, genHiddenConstructor=true)")
    @Deprecated
    private void __metadata() {}

+17 −18
Original line number Diff line number Diff line
@@ -45,21 +45,21 @@ import java.util.Map;
 * @hide
 */
@SystemApi
public abstract class DisplayHasherService extends Service {
public abstract class DisplayHashingService extends Service {

    /** @hide **/
    public static final String EXTRA_VERIFIED_DISPLAY_HASH =
            "android.service.displayhash.extra.VERIFIED_DISPLAY_HASH";

    /**
     * Name under which a DisplayHasherService component publishes information
     * Name under which a DisplayHashingService component publishes information
     * about itself.  This meta-data must reference an XML resource containing a
     * {@link com.android.internal.R.styleable#DisplayHasherService} tag.
     * {@link com.android.internal.R.styleable#DisplayHashingService} tag.
     *
     * @hide
     */
    @SystemApi
    public static final String SERVICE_META_DATA = "android.displayhash.display_hasher_service";
    public static final String SERVICE_META_DATA = "android.displayhash.display_hashing_service";

    /**
     * The {@link Intent} action that must be declared as handled by a service in its manifest
@@ -69,18 +69,18 @@ public abstract class DisplayHasherService extends Service {
     */
    @SystemApi
    public static final String SERVICE_INTERFACE =
            "android.service.displayhash.DisplayHasherService";
            "android.service.displayhash.DisplayHashingService";

    private DisplayHasherServiceWrapper mWrapper;
    private DisplayHashingServiceWrapper mWrapper;
    private Handler mHandler;

    public DisplayHasherService() {
    public DisplayHashingService() {
    }

    @Override
    public void onCreate() {
        super.onCreate();
        mWrapper = new DisplayHasherServiceWrapper();
        mWrapper = new DisplayHashingServiceWrapper();
        mHandler = new Handler(Looper.getMainLooper(), null, true);
    }

@@ -105,7 +105,6 @@ public abstract class DisplayHasherService extends Service {
     *                      if successfully generated a DisplayHash or {@link
     *                      DisplayHashResultCallback#onDisplayHashError(int)} if failed.
     */
    @Nullable
    public abstract void onGenerateDisplayHash(@NonNull byte[] salt,
            @NonNull HardwareBuffer buffer, @NonNull Rect bounds,
            @NonNull String hashAlgorithm, @NonNull DisplayHashResultCallback callback);
@@ -125,8 +124,8 @@ public abstract class DisplayHasherService extends Service {
     *                    HardwareBuffer, Rect, String, DisplayHashResultCallback)} to
     *                    generate the token.
     * @param displayHash The token to verify that it was generated by the system.
     * @return a {@link VerifiedDisplayHash} if the token was generated by the system or null
     * if the token cannot be verified.
     * @return a {@link VerifiedDisplayHash} if the provided display hash was originally generated
     * by the system or null if the system did not generate the display hash.
     */
    @Nullable
    public abstract VerifiedDisplayHash onVerifyDisplayHash(@NonNull byte[] salt,
@@ -150,13 +149,13 @@ public abstract class DisplayHasherService extends Service {
        callback.sendResult(data);
    }

    private final class DisplayHasherServiceWrapper extends IDisplayHasherService.Stub {
    private final class DisplayHashingServiceWrapper extends IDisplayHashingService.Stub {
        @Override
        public void generateDisplayHash(byte[] salt, HardwareBuffer buffer, Rect bounds,
                String hashAlgorithm, RemoteCallback callback) {
            mHandler.sendMessage(
                    obtainMessage(DisplayHasherService::onGenerateDisplayHash,
                            DisplayHasherService.this, salt, buffer, bounds,
                    obtainMessage(DisplayHashingService::onGenerateDisplayHash,
                            DisplayHashingService.this, salt, buffer, bounds,
                            hashAlgorithm, new DisplayHashResultCallback() {
                                @Override
                                public void onDisplayHashResult(
@@ -179,14 +178,14 @@ public abstract class DisplayHasherService extends Service {
        public void verifyDisplayHash(byte[] salt, DisplayHash displayHash,
                RemoteCallback callback) {
            mHandler.sendMessage(
                    obtainMessage(DisplayHasherService::verifyDisplayHash,
                            DisplayHasherService.this, salt, displayHash, callback));
                    obtainMessage(DisplayHashingService::verifyDisplayHash,
                            DisplayHashingService.this, salt, displayHash, callback));
        }

        @Override
        public void getDisplayHashAlgorithms(RemoteCallback callback) {
            mHandler.sendMessage(obtainMessage(DisplayHasherService::getDisplayHashAlgorithms,
                    DisplayHasherService.this, callback));
            mHandler.sendMessage(obtainMessage(DisplayHashingService::getDisplayHashAlgorithms,
                    DisplayHashingService.this, callback));
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import android.view.displayhash.DisplayHash;
 *
 * @hide
 */
oneway interface IDisplayHasherService {
oneway interface IDisplayHashingService {
    /**
     * Generates the DisplayHash that can be used to validate that the system generated the token.
     *
Loading