summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xapi/current.txt12
-rw-r--r--api/system-current.txt73
-rw-r--r--core/java/android/app/assist/AssistStructure.java7
-rw-r--r--core/java/android/os/UserManager.java15
-rw-r--r--core/java/android/service/intelligence/IntelligenceService.java71
-rw-r--r--core/java/android/service/intelligence/InteractionContext.java120
-rw-r--r--core/java/android/service/intelligence/InteractionSessionId.java55
-rw-r--r--core/java/android/view/intelligence/ContentCaptureEvent.java176
-rw-r--r--core/java/android/view/intelligence/IntelligenceManager.java143
-rw-r--r--core/java/android/view/intelligence/ViewNode.java44
-rw-r--r--core/res/AndroidManifest.xml8
11 files changed, 723 insertions, 1 deletions
diff --git a/api/current.txt b/api/current.txt
index c1cd0fba968b..3deb15a20a50 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -34117,6 +34117,7 @@ package android.os {
field public static final java.lang.String DISALLOW_INSTALL_APPS = "no_install_apps";
field public static final java.lang.String DISALLOW_INSTALL_UNKNOWN_SOURCES = "no_install_unknown_sources";
field public static final java.lang.String DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY = "no_install_unknown_sources_globally";
+ field public static final java.lang.String DISALLOW_INTELLIGENCE_CAPTURE = "no_intelligence_capture";
field public static final java.lang.String DISALLOW_MODIFY_ACCOUNTS = "no_modify_accounts";
field public static final java.lang.String DISALLOW_MOUNT_PHYSICAL_MEDIA = "no_physical_media";
field public static final java.lang.String DISALLOW_NETWORK_RESET = "no_network_reset";
@@ -51561,6 +51562,17 @@ package android.view.inputmethod {
}
+package android.view.intelligence {
+
+ public final class IntelligenceManager {
+ method public void disableContentCapture();
+ method public android.content.ComponentName getIntelligenceServiceComponentName();
+ method public boolean isContentCaptureEnabled();
+ field public static final int FLAG_USER_INPUT = 1; // 0x1
+ }
+
+}
+
package android.view.textclassifier {
public final class ConversationActions implements android.os.Parcelable {
diff --git a/api/system-current.txt b/api/system-current.txt
index a04a39867595..3074efdc5567 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -24,6 +24,7 @@ package android {
field public static final java.lang.String BIND_DIRECTORY_SEARCH = "android.permission.BIND_DIRECTORY_SEARCH";
field public static final java.lang.String BIND_EUICC_SERVICE = "android.permission.BIND_EUICC_SERVICE";
field public static final java.lang.String BIND_IMS_SERVICE = "android.permission.BIND_IMS_SERVICE";
+ field public static final java.lang.String BIND_INTELLIGENCE_SERVICE = "android.permission.BIND_INTELLIGENCE_SERVICE";
field public static final java.lang.String BIND_KEYGUARD_APPWIDGET = "android.permission.BIND_KEYGUARD_APPWIDGET";
field public static final java.lang.String BIND_NETWORK_RECOMMENDATION_SERVICE = "android.permission.BIND_NETWORK_RECOMMENDATION_SERVICE";
field public static final java.lang.String BIND_NOTIFICATION_ASSISTANT_SERVICE = "android.permission.BIND_NOTIFICATION_ASSISTANT_SERVICE";
@@ -614,6 +615,14 @@ package android.app.admin {
}
+package android.app.assist {
+
+ public static class AssistStructure.ViewNode {
+ ctor public AssistStructure.ViewNode();
+ }
+
+}
+
package android.app.backup {
public class BackupDataInput {
@@ -4861,6 +4870,36 @@ package android.service.euicc {
}
+package android.service.intelligence {
+
+ public abstract class IntelligenceService extends android.app.Service {
+ ctor public IntelligenceService();
+ method public abstract void onContentCaptureEvent(android.service.intelligence.InteractionSessionId, java.util.List<android.view.intelligence.ContentCaptureEvent>);
+ method public void onCreateInteractionSession(android.service.intelligence.InteractionContext, android.service.intelligence.InteractionSessionId);
+ method public void onDestroyInteractionSession(android.service.intelligence.InteractionSessionId);
+ field public static final java.lang.String SERVICE_INTERFACE = "android.service.intelligence.IntelligenceService";
+ }
+
+ public final class InteractionContext implements android.os.Parcelable {
+ method public int describeContents();
+ method public android.content.ComponentName getActivityComponent();
+ method public int getDisplayId();
+ method public int getFlags();
+ method public int getTaskId();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.service.intelligence.InteractionContext> CREATOR;
+ field public static final int FLAG_DISABLED_BY_APP = 1; // 0x1
+ field public static final int FLAG_DISABLED_BY_FLAG_SECURE = 2; // 0x2
+ }
+
+ public final class InteractionSessionId implements android.os.Parcelable {
+ method public int describeContents();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.service.intelligence.InteractionSessionId> CREATOR;
+ }
+
+}
+
package android.service.notification {
public final class Adjustment implements android.os.Parcelable {
@@ -6898,6 +6937,40 @@ package android.view.accessibility {
}
+package android.view.intelligence {
+
+ public final class ContentCaptureEvent implements android.os.Parcelable {
+ method public int describeContents();
+ method public long getEventTime();
+ method public int getFlags();
+ method public android.view.autofill.AutofillId getId();
+ method public java.lang.CharSequence getText();
+ method public int getType();
+ method public android.view.intelligence.ViewNode getViewNode();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.view.intelligence.ContentCaptureEvent> CREATOR;
+ field public static final int TYPE_ACTIVITY_PAUSED = 3; // 0x3
+ field public static final int TYPE_ACTIVITY_RESUMED = 2; // 0x2
+ field public static final int TYPE_ACTIVITY_STARTED = 1; // 0x1
+ field public static final int TYPE_ACTIVITY_STOPPED = 4; // 0x4
+ field public static final int TYPE_VIEW_ADDED = 5; // 0x5
+ field public static final int TYPE_VIEW_REMOVED = 6; // 0x6
+ field public static final int TYPE_VIEW_TEXT_CHANGED = 7; // 0x7
+ }
+
+ public final class IntelligenceManager {
+ method public java.util.Set<android.content.ComponentName> getContentCaptureDisabledActivities();
+ method public java.util.Set<java.lang.String> getContentCaptureDisabledPackages();
+ method public void setActivityContentCaptureEnabled(android.content.ComponentName, boolean);
+ method public void setPackageContentCaptureEnabled(java.lang.String, boolean);
+ }
+
+ public final class ViewNode extends android.app.assist.AssistStructure.ViewNode {
+ method public android.view.autofill.AutofillId getParentAutofillId();
+ }
+
+}
+
package android.webkit {
public abstract class CookieManager {
diff --git a/core/java/android/app/assist/AssistStructure.java b/core/java/android/app/assist/AssistStructure.java
index fefb8d3fc139..43f902a2a7f7 100644
--- a/core/java/android/app/assist/AssistStructure.java
+++ b/core/java/android/app/assist/AssistStructure.java
@@ -2,6 +2,7 @@ package android.app.assist;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
@@ -713,7 +714,11 @@ public class AssistStructure implements Parcelable {
ViewNode[] mChildren;
- ViewNode() {
+ // TODO(b/111276913): temporarily made public / @hide until we decide what will be used by
+ // ScreenObservation.
+ /** @hide */
+ @SystemApi
+ public ViewNode() {
}
ViewNode(ParcelTransferReader reader, int nestingLevel) {
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 1a84197974b4..92b316914d82 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -936,6 +936,21 @@ public class UserManager {
public static final String DISALLOW_AUTOFILL = "no_autofill";
/**
+ * Specifies if the contents of a user's screen is not allowed to be captured for artificial
+ * intelligence purposes.
+ *
+ * <p>Device owner and profile owner can set this restriction. When it is set by device owner,
+ * only the target user will be affected.
+ *
+ * <p>The default value is <code>false</code>.
+ *
+ * @see DevicePolicyManager#addUserRestriction(ComponentName, String)
+ * @see DevicePolicyManager#clearUserRestriction(ComponentName, String)
+ * @see #getUserRestrictions()
+ */
+ public static final String DISALLOW_INTELLIGENCE_CAPTURE = "no_intelligence_capture";
+
+ /**
* Specifies if user switching is blocked on the current user.
*
* <p> This restriction can only be set by the device owner, it will be applied to all users.
diff --git a/core/java/android/service/intelligence/IntelligenceService.java b/core/java/android/service/intelligence/IntelligenceService.java
new file mode 100644
index 000000000000..4b8825d64559
--- /dev/null
+++ b/core/java/android/service/intelligence/IntelligenceService.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.service.intelligence;
+
+import android.annotation.NonNull;
+import android.annotation.SystemApi;
+import android.app.Service;
+import android.content.Intent;
+import android.view.intelligence.ContentCaptureEvent;
+
+import java.util.List;
+
+/**
+ * A service used to captures the content of the screen.
+ *
+ * <p>The data collected by this service can be analyzed and combined with other sources to provide
+ * contextual data in other areas of the system such as Autofill.
+ *
+ * @hide
+ */
+@SystemApi
+public abstract class IntelligenceService extends Service {
+
+ /**
+ * The {@link Intent} that must be declared as handled by the service.
+ * To be supported, the service must also require the
+ * {@link android.Manifest.permission#BIND_INTELLIGENCE_SERVICE} permission so
+ * that other applications can not abuse it.
+ */
+ public static final String SERVICE_INTERFACE =
+ "android.service.intelligence.IntelligenceService";
+
+ /**
+ * Creates a new interaction session.
+ *
+ * @param context interaction context
+ * @param sessionId the session's Id
+ */
+ public void onCreateInteractionSession(@NonNull InteractionContext context,
+ @NonNull InteractionSessionId sessionId) {}
+
+ /**
+ * Notifies the service of {@link ContentCaptureEvent events} associated with a content capture
+ * session.
+ *
+ * @param sessionId the session's Id
+ * @param events the events
+ */
+ public abstract void onContentCaptureEvent(@NonNull InteractionSessionId sessionId,
+ @NonNull List<ContentCaptureEvent> events);
+
+ /**
+ * Destroys the content capture session identified by the specified {@code sessionId}.
+ *
+ * @param sessionId the id of the session to destroy
+ */
+ public void onDestroyInteractionSession(@NonNull InteractionSessionId sessionId) {}
+}
diff --git a/core/java/android/service/intelligence/InteractionContext.java b/core/java/android/service/intelligence/InteractionContext.java
new file mode 100644
index 000000000000..4d83820f2a2a
--- /dev/null
+++ b/core/java/android/service/intelligence/InteractionContext.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.service.intelligence;
+
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.annotation.SystemApi;
+import android.app.TaskInfo;
+import android.content.ComponentName;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+// TODO(b/111276913): add javadocs / implement Parcelable / implement equals/hashcode/toString
+/** @hide */
+@SystemApi
+public final class InteractionContext implements Parcelable {
+
+ /**
+ * Flag used to indicate that the app explicitly disabled contents capture for the activity
+ * (using
+ * {@link android.view.intelligence.IntelligenceManager#disableContentCapture()}),
+ * in which case the service will just receive activity-level events.
+ */
+ public static final int FLAG_DISABLED_BY_APP = 0x1;
+
+ /**
+ * Flag used to indicate that the activity's window is tagged with
+ * {@link android.view.Display#FLAG_SECURE}, in which case the service will just receive
+ * activity-level events.
+ */
+ public static final int FLAG_DISABLED_BY_FLAG_SECURE = 0x2;
+
+ /** @hide */
+ @IntDef(flag = true, prefix = { "FLAG_" }, value = {
+ FLAG_DISABLED_BY_APP,
+ FLAG_DISABLED_BY_FLAG_SECURE
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ @interface ContextCreationFlags{}
+
+ /** @hide */
+ InteractionContext() {
+ }
+
+ /**
+ * Gets the id of the {@link TaskInfo task} associated with this context.
+ */
+ public int getTaskId() {
+ //TODO(b/111276913): implement
+ return 108;
+ }
+
+ /**
+ * Gets the activity associated with this context.
+ */
+ public @NonNull ComponentName getActivityComponent() {
+ //TODO(b/111276913): implement
+ return null;
+ }
+
+ /**
+ * Gets the ID of the display associated with this context, as defined by
+ * {G android.hardware.display.DisplayManager#getDisplay(int) DisplayManager.getDisplay()}.
+ */
+ public int getDisplayId() {
+ //TODO(b/111276913): implement
+ return 42;
+ }
+
+ /**
+ * Gets the flags associated with this context.
+ *
+ * @return any combination of {@link #FLAG_DISABLED_BY_FLAG_SECURE} and
+ * {@link #FLAG_DISABLED_BY_APP}.
+ */
+ public @ContextCreationFlags int getFlags() {
+ //TODO(b/111276913): implement
+ return 42;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel parcel, int flags) {
+ }
+
+ public static final Parcelable.Creator<InteractionContext> CREATOR =
+ new Parcelable.Creator<InteractionContext>() {
+
+ @Override
+ public InteractionContext createFromParcel(Parcel parcel) {
+ // TODO(b/111276913): implement
+ return null;
+ }
+
+ @Override
+ public InteractionContext[] newArray(int size) {
+ return new InteractionContext[size];
+ }
+ };
+}
diff --git a/core/java/android/service/intelligence/InteractionSessionId.java b/core/java/android/service/intelligence/InteractionSessionId.java
new file mode 100644
index 000000000000..4c9d706b0b40
--- /dev/null
+++ b/core/java/android/service/intelligence/InteractionSessionId.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.intelligence;
+
+import android.annotation.SystemApi;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+// TODO(b/111276913): add javadocs / implement equals/hashcode/string
+/** @hide */
+@SystemApi
+public final class InteractionSessionId implements Parcelable {
+
+ /** @hide */
+ public InteractionSessionId() {
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel parcel, int flags) {
+ }
+
+ public static final Parcelable.Creator<InteractionSessionId> CREATOR =
+ new Parcelable.Creator<InteractionSessionId>() {
+
+ @Override
+ public InteractionSessionId createFromParcel(Parcel parcel) {
+ // TODO(b/111276913): implement
+ return null;
+ }
+
+ @Override
+ public InteractionSessionId[] newArray(int size) {
+ return new InteractionSessionId[size];
+ }
+ };
+}
diff --git a/core/java/android/view/intelligence/ContentCaptureEvent.java b/core/java/android/view/intelligence/ContentCaptureEvent.java
new file mode 100644
index 000000000000..b8330e5568fb
--- /dev/null
+++ b/core/java/android/view/intelligence/ContentCaptureEvent.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.view.intelligence;
+
+import android.annotation.IntDef;
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.view.autofill.AutofillId;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+// TODO(b/111276913): add javadocs / implement Parcelable / implement
+/** @hide */
+@SystemApi
+public final class ContentCaptureEvent implements Parcelable {
+
+ /**
+ * Called when the activity is started.
+ */
+ public static final int TYPE_ACTIVITY_STARTED = 1;
+
+ /**
+ * Called when the activity is resumed.
+ */
+ public static final int TYPE_ACTIVITY_RESUMED = 2;
+
+ /**
+ * Called when the activity is paused.
+ */
+ public static final int TYPE_ACTIVITY_PAUSED = 3;
+
+ /**
+ * Called when the activity is stopped.
+ */
+ public static final int TYPE_ACTIVITY_STOPPED = 4;
+
+ /**
+ * Called when a node has been added to the screen and is visible to the user.
+ *
+ * <p>The metadata of the node is available through {@link #getViewNode()}.
+ */
+ public static final int TYPE_VIEW_ADDED = 5;
+
+ /**
+ * Called when a node has been removed from the screen and is not visible to the user anymore.
+ *
+ * <p>The id of the node is available through {@link #getId()}.
+ */
+ public static final int TYPE_VIEW_REMOVED = 6;
+
+ /**
+ * Called when the text of a node has been changed.
+ *
+ * <p>The id of the node is available through {@link #getId()}, and the new text is
+ * available through {@link #getText()}.
+ */
+ public static final int TYPE_VIEW_TEXT_CHANGED = 7;
+
+ // TODO(b/111276913): add event to indicate when FLAG_SECURE was changed?
+
+ /** @hide */
+ @IntDef(prefix = { "TYPE_" }, value = {
+ TYPE_ACTIVITY_STARTED,
+ TYPE_ACTIVITY_PAUSED,
+ TYPE_ACTIVITY_RESUMED,
+ TYPE_ACTIVITY_STOPPED,
+ TYPE_VIEW_ADDED,
+ TYPE_VIEW_REMOVED,
+ TYPE_VIEW_TEXT_CHANGED
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ @interface EventType{}
+
+ /** @hide */
+ ContentCaptureEvent() {
+ }
+
+ /**
+ * Gets the type of the event.
+ *
+ * @return one of {@link #TYPE_ACTIVITY_STARTED}, {@link #TYPE_ACTIVITY_RESUMED},
+ * {@link #TYPE_ACTIVITY_PAUSED}, {@link #TYPE_ACTIVITY_STOPPED},
+ * {@link #TYPE_VIEW_ADDED}, {@link #TYPE_VIEW_REMOVED}, or {@link #TYPE_VIEW_TEXT_CHANGED}.
+ */
+ public @EventType int getType() {
+ return 42;
+ }
+
+ /**
+ * Gets when the event was generated, in ms.
+ */
+ public long getEventTime() {
+ return 48151623;
+ }
+
+ /**
+ * Gets optional flags associated with the event.
+ *
+ * @return either {@code 0} or
+ * {@link android.view.intelligence.IntelligenceManager#FLAG_USER_INPUT}.
+ */
+ public int getFlags() {
+ return 0;
+ }
+
+ /**
+ * Gets the whole metadata of the node associated with the event.
+ *
+ * <p>Only set on {@link #TYPE_VIEW_ADDED} events.
+ */
+ @Nullable
+ public ViewNode getViewNode() {
+ return null;
+ }
+
+ /**
+ * Gets the {@link AutofillId} of the node associated with the event.
+ *
+ * <p>Only set on {@link #TYPE_VIEW_REMOVED} and {@link #TYPE_VIEW_TEXT_CHANGED} events.
+ */
+ @Nullable
+ public AutofillId getId() {
+ return null;
+ }
+
+ /**
+ * Gets the current text of the node associated with the event.
+ *
+ * <p>Only set on {@link #TYPE_VIEW_TEXT_CHANGED} events.
+ */
+ @Nullable
+ public CharSequence getText() {
+ return null;
+ }
+
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel parcel, int flags) {
+ }
+
+ public static final Parcelable.Creator<ContentCaptureEvent> CREATOR =
+ new Parcelable.Creator<ContentCaptureEvent>() {
+
+ @Override
+ public ContentCaptureEvent createFromParcel(Parcel parcel) {
+ // TODO(b/111276913): implement
+ return null;
+ }
+
+ @Override
+ public ContentCaptureEvent[] newArray(int size) {
+ return new ContentCaptureEvent[size];
+ }
+ };
+}
diff --git a/core/java/android/view/intelligence/IntelligenceManager.java b/core/java/android/view/intelligence/IntelligenceManager.java
new file mode 100644
index 000000000000..cbe73efe7f75
--- /dev/null
+++ b/core/java/android/view/intelligence/IntelligenceManager.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.view.intelligence;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+import android.content.ComponentName;
+import android.content.Context;
+
+import com.android.internal.util.Preconditions;
+
+import java.util.Set;
+
+/**
+ * TODO(b/111276913): add javadocs / implement / add SystemService / PackageFeature
+ */
+public final class IntelligenceManager {
+
+ /**
+ * Used to indicate that a text change was caused by user input (for example, through IME).
+ */
+ //TODO(b/111276913): link to notifyTextChanged() method once available
+ public static final int FLAG_USER_INPUT = 0x1;
+
+ private final Context mContext;
+
+ /** @hide */
+ public IntelligenceManager(@NonNull Context context) {
+ mContext = Preconditions.checkNotNull(context, "context cannot be null");
+ }
+
+ /**
+ * Returns the component name of the {@link android.service.intelligence.IntelligenceService}
+ * that is enabled for the current user.
+ */
+ @Nullable
+ public ComponentName getIntelligenceServiceComponentName() {
+ //TODO(b/111276913): implement
+ return null;
+ }
+
+ /**
+ * Checks whether contents capture is enabled for this activity.
+ */
+ public boolean isContentCaptureEnabled() {
+ //TODO(b/111276913): implement
+ return false;
+ }
+
+ /**
+ * Called by apps to disable content capture.
+ *
+ * <p><b>Note: </b> this call is not persisted accross reboots, so apps should typically call
+ * it on {@link android.app.Activity#onCreate(android.os.Bundle, android.os.PersistableBundle)}.
+ */
+ public void disableContentCapture() {
+ }
+
+ /**
+ * Called by the the service {@link android.service.intelligence.IntelligenceService}
+ * to define whether content capture should be enabled for activities with such
+ * {@link android.content.ComponentName}.
+ *
+ * <p>Useful to blacklist a particular activity.
+ *
+ * @throws UnsupportedOperationException if not called by the UID that owns the
+ * {@link android.service.intelligence.IntelligenceService} associated with the
+ * current user.
+ *
+ * @hide
+ */
+ @SystemApi
+ public void setActivityContentCaptureEnabled(@NonNull ComponentName activity,
+ boolean enabled) {
+ //TODO(b/111276913): implement
+ }
+
+ /**
+ * Called by the the service {@link android.service.intelligence.IntelligenceService}
+ * to define whether content capture should be enabled for activities of the app with such
+ * {@code packageName}.
+ *
+ * <p>Useful to blacklist any activity from a particular app.
+ *
+ * @throws UnsupportedOperationException if not called by the UID that owns the
+ * {@link android.service.intelligence.IntelligenceService} associated with the
+ * current user.
+ *
+ * @hide
+ */
+ @SystemApi
+ public void setPackageContentCaptureEnabled(@NonNull String packageName, boolean enabled) {
+ //TODO(b/111276913): implement
+ }
+
+ /**
+ * Gets the activities where content capture was disabled by
+ * {@link #setActivityContentCaptureEnabled(ComponentName, boolean)}.
+ *
+ * @throws UnsupportedOperationException if not called by the UID that owns the
+ * {@link android.service.intelligence.IntelligenceService} associated with the
+ * current user.
+ *
+ * @hide
+ */
+ @SystemApi
+ @NonNull
+ public Set<ComponentName> getContentCaptureDisabledActivities() {
+ //TODO(b/111276913): implement
+ return null;
+ }
+
+ /**
+ * Gets the apps where content capture was disabled by
+ * {@link #setPackageContentCaptureEnabled(String, boolean)}.
+ *
+ * @throws UnsupportedOperationException if not called by the UID that owns the
+ * {@link android.service.intelligence.IntelligenceService} associated with the
+ * current user.
+ *
+ * @hide
+ */
+ @SystemApi
+ @NonNull
+ public Set<String> getContentCaptureDisabledPackages() {
+ //TODO(b/111276913): implement
+ return null;
+ }
+}
diff --git a/core/java/android/view/intelligence/ViewNode.java b/core/java/android/view/intelligence/ViewNode.java
new file mode 100644
index 000000000000..357ecf599f7a
--- /dev/null
+++ b/core/java/android/view/intelligence/ViewNode.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.view.intelligence;
+
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+import android.app.assist.AssistStructure;
+import android.view.autofill.AutofillId;
+
+//TODO(b/111276913): add javadocs / implement Parcelable / implement
+//TODO(b/111276913): for now it's extending ViewNode directly as it needs most of its properties,
+// but it might be better to create a common, abstract android.view.ViewNode class that both extend
+// instead
+/** @hide */
+@SystemApi
+public final class ViewNode extends AssistStructure.ViewNode {
+
+ /** @hide */
+ public ViewNode() {
+ }
+
+ /**
+ * Returns the {@link AutofillId} of this view's parent, if the parent is also part of the
+ * screen observation tree.
+ */
+ @Nullable
+ public AutofillId getParentAutofillId() {
+ //TODO(b/111276913): implement
+ return null;
+ }
+}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 4b3fbe4bc2a3..093a86089aab 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -3019,6 +3019,14 @@
<permission android:name="android.permission.BIND_TEXTCLASSIFIER_SERVICE"
android:protectionLevel="signature" />
+ <!-- Must be required by a android.service.intelligence.IntelligenceService,
+ to ensure that only the system can bind to it.
+ @SystemApi @hide This is not a third-party API (intended for OEMs and system apps).
+ <p>Protection level: signature
+ -->
+ <permission android:name="android.permission.BIND_INTELLIGENCE_SERVICE"
+ android:protectionLevel="signature" />
+
<!-- Must be required by hotword enrollment application,
to ensure that only the system can interact with it.
@hide <p>Not for use by third-party applications.</p> -->