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

Commit 2e605fd6 authored by chaviw's avatar chaviw
Browse files

Add throttling to generateDisplayHash

Calling generateDisplayHash can cause the system to slow down if there
are too many requests. Add throttling logic to prevent apps from calling
the API too frequently. The throttling time is based on a value sent
from ExtServices so it can be adjusted later

Test: DisplayHashManagerTest
Bug: 155825630
Change-Id: Id49d1c4113fc65d7b73a1e7b9fc73f50a8d7041f
parent a79ee5c9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -51520,6 +51520,7 @@ package android.view.displayhash {
    field public static final int DISPLAY_HASH_ERROR_INVALID_HASH_ALGORITHM = -5; // 0xfffffffb
    field public static final int DISPLAY_HASH_ERROR_MISSING_WINDOW = -3; // 0xfffffffd
    field public static final int DISPLAY_HASH_ERROR_NOT_VISIBLE_ON_SCREEN = -4; // 0xfffffffc
    field public static final int DISPLAY_HASH_ERROR_TOO_MANY_REQUESTS = -6; // 0xfffffffa
    field public static final int DISPLAY_HASH_ERROR_UNKNOWN = -1; // 0xffffffff
  }
+2 −0
Original line number Diff line number Diff line
@@ -320,6 +320,7 @@ package android {
    field public static final int requiredSystemPropertyValue = 16844134; // 0x1010566
    field public static final int sdkVersion = 16844304; // 0x1010610
    field public static final int supportsAmbientMode = 16844173; // 0x101058d
    field public static final int throttleDurationMillis = 16844360; // 0x1010648
    field public static final int userRestriction = 16844164; // 0x1010584
  }
@@ -9784,6 +9785,7 @@ package android.service.displayhash {
    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";
  }
}
+8 −0
Original line number Diff line number Diff line
@@ -2863,6 +2863,14 @@ package android.view.contentcapture {

}

package android.view.displayhash {

  public final class DisplayHashManager {
    method @RequiresPermission("android.permission.READ_FRAME_BUFFER") public void setDisplayHashThrottlingEnabled(boolean);
  }

}

package android.view.inputmethod {

  public final class InlineSuggestion implements android.os.Parcelable {
+10 −0
Original line number Diff line number Diff line
@@ -51,6 +51,16 @@ public abstract class DisplayHasherService extends Service {
    public static final String EXTRA_VERIFIED_DISPLAY_HASH =
            "android.service.displayhash.extra.VERIFIED_DISPLAY_HASH";

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

    /**
     * The {@link Intent} action that must be declared as handled by a service in its manifest
     * for the system to recognize it as a DisplayHash providing service.
+9 −0
Original line number Diff line number Diff line
@@ -776,6 +776,15 @@ interface IWindowManager
     */
    VerifiedDisplayHash verifyDisplayHash(in DisplayHash displayHash);

    /**
     * Call to enable or disable the throttling when generating a display hash. This should only be
     * used for testing. Throttling is enabled by default.
     *
     * Must be called from a process that has {@link android.Manifest.permission#READ_FRAME_BUFFER}
     * permission.
     */
     void setDisplayHashThrottlingEnabled(boolean enable);

    /**
     * Registers a listener for a {@link android.window.WindowContext} to handle configuration
     * changes from the server side.
Loading