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

Bug: 258074235
Test: make update-api
Test: m
Change-Id: If32d75e017d1f9881bfa2865bccb57faa13c1599
This commit is contained in:
Matthew Sedam
2023-01-17 22:14:05 +00:00
parent 00058175f5
commit f87925f3eb
2 changed files with 47 additions and 0 deletions

View File

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

View File

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