summaryrefslogtreecommitdiff
path: root/test-mock/src/android/test/mock/MockPackageManager.java
diff options
context:
space:
mode:
authorPhilip P. Moltmann <moltmann@google.com>2018-03-09 16:55:55 -0800
committerPhilip P. Moltmann <moltmann@google.com>2018-03-20 13:57:14 -0700
commit18e3eb816887156f40def1c14db434ddde9ec245 (patch)
treeeb89c3addc9bac983b9d4fb1138ebe4de5fcc52a /test-mock/src/android/test/mock/MockPackageManager.java
parenta5fd0294c76c1faa3479a2093ae3e5f0838791ad (diff)
Add SoundTriggerDetectionService
The service is meant to replace the PendingIntent based API. Once all users of the PendingIntent based API switched the PendingIntent based API will be removed. To have as little as possible impact on the whole SoundTrigger framework the RemoteSoundTriggerDetectionService class implements the same interface as the PendingIntent based class. Hence the exising code has very little change. Further once the old code can be removed the amount of changed (and added) code is limited. The RemoteSoundTriggerDetectionService -> SoundTriggerDetectionService is a vanilla as possible service implementation. The special behaviors are: - The system holds a wakelock while service operations are in progress and the service is bound as foreground. Hence the service can e.g. listen to the microphone. - Service operations have a certain amount of time they are allowed to run. Once every operation is either finished or the the operation exceeded the allotted time, the system calls onStopOperation for each still pending operation. This is a similar model as for the commonly used JobService. Please note that if the time allowed for an operation is 15s and op1 was run as 0si, and op1 was run at 5s, the service is allowed to run until 20s. Hence _both_ onStopOperations will happen at 20s. This is done for ease of implementation but should not give the service more power than calling onStopOperation exactly 15s after each operation is triggered. - If an operation is done before the allotted time is reached, the service can declare the operation as finished manually by calling onOperationFinished. This is a call back into the system, hence a 'client' binder is sent to the service. If the operation is finished by calling this method onStopOperation will not be called. - As the service instance might be killed and restored between operations we add a opaque bundle 'params' to each operations. The users of the API can use this to send data from the start command to the operations. It can also just be set to null. The params are not meant to store changing state in between operations. Such state needs to be persisted using the regular methods (e.g. write it to disk) - A service can be used for multiple recognition sessions. Each recognition is uniquelity defined by its sound model UUID. Hence each operation gets at least tree arguments: Operation ID, sound mode UUID, params - As a small optimization the params are cached inside of the service instance. The time allowed for each operation is in a @SystemAPI global setting, so the service can make sure it finishes the operations before they are stopped. It might take some time to deliver the operations via the binder, hence it is not recommended to try to use every last ms of allotted time. Test: atest SoundTriggerDetectionServiceTest (added in separate CL) atest android.provider.SettingsBackupTest Change-Id: I47f813b7a5138a6f24732197813a605d29f85a93 Fixes: 73829108
Diffstat (limited to 'test-mock/src/android/test/mock/MockPackageManager.java')
-rw-r--r--test-mock/src/android/test/mock/MockPackageManager.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/test-mock/src/android/test/mock/MockPackageManager.java b/test-mock/src/android/test/mock/MockPackageManager.java
index 1af7c3a479b6..8ebb77d7a350 100644
--- a/test-mock/src/android/test/mock/MockPackageManager.java
+++ b/test-mock/src/android/test/mock/MockPackageManager.java
@@ -18,6 +18,7 @@ package android.test.mock;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.UserIdInt;
import android.app.PackageInstallObserver;
import android.content.ComponentName;
import android.content.Intent;
@@ -464,6 +465,11 @@ public class MockPackageManager extends PackageManager {
}
@Override
+ public ResolveInfo resolveServiceAsUser(Intent intent, int flags, int userId) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public List<ResolveInfo> queryIntentServices(Intent intent, int flags) {
throw new UnsupportedOperationException();
}