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);
}
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);
}
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();
}
}
Aggregations