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

Commit f750b873 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Formalize DeviceIdle's exitIdle call."

parents 745eaa39 22d444e4
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package android.os;

import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.content.Context;
@@ -28,6 +30,7 @@ import android.content.Context;
 * @hide
 */
@TestApi
@SystemApi
@SystemService(Context.DEVICE_IDLE_CONTROLLER)
public class DeviceIdleManager {
    private final Context mContext;
@@ -45,10 +48,27 @@ public class DeviceIdleManager {
        return mService;
    }

    /**
     * Ends any active idle session.
     *
     * @param reason The reason to end. Used for debugging purposes.
     */
    @RequiresPermission(android.Manifest.permission.DEVICE_POWER)
    public void endIdle(@NonNull String reason) {
        try {
            mService.exitIdle(reason);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * @return package names the system has white-listed to opt out of power save restrictions,
     * except for device idle mode.
     *
     * @hide Should be migrated to PowerWhitelistManager
     */
    @TestApi
    public @NonNull String[] getSystemPowerWhitelistExceptIdle() {
        try {
            return mService.getSystemPowerWhitelistExceptIdle();
@@ -60,7 +80,10 @@ public class DeviceIdleManager {
    /**
     * @return package names the system has white-listed to opt out of power save restrictions for
     * all modes.
     *
     * @hide Should be migrated to PowerWhitelistManager
     */
    @TestApi
    public @NonNull String[] getSystemPowerWhitelist() {
        try {
            return mService.getSystemPowerWhitelist();
+4 −0
Original line number Diff line number Diff line
@@ -8121,6 +8121,10 @@ package android.os {
    field public static final String EXTRA_VERSION = "android.os.extra.VERSION";
  }
  public class DeviceIdleManager {
    method @RequiresPermission(android.Manifest.permission.DEVICE_POWER) public void endIdle(@NonNull String);
  }
  public class Environment {
    method @NonNull public static java.util.Collection<java.io.File> getInternalMediaDirectories();
    method @NonNull public static java.io.File getOdmDirectory();
+1 −0
Original line number Diff line number Diff line
@@ -2306,6 +2306,7 @@ package android.os {
  }

  public class DeviceIdleManager {
    method @RequiresPermission("android.permission.DEVICE_POWER") public void endIdle(@NonNull String);
    method @NonNull public String[] getSystemPowerWhitelist();
    method @NonNull public String[] getSystemPowerWhitelistExceptIdle();
  }
+5 −9
Original line number Diff line number Diff line
@@ -173,12 +173,12 @@ import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.DeviceIdleManager;
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.IDeviceIdleController;
import android.os.IInterface;
import android.os.Looper;
import android.os.Message;
@@ -414,7 +414,7 @@ public class NotificationManagerService extends SystemService {
    private AlarmManager mAlarmManager;
    private ICompanionDeviceManager mCompanionManager;
    private AccessibilityManager mAccessibilityManager;
    private IDeviceIdleController mDeviceIdleController;
    private DeviceIdleManager mDeviceIdleManager;
    private IUriGrantsManager mUgm;
    private UriGrantsManagerInternal mUgmInternal;
    private RoleObserver mRoleObserver;
@@ -1888,8 +1888,7 @@ public class NotificationManagerService extends SystemService {
        mAlarmManager = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE);
        mCompanionManager = companionManager;
        mActivityManager = activityManager;
        mDeviceIdleController = IDeviceIdleController.Stub.asInterface(
                ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER));
        mDeviceIdleManager = getContext().getSystemService(DeviceIdleManager.class);
        mDpm = dpm;
        mUm = userManager;
        mPlatformCompat = IPlatformCompat.Stub.asInterface(
@@ -2361,11 +2360,8 @@ public class NotificationManagerService extends SystemService {
    }

    private void exitIdle() {
        try {
            if (mDeviceIdleController != null) {
                mDeviceIdleController.exitIdle("notification interaction");
            }
        } catch (RemoteException e) {
        if (mDeviceIdleManager != null) {
            mDeviceIdleManager.endIdle("notification interaction");
        }
    }

+4 −8
Original line number Diff line number Diff line
@@ -129,10 +129,10 @@ import android.media.IAudioService;
import android.media.session.MediaSessionLegacyHelper;
import android.os.Binder;
import android.os.Bundle;
import android.os.DeviceIdleManager;
import android.os.FactoryTest;
import android.os.Handler;
import android.os.IBinder;
import android.os.IDeviceIdleController;
import android.os.Message;
import android.os.PowerManager;
import android.os.PowerManager.WakeReason;
@@ -4321,13 +4321,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if (!keyguardOn()) {
            voiceIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
        } else {
            IDeviceIdleController dic = IDeviceIdleController.Stub.asInterface(
                    ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER));
            if (dic != null) {
                try {
                    dic.exitIdle("voice-search");
                } catch (RemoteException e) {
                }
            DeviceIdleManager dim = mContext.getSystemService(DeviceIdleManager.class);
            if (dim != null) {
                dim.endIdle("voice-search");
            }
            voiceIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
            voiceIntent.putExtra(RecognizerIntent.EXTRA_SECURE, true);