Merge "Add hidden TYPE_ACTIVITY_STARTED to allow notify activity start event." into sc-dev

This commit is contained in:
Joanne Chung
2021-06-24 03:48:29 +00:00
committed by Android (Google) Code Review
2 changed files with 26 additions and 2 deletions

View File

@@ -55,12 +55,25 @@ public final class ActivityEvent implements Parcelable {
*/ */
public static final int TYPE_ACTIVITY_DESTROYED = Event.ACTIVITY_DESTROYED; public static final int TYPE_ACTIVITY_DESTROYED = Event.ACTIVITY_DESTROYED;
/**
* TODO: change to public field.
* The activity was started.
*
* <p>There are some reason, ACTIVITY_START cannot be added into UsageStats. We don't depend on
* UsageEvents for Activity start.
* </p>
*
* @hide
*/
public static final int TYPE_ACTIVITY_STARTED = 10000;
/** @hide */ /** @hide */
@IntDef(prefix = { "TYPE_" }, value = { @IntDef(prefix = { "TYPE_" }, value = {
TYPE_ACTIVITY_RESUMED, TYPE_ACTIVITY_RESUMED,
TYPE_ACTIVITY_PAUSED, TYPE_ACTIVITY_PAUSED,
TYPE_ACTIVITY_STOPPED, TYPE_ACTIVITY_STOPPED,
TYPE_ACTIVITY_DESTROYED TYPE_ACTIVITY_DESTROYED,
TYPE_ACTIVITY_STARTED
}) })
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface ActivityEventType{} public @interface ActivityEventType{}
@@ -86,7 +99,8 @@ public final class ActivityEvent implements Parcelable {
* Gets the event type. * Gets the event type.
* *
* @return either {@link #TYPE_ACTIVITY_RESUMED}, {@value #TYPE_ACTIVITY_PAUSED}, * @return either {@link #TYPE_ACTIVITY_RESUMED}, {@value #TYPE_ACTIVITY_PAUSED},
* {@value #TYPE_ACTIVITY_STOPPED}, or {@value #TYPE_ACTIVITY_DESTROYED}. * {@value #TYPE_ACTIVITY_STOPPED}, {@value #TYPE_ACTIVITY_DESTROYED} or 10000 if the Activity
* was started.
*/ */
@ActivityEventType @ActivityEventType
public int getEventType() { public int getEventType() {
@@ -104,6 +118,8 @@ public final class ActivityEvent implements Parcelable {
return "ACTIVITY_STOPPED"; return "ACTIVITY_STOPPED";
case TYPE_ACTIVITY_DESTROYED: case TYPE_ACTIVITY_DESTROYED:
return "ACTIVITY_DESTROYED"; return "ACTIVITY_DESTROYED";
case TYPE_ACTIVITY_STARTED:
return "ACTIVITY_STARTED";
default: default:
return "UKNOWN_TYPE: " + type; return "UKNOWN_TYPE: " + type;
} }

View File

@@ -278,6 +278,7 @@ import android.os.SystemClock;
import android.os.Trace; import android.os.Trace;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.storage.StorageManager; import android.os.storage.StorageManager;
import android.service.contentcapture.ActivityEvent;
import android.service.dreams.DreamActivity; import android.service.dreams.DreamActivity;
import android.service.dreams.DreamManagerInternal; import android.service.dreams.DreamManagerInternal;
import android.service.voice.IVoiceInteractionSession; import android.service.voice.IVoiceInteractionSession;
@@ -328,6 +329,7 @@ import com.android.internal.util.function.pooled.PooledLambda;
import com.android.server.LocalServices; import com.android.server.LocalServices;
import com.android.server.am.AppTimeTracker; import com.android.server.am.AppTimeTracker;
import com.android.server.am.PendingIntentRecord; import com.android.server.am.PendingIntentRecord;
import com.android.server.contentcapture.ContentCaptureManagerInternal;
import com.android.server.display.color.ColorDisplayService; import com.android.server.display.color.ColorDisplayService;
import com.android.server.policy.WindowManagerPolicy; import com.android.server.policy.WindowManagerPolicy;
import com.android.server.uri.NeededUriGrants; import com.android.server.uri.NeededUriGrants;
@@ -4878,6 +4880,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
true /* activityChange */, true /* updateOomAdj */, true /* activityChange */, true /* updateOomAdj */,
true /* addPendingTopUid */); true /* addPendingTopUid */);
} }
final ContentCaptureManagerInternal contentCaptureService =
LocalServices.getService(ContentCaptureManagerInternal.class);
if (contentCaptureService != null) {
contentCaptureService.notifyActivityEvent(mUserId, mActivityComponent,
ActivityEvent.TYPE_ACTIVITY_STARTED);
}
break; break;
case PAUSED: case PAUSED:
mAtmService.updateBatteryStats(this, false); mAtmService.updateBatteryStats(this, false);