diff --git a/api/system-current.txt b/api/system-current.txt index 27241330f2ff3..147ccd8bfe1c6 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -6428,6 +6428,7 @@ package android.service.contentcapture { method public int getEventType(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator CREATOR; + field public static final int TYPE_ACTIVITY_DESTROYED = 24; // 0x18 field public static final int TYPE_ACTIVITY_PAUSED = 2; // 0x2 field public static final int TYPE_ACTIVITY_RESUMED = 1; // 0x1 field public static final int TYPE_ACTIVITY_STOPPED = 23; // 0x17 diff --git a/api/test-current.txt b/api/test-current.txt index 4ccfa1c06745c..4e3a9842adbe0 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -2394,6 +2394,7 @@ package android.service.contentcapture { method public int getEventType(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator CREATOR; + field public static final int TYPE_ACTIVITY_DESTROYED = 24; // 0x18 field public static final int TYPE_ACTIVITY_PAUSED = 2; // 0x2 field public static final int TYPE_ACTIVITY_RESUMED = 1; // 0x1 field public static final int TYPE_ACTIVITY_STOPPED = 23; // 0x17 diff --git a/core/java/android/service/contentcapture/ActivityEvent.java b/core/java/android/service/contentcapture/ActivityEvent.java index 5407c1d9b832c..fc781c2035f62 100644 --- a/core/java/android/service/contentcapture/ActivityEvent.java +++ b/core/java/android/service/contentcapture/ActivityEvent.java @@ -52,11 +52,17 @@ public final class ActivityEvent implements Parcelable { */ public static final int TYPE_ACTIVITY_STOPPED = Event.ACTIVITY_STOPPED; + /** + * The activity was destroyed. + */ + public static final int TYPE_ACTIVITY_DESTROYED = Event.ACTIVITY_DESTROYED; + /** @hide */ @IntDef(prefix = { "TYPE_" }, value = { TYPE_ACTIVITY_RESUMED, TYPE_ACTIVITY_PAUSED, - TYPE_ACTIVITY_STOPPED + TYPE_ACTIVITY_STOPPED, + TYPE_ACTIVITY_DESTROYED }) @Retention(RetentionPolicy.SOURCE) public @interface ActivityEventType{} @@ -81,7 +87,8 @@ public final class ActivityEvent implements Parcelable { /** * Gets the event type. * - * @return either {@link #TYPE_ACTIVITY_RESUMED} or {@value #TYPE_ACTIVITY_PAUSED}. + * @return either {@link #TYPE_ACTIVITY_RESUMED}, {@value #TYPE_ACTIVITY_PAUSED}, + * {@value #TYPE_ACTIVITY_STOPPED}, or {@value #TYPE_ACTIVITY_DESTROYED}. */ @ActivityEventType public int getEventType() { @@ -97,6 +104,8 @@ public final class ActivityEvent implements Parcelable { return "ACTIVITY_PAUSED"; case TYPE_ACTIVITY_STOPPED: return "ACTIVITY_STOPPED"; + case TYPE_ACTIVITY_DESTROYED: + return "ACTIVITY_DESTROYED"; default: return "UKNOWN_TYPE: " + type; } diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 82254761817e8..c7f18d068e59f 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -2935,7 +2935,8 @@ public class ActivityManagerService extends IActivityManager.Stub } } if (mContentCaptureService != null && (event == Event.ACTIVITY_PAUSED - || event == Event.ACTIVITY_RESUMED || event == Event.ACTIVITY_STOPPED)) { + || event == Event.ACTIVITY_RESUMED || event == Event.ACTIVITY_STOPPED + || event == Event.ACTIVITY_DESTROYED)) { mContentCaptureService.notifyActivityEvent(userId, activity, event); } }