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 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();

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_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";
@@ -9862,7 +9863,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;
}
@@ -9871,17 +9872,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";
}
}

View File

@@ -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() {}

View File

@@ -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));
}
}
}

View File

@@ -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.
*

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 callback The callback to handle the results of generating the display hash
*/
@Nullable
public void generateDisplayHash(@NonNull String hashAlgorithm,
@Nullable Rect bounds, @NonNull Executor executor,
@NonNull DisplayHashResultCallback callback) {

View File

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

View File

@@ -35,7 +35,8 @@ import java.util.Collections;
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)
public final class DisplayHashManager {
@@ -75,7 +76,7 @@ public final class DisplayHashManager {
return sSupportedHashAlgorithms;
} catch (RemoteException 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);
} catch (RemoteException 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;
import android.annotation.CurrentTimeMillisLong;
import android.annotation.NonNull;
import android.graphics.Rect;
import android.os.Parcelable;
@@ -30,6 +31,7 @@ public final class VerifiedDisplayHash implements Parcelable {
/**
* The timestamp when the hash was generated.
*/
@CurrentTimeMillisLong
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!
// CHECKSTYLE:OFF Generated code
@@ -106,11 +108,13 @@ public final class VerifiedDisplayHash implements Parcelable {
*/
@DataClass.Generated.Member
public VerifiedDisplayHash(
long timeMillis,
@CurrentTimeMillisLong long timeMillis,
@NonNull Rect boundsInWindow,
@NonNull String hashAlgorithm,
@NonNull byte[] imageHash) {
this.mTimeMillis = timeMillis;
com.android.internal.util.AnnotationValidations.validate(
CurrentTimeMillisLong.class, null, mTimeMillis);
this.mBoundsInWindow = boundsInWindow;
com.android.internal.util.AnnotationValidations.validate(
NonNull.class, null, mBoundsInWindow);
@@ -128,7 +132,7 @@ public final class VerifiedDisplayHash implements Parcelable {
* The timestamp when the hash was generated.
*/
@DataClass.Generated.Member
public long getTimeMillis() {
public @CurrentTimeMillisLong long getTimeMillis() {
return mTimeMillis;
}
@@ -200,6 +204,8 @@ public final class VerifiedDisplayHash implements Parcelable {
byte[] imageHash = in.createByteArray();
this.mTimeMillis = timeMillis;
com.android.internal.util.AnnotationValidations.validate(
CurrentTimeMillisLong.class, null, mTimeMillis);
this.mBoundsInWindow = boundsInWindow;
com.android.internal.util.AnnotationValidations.validate(
NonNull.class, null, mBoundsInWindow);
@@ -228,10 +234,10 @@ public final class VerifiedDisplayHash implements Parcelable {
};
@DataClass.Generated(
time = 1613168749684L,
codegenVersion = "1.0.22",
time = 1617747271440L,
codegenVersion = "1.0.23",
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
private void __metadata() {}

View File

@@ -5682,12 +5682,12 @@
<permission android:name="android.permission.CONTROL_DEVICE_STATE"
android:protectionLevel="signature" />
<!-- Must be required by a
{@link android.service.displayhash.DisplayHasherService}
<!-- @hide @SystemApi Must be required by a
{@link android.service.displayhash.DisplayHashingService}
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" />
<!-- @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. -->
<attr name="lStar" format="float"/>
<declare-styleable name="DisplayHasherService">
<declare-styleable name="DisplayHashingService">
<!-- The throttle duration for display hash requests
@hide @SystemApi -->
<attr name="throttleDurationMillis" format="integer" />

View File

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