Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f980cbd authored by Joanne Chung's avatar Joanne Chung Committed by Android (Google) Code Review
Browse files

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

parents 293b6bf6 cdcf3a83
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -55,12 +55,25 @@ public final class ActivityEvent implements Parcelable {
     */
    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 */
    @IntDef(prefix = { "TYPE_" }, value = {
            TYPE_ACTIVITY_RESUMED,
            TYPE_ACTIVITY_PAUSED,
            TYPE_ACTIVITY_STOPPED,
            TYPE_ACTIVITY_DESTROYED
            TYPE_ACTIVITY_DESTROYED,
            TYPE_ACTIVITY_STARTED
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ActivityEventType{}
@@ -86,7 +99,8 @@ public final class ActivityEvent implements Parcelable {
     * Gets the event type.
     *
     * @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
    public int getEventType() {
@@ -104,6 +118,8 @@ public final class ActivityEvent implements Parcelable {
                return "ACTIVITY_STOPPED";
            case TYPE_ACTIVITY_DESTROYED:
                return "ACTIVITY_DESTROYED";
            case TYPE_ACTIVITY_STARTED:
                return "ACTIVITY_STARTED";
            default:
                return "UKNOWN_TYPE: " + type;
        }
+8 −0
Original line number Diff line number Diff line
@@ -278,6 +278,7 @@ import android.os.SystemClock;
import android.os.Trace;
import android.os.UserHandle;
import android.os.storage.StorageManager;
import android.service.contentcapture.ActivityEvent;
import android.service.dreams.DreamActivity;
import android.service.dreams.DreamManagerInternal;
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.am.AppTimeTracker;
import com.android.server.am.PendingIntentRecord;
import com.android.server.contentcapture.ContentCaptureManagerInternal;
import com.android.server.display.color.ColorDisplayService;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.uri.NeededUriGrants;
@@ -4878,6 +4880,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                            true /* activityChange */, true /* updateOomAdj */,
                            true /* addPendingTopUid */);
                }
                final ContentCaptureManagerInternal contentCaptureService =
                        LocalServices.getService(ContentCaptureManagerInternal.class);
                if (contentCaptureService != null) {
                    contentCaptureService.notifyActivityEvent(mUserId, mActivityComponent,
                            ActivityEvent.TYPE_ACTIVITY_STARTED);
                }
                break;
            case PAUSED:
                mAtmService.updateBatteryStats(this, false);