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

Commit bc308988 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Add new api Activity.getStartInitiatedTime.

This api will return the timestamp at which this activity start was last
initiated by the system. Implementation is wip.

Bug: 9058261
Test: cts-tradefed run singleCommand cts-dev -m CtsAppTestCases -t \
      android.app.cts.ActivityStartTimeTest

Change-Id: I396458ecefbb09108f414b95f9c0beb6d609a4e1
parent bf02434e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3611,6 +3611,7 @@ package android.app {
    method public android.net.Uri getReferrer();
    method public int getRequestedOrientation();
    method public final android.view.SearchEvent getSearchEvent();
    method public long getStartInitiatedTime();
    method public int getTaskId();
    method public final java.lang.CharSequence getTitle();
    method public final int getTitleColor();
+1 −0
Original line number Diff line number Diff line
@@ -3737,6 +3737,7 @@ package android.app {
    method public android.net.Uri getReferrer();
    method public int getRequestedOrientation();
    method public final android.view.SearchEvent getSearchEvent();
    method public long getStartInitiatedTime();
    method public int getTaskId();
    method public final java.lang.CharSequence getTitle();
    method public final int getTitleColor();
+1 −0
Original line number Diff line number Diff line
@@ -3613,6 +3613,7 @@ package android.app {
    method public android.net.Uri getReferrer();
    method public int getRequestedOrientation();
    method public final android.view.SearchEvent getSearchEvent();
    method public long getStartInitiatedTime();
    method public int getTaskId();
    method public final java.lang.CharSequence getTitle();
    method public final int getTitleColor();
+20 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.app;

import android.metrics.LogMaker;
import android.graphics.Rect;
import android.os.SystemClock;
import android.view.ViewRootImpl.ActivityConfigCallback;
import android.view.autofill.AutofillId;
import android.view.autofill.AutofillManager;
@@ -7416,6 +7417,25 @@ public class Activity extends ContextThemeWrapper
        }
    }

    /**
     * Return the timestamp at which this activity start was last initiated by the system in the
     * {@link SystemClock#uptimeMillis()} time base.
     *
     * This can be used to understand how much time is taken for an activity to be started and
     * displayed to the user.
     *
     * @return timestamp at which this activity start was initiated by the system
     *         or {@code 0} if for any reason the timestamp could not be retrieved.
     */
    public long getStartInitiatedTime() {
        try {
            return ActivityManager.getService().getActivityStartInitiatedTime(mToken);
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to call getActivityStartTime", e);
            return 0;
        }
    }

    class HostCallbacks extends FragmentHostCallback<Activity> {
        public HostCallbacks() {
            super(Activity.this /*activity*/);
+2 −0
Original line number Diff line number Diff line
@@ -640,6 +640,8 @@ interface IActivityManager {
     */
     void backgroundWhitelistUid(int uid);

     long getActivityStartInitiatedTime(IBinder token);

    // WARNING: when these transactions are updated, check if they are any callers on the native
    // side. If so, make sure they are using the correct transaction ids and arguments.
    // If a transaction which will also be used on the native side is being inserted, add it
Loading