Merge "Updated DisplayHash APIs" into sc-dev

This commit is contained in:
Chavi Weingarten
2021-04-19 16:30:45 +00:00
committed by Android (Google) Code Review
12 changed files with 98 additions and 89 deletions

View File

@@ -48518,7 +48518,7 @@ package android.view {
method public android.view.View focusSearch(int); method public android.view.View focusSearch(int);
method public void forceHasOverlappingRendering(boolean); method public void forceHasOverlappingRendering(boolean);
method public void forceLayout(); 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 static int generateViewId();
method public CharSequence getAccessibilityClassName(); method public CharSequence getAccessibilityClassName();
method public android.view.View.AccessibilityDelegate getAccessibilityDelegate(); method public android.view.View.AccessibilityDelegate getAccessibilityDelegate();

View File

@@ -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_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_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_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_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_EUICC_SERVICE = "android.permission.BIND_EUICC_SERVICE";
field public static final String BIND_EXTERNAL_STORAGE_SERVICE = "android.permission.BIND_EXTERNAL_STORAGE_SERVICE"; field public static final String BIND_EXTERNAL_STORAGE_SERVICE = "android.permission.BIND_EXTERNAL_STORAGE_SERVICE";
@@ -9862,7 +9863,7 @@ package android.service.displayhash {
public final class DisplayHashParams implements android.os.Parcelable { public final class DisplayHashParams implements android.os.Parcelable {
method public int describeContents(); method public int describeContents();
method @Nullable public android.util.Size getBufferSize(); method @Nullable public android.util.Size getBufferSize();
method public boolean isGrayscaleBuffer(); method public boolean isUseGrayscale();
method public void writeToParcel(@NonNull android.os.Parcel, int); method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.service.displayhash.DisplayHashParams> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.service.displayhash.DisplayHashParams> CREATOR;
} }
@@ -9871,17 +9872,17 @@ package android.service.displayhash {
ctor public DisplayHashParams.Builder(); ctor public DisplayHashParams.Builder();
method @NonNull public android.service.displayhash.DisplayHashParams build(); 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 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 { public abstract class DisplayHashingService extends android.app.Service {
ctor public DisplayHasherService(); ctor public DisplayHashingService();
method @NonNull public final android.os.IBinder onBind(@NonNull android.content.Intent); 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 @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); 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_INTERFACE = "android.service.displayhash.DisplayHashingService";
field public static final String SERVICE_META_DATA = "android.displayhash.display_hasher_service"; field public static final String SERVICE_META_DATA = "android.displayhash.display_hashing_service";
} }
} }

View File

@@ -28,7 +28,7 @@ import android.view.displayhash.DisplayHashResultCallback;
import com.android.internal.util.DataClass; 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} * display data that will be used to generate the {@link android.view.displayhash.DisplayHash}
* *
* @hide * @hide
@@ -38,9 +38,9 @@ import com.android.internal.util.DataClass;
public final class DisplayHashParams implements Parcelable { public final class DisplayHashParams implements Parcelable {
/** /**
* The size to scale the buffer to so the hash algorithm can properly generate the hash. The * 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, * buffer given to the {@link DisplayHashingService#onGenerateDisplayHash(byte[],
* Rect, String, DisplayHashResultCallback)} will be stretched based on the value set here. * HardwareBuffer, Rect, String, DisplayHashResultCallback)} will be stretched based on the
* If {@code null}, the buffer size will not be changed. * value set here. If {@code null}, the buffer size will not be changed.
*/ */
@Nullable @Nullable
private final Size mBufferSize; private final Size mBufferSize;
@@ -48,7 +48,7 @@ public final class DisplayHashParams implements Parcelable {
/** /**
* Whether the content will be captured in grayscale or color. * Whether the content will be captured in grayscale or color.
*/ */
private final boolean mGrayscaleBuffer; private final boolean mUseGrayscale;
/** /**
* A builder for {@link DisplayHashParams} * A builder for {@link DisplayHashParams}
@@ -56,7 +56,7 @@ public final class DisplayHashParams implements Parcelable {
public static final class Builder { public static final class Builder {
@Nullable @Nullable
private Size mBufferSize; private Size mBufferSize;
private boolean mGrayscaleBuffer; private boolean mUseGrayscale;
/** /**
* Creates a new Builder. * 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. * The size to scale the buffer to so the hash algorithm can properly generate the hash.
*/ */
@NonNull @NonNull
public Builder setBufferSize(int w, int h) { public Builder setBufferSize(int width, int height) {
mBufferSize = new Size(w, h); mBufferSize = new Size(width, height);
return this; return this;
} }
@@ -77,15 +77,15 @@ public final class DisplayHashParams implements Parcelable {
* Whether the content will be captured in grayscale or color. * Whether the content will be captured in grayscale or color.
*/ */
@NonNull @NonNull
public Builder setGrayscaleBuffer(boolean value) { public Builder setUseGrayscale(boolean useGrayscale) {
mGrayscaleBuffer = value; mUseGrayscale = useGrayscale;
return this; return this;
} }
/** Builds the instance. This builder should not be touched after calling this! */ /** Builds the instance. This builder should not be touched after calling this! */
@NonNull @NonNull
public DisplayHashParams build() { 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 * @param bufferSize
* The size to scale the buffer to so the hash algorithm can properly generate the hash. The * 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, * buffer given to the {@link DisplayHashingService#onGenerateDisplayHash(byte[],
* Rect, String, DisplayHashResultCallback)} will be stretched based on the value set here. * HardwareBuffer, Rect, String, DisplayHashResultCallback)} will be stretched based on the
* If {@code null}, the buffer size will not be changed. * value set here. If {@code null}, the buffer size will not be changed.
* @param grayscaleBuffer * @param useGrayscale
* Whether the content will be captured in grayscale or color. * Whether the content will be captured in grayscale or color.
* @hide * @hide
*/ */
@DataClass.Generated.Member @DataClass.Generated.Member
public DisplayHashParams( public DisplayHashParams(
@Nullable Size bufferSize, @Nullable Size bufferSize,
boolean grayscaleBuffer) { boolean useGrayscale) {
this.mBufferSize = bufferSize; this.mBufferSize = bufferSize;
this.mGrayscaleBuffer = grayscaleBuffer; this.mUseGrayscale = useGrayscale;
// onConstructed(); // You can define this method to get a callback // 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 * 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, * buffer given to the {@link DisplayHashingService#onGenerateDisplayHash(byte[],
* Rect, String, DisplayHashResultCallback)} will be stretched based on the value set here. * HardwareBuffer, Rect, String, DisplayHashResultCallback)} will be stretched based on the
* If {@code null}, the buffer size will not be changed. * value set here. If {@code null}, the buffer size will not be changed.
*/ */
@DataClass.Generated.Member @DataClass.Generated.Member
public @Nullable Size getBufferSize() { public @Nullable Size getBufferSize() {
@@ -141,8 +141,8 @@ public final class DisplayHashParams implements Parcelable {
* Whether the content will be captured in grayscale or color. * Whether the content will be captured in grayscale or color.
*/ */
@DataClass.Generated.Member @DataClass.Generated.Member
public boolean isGrayscaleBuffer() { public boolean isUseGrayscale() {
return mGrayscaleBuffer; return mUseGrayscale;
} }
@Override @Override
@@ -153,7 +153,7 @@ public final class DisplayHashParams implements Parcelable {
return "DisplayHashParams { " + return "DisplayHashParams { " +
"bufferSize = " + mBufferSize + ", " + "bufferSize = " + mBufferSize + ", " +
"grayscaleBuffer = " + mGrayscaleBuffer + "useGrayscale = " + mUseGrayscale +
" }"; " }";
} }
@@ -164,7 +164,7 @@ public final class DisplayHashParams implements Parcelable {
// void parcelFieldName(Parcel dest, int flags) { ... } // void parcelFieldName(Parcel dest, int flags) { ... }
byte flg = 0; byte flg = 0;
if (mGrayscaleBuffer) flg |= 0x2; if (mUseGrayscale) flg |= 0x2;
if (mBufferSize != null) flg |= 0x1; if (mBufferSize != null) flg |= 0x1;
dest.writeByte(flg); dest.writeByte(flg);
if (mBufferSize != null) dest.writeSize(mBufferSize); if (mBufferSize != null) dest.writeSize(mBufferSize);
@@ -182,11 +182,11 @@ public final class DisplayHashParams implements Parcelable {
// static FieldType unparcelFieldName(Parcel in) { ... } // static FieldType unparcelFieldName(Parcel in) { ... }
byte flg = in.readByte(); byte flg = in.readByte();
boolean grayscaleBuffer = (flg & 0x2) != 0; boolean useGrayscale = (flg & 0x2) != 0;
Size bufferSize = (flg & 0x1) == 0 ? null : (Size) in.readSize(); Size bufferSize = (flg & 0x1) == 0 ? null : (Size) in.readSize();
this.mBufferSize = bufferSize; this.mBufferSize = bufferSize;
this.mGrayscaleBuffer = grayscaleBuffer; this.mUseGrayscale = useGrayscale;
// onConstructed(); // You can define this method to get a callback // onConstructed(); // You can define this method to get a callback
} }
@@ -206,10 +206,10 @@ public final class DisplayHashParams implements Parcelable {
}; };
@DataClass.Generated( @DataClass.Generated(
time = 1617735166254L, time = 1618436855096L,
codegenVersion = "1.0.23", codegenVersion = "1.0.23",
sourceFile = "frameworks/base/core/java/android/service/displayhash/DisplayHashParams.java", 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 @Deprecated
private void __metadata() {} private void __metadata() {}

View File

@@ -45,21 +45,21 @@ import java.util.Map;
* @hide * @hide
*/ */
@SystemApi @SystemApi
public abstract class DisplayHasherService extends Service { public abstract class DisplayHashingService extends Service {
/** @hide **/ /** @hide **/
public static final String EXTRA_VERIFIED_DISPLAY_HASH = public static final String EXTRA_VERIFIED_DISPLAY_HASH =
"android.service.displayhash.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 * 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 * @hide
*/ */
@SystemApi @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 * 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 @SystemApi
public static final String SERVICE_INTERFACE = public static final String SERVICE_INTERFACE =
"android.service.displayhash.DisplayHasherService"; "android.service.displayhash.DisplayHashingService";
private DisplayHasherServiceWrapper mWrapper; private DisplayHashingServiceWrapper mWrapper;
private Handler mHandler; private Handler mHandler;
public DisplayHasherService() { public DisplayHashingService() {
} }
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
mWrapper = new DisplayHasherServiceWrapper(); mWrapper = new DisplayHashingServiceWrapper();
mHandler = new Handler(Looper.getMainLooper(), null, true); mHandler = new Handler(Looper.getMainLooper(), null, true);
} }
@@ -105,7 +105,6 @@ public abstract class DisplayHasherService extends Service {
* if successfully generated a DisplayHash or {@link * if successfully generated a DisplayHash or {@link
* DisplayHashResultCallback#onDisplayHashError(int)} if failed. * DisplayHashResultCallback#onDisplayHashError(int)} if failed.
*/ */
@Nullable
public abstract void onGenerateDisplayHash(@NonNull byte[] salt, public abstract void onGenerateDisplayHash(@NonNull byte[] salt,
@NonNull HardwareBuffer buffer, @NonNull Rect bounds, @NonNull HardwareBuffer buffer, @NonNull Rect bounds,
@NonNull String hashAlgorithm, @NonNull DisplayHashResultCallback callback); @NonNull String hashAlgorithm, @NonNull DisplayHashResultCallback callback);
@@ -125,8 +124,8 @@ public abstract class DisplayHasherService extends Service {
* HardwareBuffer, Rect, String, DisplayHashResultCallback)} to * HardwareBuffer, Rect, String, DisplayHashResultCallback)} to
* generate the token. * generate the token.
* @param displayHash The token to verify that it was generated by the system. * @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 * @return a {@link VerifiedDisplayHash} if the provided display hash was originally generated
* if the token cannot be verified. * by the system or null if the system did not generate the display hash.
*/ */
@Nullable @Nullable
public abstract VerifiedDisplayHash onVerifyDisplayHash(@NonNull byte[] salt, public abstract VerifiedDisplayHash onVerifyDisplayHash(@NonNull byte[] salt,
@@ -150,13 +149,13 @@ public abstract class DisplayHasherService extends Service {
callback.sendResult(data); callback.sendResult(data);
} }
private final class DisplayHasherServiceWrapper extends IDisplayHasherService.Stub { private final class DisplayHashingServiceWrapper extends IDisplayHashingService.Stub {
@Override @Override
public void generateDisplayHash(byte[] salt, HardwareBuffer buffer, Rect bounds, public void generateDisplayHash(byte[] salt, HardwareBuffer buffer, Rect bounds,
String hashAlgorithm, RemoteCallback callback) { String hashAlgorithm, RemoteCallback callback) {
mHandler.sendMessage( mHandler.sendMessage(
obtainMessage(DisplayHasherService::onGenerateDisplayHash, obtainMessage(DisplayHashingService::onGenerateDisplayHash,
DisplayHasherService.this, salt, buffer, bounds, DisplayHashingService.this, salt, buffer, bounds,
hashAlgorithm, new DisplayHashResultCallback() { hashAlgorithm, new DisplayHashResultCallback() {
@Override @Override
public void onDisplayHashResult( public void onDisplayHashResult(
@@ -179,14 +178,14 @@ public abstract class DisplayHasherService extends Service {
public void verifyDisplayHash(byte[] salt, DisplayHash displayHash, public void verifyDisplayHash(byte[] salt, DisplayHash displayHash,
RemoteCallback callback) { RemoteCallback callback) {
mHandler.sendMessage( mHandler.sendMessage(
obtainMessage(DisplayHasherService::verifyDisplayHash, obtainMessage(DisplayHashingService::verifyDisplayHash,
DisplayHasherService.this, salt, displayHash, callback)); DisplayHashingService.this, salt, displayHash, callback));
} }
@Override @Override
public void getDisplayHashAlgorithms(RemoteCallback callback) { public void getDisplayHashAlgorithms(RemoteCallback callback) {
mHandler.sendMessage(obtainMessage(DisplayHasherService::getDisplayHashAlgorithms, mHandler.sendMessage(obtainMessage(DisplayHashingService::getDisplayHashAlgorithms,
DisplayHasherService.this, callback)); DisplayHashingService.this, callback));
} }
} }
} }

View File

@@ -26,7 +26,7 @@ import android.view.displayhash.DisplayHash;
* *
* @hide * @hide
*/ */
oneway interface IDisplayHasherService { oneway interface IDisplayHashingService {
/** /**
* Generates the DisplayHash that can be used to validate that the system generated the token. * Generates the DisplayHash that can be used to validate that the system generated the token.
* *

View File

@@ -30927,7 +30927,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @param executor The executor that the callback should be invoked on. * @param executor The executor that the callback should be invoked on.
* @param callback The callback to handle the results of generating the display hash * @param callback The callback to handle the results of generating the display hash
*/ */
@Nullable
public void generateDisplayHash(@NonNull String hashAlgorithm, public void generateDisplayHash(@NonNull String hashAlgorithm,
@Nullable Rect bounds, @NonNull Executor executor, @Nullable Rect bounds, @NonNull Executor executor,
@NonNull DisplayHashResultCallback callback) { @NonNull DisplayHashResultCallback callback) {

View File

@@ -16,6 +16,7 @@
package android.view.displayhash; package android.view.displayhash;
import android.annotation.CurrentTimeMillisLong;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.SystemApi; import android.annotation.SystemApi;
import android.graphics.Rect; import android.graphics.Rect;
@@ -31,6 +32,7 @@ public final class DisplayHash implements Parcelable {
/** /**
* The timestamp when the hash was generated. * The timestamp when the hash was generated.
*/ */
@CurrentTimeMillisLong
private final long mTimeMillis; private final long mTimeMillis;
/** /**
@@ -73,7 +75,7 @@ public final class DisplayHash implements Parcelable {
* @hide * @hide
*/ */
@SystemApi @SystemApi
public DisplayHash(long timeMillis, @NonNull Rect boundsInWindow, public DisplayHash(@CurrentTimeMillisLong long timeMillis, @NonNull Rect boundsInWindow,
@NonNull String hashAlgorithm, @NonNull byte[] imageHash, @NonNull byte[] hmac) { @NonNull String hashAlgorithm, @NonNull byte[] imageHash, @NonNull byte[] hmac) {
mTimeMillis = timeMillis; mTimeMillis = timeMillis;
mBoundsInWindow = boundsInWindow; mBoundsInWindow = boundsInWindow;
@@ -92,6 +94,7 @@ public final class DisplayHash implements Parcelable {
* @hide * @hide
*/ */
@SystemApi @SystemApi
@CurrentTimeMillisLong
public long getTimeMillis() { public long getTimeMillis() {
return mTimeMillis; return mTimeMillis;
} }

View File

@@ -35,7 +35,8 @@ import java.util.Collections;
import java.util.Set; import java.util.Set;
/** /**
* Utility class for DisplayHash requests. * Manages DisplayHash requests. The manager object can be retrieved by calling
* {@code Context.getSystemService(Context.DISPLAY_HASH_SERVICE)}
*/ */
@SystemService(DISPLAY_HASH_SERVICE) @SystemService(DISPLAY_HASH_SERVICE)
public final class DisplayHashManager { public final class DisplayHashManager {
@@ -75,7 +76,7 @@ public final class DisplayHashManager {
return sSupportedHashAlgorithms; return sSupportedHashAlgorithms;
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Failed to send request getSupportedHashingAlgorithms", e); Log.e(TAG, "Failed to send request getSupportedHashingAlgorithms", e);
return Collections.emptySet(); throw e.rethrowFromSystemServer();
} }
} }
} }
@@ -93,7 +94,7 @@ public final class DisplayHashManager {
return WindowManagerGlobal.getWindowManagerService().verifyDisplayHash(displayHash); return WindowManagerGlobal.getWindowManagerService().verifyDisplayHash(displayHash);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Failed to send request verifyImpressionToken", e); Log.e(TAG, "Failed to send request verifyImpressionToken", e);
return null; throw e.rethrowFromSystemServer();
} }
} }

View File

@@ -16,6 +16,7 @@
package android.view.displayhash; package android.view.displayhash;
import android.annotation.CurrentTimeMillisLong;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Parcelable; import android.os.Parcelable;
@@ -30,6 +31,7 @@ public final class VerifiedDisplayHash implements Parcelable {
/** /**
* The timestamp when the hash was generated. * The timestamp when the hash was generated.
*/ */
@CurrentTimeMillisLong
private final long mTimeMillis; private final long mTimeMillis;
/** /**
@@ -78,7 +80,7 @@ public final class VerifiedDisplayHash implements Parcelable {
// Code below generated by codegen v1.0.22. // Code below generated by codegen v1.0.23.
// //
// DO NOT MODIFY! // DO NOT MODIFY!
// CHECKSTYLE:OFF Generated code // CHECKSTYLE:OFF Generated code
@@ -106,11 +108,13 @@ public final class VerifiedDisplayHash implements Parcelable {
*/ */
@DataClass.Generated.Member @DataClass.Generated.Member
public VerifiedDisplayHash( public VerifiedDisplayHash(
long timeMillis, @CurrentTimeMillisLong long timeMillis,
@NonNull Rect boundsInWindow, @NonNull Rect boundsInWindow,
@NonNull String hashAlgorithm, @NonNull String hashAlgorithm,
@NonNull byte[] imageHash) { @NonNull byte[] imageHash) {
this.mTimeMillis = timeMillis; this.mTimeMillis = timeMillis;
com.android.internal.util.AnnotationValidations.validate(
CurrentTimeMillisLong.class, null, mTimeMillis);
this.mBoundsInWindow = boundsInWindow; this.mBoundsInWindow = boundsInWindow;
com.android.internal.util.AnnotationValidations.validate( com.android.internal.util.AnnotationValidations.validate(
NonNull.class, null, mBoundsInWindow); NonNull.class, null, mBoundsInWindow);
@@ -128,7 +132,7 @@ public final class VerifiedDisplayHash implements Parcelable {
* The timestamp when the hash was generated. * The timestamp when the hash was generated.
*/ */
@DataClass.Generated.Member @DataClass.Generated.Member
public long getTimeMillis() { public @CurrentTimeMillisLong long getTimeMillis() {
return mTimeMillis; return mTimeMillis;
} }
@@ -200,6 +204,8 @@ public final class VerifiedDisplayHash implements Parcelable {
byte[] imageHash = in.createByteArray(); byte[] imageHash = in.createByteArray();
this.mTimeMillis = timeMillis; this.mTimeMillis = timeMillis;
com.android.internal.util.AnnotationValidations.validate(
CurrentTimeMillisLong.class, null, mTimeMillis);
this.mBoundsInWindow = boundsInWindow; this.mBoundsInWindow = boundsInWindow;
com.android.internal.util.AnnotationValidations.validate( com.android.internal.util.AnnotationValidations.validate(
NonNull.class, null, mBoundsInWindow); NonNull.class, null, mBoundsInWindow);
@@ -228,10 +234,10 @@ public final class VerifiedDisplayHash implements Parcelable {
}; };
@DataClass.Generated( @DataClass.Generated(
time = 1613168749684L, time = 1617747271440L,
codegenVersion = "1.0.22", codegenVersion = "1.0.23",
sourceFile = "frameworks/base/core/java/android/view/displayhash/VerifiedDisplayHash.java", sourceFile = "frameworks/base/core/java/android/view/displayhash/VerifiedDisplayHash.java",
inputSignatures = "private final long mTimeMillis\nprivate final @android.annotation.NonNull android.graphics.Rect mBoundsInWindow\nprivate final @android.annotation.NonNull java.lang.String mHashAlgorithm\nprivate final @android.annotation.NonNull byte[] mImageHash\nprivate java.lang.String imageHashToString()\nprivate java.lang.String byteArrayToString(byte[])\nclass VerifiedDisplayHash extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genAidl=true)") inputSignatures = "private final @android.annotation.CurrentTimeMillisLong long mTimeMillis\nprivate final @android.annotation.NonNull android.graphics.Rect mBoundsInWindow\nprivate final @android.annotation.NonNull java.lang.String mHashAlgorithm\nprivate final @android.annotation.NonNull byte[] mImageHash\nprivate java.lang.String imageHashToString()\nprivate java.lang.String byteArrayToString(byte[])\nclass VerifiedDisplayHash extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genAidl=true)")
@Deprecated @Deprecated
private void __metadata() {} private void __metadata() {}

View File

@@ -5682,12 +5682,12 @@
<permission android:name="android.permission.CONTROL_DEVICE_STATE" <permission android:name="android.permission.CONTROL_DEVICE_STATE"
android:protectionLevel="signature" /> android:protectionLevel="signature" />
<!-- Must be required by a <!-- @hide @SystemApi Must be required by a
{@link android.service.displayhash.DisplayHasherService} {@link android.service.displayhash.DisplayHashingService}
to ensure that only the system can bind to it. to ensure that only the system can bind to it.
@hide This is not a third-party API (intended for OEMs and system apps). This is not a third-party API (intended for OEMs and system apps).
--> -->
<permission android:name="android.permission.BIND_DISPLAY_HASHER_SERVICE" <permission android:name="android.permission.BIND_DISPLAY_HASHING_SERVICE"
android:protectionLevel="signature" /> android:protectionLevel="signature" />
<!-- @hide @TestApi Allows an application to enable/disable toast rate limiting. <!-- @hide @TestApi Allows an application to enable/disable toast rate limiting.

View File

@@ -9577,7 +9577,7 @@
<!-- Perceptual luminance of a color, in accessibility friendly color space. From 0 to 100. --> <!-- Perceptual luminance of a color, in accessibility friendly color space. From 0 to 100. -->
<attr name="lStar" format="float"/> <attr name="lStar" format="float"/>
<declare-styleable name="DisplayHasherService"> <declare-styleable name="DisplayHashingService">
<!-- The throttle duration for display hash requests <!-- The throttle duration for display hash requests
@hide @SystemApi --> @hide @SystemApi -->
<attr name="throttleDurationMillis" format="integer" /> <attr name="throttleDurationMillis" format="integer" />

View File

@@ -16,8 +16,8 @@
package com.android.server.wm; package com.android.server.wm;
import static android.service.displayhash.DisplayHasherService.EXTRA_VERIFIED_DISPLAY_HASH; import static android.service.displayhash.DisplayHashingService.EXTRA_VERIFIED_DISPLAY_HASH;
import static android.service.displayhash.DisplayHasherService.SERVICE_META_DATA; import static android.service.displayhash.DisplayHashingService.SERVICE_META_DATA;
import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_INVALID_HASH_ALGORITHM; import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_INVALID_HASH_ALGORITHM;
import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_TOO_MANY_REQUESTS; import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_TOO_MANY_REQUESTS;
import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_UNKNOWN; import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_UNKNOWN;
@@ -52,8 +52,8 @@ import android.os.RemoteCallback;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.UserHandle; import android.os.UserHandle;
import android.service.displayhash.DisplayHashParams; import android.service.displayhash.DisplayHashParams;
import android.service.displayhash.DisplayHasherService; import android.service.displayhash.DisplayHashingService;
import android.service.displayhash.IDisplayHasherService; import android.service.displayhash.IDisplayHashingService;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Size; import android.util.Size;
import android.util.Slog; import android.util.Slog;
@@ -79,7 +79,7 @@ import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
/** /**
* Handles requests into {@link android.service.displayhash.DisplayHasherService} * Handles requests into {@link DisplayHashingService}
* *
* Do not hold the {@link WindowManagerService#mGlobalLock} when calling methods since they are * Do not hold the {@link WindowManagerService#mGlobalLock} when calling methods since they are
* blocking calls into another service. * blocking calls into another service.
@@ -91,7 +91,7 @@ public class DisplayHashController {
private final Object mServiceConnectionLock = new Object(); private final Object mServiceConnectionLock = new Object();
@GuardedBy("mServiceConnectionLock") @GuardedBy("mServiceConnectionLock")
private DisplayHasherServiceConnection mServiceConnection; private DisplayHashingServiceConnection mServiceConnection;
private final Context mContext; private final Context mContext;
@@ -150,7 +150,7 @@ public class DisplayHashController {
private boolean mDisplayHashThrottlingEnabled = true; private boolean mDisplayHashThrottlingEnabled = true;
private interface Command { private interface Command {
void run(IDisplayHasherService service) throws RemoteException; void run(IDisplayHashingService service) throws RemoteException;
} }
DisplayHashController(Context context) { DisplayHashController(Context context) {
@@ -233,7 +233,7 @@ public class DisplayHashController {
(float) size.getHeight() / boundsInWindow.height()); (float) size.getHeight() / boundsInWindow.height());
} }
args.setGrayscale(displayHashParams.isGrayscaleBuffer()); args.setGrayscale(displayHashParams.isUseGrayscale());
SurfaceControl.ScreenshotHardwareBuffer screenshotHardwareBuffer = SurfaceControl.ScreenshotHardwareBuffer screenshotHardwareBuffer =
SurfaceControl.captureLayers(args.build()); SurfaceControl.captureLayers(args.build());
@@ -405,9 +405,9 @@ public class DisplayHashController {
} }
} }
TypedArray sa = res.obtainAttributes(attrs, R.styleable.DisplayHasherService); TypedArray sa = res.obtainAttributes(attrs, R.styleable.DisplayHashingService);
mThrottleDurationMillis = sa.getInt( mThrottleDurationMillis = sa.getInt(
R.styleable.DisplayHasherService_throttleDurationMillis, 0); R.styleable.DisplayHashingService_throttleDurationMillis, 0);
sa.recycle(); sa.recycle();
mParsedXml = true; mParsedXml = true;
return true; return true;
@@ -424,7 +424,7 @@ public class DisplayHashController {
if (DEBUG) Slog.v(TAG, "creating connection"); if (DEBUG) Slog.v(TAG, "creating connection");
// Create the connection // Create the connection
mServiceConnection = new DisplayHasherServiceConnection(); mServiceConnection = new DisplayHashingServiceConnection();
final ComponentName component = getServiceComponentName(); final ComponentName component = getServiceComponentName();
if (DEBUG) Slog.v(TAG, "binding to: " + component); if (DEBUG) Slog.v(TAG, "binding to: " + component);
@@ -455,7 +455,7 @@ public class DisplayHashController {
return null; return null;
} }
final Intent intent = new Intent(DisplayHasherService.SERVICE_INTERFACE); final Intent intent = new Intent(DisplayHashingService.SERVICE_INTERFACE);
intent.setPackage(packageName); intent.setPackage(packageName);
final ResolveInfo resolveInfo = mContext.getPackageManager().resolveService(intent, final ResolveInfo resolveInfo = mContext.getPackageManager().resolveService(intent,
PackageManager.GET_SERVICES | PackageManager.GET_META_DATA); PackageManager.GET_SERVICES | PackageManager.GET_META_DATA);
@@ -472,10 +472,10 @@ public class DisplayHashController {
if (serviceInfo == null) return null; if (serviceInfo == null) return null;
final ComponentName name = new ComponentName(serviceInfo.packageName, serviceInfo.name); final ComponentName name = new ComponentName(serviceInfo.packageName, serviceInfo.name);
if (!Manifest.permission.BIND_DISPLAY_HASHER_SERVICE if (!Manifest.permission.BIND_DISPLAY_HASHING_SERVICE
.equals(serviceInfo.permission)) { .equals(serviceInfo.permission)) {
Slog.w(TAG, name.flattenToShortString() + " requires permission " Slog.w(TAG, name.flattenToShortString() + " requires permission "
+ Manifest.permission.BIND_DISPLAY_HASHER_SERVICE); + Manifest.permission.BIND_DISPLAY_HASHING_SERVICE);
return null; return null;
} }
@@ -488,7 +488,7 @@ public class DisplayHashController {
private Bundle mResult; private Bundle mResult;
private final CountDownLatch mCountDownLatch = new CountDownLatch(1); private final CountDownLatch mCountDownLatch = new CountDownLatch(1);
public Bundle run(BiConsumer<IDisplayHasherService, RemoteCallback> func) { public Bundle run(BiConsumer<IDisplayHashingService, RemoteCallback> func) {
connectAndRun(service -> { connectAndRun(service -> {
RemoteCallback callback = new RemoteCallback(result -> { RemoteCallback callback = new RemoteCallback(result -> {
mResult = result; mResult = result;
@@ -507,9 +507,9 @@ public class DisplayHashController {
} }
} }
private class DisplayHasherServiceConnection implements ServiceConnection { private class DisplayHashingServiceConnection implements ServiceConnection {
@GuardedBy("mServiceConnectionLock") @GuardedBy("mServiceConnectionLock")
private IDisplayHasherService mRemoteService; private IDisplayHashingService mRemoteService;
@GuardedBy("mServiceConnectionLock") @GuardedBy("mServiceConnectionLock")
private ArrayList<Command> mQueuedCommands; private ArrayList<Command> mQueuedCommands;
@@ -518,7 +518,7 @@ public class DisplayHashController {
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
if (DEBUG) Slog.v(TAG, "onServiceConnected(): " + name); if (DEBUG) Slog.v(TAG, "onServiceConnected(): " + name);
synchronized (mServiceConnectionLock) { synchronized (mServiceConnectionLock) {
mRemoteService = IDisplayHasherService.Stub.asInterface(service); mRemoteService = IDisplayHashingService.Stub.asInterface(service);
if (mQueuedCommands != null) { if (mQueuedCommands != null) {
final int size = mQueuedCommands.size(); final int size = mQueuedCommands.size();
if (DEBUG) Slog.d(TAG, "running " + size + " queued commands"); if (DEBUG) Slog.d(TAG, "running " + size + " queued commands");