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

Commit c231a836 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "New Importance API for Rb" into main

parents b5402603 0162f2a1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ package android {
    field public static final String FORCE_STOP_PACKAGES = "android.permission.FORCE_STOP_PACKAGES";
    field public static final String GET_APP_METADATA = "android.permission.GET_APP_METADATA";
    field public static final String GET_APP_OPS_STATS = "android.permission.GET_APP_OPS_STATS";
    field @FlaggedApi("android.app.get_binding_uid_importance") public static final String GET_BINDING_UID_IMPORTANCE = "android.permission.GET_BINDING_UID_IMPORTANCE";
    field public static final String GET_HISTORICAL_APP_OPS_STATS = "android.permission.GET_HISTORICAL_APP_OPS_STATS";
    field public static final String GET_PROCESS_STATE_AND_OOM_SCORE = "android.permission.GET_PROCESS_STATE_AND_OOM_SCORE";
    field public static final String GET_RUNTIME_PERMISSIONS = "android.permission.GET_RUNTIME_PERMISSIONS";
@@ -543,6 +544,7 @@ package android.app {
  public class ActivityManager {
    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 @FlaggedApi("android.app.get_binding_uid_importance") @RequiresPermission(android.Manifest.permission.GET_BINDING_UID_IMPORTANCE) public int getBindingUidImportance(int);
    method @RequiresPermission(anyOf={"android.permission.INTERACT_ACROSS_USERS", "android.permission.INTERACT_ACROSS_USERS_FULL"}) public static int getCurrentUser();
    method @FlaggedApi("android.app.app_start_info") @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);
+27 −1
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ import android.os.PowerExemptionManager.ReasonCode;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
@@ -4268,6 +4267,33 @@ public class ActivityManager {
        }
    }

    /**
     * Same as {@link #getUidImportance(int)}, but it only works on UIDs that currently
     * have a service binding, or provider reference, to the calling UID, even if the target UID
     * belong to another android user or profile.
     *
     * <p>This will return {@link RunningAppProcessInfo#IMPORTANCE_GONE} on all other UIDs,
     * regardless of if they're valid or not.
     *
     * <p>Privileged system apps may prefer this API to {@link #getUidImportance(int)} to
     * avoid requesting the permission {@link Manifest.permission#PACKAGE_USAGE_STATS}, which
     * would allow access to APIs that return more senstive information.
     *
     * @hide
     */
    @FlaggedApi(Flags.FLAG_GET_BINDING_UID_IMPORTANCE)
    @SystemApi
    @RequiresPermission(Manifest.permission.GET_BINDING_UID_IMPORTANCE)
    public @RunningAppProcessInfo.Importance int getBindingUidImportance(int uid) {
        try {
            int procState = getService().getBindingUidProcessState(uid,
                    mContext.getOpPackageName());
            return RunningAppProcessInfo.procStateToImportanceForClient(procState, mContext);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Callback to get reports about changes to the importance of a uid.  Use with
     * {@link #addOnUidImportanceListener}.
+1 −0
Original line number Diff line number Diff line
@@ -949,4 +949,5 @@ interface IActivityManager {
     * @param err The binder transaction error
     */
    oneway void frozenBinderTransactionDetected(int debugPid, int code, int flags, int err);
    int getBindingUidProcessState(int uid, in String callingPackage);
}
+8 −1
Original line number Diff line number Diff line
@@ -6,3 +6,10 @@ flag {
     description: "Control collecting of ApplicationStartInfo records and APIs."
     bug: "247814855"
}

flag {
     namespace: "backstage_power"
     name: "get_binding_uid_importance"
     description: "API to get importance of UID that's binding to the caller"
     bug: "292533010"
}
+9 −0
Original line number Diff line number Diff line
@@ -7782,6 +7782,15 @@
    <permission android:name="android.permission.WRITE_FLAGS"
        android:protectionLevel="signature" />

    <!-- @hide @SystemApi
         @FlaggedApi("android.app.get_binding_uid_importance")
         Allows to get the importance of an UID that has a service
         binding to the app.
         <p>Protection level: signature|privileged
    -->
    <permission android:name="android.permission.GET_BINDING_UID_IMPORTANCE"
        android:protectionLevel="signature|privileged" />

    <!-- @hide Allows internal applications to manage displays.
        <p>This means intercept internal signals about displays being (dis-)connected
        and being able to enable or disable the external displays.
Loading