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

Commit 4a9cddd4 authored by Jing Ji's avatar Jing Ji Committed by Android (Google) Code Review
Browse files

Merge changes from topic "app_kill_stats"

* changes:
  Add support to get historical app process exit reason
  Add support to send notification from Zygote to system_server
parents bf9c2890 8055a3a4
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -3977,6 +3977,7 @@ package android.app {
    method public android.util.Size getAppTaskThumbnailSize();
    method public java.util.List<android.app.ActivityManager.AppTask> getAppTasks();
    method public android.content.pm.ConfigurationInfo getDeviceConfigurationInfo();
    method @Nullable public java.util.List<android.app.ApplicationExitInfo> getHistoricalProcessExitReasons(@Nullable String, @IntRange(from=0) int, @IntRange(from=0) int);
    method public int getLargeMemoryClass();
    method public int getLauncherLargeIconDensity();
    method public int getLauncherLargeIconSize();
@@ -3994,6 +3995,7 @@ package android.app {
    method public boolean isActivityStartAllowedOnDisplay(@NonNull android.content.Context, int, @NonNull android.content.Intent);
    method public boolean isBackgroundRestricted();
    method @Deprecated public boolean isInLockTaskMode();
    method public static boolean isLowMemoryKillReportSupported();
    method public boolean isLowRamDevice();
    method @Deprecated public static boolean isRunningInTestHarness();
    method public static boolean isRunningInUserTestHarness();
@@ -4507,6 +4509,35 @@ package android.app {
    field public String serviceDetails;
  }
  public final class ApplicationExitInfo implements android.os.Parcelable {
    method public int describeContents();
    method public int getDefiningUid();
    method @Nullable public String getDescription();
    method public int getImportance();
    method public int getPackageUid();
    method public int getPid();
    method @NonNull public String getProcessName();
    method public int getPss();
    method public int getRealUid();
    method public int getReason();
    method public int getRss();
    method public int getStatus();
    method public long getTimestamp();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.ApplicationExitInfo> CREATOR;
    field public static final int REASON_ANR = 6; // 0x6
    field public static final int REASON_CRASH = 4; // 0x4
    field public static final int REASON_CRASH_NATIVE = 5; // 0x5
    field public static final int REASON_EXCESSIVE_RESOURCE_USAGE = 9; // 0x9
    field public static final int REASON_EXIT_SELF = 1; // 0x1
    field public static final int REASON_INITIALIZATION_FAILURE = 7; // 0x7
    field public static final int REASON_LOW_MEMORY = 3; // 0x3
    field public static final int REASON_OTHER = 10; // 0xa
    field public static final int REASON_PERMISSION_CHANGE = 8; // 0x8
    field public static final int REASON_SIGNALED = 2; // 0x2
    field public static final int REASON_UNKNOWN = 0; // 0x0
  }
  public final class AsyncNotedAppOp implements android.os.Parcelable {
    method public int describeContents();
    method @Nullable public String getFeatureId();
+4 −0
Original line number Diff line number Diff line
@@ -567,6 +567,10 @@ package android.app {
    field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.PackageOps> CREATOR;
  }
  public final class ApplicationExitInfo implements android.os.Parcelable {
    method @NonNull public android.os.UserHandle getUserHandle();
  }
  public class BroadcastOptions {
    method public static android.app.BroadcastOptions makeBasic();
    method @RequiresPermission("android.permission.START_ACTIVITIES_FROM_BACKGROUND") public void setBackgroundActivityStartsAllowed(boolean);
+45 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
import android.Manifest;
import android.annotation.DrawableRes;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
@@ -3479,6 +3480,50 @@ public class ActivityManager {
        }
    }

    /**
     * Return a list of {@link ApplicationExitInfo} records containing the reasons for the most
     * recent app deaths.
     *
     * <p class="note"> Note: System stores this historical information in a ring buffer and only
     * the most recent records will be returned. </p>
     *
     * <p class="note"> Note: In the case that this application was bound to an external service
     * with flag {@link android.content.Context#BIND_EXTERNAL_SERVICE}, the process of that external
     * service will be included in this package's exit info. </p>
     *
     * @param packageName Optional, a null value means match all packages belonging to the
     *                    caller's UID. If this package belongs to another UID, you must hold
     *                    {@link android.Manifest.permission#DUMP} in order to retrieve it.
     * @param pid         A process ID that used to belong to this package but died later; a value
     *                    of 0 means to ignore this parameter and return all matching records.
     * @param maxNum      The maximum number of results to be returned; a value of 0
     *                    means to ignore this parameter and return all matching records
     *
     * @return a list of {@link ApplicationExitInfo} records matching the criteria, sorted in
     *         the order from most recent to least recent.
     */
    @Nullable
    public List<ApplicationExitInfo> getHistoricalProcessExitReasons(@Nullable String packageName,
            @IntRange(from = 0) int pid, @IntRange(from = 0) int maxNum) {
        try {
            ParceledListSlice<ApplicationExitInfo> r = getService().getHistoricalProcessExitReasons(
                    packageName, pid, maxNum, mContext.getUserId());
            return r == null ? null : r.getList();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /*
     * @return Whether or not the low memory kill will be reported in
     * {@link #getHistoricalProcessExitReasons}.
     *
     * @see {@link ApplicationExitInfo#REASON_LOW_MEMORY}
     */
    public static boolean isLowMemoryKillReportSupported() {
        return SystemProperties.getBoolean("persist.sys.lmk.reportkills", false);
    }

    /**
     * Return the importance of a given package name, based on the processes that are
     * currently running.  The return value is one of the importance constants defined
+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 ApplicationExitInfo;
+901 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading