Class ShadowPowerManager

    • Constructor Detail

      • ShadowPowerManager

        public ShadowPowerManager()
    • Method Detail

      • turnScreenOn

        public void turnScreenOn​(boolean screenOn)
        Emulates turning the screen on/off if the screen is not already on/off.
      • setIsPowerSaveMode

        public void setIsPowerSaveMode​(boolean powerSaveMode)
      • isWakeLockLevelSupported

        protected boolean isWakeLockLevelSupported​(int level)
      • setIsWakeLockLevelSupported

        public void setIsWakeLockLevelSupported​(int level,
                                                boolean supported)
      • setIsDeviceIdleMode

        public void setIsDeviceIdleMode​(boolean isDeviceIdleMode)
        Sets the value returned by isDeviceIdleMode().
      • setIsLightDeviceIdleMode

        public void setIsLightDeviceIdleMode​(boolean lightDeviceIdleMode)
        Sets the value returned by isLightDeviceIdleMode().
      • getLocationPowerSaveMode

        protected int getLocationPowerSaveMode()
        Returns how location features should behave when battery saver is on. When battery saver is off, this will always return #LOCATION_MODE_NO_CHANGE.
      • setLocationPowerSaveMode

        public void setLocationPowerSaveMode​(int locationMode)
        Sets the value returned by getLocationPowerSaveMode() when battery saver is on.
      • getCurrentThermalStatus

        protected int getCurrentThermalStatus()
        This function returns the current thermal status of the device.
      • addThermalStatusListener

        protected void addThermalStatusListener​(Object listener)
        This function adds a listener for thermal status change.
      • getThermalStatusListeners

        public<Object> getThermalStatusListeners()
        This function gets listeners for thermal status change.
      • removeThermalStatusListener

        protected void removeThermalStatusListener​(Object listener)
        This function removes a listener for thermal status change.
      • setCurrentThermalStatus

        public void setCurrentThermalStatus​(int thermalStatus)
        Sets the value returned by getCurrentThermalStatus().
      • reset

        public static void reset()
        Discards the most recent PowerManager.WakeLocks
      • getLatestWakeLock

        public static PowerManager.WakeLock getLatestWakeLock()
        Retrieves the most recent wakelock registered by the application
        Most recent wake lock.
      • clearWakeLocks

        public static void clearWakeLocks()
        Clears most recent recorded wakelock.
      • setIgnoringBatteryOptimizations

        public void setIgnoringBatteryOptimizations​(String packageName,
                                                    boolean value)
      • setBatteryDischargePrediction

        protected void setBatteryDischargePrediction​(Duration timeRemaining,
                                                     boolean isPersonalized)
        Differs from real implementation as device charging state is not checked.
        timeRemaining - The time remaining as a Duration.
        isPersonalized - true if personalized based on device usage history, false otherwise.
      • isBatteryDischargePredictionPersonalized

        protected boolean isBatteryDischargePredictionPersonalized()
        Returns whether the current battery life remaining estimate is personalized based on device usage history or not. This value does not take a device's powered or charging state into account.
        A boolean indicating if the current discharge estimate is personalized based on historical device usage or not.
      • getTimesRebooted

        public int getTimesRebooted()
        Returns the number of times reboot(String) was called.
      • getRebootReasons

        public<String> getRebootReasons()
        Returns the list of reasons for each reboot, in chronological order.
      • setAmbientDisplayAvailable

        public void setAmbientDisplayAvailable​(boolean available)
        Sets the value returned by isAmbientDisplayAvailable().
      • setIsRebootingUserspaceSupported

        public void setIsRebootingUserspaceSupported​(boolean supported)
        Sets the value returned by isRebootingUserspaceSupported().
      • suppressAmbientDisplay

        protected void suppressAmbientDisplay​(String token,
                                              boolean suppress)
        If true, suppress the device's ambient display. Ambient display is defined as anything visible on the display when PowerManager.isInteractive() is false.
        token - An identifier for the ambient display suppression.
        suppress - If true, suppresses the ambient display. Otherwise, unsuppresses the ambient display for the given token.
      • setAdaptivePowerSaveEnabled

        protected boolean setAdaptivePowerSaveEnabled​(boolean enabled)
        Sets whether Adaptive Power Saver is enabled.

        This has no effect, other than the value of getAdaptivePowerSaveEnabled() is changed, which can be used to ensure this method is called correctly.

        true if the value has changed.