use of android.hardware.display.DisplayManager in project android_frameworks_base by crdroidandroid.
the class MediaProjection method createVirtualDisplay.
/**
* @hide
*/
public VirtualDisplay createVirtualDisplay(@NonNull String name, int width, int height, int dpi, boolean isSecure, @Nullable Surface surface, @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler) {
DisplayManager dm = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE);
int flags = isSecure ? DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE : 0;
return dm.createVirtualDisplay(this, name, width, height, dpi, surface, flags | DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR | DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION, callback, handler);
}
use of android.hardware.display.DisplayManager in project android_packages_apps_Dialer by LineageOS.
the class CallCardPresenter method sendAccessibilityEvent.
static boolean sendAccessibilityEvent(Context context, InCallScreen inCallScreen) {
AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
if (!am.isEnabled()) {
LogUtil.w("CallCardPresenter.sendAccessibilityEvent", "accessibility is off");
return false;
}
if (inCallScreen == null) {
LogUtil.w("CallCardPresenter.sendAccessibilityEvent", "incallscreen is null");
return false;
}
Fragment fragment = inCallScreen.getInCallScreenFragment();
if (fragment == null || fragment.getView() == null || fragment.getView().getParent() == null) {
LogUtil.w("CallCardPresenter.sendAccessibilityEvent", "fragment/view/parent is null");
return false;
}
DisplayManager displayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
boolean screenIsOn = display.getState() == Display.STATE_ON;
LogUtil.d("CallCardPresenter.sendAccessibilityEvent", "screen is on: %b", screenIsOn);
if (!screenIsOn) {
return false;
}
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_ANNOUNCEMENT);
inCallScreen.dispatchPopulateAccessibilityEvent(event);
View view = inCallScreen.getInCallScreenFragment().getView();
view.getParent().requestSendAccessibilityEvent(view, event);
return true;
}
use of android.hardware.display.DisplayManager in project grafika by google.
the class ScreenRecordActivity method startRecording.
@RequiresApi(api = Build.VERSION_CODES.M)
private void startRecording() {
DisplayManager dm = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
Display defaultDisplay;
if (dm != null) {
defaultDisplay = dm.getDisplay(Display.DEFAULT_DISPLAY);
} else {
throw new IllegalStateException("Cannot display manager?!?");
}
if (defaultDisplay == null) {
throw new RuntimeException("No display found.");
}
// Get the display size and density.
DisplayMetrics metrics = getResources().getDisplayMetrics();
int screenWidth = metrics.widthPixels;
int screenHeight = metrics.heightPixels;
int screenDensity = metrics.densityDpi;
prepareVideoEncoder(screenWidth, screenHeight);
try {
File outputFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/grafika", "Screen-record-" + Long.toHexString(System.currentTimeMillis()) + ".mp4");
if (!outputFile.getParentFile().exists()) {
outputFile.getParentFile().mkdirs();
}
muxer = new MediaMuxer(outputFile.getCanonicalPath(), MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
} catch (IOException ioe) {
throw new RuntimeException("MediaMuxer creation failed", ioe);
}
// Start the video input.
mediaProjection.createVirtualDisplay("Recording Display", screenWidth, screenHeight, screenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, /* flags */
inputSurface, null, /* callback */
null);
}
use of android.hardware.display.DisplayManager in project robolectric by robolectric.
the class BootstrapTest method shouldSetUpRealisticDisplay.
@Test
@Config(qualifiers = "w480dp-h640dp")
public void shouldSetUpRealisticDisplay() 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(480);
assertThat(displayInfo.appHeight).isEqualTo(640);
assertThat(displayInfo.smallestNominalAppWidth).isEqualTo(480);
assertThat(displayInfo.smallestNominalAppHeight).isEqualTo(480);
assertThat(displayInfo.largestNominalAppWidth).isEqualTo(640);
assertThat(displayInfo.largestNominalAppHeight).isEqualTo(640);
assertThat(displayInfo.logicalWidth).isEqualTo(480);
assertThat(displayInfo.logicalHeight).isEqualTo(640);
assertThat(displayInfo.rotation).isEqualTo(ROTATION_0);
assertThat(displayInfo.logicalDensityDpi).isEqualTo(160);
assertThat(displayInfo.physicalXDpi).isEqualTo(160f);
assertThat(displayInfo.physicalYDpi).isEqualTo(160f);
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(480);
assertThat(displayMetrics.heightPixels).isEqualTo(640);
}
use of android.hardware.display.DisplayManager in project Signal-Android by WhisperSystems.
the class SignalCameraView method onAttachedToWindow.
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
DisplayManager dpyMgr = (DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE);
dpyMgr.registerDisplayListener(mDisplayListener, new Handler(Looper.getMainLooper()));
}
Aggregations