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

Commit b0dea6b1 authored by Kunal Malhotra's avatar Kunal Malhotra Committed by Android (Google) Code Review
Browse files

Merge "FGS Metrics Logging Improvements" into udc-dev

parents c3428ddc b9cb0ee7
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ package android {
    field public static final String LOCAL_MAC_ADDRESS = "android.permission.LOCAL_MAC_ADDRESS";
    field public static final String LOCATION_BYPASS = "android.permission.LOCATION_BYPASS";
    field public static final String LOCK_DEVICE = "android.permission.LOCK_DEVICE";
    field public static final String LOG_PROCESS_ACTIVITIES = "android.permission.LOG_PROCESS_ACTIVITIES";
    field public static final String LOG_FOREGROUND_RESOURCE_USE = "android.permission.LOG_FOREGROUND_RESOURCE_USE";
    field public static final String LOOP_RADIO = "android.permission.LOOP_RADIO";
    field public static final String MANAGE_ACCESSIBILITY = "android.permission.MANAGE_ACCESSIBILITY";
    field @Deprecated public static final String MANAGE_ACTIVITY_STACKS = "android.permission.MANAGE_ACTIVITY_STACKS";
@@ -538,15 +538,15 @@ package android.app {
    method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public int getUidImportance(int);
    method @RequiresPermission(android.Manifest.permission.FORCE_STOP_PACKAGES) public void killProcessesWhenImperceptible(@NonNull int[], @NonNull String);
    method @RequiresPermission(android.Manifest.permission.KILL_UID) public void killUid(int, String);
    method @RequiresPermission(android.Manifest.permission.LOG_PROCESS_ACTIVITIES) public void noteForegroundResourceUse(int, int, int, int);
    method @RequiresPermission(android.Manifest.permission.LOG_FOREGROUND_RESOURCE_USE) public void noteForegroundResourceUseBegin(int, int, int) throws java.lang.SecurityException;
    method @RequiresPermission(android.Manifest.permission.LOG_FOREGROUND_RESOURCE_USE) public void noteForegroundResourceUseEnd(int, int, int) throws java.lang.SecurityException;
    method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public void removeOnUidImportanceListener(android.app.ActivityManager.OnUidImportanceListener);
    method public void setDeviceLocales(@NonNull android.os.LocaleList);
    method @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS) public static void setPersistentVrThread(int);
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}) public boolean startProfile(@NonNull android.os.UserHandle);
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}) public boolean stopProfile(@NonNull android.os.UserHandle);
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public boolean switchUser(@NonNull android.os.UserHandle);
    field public static final int FOREGROUND_SERVICE_API_EVENT_BEGIN = 1; // 0x1
    field public static final int FOREGROUND_SERVICE_API_EVENT_END = 2; // 0x2
    field public static final int FOREGROUND_SERVICE_API_TYPE_AUDIO = 5; // 0x5
    field public static final int FOREGROUND_SERVICE_API_TYPE_BLUETOOTH = 2; // 0x2
    field public static final int FOREGROUND_SERVICE_API_TYPE_CAMERA = 1; // 0x1
    field public static final int FOREGROUND_SERVICE_API_TYPE_CDM = 9; // 0x9
+25 −17
Original line number Diff line number Diff line
@@ -666,6 +666,7 @@ public class ActivityManager {
     * Used to log FGS API events from Audio API
     * @hide
     */
    @SystemApi
    public static final int FOREGROUND_SERVICE_API_TYPE_AUDIO = 5;
    /**
     * Used to log FGS API events from microphone API
@@ -715,13 +716,11 @@ public class ActivityManager {
     * Used to log a start event for an FGS API
     * @hide
     */
    @SystemApi
    public static final int FOREGROUND_SERVICE_API_EVENT_BEGIN = 1;
    /**
     * Used to log a stop event for an FGS API
     * @hide
     */
    @SystemApi
    public static final int FOREGROUND_SERVICE_API_EVENT_END = 2;
    /**
     * Constants used to denote API state
@@ -5617,23 +5616,32 @@ public class ActivityManager {
     *
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.LOG_PROCESS_ACTIVITIES)
    public void noteForegroundResourceUse(@ForegroundServiceApiType int apiType,
            @ForegroundServiceApiEvent int apiEvent, int uid, int pid) {
    @RequiresPermission(android.Manifest.permission.LOG_FOREGROUND_RESOURCE_USE)
    public void noteForegroundResourceUseBegin(@ForegroundServiceApiType int apiType,
            int uid, int pid) throws SecurityException {
        try {
            switch (apiEvent) {
                case FOREGROUND_SERVICE_API_EVENT_BEGIN:
            getService().logFgsApiBegin(apiType, uid, pid);
                    break;
                case FOREGROUND_SERVICE_API_EVENT_END:
                    getService().logFgsApiEnd(apiType, uid, pid);
                    break;
                default:
                    throw new IllegalArgumentException("Argument of "
                            + apiType + " not supported for foreground resource use logging");
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Internal method for logging API end. Used with
     * FGS metrics logging. Is called by APIs that are
     * used with FGS to log an API event (eg when
     * the camera starts).
     * @hide
     *
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.LOG_FOREGROUND_RESOURCE_USE)
    public void noteForegroundResourceUseEnd(@ForegroundServiceApiType int apiType,
            int uid, int pid) throws SecurityException {
        try {
            getService().logFgsApiEnd(apiType, uid, pid);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
    }

+3 −3
Original line number Diff line number Diff line
@@ -870,11 +870,11 @@ interface IActivityManager {
    boolean shouldServiceTimeOut(in ComponentName className, in IBinder token);

    /** Logs start of an API call to associate with an FGS, used for FGS Type Metrics */
    oneway void logFgsApiBegin(int apiType, int appUid, int appPid);
    void logFgsApiBegin(int apiType, int appUid, int appPid);

    /** Logs stop of an API call to associate with an FGS, used for FGS Type Metrics */
    oneway void logFgsApiEnd(int apiType, int appUid, int appPid);
    void logFgsApiEnd(int apiType, int appUid, int appPid);

    /** Logs API state change to associate with an FGS, used for FGS Type Metrics */
    oneway void logFgsApiStateChanged(int apiType, int state, int appUid, int appPid);
    void logFgsApiStateChanged(int apiType, int state, int appUid, int appPid);
}
+2 −2
Original line number Diff line number Diff line
@@ -7620,8 +7620,8 @@

    <!-- @SystemApi Allows to call APIs that log process lifecycle events
         @hide -->
    <permission android:name="android.permission.LOG_PROCESS_ACTIVITIES"
                android:protectionLevel="signature|privileged" />
    <permission android:name="android.permission.LOG_FOREGROUND_RESOURCE_USE"
                android:protectionLevel="signature|module" />

    <!-- @hide Allows an application to get type of any provider uri.
         <p>Not for use by third-party applications.
+2 −0
Original line number Diff line number Diff line
@@ -511,6 +511,8 @@ applications that come with the platform
        <permission name="android.permission.WRITE_APN_SETTINGS"/>
        <!-- Permission required for GTS test - GtsStatsdHostTestCases -->
        <permission name="android.permission.READ_RESTRICTED_STATS"/>
        <!-- Permission required for CTS test -->
        <permission name="android.permission.LOG_FOREGROUND_RESOURCE_USE"/>
    </privapp-permissions>

    <privapp-permissions package="com.android.statementservice">
Loading