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

Commit 7b29eaee authored by Matthew Sedam's avatar Matthew Sedam Committed by Android (Google) Code Review
Browse files

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

parents 74aa2f65 f87925f3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1414,6 +1414,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.
     *