Class ShadowDisplayManager


  • @Implements(value=android.hardware.display.DisplayManager.class,
                minSdk=17,
                looseSignatures=true)
    public class ShadowDisplayManager
    extends java.lang.Object
    For tests, display properties may be changed and devices may be added or removed programmatically.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void __constructor__​(android.content.Context context)  
      static int addDisplay​(java.lang.String qualifiersStr)
      Adds a simulated display and drain the main looper queue to ensure all the callbacks are processed.
      static void changeDisplay​(int displayId, java.lang.String qualifiersStr)
      Changes properties of a simulated display.
      static void configureDefaultDisplay​(android.content.res.Configuration configuration, android.util.DisplayMetrics displayMetrics)
      internal only
      float getSaturationLevel()
      Returns the current display saturation level set via DisplayManager.setSaturationLevel(float).
      static void removeDisplay​(int displayId)
      Removes a simulated display and idles the main looper to ensure all listeners are notified.
      protected void setBrightnessConfiguration​(java.lang.Object config)  
      protected void setBrightnessConfigurationForUser​(java.lang.Object config, int userId, java.lang.String packageName)  
      static void setBrightnessEvents​(java.util.List<android.hardware.display.BrightnessChangeEvent> events)
      Set the slider events the system has seen.
      static void setDefaultBrightnessConfiguration​(java.lang.Object config)
      Set the default brightness configuration for this device.
      void setSaturationLevel​(float level)
      Sets the current display saturation level.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShadowDisplayManager

        public ShadowDisplayManager()
    • Method Detail

      • __constructor__

        @Implementation
        protected void __constructor__​(android.content.Context context)
      • addDisplay

        public static int addDisplay​(java.lang.String qualifiersStr)
        Adds a simulated display and drain the main looper queue to ensure all the callbacks are processed.
        Parameters:
        qualifiersStr - the Qualifiers string representing characteristics of the new display.
        Returns:
        the new display's ID
      • configureDefaultDisplay

        public static void configureDefaultDisplay​(android.content.res.Configuration configuration,
                                                   android.util.DisplayMetrics displayMetrics)
        internal only
      • changeDisplay

        public static void changeDisplay​(int displayId,
                                         java.lang.String qualifiersStr)
        Changes properties of a simulated display. If {@param qualifiersStr} starts with a plus ('+') sign, the display's previous configuration is modified with the given qualifiers; otherwise defaults are applied as described here.

        Idles the main looper to ensure all listeners are notified.

        Parameters:
        displayId - the display id to change
        qualifiersStr - the Qualifiers string representing characteristics of the new display
      • removeDisplay

        public static void removeDisplay​(int displayId)
        Removes a simulated display and idles the main looper to ensure all listeners are notified.
        Parameters:
        displayId - the display id to remove
      • getSaturationLevel

        public float getSaturationLevel()
        Returns the current display saturation level set via DisplayManager.setSaturationLevel(float).
      • setSaturationLevel

        public void setSaturationLevel​(float level)
        Sets the current display saturation level. This is a workaround for tests which cannot use the relevant hidden SystemApi, DisplayManager.setSaturationLevel(float).
      • setBrightnessConfiguration

        @Implementation(minSdk=28)
        @HiddenApi
        protected void setBrightnessConfiguration​(java.lang.Object config)
      • setBrightnessConfigurationForUser

        @Implementation(minSdk=28)
        @HiddenApi
        protected void setBrightnessConfigurationForUser​(java.lang.Object config,
                                                         int userId,
                                                         java.lang.String packageName)
      • setDefaultBrightnessConfiguration

        public static void setDefaultBrightnessConfiguration​(java.lang.Object config)
        Set the default brightness configuration for this device.
      • setBrightnessEvents

        public static void setBrightnessEvents​(java.util.List<android.hardware.display.BrightnessChangeEvent> events)
        Set the slider events the system has seen.