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

Commit a61ddcbd authored by Yisroel Forta's avatar Yisroel Forta Committed by Android (Google) Code Review
Browse files

Merge "Add ApplicationStartInfo API and objects"

parents e58e79ac d5947b6b
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
@@ -4614,6 +4614,7 @@ package android.app {
    method public java.util.List<android.app.ActivityManager.AppTask> getAppTasks();
    method public android.content.pm.ConfigurationInfo getDeviceConfigurationInfo();
    method @NonNull public java.util.List<android.app.ApplicationExitInfo> getHistoricalProcessExitReasons(@Nullable String, @IntRange(from=0) int, @IntRange(from=0) int);
    method @NonNull public java.util.List<android.app.ApplicationStartInfo> getHistoricalProcessStartReasons(@IntRange(from=0) int);
    method public int getLargeMemoryClass();
    method public int getLauncherLargeIconDensity();
    method public int getLauncherLargeIconSize();
@@ -4639,7 +4640,9 @@ package android.app {
    method @RequiresPermission(android.Manifest.permission.KILL_BACKGROUND_PROCESSES) public void killBackgroundProcesses(String);
    method @RequiresPermission(android.Manifest.permission.REORDER_TASKS) public void moveTaskToFront(int, int);
    method @RequiresPermission(android.Manifest.permission.REORDER_TASKS) public void moveTaskToFront(int, int, android.os.Bundle);
    method public void removeApplicationStartInfoCompleteListener();
    method @Deprecated public void restartPackage(String);
    method public void setApplicationStartInfoCompleteListener(@NonNull java.util.concurrent.Executor, @NonNull android.app.ActivityManager.ApplicationStartInfoCompleteListener);
    method public void setProcessStateSummary(@Nullable byte[]);
    method public static void setVrThread(int);
    method public void setWatchHeapLimit(long);
@@ -4662,6 +4665,10 @@ package android.app {
    method public void startActivity(android.content.Context, android.content.Intent, android.os.Bundle);
  }
  public static interface ActivityManager.ApplicationStartInfoCompleteListener {
    method public void onApplicationStartInfoComplete(@NonNull android.app.ApplicationStartInfo);
  }
  public static class ActivityManager.MemoryInfo implements android.os.Parcelable {
    ctor public ActivityManager.MemoryInfo();
    method public int describeContents();
@@ -5221,6 +5228,52 @@ package android.app {
    field public static final int REASON_USER_STOPPED = 11; // 0xb
  }
  public final class ApplicationStartInfo implements android.os.Parcelable {
    method public int describeContents();
    method public int getDefiningUid();
    method @Nullable public android.content.Intent getIntent();
    method public int getLaunchMode();
    method public int getPackageUid();
    method public int getPid();
    method @NonNull public String getProcessName();
    method public int getRealUid();
    method public int getReason();
    method public int getStartType();
    method public int getStartupState();
    method @NonNull public java.util.Map<java.lang.Integer,java.lang.Long> getStartupTimestamps();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.ApplicationStartInfo> CREATOR;
    field public static final int LAUNCH_MODE_SINGLE_INSTANCE = 2; // 0x2
    field public static final int LAUNCH_MODE_SINGLE_INSTANCE_PER_TASK = 4; // 0x4
    field public static final int LAUNCH_MODE_SINGLE_TASK = 3; // 0x3
    field public static final int LAUNCH_MODE_SINGLE_TOP = 1; // 0x1
    field public static final int LAUNCH_MODE_STANDARD = 0; // 0x0
    field public static final int STARTUP_STATE_ERROR = 1; // 0x1
    field public static final int STARTUP_STATE_FIRST_FRAME_DRAWN = 2; // 0x2
    field public static final int STARTUP_STATE_STARTED = 0; // 0x0
    field public static final int START_REASON_ALARM = 0; // 0x0
    field public static final int START_REASON_BACKUP = 1; // 0x1
    field public static final int START_REASON_BOOT_COMPLETE = 2; // 0x2
    field public static final int START_REASON_BROADCAST = 3; // 0x3
    field public static final int START_REASON_CONTENT_PROVIDER = 4; // 0x4
    field public static final int START_REASON_JOB = 5; // 0x5
    field public static final int START_REASON_LAUNCHER = 6; // 0x6
    field public static final int START_REASON_OTHER = 7; // 0x7
    field public static final int START_REASON_PUSH = 8; // 0x8
    field public static final int START_REASON_RESUMED_ACTIVITY = 9; // 0x9
    field public static final int START_REASON_SERVICE = 10; // 0xa
    field public static final int START_REASON_START_ACTIVITY = 11; // 0xb
    field public static final int START_TIMESTAMP_APPLICATION_ONCREATE = 2; // 0x2
    field public static final int START_TIMESTAMP_BIND_APPLICATION = 3; // 0x3
    field public static final int START_TIMESTAMP_FIRST_FRAME = 4; // 0x4
    field public static final int START_TIMESTAMP_FULLY_DRAWN = 5; // 0x5
    field public static final int START_TIMESTAMP_JAVA_CLASSLOADING_COMPLETE = 1; // 0x1
    field public static final int START_TIMESTAMP_LAUNCH = 0; // 0x0
    field public static final int START_TYPE_COLD = 0; // 0x0
    field public static final int START_TYPE_HOT = 2; // 0x2
    field public static final int START_TYPE_WARM = 1; // 0x1
  }
  public final class AsyncNotedAppOp implements android.os.Parcelable {
    method public int describeContents();
    method @Nullable public String getAttributionTag();
+1 −0
Original line number Diff line number Diff line
@@ -525,6 +525,7 @@ package android.app {
    method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public void addOnUidImportanceListener(android.app.ActivityManager.OnUidImportanceListener, int);
    method @RequiresPermission(android.Manifest.permission.FORCE_STOP_PACKAGES) public void forceStopPackage(String);
    method @RequiresPermission(anyOf={"android.permission.INTERACT_ACROSS_USERS", "android.permission.INTERACT_ACROSS_USERS_FULL"}) public static int getCurrentUser();
    method @NonNull @RequiresPermission(android.Manifest.permission.DUMP) public java.util.List<android.app.ApplicationStartInfo> getExternalHistoricalProcessStartReasons(@NonNull String, @IntRange(from=0) int);
    method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public int getPackageImportance(String);
    method @NonNull public java.util.Collection<java.util.Locale> getSupportedLocales();
    method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public int getUidImportance(int);
+117 −0
Original line number Diff line number Diff line
@@ -3675,6 +3675,123 @@ public class ActivityManager {
        }
    }

    /**
     * Return a list of {@link ApplicationStartInfo} records containing the information about the
     * most recent app startups.
     *
     * <p class="note"> Note: System stores this historical information in a ring buffer and only
     * the most recent records will be returned. </p>
     *
     * @param maxNum      The maximum number of results to be returned; a value of 0
     *                    means to ignore this parameter and return all matching records. If fewer
     *                    records exist, all existing records will be returned.
     *
     * @return a list of {@link ApplicationStartInfo} records matching the criteria, sorted in
     *         the order from most recent to least recent.
     */
    @NonNull
    public List<ApplicationStartInfo> getHistoricalProcessStartReasons(
            @IntRange(from = 0) int maxNum) {
        try {
            ParceledListSlice<ApplicationStartInfo> startInfos = getService()
                    .getHistoricalProcessStartReasons(null, maxNum, mContext.getUserId());
            return startInfos == null ? Collections.emptyList() : startInfos.getList();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Return a list of {@link ApplicationStartInfo} records containing the information about the
     * most recent app startups.
     *
     * <p class="note"> Note: System stores this historical information in a ring buffer and only
     * the most recent records will be returned. </p>
     *
     * @param packageName Package name for which app startups to receive.
     * @param maxNum      The maximum number of results to be returned; a value of 0
     *                    means to ignore this parameter and return all matching records. If fewer
     *                    records exist, all existing records will be returned.
     *
     * @return a list of {@link ApplicationStartInfo} records matching the criteria, sorted in
     *         the order from most recent to least recent.
     *
     * @hide
     */
    @NonNull
    @SystemApi
    @RequiresPermission(Manifest.permission.DUMP)
    public List<ApplicationStartInfo> getExternalHistoricalProcessStartReasons(
            @NonNull String packageName, @IntRange(from = 0) int maxNum) {
        try {
            ParceledListSlice<ApplicationStartInfo> startInfos = getService()
                    .getHistoricalProcessStartReasons(packageName, maxNum, mContext.getUserId());
            return startInfos == null ? Collections.emptyList() : startInfos.getList();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Callback to receive {@link ApplicationStartInfo} object once recording of startup related
     * metrics is complete.
     * Use with {@link #setApplicationStartInfoCompleteListener}.
     */
    public interface ApplicationStartInfoCompleteListener {
        /** {@link ApplicationStartInfo} is complete, no more info will be added. */
        void onApplicationStartInfoComplete(@NonNull ApplicationStartInfo applicationStartInfo);
    }

    /**
     * Sets a callback to be notified when the {@link ApplicationStartInfo} records of this startup
     * are complete.
     *
     * <p class="note"> Note: callback will not wait for {@link Activity#reportFullyDrawn} to occur.
     * Timestamp for fully drawn may be added after callback occurs. Set callback after invoking
     * {@link Activity#reportFullyDrawn} if timestamp for fully drawn is required.</p>
     *
     * <p class="note"> Note: if start records have already been retrieved, the callback will be
     * invoked immediately on the specified executor with the previously resolved AppStartInfo.</p>
     *
     * <p class="note"> Note: callback is asynchronous and should be made from a background thread.
     * </p>
     *
     * @param executor    The executor on which the listener should be called.
     * @param listener    Callback to be called when collection of {@link ApplicationStartInfo} is
     *                    complete. Will replace existing listener if one is already attached.
     *
     * @throws IllegalArgumentException if executor or listener are null.
     */
    public void setApplicationStartInfoCompleteListener(@NonNull final Executor executor,
            @NonNull final ApplicationStartInfoCompleteListener listener) {
        Preconditions.checkNotNull(executor, "executor cannot be null");
        Preconditions.checkNotNull(listener, "listener cannot be null");
        IApplicationStartInfoCompleteListener callback =
                new IApplicationStartInfoCompleteListener.Stub() {
            @Override
            public void onApplicationStartInfoComplete(ApplicationStartInfo applicationStartInfo) {
                executor.execute(() ->
                        listener.onApplicationStartInfoComplete(applicationStartInfo));
            }
        };
        try {
            getService().setApplicationStartInfoCompleteListener(callback, mContext.getUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Removes the callback set by {@link #setApplicationStartInfoCompleteListener} if there is one.
     */
    public void removeApplicationStartInfoCompleteListener() {
        try {
            getService().removeApplicationStartInfoCompleteListener(mContext.getUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Return a list of {@link ApplicationExitInfo} records containing the reasons for the most
     * recent app deaths.
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.app;

parcelable ApplicationStartInfo;
+598 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading