Loading core/java/android/hardware/location/IContextHubService.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -113,4 +113,8 @@ interface IContextHubService { // Queries for a list of preloaded nanoapps @EnforcePermission("ACCESS_CONTEXT_HUB") long[] getPreloadedNanoAppIds(in ContextHubInfo hubInfo); // Enables or disables test mode @EnforcePermission("ACCESS_CONTEXT_HUB") boolean setTestMode(in boolean enable); } services/core/java/com/android/server/location/contexthub/ContextHubService.java +28 −0 Original line number Diff line number Diff line Loading @@ -1155,6 +1155,34 @@ public class ContextHubService extends IContextHubService.Stub { return nanoappIds; } @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_CONTEXT_HUB) /** * Puts the context hub in and out of test mode. Test mode is a clean state * where tests can be executed in the same environment. If enable is true, * this will enable test mode by unloading all nanoapps. If enable is false, * this will disable test mode and reverse the actions of enabling test mode * by loading all preloaded nanoapps. This puts CHRE in a normal state. * * This should only be used for a test environment, either through a * @TestApi or development tools. This should not be used in a production * environment. * * @param enable If true, put the context hub in test mode. If false, disable * test mode. * @return If true, the operation was successful; false otherwise. */ @Override public boolean setTestMode(boolean enable) { super.setTestMode_enforcePermission(); boolean status = mContextHubWrapper.setTestMode(enable); // Query nanoapps to update service state after test mode state change. for (int contextHubId: mDefaultClientMap.keySet()) { queryNanoAppsInternal(contextHubId); } return status; } @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; Loading services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java +37 −0 Original line number Diff line number Diff line Loading @@ -382,6 +382,23 @@ public abstract class IContextHubWrapper { */ public abstract void registerExistingCallback(int contextHubId) throws RemoteException; /** * Puts the context hub in and out of test mode. Test mode is a clean state * where tests can be executed in the same environment. If enable is true, * this will enable test mode by unloading all nanoapps. If enable is false, * this will disable test mode and reverse the actions of enabling test mode * by loading all preloaded nanoapps. This puts CHRE in a normal state. * * This should only be used for a test environment, either through a * @TestApi or development tools. This should not be used in a production * environment. * * @param enable If true, put the context hub in test mode. If false, disable * test mode. * @return If true, the operation was successful; false otherwise. */ public abstract boolean setTestMode(boolean enable); private static class ContextHubWrapperAidl extends IContextHubWrapper implements IBinder.DeathRecipient { private android.hardware.contexthub.IContextHub mHub; Loading Loading @@ -741,6 +758,22 @@ public abstract class IContextHubWrapper { registerExistingCallback(contextHubId); } public boolean setTestMode(boolean enable) { android.hardware.contexthub.IContextHub hub = getHub(); if (hub == null) { return false; } try { hub.setTestMode(enable); return true; } catch (RemoteException | ServiceSpecificException e) { Log.e(TAG, "Exception while setting test mode (enable: " + (enable ? "true" : "false") + "): " + e.getMessage()); return false; } } private void onSettingChanged(byte setting, boolean enabled) { android.hardware.contexthub.IContextHub hub = getHub(); if (hub == null) { Loading Loading @@ -911,6 +944,10 @@ public abstract class IContextHubWrapper { mHub.registerCallback(contextHubId, callback); } public boolean setTestMode(boolean enable) { return false; } public boolean supportsBtSettingNotifications() { return false; } Loading Loading
core/java/android/hardware/location/IContextHubService.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -113,4 +113,8 @@ interface IContextHubService { // Queries for a list of preloaded nanoapps @EnforcePermission("ACCESS_CONTEXT_HUB") long[] getPreloadedNanoAppIds(in ContextHubInfo hubInfo); // Enables or disables test mode @EnforcePermission("ACCESS_CONTEXT_HUB") boolean setTestMode(in boolean enable); }
services/core/java/com/android/server/location/contexthub/ContextHubService.java +28 −0 Original line number Diff line number Diff line Loading @@ -1155,6 +1155,34 @@ public class ContextHubService extends IContextHubService.Stub { return nanoappIds; } @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_CONTEXT_HUB) /** * Puts the context hub in and out of test mode. Test mode is a clean state * where tests can be executed in the same environment. If enable is true, * this will enable test mode by unloading all nanoapps. If enable is false, * this will disable test mode and reverse the actions of enabling test mode * by loading all preloaded nanoapps. This puts CHRE in a normal state. * * This should only be used for a test environment, either through a * @TestApi or development tools. This should not be used in a production * environment. * * @param enable If true, put the context hub in test mode. If false, disable * test mode. * @return If true, the operation was successful; false otherwise. */ @Override public boolean setTestMode(boolean enable) { super.setTestMode_enforcePermission(); boolean status = mContextHubWrapper.setTestMode(enable); // Query nanoapps to update service state after test mode state change. for (int contextHubId: mDefaultClientMap.keySet()) { queryNanoAppsInternal(contextHubId); } return status; } @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; Loading
services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java +37 −0 Original line number Diff line number Diff line Loading @@ -382,6 +382,23 @@ public abstract class IContextHubWrapper { */ public abstract void registerExistingCallback(int contextHubId) throws RemoteException; /** * Puts the context hub in and out of test mode. Test mode is a clean state * where tests can be executed in the same environment. If enable is true, * this will enable test mode by unloading all nanoapps. If enable is false, * this will disable test mode and reverse the actions of enabling test mode * by loading all preloaded nanoapps. This puts CHRE in a normal state. * * This should only be used for a test environment, either through a * @TestApi or development tools. This should not be used in a production * environment. * * @param enable If true, put the context hub in test mode. If false, disable * test mode. * @return If true, the operation was successful; false otherwise. */ public abstract boolean setTestMode(boolean enable); private static class ContextHubWrapperAidl extends IContextHubWrapper implements IBinder.DeathRecipient { private android.hardware.contexthub.IContextHub mHub; Loading Loading @@ -741,6 +758,22 @@ public abstract class IContextHubWrapper { registerExistingCallback(contextHubId); } public boolean setTestMode(boolean enable) { android.hardware.contexthub.IContextHub hub = getHub(); if (hub == null) { return false; } try { hub.setTestMode(enable); return true; } catch (RemoteException | ServiceSpecificException e) { Log.e(TAG, "Exception while setting test mode (enable: " + (enable ? "true" : "false") + "): " + e.getMessage()); return false; } } private void onSettingChanged(byte setting, boolean enabled) { android.hardware.contexthub.IContextHub hub = getHub(); if (hub == null) { Loading Loading @@ -911,6 +944,10 @@ public abstract class IContextHubWrapper { mHub.registerCallback(contextHubId, callback); } public boolean setTestMode(boolean enable) { return false; } public boolean supportsBtSettingNotifications() { return false; } Loading