summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorKholoud Mohamed <kholoudm@google.com>2021-03-01 18:37:03 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-03-01 18:37:03 +0000
commit93d631e2f0af446fcf11d90ce06fd25a8bd4734d (patch)
tree5aa7aabfd0ac62e80201158a9805f6f7ab847e5a /core/java
parent69d8c2551825f6fca74fe9ce304d1a79e929c3a1 (diff)
parent28913aa2f960bbb07c3c06e95bd5b18be5439382 (diff)
Merge "Add testAPIs in ContentCaptureManager" into sc-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/contentcapture/ContentCaptureManager.java71
-rw-r--r--core/java/android/view/contentcapture/IContentCaptureManager.aidl15
2 files changed, 86 insertions, 0 deletions
diff --git a/core/java/android/view/contentcapture/ContentCaptureManager.java b/core/java/android/view/contentcapture/ContentCaptureManager.java
index 10f6c610d5d3..46e0306cefc8 100644
--- a/core/java/android/view/contentcapture/ContentCaptureManager.java
+++ b/core/java/android/view/contentcapture/ContentCaptureManager.java
@@ -23,10 +23,13 @@ import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.UiThread;
+import android.annotation.UserIdInt;
+import android.app.Service;
import android.content.ComponentName;
import android.content.ContentCaptureOptions;
import android.content.Context;
@@ -755,6 +758,74 @@ public final class ContentCaptureManager {
}
}
+ /**
+ * Resets the temporary content capture service implementation to the default component.
+ *
+ * @hide
+ */
+ @TestApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_CONTENT_CAPTURE)
+ public static void resetTemporaryService(@UserIdInt int userId) {
+ final IContentCaptureManager service = getService();
+ if (service == null) {
+ Log.e(TAG, "IContentCaptureManager is null");
+ }
+ try {
+ service.resetTemporaryService(userId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Temporarily sets the content capture service implementation.
+ *
+ * @param userId user Id to set the temporary service on.
+ * @param serviceName name of the new component
+ * @param duration how long the change will be valid (the service will be automatically reset
+ * to the default component after this timeout expires).
+ *
+ * @hide
+ */
+ @TestApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_CONTENT_CAPTURE)
+ public static void setTemporaryService(
+ @UserIdInt int userId, @NonNull String serviceName, int duration) {
+ final IContentCaptureManager service = getService();
+ if (service == null) {
+ Log.e(TAG, "IContentCaptureManager is null");
+ }
+ try {
+ service.setTemporaryService(userId, serviceName, duration);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Sets whether the default content capture service should be used.
+ *
+ * @hide
+ */
+ @TestApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_CONTENT_CAPTURE)
+ public static void setDefaultServiceEnabled(@UserIdInt int userId, boolean enabled) {
+ final IContentCaptureManager service = getService();
+ if (service == null) {
+ Log.e(TAG, "IContentCaptureManager is null");
+ }
+ try {
+ service.setDefaultServiceEnabled(userId, enabled);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ private static IContentCaptureManager getService() {
+ return IContentCaptureManager.Stub.asInterface(ServiceManager.getService(
+ Service.CONTENT_CAPTURE_MANAGER_SERVICE));
+ }
+
private interface MyRunnable {
void run(@NonNull SyncResultReceiver receiver) throws RemoteException;
}
diff --git a/core/java/android/view/contentcapture/IContentCaptureManager.aidl b/core/java/android/view/contentcapture/IContentCaptureManager.aidl
index 01ead4601e59..ef8295c30fdf 100644
--- a/core/java/android/view/contentcapture/IContentCaptureManager.aidl
+++ b/core/java/android/view/contentcapture/IContentCaptureManager.aidl
@@ -85,4 +85,19 @@ oneway interface IContentCaptureManager {
* Returns a list with the ContentCaptureConditions for the package (or null if not defined).
*/
void getContentCaptureConditions(String packageName, in IResultReceiver result);
+
+ /**
+ * Resets the temporary service implementation to the default component.
+ */
+ void resetTemporaryService(int userId);
+
+ /**
+ * Temporarily sets the service implementation.
+ */
+ void setTemporaryService(int userId, in String serviceName, int duration);
+
+ /**
+ * Sets whether the default service should be used.
+ */
+ void setDefaultServiceEnabled(int userId, boolean enabled);
}