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

Commit ca25b876 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Fixes to idle alarm scheduling, package importance."

parents a08c444d 1e38382b
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -3555,6 +3555,7 @@ package android.app {
    method public int getMemoryClass();
    method public void getMemoryInfo(android.app.ActivityManager.MemoryInfo);
    method public static void getMyMemoryState(android.app.ActivityManager.RunningAppProcessInfo);
    method public int getPackageImportance(java.lang.String);
    method public android.os.Debug.MemoryInfo[] getProcessMemoryInfo(int[]);
    method public java.util.List<android.app.ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState();
    method public deprecated java.util.List<android.app.ActivityManager.RecentTaskInfo> getRecentTasks(int, int) throws java.lang.SecurityException;
@@ -3647,9 +3648,11 @@ package android.app {
    field public static final int IMPORTANCE_BACKGROUND = 400; // 0x190
    field public static final int IMPORTANCE_EMPTY = 500; // 0x1f4
    field public static final int IMPORTANCE_FOREGROUND = 100; // 0x64
    field public static final int IMPORTANCE_FOREGROUND_SERVICE = 125; // 0x7d
    field public static final int IMPORTANCE_GONE = 1000; // 0x3e8
    field public static final int IMPORTANCE_PERCEPTIBLE = 130; // 0x82
    field public static final int IMPORTANCE_SERVICE = 300; // 0x12c
    field public static final int IMPORTANCE_TOP_SLEEPING = 150; // 0x96
    field public static final int IMPORTANCE_VISIBLE = 200; // 0xc8
    field public static final int REASON_PROVIDER_IN_USE = 1; // 0x1
    field public static final int REASON_SERVICE_IN_USE = 2; // 0x2
@@ -28677,7 +28680,7 @@ package android.service.voice {
    field public static final int START_WITH_SCREENSHOT = 2; // 0x2
  }
  public abstract class VoiceInteractionSession implements android.view.KeyEvent.Callback {
  public abstract class VoiceInteractionSession implements android.content.ComponentCallbacks2 android.view.KeyEvent.Callback {
    ctor public VoiceInteractionSession(android.content.Context);
    ctor public VoiceInteractionSession(android.content.Context, android.os.Handler);
    method public void finish();
@@ -28693,6 +28696,7 @@ package android.service.voice {
    method public abstract void onCommand(android.service.voice.VoiceInteractionSession.Caller, android.service.voice.VoiceInteractionSession.Request, java.lang.String, android.os.Bundle);
    method public void onCompleteVoice(android.service.voice.VoiceInteractionSession.Caller, android.service.voice.VoiceInteractionSession.Request, java.lang.CharSequence, android.os.Bundle);
    method public void onComputeInsets(android.service.voice.VoiceInteractionSession.Insets);
    method public void onConfigurationChanged(android.content.res.Configuration);
    method public abstract void onConfirm(android.service.voice.VoiceInteractionSession.Caller, android.service.voice.VoiceInteractionSession.Request, java.lang.CharSequence, android.os.Bundle);
    method public void onCreate(android.os.Bundle, int);
    method public android.view.View onCreateContentView();
@@ -28705,10 +28709,12 @@ package android.service.voice {
    method public boolean onKeyLongPress(int, android.view.KeyEvent);
    method public boolean onKeyMultiple(int, int, android.view.KeyEvent);
    method public boolean onKeyUp(int, android.view.KeyEvent);
    method public void onLowMemory();
    method public abstract void onPickOption(android.service.voice.VoiceInteractionSession.Caller, android.service.voice.VoiceInteractionSession.Request, java.lang.CharSequence, android.app.VoiceInteractor.PickOptionRequest.Option[], android.os.Bundle);
    method public void onShow(android.os.Bundle, int);
    method public void onTaskFinished(android.content.Intent, int);
    method public void onTaskStarted(android.content.Intent, int);
    method public void onTrimMemory(int);
    method public void setContentView(android.view.View);
    method public void setKeepAwake(boolean);
    method public void setTheme(int);
+7 −1
Original line number Diff line number Diff line
@@ -3644,6 +3644,7 @@ package android.app {
    method public int getMemoryClass();
    method public void getMemoryInfo(android.app.ActivityManager.MemoryInfo);
    method public static void getMyMemoryState(android.app.ActivityManager.RunningAppProcessInfo);
    method public int getPackageImportance(java.lang.String);
    method public android.os.Debug.MemoryInfo[] getProcessMemoryInfo(int[]);
    method public java.util.List<android.app.ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState();
    method public deprecated java.util.List<android.app.ActivityManager.RecentTaskInfo> getRecentTasks(int, int) throws java.lang.SecurityException;
@@ -3736,9 +3737,11 @@ package android.app {
    field public static final int IMPORTANCE_BACKGROUND = 400; // 0x190
    field public static final int IMPORTANCE_EMPTY = 500; // 0x1f4
    field public static final int IMPORTANCE_FOREGROUND = 100; // 0x64
    field public static final int IMPORTANCE_FOREGROUND_SERVICE = 125; // 0x7d
    field public static final int IMPORTANCE_GONE = 1000; // 0x3e8
    field public static final int IMPORTANCE_PERCEPTIBLE = 130; // 0x82
    field public static final int IMPORTANCE_SERVICE = 300; // 0x12c
    field public static final int IMPORTANCE_TOP_SLEEPING = 150; // 0x96
    field public static final int IMPORTANCE_VISIBLE = 200; // 0xc8
    field public static final int REASON_PROVIDER_IN_USE = 1; // 0x1
    field public static final int REASON_SERVICE_IN_USE = 2; // 0x2
@@ -30773,7 +30776,7 @@ package android.service.voice {
    field public static final int START_WITH_SCREENSHOT = 2; // 0x2
  }
  public abstract class VoiceInteractionSession implements android.view.KeyEvent.Callback {
  public abstract class VoiceInteractionSession implements android.content.ComponentCallbacks2 android.view.KeyEvent.Callback {
    ctor public VoiceInteractionSession(android.content.Context);
    ctor public VoiceInteractionSession(android.content.Context, android.os.Handler);
    method public void finish();
@@ -30789,6 +30792,7 @@ package android.service.voice {
    method public abstract void onCommand(android.service.voice.VoiceInteractionSession.Caller, android.service.voice.VoiceInteractionSession.Request, java.lang.String, android.os.Bundle);
    method public void onCompleteVoice(android.service.voice.VoiceInteractionSession.Caller, android.service.voice.VoiceInteractionSession.Request, java.lang.CharSequence, android.os.Bundle);
    method public void onComputeInsets(android.service.voice.VoiceInteractionSession.Insets);
    method public void onConfigurationChanged(android.content.res.Configuration);
    method public abstract void onConfirm(android.service.voice.VoiceInteractionSession.Caller, android.service.voice.VoiceInteractionSession.Request, java.lang.CharSequence, android.os.Bundle);
    method public void onCreate(android.os.Bundle, int);
    method public android.view.View onCreateContentView();
@@ -30801,10 +30805,12 @@ package android.service.voice {
    method public boolean onKeyLongPress(int, android.view.KeyEvent);
    method public boolean onKeyMultiple(int, int, android.view.KeyEvent);
    method public boolean onKeyUp(int, android.view.KeyEvent);
    method public void onLowMemory();
    method public abstract void onPickOption(android.service.voice.VoiceInteractionSession.Caller, android.service.voice.VoiceInteractionSession.Request, java.lang.CharSequence, android.app.VoiceInteractor.PickOptionRequest.Option[], android.os.Bundle);
    method public void onShow(android.os.Bundle, int);
    method public void onTaskFinished(android.content.Intent, int);
    method public void onTaskStarted(android.content.Intent, int);
    method public void onTrimMemory(int);
    method public void setContentView(android.view.View);
    method public void setKeepAwake(boolean);
    method public void setTheme(int);
+15 −0
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ public class Am extends BaseCommand {
                "       am restart\n" +
                "       am idle-maintenance\n" +
                "       am screen-compat [on|off] <PACKAGE>\n" +
                "       am package-importance <PACKAGE>\n" +
                "       am to-uri [INTENT]\n" +
                "       am to-intent-uri [INTENT]\n" +
                "       am to-app-uri [INTENT]\n" +
@@ -233,6 +234,8 @@ public class Am extends BaseCommand {
                "\n" +
                "am screen-compat: control screen compatibility mode of <PACKAGE>.\n" +
                "\n" +
                "am package-importance: print current importance of <PACKAGE>.\n" +
                "\n" +
                "am to-uri: print the given Intent specification as a URI.\n" +
                "\n" +
                "am to-intent-uri: print the given Intent specification as an intent: URI.\n" +
@@ -365,6 +368,8 @@ public class Am extends BaseCommand {
            runIdleMaintenance();
        } else if (op.equals("screen-compat")) {
            runScreenCompat();
        } else if (op.equals("package-importance")) {
            runPackageImportance();
        } else if (op.equals("to-uri")) {
            runToUri(0);
        } else if (op.equals("to-intent-uri")) {
@@ -1604,6 +1609,16 @@ public class Am extends BaseCommand {
        } while (packageName != null);
    }

    private void runPackageImportance() throws Exception {
        String packageName = nextArgRequired();
        try {
            int procState = mAm.getPackageProcessState(packageName);
            System.out.println(
                    ActivityManager.RunningAppProcessInfo.procStateToImportance(procState));
        } catch (RemoteException e) {
        }
    }

    private void runToUri(int flags) throws Exception {
        Intent intent = makeIntent(UserHandle.USER_CURRENT);
        System.out.println(intent.toUri(flags));
+69 −24
Original line number Diff line number Diff line
@@ -2010,27 +2010,47 @@ public class ActivityManager {
        public int lastTrimLevel;

        /**
         * Constant for {@link #importance}: this process is running the
         * foreground UI.
         * Constant for {@link #importance}: This process is running the
         * foreground UI; that is, it is the thing currently at the top of the screen
         * that the user is interacting with.
         */
        public static final int IMPORTANCE_FOREGROUND = 100;
        
        /**
         * Constant for {@link #importance}: this process is running something
         * Constant for {@link #importance}: This process is running a foreground
         * service, for example to perform music playback even while the user is
         * not immediately in the app.  This generally indicates that the process
         * is doing something the user actively cares about.
         */
        public static final int IMPORTANCE_FOREGROUND_SERVICE = 125;

        /**
         * Constant for {@link #importance}: This process is running the foreground
         * UI, but the device is asleep so it is not visible to the user.  This means
         * the user is not really aware of the process, because they can not see or
         * interact with it, but it is quite important because it what they expect to
         * return to once unlocking the device.
         */
        public static final int IMPORTANCE_TOP_SLEEPING = 150;

        /**
         * Constant for {@link #importance}: This process is running something
         * that is actively visible to the user, though not in the immediate
         * foreground.
         * foreground.  This may be running a window that is behind the current
         * foreground (so paused and with its state saved, not interacting with
         * the user, but visible to them to some degree); it may also be running
         * other services under the system's control that it inconsiders important.
         */
        public static final int IMPORTANCE_VISIBLE = 200;
        
        /**
         * Constant for {@link #importance}: this process is running something
         * that is considered to be actively perceptible to the user.  An
         * example would be an application performing background music playback.
         * Constant for {@link #importance}: This process is not something the user
         * is directly aware of, but is otherwise perceptable to them to some degree.
         */
        public static final int IMPORTANCE_PERCEPTIBLE = 130;
        
        /**
         * Constant for {@link #importance}: this process is running an
         * Constant for {@link #importance}: This process is running an
         * application that can not save its state, and thus can't be killed
         * while in the background.
         * @hide
@@ -2038,42 +2058,51 @@ public class ActivityManager {
        public static final int IMPORTANCE_CANT_SAVE_STATE = 170;
        
        /**
         * Constant for {@link #importance}: this process is contains services
         * that should remain running.
         * Constant for {@link #importance}: This process is contains services
         * that should remain running.  These are background services apps have
         * started, not something the user is aware of, so they may be killed by
         * the system relatively freely (though it is generally desired that they
         * stay running as long as they want to).
         */
        public static final int IMPORTANCE_SERVICE = 300;
        
        /**
         * Constant for {@link #importance}: this process process contains
         * Constant for {@link #importance}: This process process contains
         * background code that is expendable.
         */
        public static final int IMPORTANCE_BACKGROUND = 400;
        
        /**
         * Constant for {@link #importance}: this process is empty of any
         * Constant for {@link #importance}: This process is empty of any
         * actively running code.
         */
        public static final int IMPORTANCE_EMPTY = 500;

        /**
         * Constant for {@link #importance}: this process does not exist.
         * Constant for {@link #importance}: This process does not exist.
         */
        public static final int IMPORTANCE_GONE = 1000;

        /** @hide */
        public static int procStateToImportance(int procState) {
            if (procState >= ActivityManager.PROCESS_STATE_HOME) {
                return ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
            } else if (procState >= ActivityManager.PROCESS_STATE_SERVICE) {
                return ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE;
            } else if (procState > ActivityManager.PROCESS_STATE_HEAVY_WEIGHT) {
                return ActivityManager.RunningAppProcessInfo.IMPORTANCE_CANT_SAVE_STATE;
            } else if (procState >= ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND) {
                return ActivityManager.RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE;
            } else if (procState >= ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE) {
                return ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE;
            if (procState == PROCESS_STATE_NONEXISTENT) {
                return IMPORTANCE_GONE;
            } else if (procState >= PROCESS_STATE_HOME) {
                return IMPORTANCE_BACKGROUND;
            } else if (procState >= PROCESS_STATE_SERVICE) {
                return IMPORTANCE_SERVICE;
            } else if (procState > PROCESS_STATE_HEAVY_WEIGHT) {
                return IMPORTANCE_CANT_SAVE_STATE;
            } else if (procState >= PROCESS_STATE_IMPORTANT_BACKGROUND) {
                return IMPORTANCE_PERCEPTIBLE;
            } else if (procState >= PROCESS_STATE_IMPORTANT_FOREGROUND) {
                return IMPORTANCE_VISIBLE;
            } else if (procState >= PROCESS_STATE_TOP_SLEEPING) {
                return IMPORTANCE_TOP_SLEEPING;
            } else if (procState >= PROCESS_STATE_FOREGROUND_SERVICE) {
                return IMPORTANCE_FOREGROUND_SERVICE;
            } else {
                return ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
                return IMPORTANCE_FOREGROUND;
            }
        }

@@ -2252,6 +2281,22 @@ public class ActivityManager {
        }
    }

    /**
     * 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
     * in {@link RunningAppProcessInfo}, giving you the highest importance of all the
     * processes that this package has code running inside of.  If there are no processes
     * running its code, {@link RunningAppProcessInfo#IMPORTANCE_GONE} is returned.
     */
    public int getPackageImportance(String packageName) {
        try {
            int procState = ActivityManagerNative.getDefault().getPackageProcessState(packageName);
            return RunningAppProcessInfo.procStateToImportance(procState);
        } catch (RemoteException e) {
            return RunningAppProcessInfo.IMPORTANCE_GONE;
        }
    }

    /**
     * Return global memory state information for the calling process.  This
     * does not fill in all fields of the {@link RunningAppProcessInfo}.  The
+97 −18

File changed.

Preview size limit exceeded, changes collapsed.

Loading