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

Commit f87925f3 authored by Matthew Sedam's avatar Matthew Sedam
Browse files

Add enableTestMode() and disableTestMode() test APIs to ContextHubManager

Bug: 258074235
Test: make update-api
Test: m
Change-Id: If32d75e017d1f9881bfa2865bccb57faa13c1599
parent 00058175
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1416,6 +1416,8 @@ package android.hardware.lights {
package android.hardware.location {

  public final class ContextHubManager {
    method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_CONTEXT_HUB) public boolean disableTestMode();
    method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_CONTEXT_HUB) public boolean enableTestMode();
    method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_CONTEXT_HUB) public long[] getPreloadedNanoAppIds(@NonNull android.hardware.location.ContextHubInfo);
  }

+45 −0
Original line number Diff line number Diff line
@@ -994,6 +994,51 @@ public final class ContextHubManager {
        return nanoappIds;
    }

    /**
     * Puts the Context Hub in test mode.
     *
     * The purpose of this API is to make testing CHRE/Context Hub more
     * predictable and robust. This temporarily unloads all
     * nanoapps.
     *
     * Note that this API must not cause CHRE/Context Hub to behave differently
     * in test compared to production.
     *
     * @return true if the enable test mode operation succeeded.
     * @hide
     */
    @TestApi
    @RequiresPermission(android.Manifest.permission.ACCESS_CONTEXT_HUB)
    @NonNull public boolean enableTestMode() {
        try {
            return mService.setTestMode(true);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Puts the Context Hub out of test mode.
     *
     * This API will undo any previously made enableTestMode() calls.
     * After this API is called, it should restore the state of the system
     * to the normal/production mode before any enableTestMode() call was
     * made. If the enableTestMode() call unloaded any nanoapps
     * to enter test mode, it should reload those nanoapps in this API call.
     *
     * @return true if the disable operation succeeded.
     * @hide
     */
    @TestApi
    @RequiresPermission(android.Manifest.permission.ACCESS_CONTEXT_HUB)
    @NonNull public boolean disableTestMode() {
        try {
            return mService.setTestMode(false);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Unregister a callback for receive messages from the context hub.
     *