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

Commit b64c21ca authored by Makoto Onuki's avatar Makoto Onuki Committed by android-build-team Robot
Browse files

DO NOT MERGE Extreme battery saver experiment

PS1 is just a squashed cherry-picks of:
- https://googleplex-android-review.git.corp.google.com/#/c/platform/frameworks/base/+/2808591/
- https://googleplex-android-review.git.corp.google.com/#/c/platform/frameworks/base/+/2542212/

Test: Tested manually
Bug: 64976537
Change-Id: I99f93471e348bdd31ac08fbd91b27bab8c8e498b
(cherry picked from commit d8a9b29e12b4ef45e6d66fcc54038adfc6c8fdbf)
parent 00418a60
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -177,7 +177,7 @@ public abstract class ActivityManagerInternal {
    /**
    /**
     * Allow DeviceIdleController to tell us about what apps are whitelisted.
     * Allow DeviceIdleController to tell us about what apps are whitelisted.
     */
     */
    public abstract void setDeviceIdleWhitelist(int[] appids);
    public abstract void setDeviceIdleWhitelist(int[] userAppids, int[] allAppids);


    /**
    /**
     * Update information about which app IDs are on the temp whitelist.
     * Update information about which app IDs are on the temp whitelist.
+12 −2
Original line number Original line Diff line number Diff line
@@ -252,8 +252,10 @@ public class AppOpsManager {
    public static final int OP_INSTANT_APP_START_FOREGROUND = 68;
    public static final int OP_INSTANT_APP_START_FOREGROUND = 68;
    /** @hide Answer incoming phone calls */
    /** @hide Answer incoming phone calls */
    public static final int OP_ANSWER_PHONE_CALLS = 69;
    public static final int OP_ANSWER_PHONE_CALLS = 69;
    /** @hide Run jobs when in background */
    public static final int OP_RUN_ANY_IN_BACKGROUND = 70;
    /** @hide */
    /** @hide */
    public static final int _NUM_OP = 70;
    public static final int _NUM_OP = 71;


    /** Access to coarse location information. */
    /** Access to coarse location information. */
    public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
    public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
@@ -492,7 +494,8 @@ public class AppOpsManager {
            OP_REQUEST_INSTALL_PACKAGES,
            OP_REQUEST_INSTALL_PACKAGES,
            OP_PICTURE_IN_PICTURE,
            OP_PICTURE_IN_PICTURE,
            OP_INSTANT_APP_START_FOREGROUND,
            OP_INSTANT_APP_START_FOREGROUND,
            OP_ANSWER_PHONE_CALLS
            OP_ANSWER_PHONE_CALLS,
            OP_RUN_ANY_IN_BACKGROUND,
    };
    };


    /**
    /**
@@ -570,6 +573,7 @@ public class AppOpsManager {
            OPSTR_PICTURE_IN_PICTURE,
            OPSTR_PICTURE_IN_PICTURE,
            OPSTR_INSTANT_APP_START_FOREGROUND,
            OPSTR_INSTANT_APP_START_FOREGROUND,
            OPSTR_ANSWER_PHONE_CALLS,
            OPSTR_ANSWER_PHONE_CALLS,
            null, // OP_RUN_ANY_IN_BACKGROUND
    };
    };


    /**
    /**
@@ -647,6 +651,7 @@ public class AppOpsManager {
            "PICTURE_IN_PICTURE",
            "PICTURE_IN_PICTURE",
            "INSTANT_APP_START_FOREGROUND",
            "INSTANT_APP_START_FOREGROUND",
            "ANSWER_PHONE_CALLS",
            "ANSWER_PHONE_CALLS",
            "RUN_ANY_IN_BACKGROUND",
    };
    };


    /**
    /**
@@ -724,6 +729,7 @@ public class AppOpsManager {
            null, // no permission for entering picture-in-picture on hide
            null, // no permission for entering picture-in-picture on hide
            Manifest.permission.INSTANT_APP_FOREGROUND_SERVICE,
            Manifest.permission.INSTANT_APP_FOREGROUND_SERVICE,
            Manifest.permission.ANSWER_PHONE_CALLS,
            Manifest.permission.ANSWER_PHONE_CALLS,
            null, // no permission for OP_RUN_ANY_IN_BACKGROUND
    };
    };


    /**
    /**
@@ -802,6 +808,7 @@ public class AppOpsManager {
            null, // ENTER_PICTURE_IN_PICTURE_ON_HIDE
            null, // ENTER_PICTURE_IN_PICTURE_ON_HIDE
            null, // INSTANT_APP_START_FOREGROUND
            null, // INSTANT_APP_START_FOREGROUND
            null, // ANSWER_PHONE_CALLS
            null, // ANSWER_PHONE_CALLS
            null, // OP_RUN_ANY_IN_BACKGROUND
    };
    };


    /**
    /**
@@ -879,6 +886,7 @@ public class AppOpsManager {
            false, // ENTER_PICTURE_IN_PICTURE_ON_HIDE
            false, // ENTER_PICTURE_IN_PICTURE_ON_HIDE
            false, // INSTANT_APP_START_FOREGROUND
            false, // INSTANT_APP_START_FOREGROUND
            false, // ANSWER_PHONE_CALLS
            false, // ANSWER_PHONE_CALLS
            false, // OP_RUN_ANY_IN_BACKGROUND
    };
    };


    /**
    /**
@@ -955,6 +963,7 @@ public class AppOpsManager {
            AppOpsManager.MODE_ALLOWED,  // OP_PICTURE_IN_PICTURE
            AppOpsManager.MODE_ALLOWED,  // OP_PICTURE_IN_PICTURE
            AppOpsManager.MODE_DEFAULT,  // OP_INSTANT_APP_START_FOREGROUND
            AppOpsManager.MODE_DEFAULT,  // OP_INSTANT_APP_START_FOREGROUND
            AppOpsManager.MODE_ALLOWED, // ANSWER_PHONE_CALLS
            AppOpsManager.MODE_ALLOWED, // ANSWER_PHONE_CALLS
            AppOpsManager.MODE_ALLOWED,  // OP_RUN_ANY_IN_BACKGROUND
    };
    };


    /**
    /**
@@ -1035,6 +1044,7 @@ public class AppOpsManager {
            false, // OP_PICTURE_IN_PICTURE
            false, // OP_PICTURE_IN_PICTURE
            false,
            false,
            false, // ANSWER_PHONE_CALLS
            false, // ANSWER_PHONE_CALLS
            false, // OP_RUN_ANY_IN_BACKGROUND
    };
    };


    /**
    /**
+1 −0
Original line number Original line Diff line number Diff line
@@ -323,6 +323,7 @@ interface IActivityManager {
    int getLaunchedFromUid(in IBinder activityToken);
    int getLaunchedFromUid(in IBinder activityToken);
    void unstableProviderDied(in IBinder connection);
    void unstableProviderDied(in IBinder connection);
    boolean isIntentSenderAnActivity(in IIntentSender sender);
    boolean isIntentSenderAnActivity(in IIntentSender sender);
    boolean isIntentSenderAForegroundService(in IIntentSender sender);
    int startActivityAsUser(in IApplicationThread caller, in String callingPackage,
    int startActivityAsUser(in IApplicationThread caller, in String callingPackage,
            in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
            in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
            int requestCode, int flags, in ProfilerInfo profilerInfo,
            int requestCode, int flags, in ProfilerInfo profilerInfo,
+16 −4
Original line number Original line Diff line number Diff line
@@ -20,18 +20,17 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.IIntentReceiver;
import android.content.IIntentReceiver;
import android.content.IIntentSender;
import android.content.IIntentSender;
import android.content.Intent;
import android.content.IntentSender;
import android.content.IntentSender;
import android.os.Bundle;
import android.os.Bundle;
import android.os.Looper;
import android.os.RemoteException;
import android.os.Handler;
import android.os.Handler;
import android.os.IBinder;
import android.os.IBinder;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserHandle;
import android.util.AndroidException;
import android.util.AndroidException;


@@ -1010,6 +1009,19 @@ public final class PendingIntent implements Parcelable {
        }
        }
    }
    }


    /**
     * @hide
     * Check whether this PendingIntent will launch a foreground service
     */
    public boolean isForegroundService() {
        try {
            return ActivityManager.getService()
                    .isIntentSenderAForegroundService(mTarget);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
    /**
     * @hide
     * @hide
     * Return the Intent of this PendingIntent.
     * Return the Intent of this PendingIntent.
+11 −0
Original line number Original line Diff line number Diff line
@@ -71,6 +71,7 @@ import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.ArraySet;
import android.util.Log;
import android.util.Log;
import android.util.MemoryIntArray;
import android.util.MemoryIntArray;
import android.util.Slog;


import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.ArrayUtils;
@@ -1847,6 +1848,13 @@ public final class Settings {
                if (makeDefault) {
                if (makeDefault) {
                    arg.putBoolean(CALL_METHOD_MAKE_DEFAULT_KEY, true);
                    arg.putBoolean(CALL_METHOD_MAKE_DEFAULT_KEY, true);
                }
                }

                // Log all EBS relevant config changes.
                if (Global.LOW_POWER_MODE_TRIGGER_LEVEL.equals(name)
                        || name.startsWith(Settings.Global.BATTERY_SAVER_CONSTANTS)) {
                    Slog.w("XXX", "Detected write: " + mCallSetCommand + ", " + name + ", args=" + arg, new RuntimeException("HERE"));
                }

                IContentProvider cp = mProviderHolder.getProvider(cr);
                IContentProvider cp = mProviderHolder.getProvider(cr);
                cp.call(cr.getPackageName(), mCallSetCommand, name, arg);
                cp.call(cr.getPackageName(), mCallSetCommand, name, arg);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
@@ -9347,6 +9355,9 @@ public final class Settings {
         */
         */
        public static final String BATTERY_SAVER_CONSTANTS = "battery_saver_constants";
        public static final String BATTERY_SAVER_CONSTANTS = "battery_saver_constants";


        /** @hide */
        public static final String BATTERY_SAVER_USE_RED_BAR = "battery_saver_use_red_bar";

        /**
        /**
         * Battery anomaly detection specific settings
         * Battery anomaly detection specific settings
         * This is encoded as a key=value list, separated by commas.
         * This is encoded as a key=value list, separated by commas.
Loading