Search in sources :

Example 21 with DisplayManager

use of android.hardware.display.DisplayManager in project Signal-Android by WhisperSystems.

the class SignalCameraView method onDetachedFromWindow.

@Override
protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
    DisplayManager dpyMgr = (DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE);
    dpyMgr.unregisterDisplayListener(mDisplayListener);
}
Also used : DisplayManager(android.hardware.display.DisplayManager)

Example 22 with DisplayManager

use of android.hardware.display.DisplayManager in project robolectric by robolectric.

the class BootstrapTest method shouldSetUpRealisticDisplay_landscapeHighDensity.

@Test
@Config(qualifiers = "w480dp-h640dp-land-hdpi")
public void shouldSetUpRealisticDisplay_landscapeHighDensity() throws Exception {
    if (Build.VERSION.SDK_INT > JELLY_BEAN) {
        DisplayManager displayManager = (DisplayManager) ApplicationProvider.getApplicationContext().getSystemService(Context.DISPLAY_SERVICE);
        DisplayInfo displayInfo = new DisplayInfo();
        Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
        display.getDisplayInfo(displayInfo);
        assertThat(displayInfo.name).isEqualTo("Built-in screen");
        assertThat(displayInfo.appWidth).isEqualTo(960);
        assertThat(displayInfo.appHeight).isEqualTo(720);
        assertThat(displayInfo.smallestNominalAppWidth).isEqualTo(720);
        assertThat(displayInfo.smallestNominalAppHeight).isEqualTo(720);
        assertThat(displayInfo.largestNominalAppWidth).isEqualTo(960);
        assertThat(displayInfo.largestNominalAppHeight).isEqualTo(960);
        assertThat(displayInfo.logicalWidth).isEqualTo(960);
        assertThat(displayInfo.logicalHeight).isEqualTo(720);
        assertThat(displayInfo.rotation).isEqualTo(ROTATION_90);
        assertThat(displayInfo.logicalDensityDpi).isEqualTo(240);
        assertThat(displayInfo.physicalXDpi).isEqualTo(240f);
        assertThat(displayInfo.physicalYDpi).isEqualTo(240f);
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
            assertThat(displayInfo.state).isEqualTo(Display.STATE_ON);
        }
    }
    DisplayMetrics displayMetrics = ApplicationProvider.getApplicationContext().getResources().getDisplayMetrics();
    assertThat(displayMetrics.widthPixels).isEqualTo(960);
    assertThat(displayMetrics.heightPixels).isEqualTo(720);
}
Also used : DisplayInfo(android.view.DisplayInfo) DisplayManager(android.hardware.display.DisplayManager) DisplayMetrics(android.util.DisplayMetrics) Display(android.view.Display) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 23 with DisplayManager

use of android.hardware.display.DisplayManager in project actor-platform by actorapp.

the class AndroidMessenger method isScreenOn.

private boolean isScreenOn() {
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
        boolean screenOn = false;
        for (Display display : dm.getDisplays()) {
            if (display.getState() != Display.STATE_OFF) {
                screenOn = true;
            }
        }
        return screenOn;
    } else {
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        // noinspection deprecation
        return pm.isScreenOn();
    }
}
Also used : PowerManager(android.os.PowerManager) DisplayManager(android.hardware.display.DisplayManager) Display(android.view.Display)

Aggregations

DisplayManager (android.hardware.display.DisplayManager)23 Display (android.view.Display)13 DisplayInfo (android.view.DisplayInfo)7 DisplayMetrics (android.util.DisplayMetrics)4 Test (org.junit.Test)2 Config (org.robolectric.annotation.Config)2 SuppressLint (android.annotation.SuppressLint)1 Point (android.graphics.Point)1 MediaMuxer (android.media.MediaMuxer)1 Handler (android.os.Handler)1 PowerManager (android.os.PowerManager)1 RequiresApi (android.support.annotation.RequiresApi)1 Fragment (android.support.v4.app.Fragment)1 View (android.view.View)1 WindowManager (android.view.WindowManager)1 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)1 AccessibilityManager (android.view.accessibility.AccessibilityManager)1 Nullable (androidx.annotation.Nullable)1 File (java.io.File)1 IOException (java.io.IOException)1