Java Examples for android.hardware.display.DisplayManager
The following java examples will help you to understand the usage of android.hardware.display.DisplayManager. These source code samples are taken from different open source projects.
Example 1
| Project: miracast-widget-master File: MiracastWidgetProvider.java View source code |
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
final int length = appWidgetIds.length;
for (int i = 0; i < length; i++) {
int appWidgetId = appWidgetIds[i];
Intent intent = new Intent(context, MainActivity.class);
intent.putExtra(MainActivity.EXTRA_WIDGET_LAUNCH, true);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.miracast_widget);
views.setOnClickPendingIntent(R.id.widget_layout_parent, pendingIntent);
final DisplayManager displayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
Display[] displays = displayManager.getDisplays();
boolean displaySet = false;
int currentDisplay = -1;
for (int j = 0; j < displays.length; j++) {
Display display = displays[j];
if (display.getDisplayId() != Display.DEFAULT_DISPLAY) {
views.setTextViewText(R.id.widget_text, display.getName());
views.setTextColor(R.id.widget_text, context.getResources().getColor(android.R.color.holo_blue_bright));
currentDisplay = display.getDisplayId();
displaySet = true;
// Track this
MiracastApplication application = (MiracastApplication) context.getApplicationContext();
Tracker tracker = application.getDefaultTracker();
sendEventDisplayFound(tracker);
}
}
if (!displaySet) {
views.setTextViewText(R.id.widget_text, "Cast Screen");
views.setTextColor(R.id.widget_text, context.getResources().getColor(android.R.color.white));
}
MiracastDisplayListener displayListener = new MiracastDisplayListener(currentDisplay, views, displayManager, appWidgetManager, appWidgetId, context);
displayManager.registerDisplayListener(displayListener, null);
// Tell the AppWidgetManager to perform an update on the current app widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}Example 2
| Project: STFService.apk-master File: GetDisplayResponder.java View source code |
@Override
public GeneratedMessageLite respond(Wire.Envelope envelope) throws InvalidProtocolBufferException {
Wire.GetDisplayRequest request = Wire.GetDisplayRequest.parseFrom(envelope.getMessage());
if (Build.VERSION.SDK_INT >= 17) {
DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
Display display = dm.getDisplay(request.getId());
DisplayMetrics real = new DisplayMetrics();
display.getRealMetrics(real);
// DisplayMetrics is adjusted for rotation, so we have to swap it back if
// necessary.
int rotation = display.getRotation();
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
return Wire.Envelope.newBuilder().setId(envelope.getId()).setType(Wire.MessageType.GET_DISPLAY).setMessage(Wire.GetDisplayResponse.newBuilder().setSuccess(true).setWidth(real.heightPixels).setHeight(real.widthPixels).setXdpi(real.ydpi).setYdpi(real.xdpi).setFps(display.getRefreshRate()).setDensity(real.density).setRotation(rotationToDegrees(rotation)).setSecure((display.getFlags() & Display.FLAG_SECURE) == Display.FLAG_SECURE).build().toByteString()).build();
} else {
return Wire.Envelope.newBuilder().setId(envelope.getId()).setType(Wire.MessageType.GET_DISPLAY).setMessage(Wire.GetDisplayResponse.newBuilder().setSuccess(true).setWidth(real.widthPixels).setHeight(real.heightPixels).setXdpi(real.xdpi).setYdpi(real.ydpi).setFps(display.getRefreshRate()).setDensity(real.density).setRotation(rotationToDegrees(rotation)).setSecure((display.getFlags() & Display.FLAG_SECURE) == Display.FLAG_SECURE).build().toByteString()).build();
}
} else {
return Wire.Envelope.newBuilder().setId(envelope.getId()).setType(Wire.MessageType.GET_DISPLAY).setMessage(Wire.GetDisplayResponse.newBuilder().setSuccess(false).build().toByteString()).build();
}
}Example 3
| Project: cw-omnibus-master File: MainActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pager = (ViewPager) findViewById(R.id.pager);
adapter = new SlidesAdapter(this);
pager.setAdapter(adapter);
TabLayout tabs = (TabLayout) findViewById(R.id.tabs);
tabs.setupWithViewPager(pager);
tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
tabs.addOnTabSelectedListener(this);
if (iCanHazO()) {
dm = getSystemService(DisplayManager.class);
dm.registerDisplayListener(this, null);
checkForPresentationDisplays();
}
}Example 4
| Project: LEHomeMobile_android-master File: ComUtil.java View source code |
public static boolean isScreenOn(Context context) {
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();
}
}Example 5
| Project: ScreenRecoder-master File: ScreenRecoder.java View source code |
@Override
public void run() {
MediaFormat format = MediaFormat.createVideoFormat("video/avc", mWidth, mHeight);
format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
format.setInteger(MediaFormat.KEY_BIT_RATE, BIT_RATE);
format.setInteger(MediaFormat.KEY_FRAME_RATE, FRAME_RATE);
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, I_FRAME_INTERVAL);
MediaCodec codec = MediaCodec.createEncoderByType("video/avc");
codec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
Surface surface = codec.createInputSurface();
codec.start();
VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(DISPLAY_NAME, mWidth, mHeight, mDensityDpi, surface, DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC);
if (virtualDisplay != null) {
stream(codec);
virtualDisplay.release();
}
codec.signalEndOfInputStream();
codec.stop();
}Example 6
| Project: SopCastComponent-master File: ScreenVideoController.java View source code |
@Override
public void start() {
mEncoder = new ScreenRecordEncoder(mVideoConfiguration);
Surface surface = mEncoder.getSurface();
mEncoder.start();
mEncoder.setOnVideoEncodeListener(mListener);
mMediaProjection = mManager.getMediaProjection(resultCode, resultData);
int width = VideoMediaCodec.getVideoSize(mVideoConfiguration.width);
int height = VideoMediaCodec.getVideoSize(mVideoConfiguration.height);
mVirtualDisplay = mMediaProjection.createVirtualDisplay("ScreenRecoder", width, height, 1, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, surface, null, null);
}Example 7
| Project: AcDisplay-master File: PowerUtils.java View source code |
@SuppressLint("NewApi")
public static boolean isScreenOn(@NonNull Context context) {
display_api: if (Device.hasKitKatWatchApi()) {
DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
Display[] displays = dm.getDisplays(null);
Display display = null;
if (displays == null || displays.length == 0) {
break display_api;
} else if (displays.length > 1) {
Timber.tag(TAG).i("The number of logical displays is " + displays.length);
}
for (Display d : displays) {
final boolean virtual = Operator.bitAnd(d.getFlags(), Display.FLAG_PRESENTATION);
if (d.isValid() && !virtual) {
display = d;
final int type;
try {
Method method = Display.class.getDeclaredMethod("getType");
method.setAccessible(true);
type = (int) method.invoke(d);
} catch (Exception e) {
continue;
}
if (type == 1) /* built-in display */
{
break;
}
}
}
if (display == null) {
return false;
}
Timber.tag(TAG).i("Display state=" + display.getState());
return display.getState() == Display.STATE_ON;
}
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
return isInteractive(pm);
}Example 8
| Project: android-ScreenCapture-master File: ScreenCaptureFragment.java View source code |
private void setUpVirtualDisplay() {
Log.i(TAG, "Setting up a VirtualDisplay: " + mSurfaceView.getWidth() + "x" + mSurfaceView.getHeight() + " (" + mScreenDensity + ")");
mVirtualDisplay = mMediaProjection.createVirtualDisplay("ScreenCapture", mSurfaceView.getWidth(), mSurfaceView.getHeight(), mScreenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mSurface, null, null);
mButtonToggle.setText(R.string.stop);
}Example 9
| Project: android-sdk-sources-for-api-level-23-master File: MediaRouter.java View source code |
// Called after sStatic is initialized
void startMonitoringRoutes(Context appContext) {
mDefaultAudioVideo = new RouteInfo(mSystemCategory);
mDefaultAudioVideo.mNameResId = com.android.internal.R.string.default_audio_route_name;
mDefaultAudioVideo.mSupportedTypes = ROUTE_TYPE_LIVE_AUDIO | ROUTE_TYPE_LIVE_VIDEO;
mDefaultAudioVideo.updatePresentationDisplay();
addRouteStatic(mDefaultAudioVideo);
// This will select the active wifi display route if there is one.
updateWifiDisplayStatus(mDisplayService.getWifiDisplayStatus());
appContext.registerReceiver(new WifiDisplayStatusChangedReceiver(), new IntentFilter(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED));
appContext.registerReceiver(new VolumeChangeReceiver(), new IntentFilter(AudioManager.VOLUME_CHANGED_ACTION));
mDisplayService.registerDisplayListener(this, mHandler);
AudioRoutesInfo newAudioRoutes = null;
try {
newAudioRoutes = mAudioService.startWatchingRoutes(mAudioRoutesObserver);
} catch (RemoteException e) {
}
if (newAudioRoutes != null) {
// This will select the active BT route if there is one and the current
// selected route is the default system route, or if there is no selected
// route yet.
updateAudioRoutes(newAudioRoutes);
}
// Bind to the media router service.
rebindAsUser(UserHandle.myUserId());
// appropriately with relevant system state.
if (mSelectedRoute == null) {
selectDefaultRouteStatic();
}
}Example 10
| Project: android-support-v4-master File: MediaRouterJellybeanMr1.java View source code |
public void setActiveScanRouteTypes(int routeTypes) {
// enable active scanning on request.
if ((routeTypes & MediaRouterJellybean.ROUTE_TYPE_LIVE_VIDEO) != 0) {
if (!mActivelyScanningWifiDisplays) {
if (mScanWifiDisplaysMethod != null) {
mActivelyScanningWifiDisplays = true;
mHandler.post(this);
} else {
Log.w(TAG, "Cannot scan for wifi displays because the " + "DisplayManager.scanWifiDisplays() method is " + "not available on this device.");
}
}
} else {
if (mActivelyScanningWifiDisplays) {
mActivelyScanningWifiDisplays = false;
mHandler.removeCallbacks(this);
}
}
}Example 11
| Project: compass-project-master File: ScreenWidgetService.java View source code |
private void initViews() {
int sizePx = dpToPx(SIZE_DP);
windowManager = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE));
displayManager = ((DisplayManager) getApplicationContext().getSystemService(Context.DISPLAY_SERVICE));
displayManager.registerDisplayListener(displayListener, null);
updateRotation();
// init compass view
compassView = new CompassView(this);
compassView.setCompassEnabled(true);
compassView.setHasBackground(true);
compassView.setStrokeWidth(0);
compassView.setScaleLines(WIDGET_SCALE_LINES);
compassView.setLayoutParams(new LinearLayout.LayoutParams(sizePx, sizePx));
// init dragLayout & add compass view
dragLayout = new DragLayout(this);
dragLayout.addView(compassView);
dragLayout.setDragListener(this);
dragLayout.setInitialPosition(params.x, params.y);
dragLayout.setScale(-0.25f);
dragLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent activityIntent = new Intent(ScreenWidgetService.this, CompassActivity.class);
activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(activityIntent);
}
});
}Example 12
| Project: cwac-mediarouter-master File: MediaRouterJellybeanMr1.java View source code |
public void setActiveScanRouteTypes(int routeTypes) {
// enable active scanning on request.
if ((routeTypes & MediaRouterJellybean.ROUTE_TYPE_LIVE_VIDEO) != 0) {
if (!mActivelyScanningWifiDisplays) {
if (mScanWifiDisplaysMethod != null) {
mActivelyScanningWifiDisplays = true;
mHandler.post(this);
} else {
Log.w(TAG, "Cannot scan for wifi displays because the " + "DisplayManager.scanWifiDisplays() method is " + "not available on this device.");
}
}
} else {
if (mActivelyScanningWifiDisplays) {
mActivelyScanningWifiDisplays = false;
mHandler.removeCallbacks(this);
}
}
}Example 13
| Project: cwac-presentation-master File: PresentationHelper.java View source code |
private void handleRoute() {
if (isEnabled()) {
Display[] displays = mgr.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);
if (displays.length == 0) {
if (current != null || isFirstRun) {
listener.clearPreso(true);
current = null;
}
} else {
Display display = displays[0];
if (display != null && display.isValid()) {
if (current == null) {
listener.showPreso(display);
current = display;
} else if (current.getDisplayId() != display.getDisplayId()) {
listener.clearPreso(true);
listener.showPreso(display);
current = display;
} else {
// no-op: should already be set
}
} else if (current != null) {
listener.clearPreso(true);
current = null;
}
}
isFirstRun = false;
}
}Example 14
| Project: droidcv-master File: CoreWorker.java View source code |
public void startRendering(int mode, Uri videoSource) throws IllegalArgumentException {
CodecWorker mWorker = null;
switch(mode) {
case CoreDisplayService.MODE_DISPLAY_SCREEN:
DisplayManager mDisplayManager = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE);
Surface encoderInputSurface = createDisplaySurface();
mDisplayManager.createVirtualDisplay("OpenCV Virtual Display", 960, 1280, 150, encoderInputSurface, DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE);
mWorker = new CodecWorker(true);
break;
case CoreDisplayService.MODE_VIDEO:
if (videoSource == null) {
throw new IllegalArgumentException("You must override the setVideoSource method in your service.");
}
mWorker = new CodecWorker(false, videoSource);
//TODO: write the rest of the code.
break;
default:
throw new UnsupportedOperationException();
}
if (mWorker != null) {
Thread encoderThread = new Thread(mWorker);
encoderThread.start();
}
}Example 15
| Project: FloatingBall-master File: ScreenShotActivity.java View source code |
private void savePic(int resultCode, Intent data) {
final MediaProjection mediaProjection = mManager.getMediaProjection(resultCode, data);
if (mediaProjection == null) {
Log.e("@@", "media projection is null");
return;
}
//ImageFormat.RGB_565
mVirtualDisplay = mediaProjection.createVirtualDisplay("ndh", Utils.getScreenSize(this).x, Utils.getScreenSize(this).y, Utils.getScreenInfo(this).densityDpi, DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC, mSurface, null, null);
Handler handler2 = new Handler(getMainLooper());
handler2.postDelayed(new Runnable() {
public void run() {
//capture the screen
mImage = mImageReader.acquireLatestImage();
if (mImage == null) {
Log.d("ndh--", "img==null");
return;
}
int width = mImage.getWidth();
int height = mImage.getHeight();
final Image.Plane[] planes = mImage.getPlanes();
final ByteBuffer buffer = planes[0].getBuffer();
int pixelStride = planes[0].getPixelStride();
int rowStride = planes[0].getRowStride();
int rowPadding = rowStride - pixelStride * width;
Bitmap bitmap = Bitmap.createBitmap(width + rowPadding / pixelStride, height, Bitmap.Config.ARGB_8888);
bitmap.copyPixelsFromBuffer(buffer);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height);
mImage.close();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss");
String strDate = dateFormat.format(new java.util.Date());
String pathImage = Environment.getExternalStorageDirectory().getPath() + "/DCIM/";
String nameImage = pathImage + strDate + ".png";
if (bitmap != null) {
try {
File dir = new File(pathImage);
if (!dir.exists() && !dir.mkdirs()) {
//最多创建两次文件夹
dir.mkdirs();
}
File fileImage = new File(nameImage);
if (!fileImage.exists() && !fileImage.createNewFile()) {
fileImage.createNewFile();
}
FileOutputStream out = new FileOutputStream(fileImage);
if (out != null) {
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
Intent media = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri contentUri = Uri.fromFile(fileImage);
media.setData(contentUri);
ScreenShotActivity.this.sendBroadcast(media);
Toast.makeText(ScreenShotActivity.this, "图片ä¿?å˜æˆ?功:" + nameImage, Toast.LENGTH_SHORT).show();
mediaProjection.stop();
finish();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
finish();
}
}
}
}, 50);
}Example 16
| Project: IntranetEpitechV2-master File: MediaRouterJellybeanMr1.java View source code |
public void setActiveScanRouteTypes(int routeTypes) {
// enable active scanning on request.
if ((routeTypes & MediaRouterJellybean.ROUTE_TYPE_LIVE_VIDEO) != 0) {
if (!mActivelyScanningWifiDisplays) {
if (mScanWifiDisplaysMethod != null) {
mActivelyScanningWifiDisplays = true;
mHandler.post(this);
} else {
Log.w(TAG, "Cannot scan for wifi displays because the " + "DisplayManager.scanWifiDisplays() method is " + "not available on this device.");
}
}
} else {
if (mActivelyScanningWifiDisplays) {
mActivelyScanningWifiDisplays = false;
mHandler.removeCallbacks(this);
}
}
}Example 17
| Project: mediarouter-abs-master File: MediaRouterJellybeanMr1.java View source code |
public void setActiveScanRouteTypes(int routeTypes) {
// enable active scanning on request.
if ((routeTypes & MediaRouterJellybean.ROUTE_TYPE_LIVE_VIDEO) != 0) {
if (!mActivelyScanningWifiDisplays) {
if (mScanWifiDisplaysMethod != null) {
mActivelyScanningWifiDisplays = true;
mHandler.post(this);
} else {
Log.w(TAG, "Cannot scan for wifi displays because the " + "DisplayManager.scanWifiDisplays() method is " + "not available on this device.");
}
}
} else {
if (mActivelyScanningWifiDisplays) {
mActivelyScanningWifiDisplays = false;
mHandler.removeCallbacks(this);
}
}
}Example 18
| Project: sdk-support-master File: MediaRouterJellybeanMr1.java View source code |
public void setActiveScanRouteTypes(int routeTypes) {
// enable active scanning on request.
if ((routeTypes & MediaRouterJellybean.ROUTE_TYPE_LIVE_VIDEO) != 0) {
if (!mActivelyScanningWifiDisplays) {
if (mScanWifiDisplaysMethod != null) {
mActivelyScanningWifiDisplays = true;
mHandler.post(this);
} else {
Log.w(TAG, "Cannot scan for wifi displays because the " + "DisplayManager.scanWifiDisplays() method is " + "not available on this device.");
}
}
} else {
if (mActivelyScanningWifiDisplays) {
mActivelyScanningWifiDisplays = false;
mHandler.removeCallbacks(this);
}
}
}Example 19
| Project: Gallery3D_EVO_3D-master File: CameraControls.java View source code |
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
adjustControlsToRightPosition();
mLastRotation = Util.getDisplayRotation((Activity) getContext());
if (ApiHelper.HAS_DISPLAY_LISTENER) {
((DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE)).registerDisplayListener((DisplayListener) mDisplayListener, null);
}
}Example 20
| Project: robolectric-master File: ShadowContextImpl.java View source code |
@Implementation
public Object getSystemService(String name) {
if (name.equals(Context.LAYOUT_INFLATER_SERVICE)) {
return new RoboLayoutInflater(RuntimeEnvironment.application);
}
Object service = systemServices.get(name);
if (service == null) {
String serviceClassName = SYSTEM_SERVICE_MAP.get(name);
if (serviceClassName == null) {
System.err.println("WARNING: unknown service " + name);
return null;
}
try {
Class<?> clazz = Class.forName(serviceClassName);
if (serviceClassName.equals("android.app.admin.DevicePolicyManager")) {
if (getApiLevel() >= N) {
service = ReflectionHelpers.callConstructor(clazz, ClassParameter.from(Context.class, RuntimeEnvironment.application), ClassParameter.from(IDevicePolicyManager.class, null), ClassParameter.from(boolean.class, false));
} else {
service = ReflectionHelpers.callConstructor(clazz, ClassParameter.from(Context.class, RuntimeEnvironment.application), ClassParameter.from(Handler.class, null));
}
} else if (serviceClassName.equals("android.app.SearchManager") || serviceClassName.equals("android.app.ActivityManager") || serviceClassName.equals("android.app.WallpaperManager")) {
service = ReflectionHelpers.callConstructor(clazz, ClassParameter.from(Context.class, RuntimeEnvironment.application), ClassParameter.from(Handler.class, null));
} else if (serviceClassName.equals("android.os.storage.StorageManager")) {
service = ReflectionHelpers.callConstructor(clazz);
} else if (serviceClassName.equals("android.nfc.NfcManager") || serviceClassName.equals("android.telecom.TelecomManager")) {
service = ReflectionHelpers.callConstructor(clazz, ClassParameter.from(Context.class, RuntimeEnvironment.application));
} else if (serviceClassName.equals("android.hardware.display.DisplayManager") || serviceClassName.equals("android.telephony.SubscriptionManager")) {
service = ReflectionHelpers.callConstructor(clazz, ClassParameter.from(Context.class, RuntimeEnvironment.application));
} else if (serviceClassName.equals("android.view.accessibility.AccessibilityManager")) {
service = AccessibilityManager.getInstance(realObject);
} else if (getApiLevel() >= JELLY_BEAN_MR1 && serviceClassName.equals("android.view.WindowManagerImpl")) {
Class<?> windowMgrImplClass = Class.forName("android.view.WindowManagerImpl");
if (getApiLevel() >= N) {
service = ReflectionHelpers.callConstructor(windowMgrImplClass, ClassParameter.from(Context.class, realObject));
} else {
Display display = newInstanceOf(Display.class);
service = ReflectionHelpers.callConstructor(windowMgrImplClass, ClassParameter.from(Display.class, display));
}
} else if (serviceClassName.equals("android.accounts.AccountManager")) {
service = ReflectionHelpers.callConstructor(Class.forName("android.accounts.AccountManager"), ClassParameter.from(Context.class, RuntimeEnvironment.application), ClassParameter.from(IAccountManager.class, null));
} else if (serviceClassName.equals("android.net.wifi.p2p.WifiP2pManager")) {
service = new WifiP2pManager(ReflectionHelpers.createNullProxy(IWifiP2pManager.class));
} else if (getApiLevel() >= KITKAT && serviceClassName.equals("android.print.PrintManager")) {
service = ReflectionHelpers.callConstructor(Class.forName("android.print.PrintManager"), ClassParameter.from(Context.class, RuntimeEnvironment.application), ClassParameter.from(android.print.IPrintManager.class, null), ClassParameter.from(int.class, -1), ClassParameter.from(int.class, -1));
} else if (serviceClassName.equals("android.hardware.SystemSensorManager")) {
if (RuntimeEnvironment.getApiLevel() >= JELLY_BEAN_MR2) {
service = new SystemSensorManager(RuntimeEnvironment.application, Looper.getMainLooper());
} else {
service = ReflectionHelpers.callConstructor(Class.forName(serviceClassName), ClassParameter.from(Looper.class, Looper.getMainLooper()));
}
} else {
service = newInstanceOf(clazz);
}
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
systemServices.put(name, service);
}
return service;
}Example 21
| Project: android-gradle-plugin-master File: ServiceCastDetector.java View source code |
@NonNull
private static Map<String, String> getServiceMap() {
if (sServiceMap == null) {
final int EXPECTED_SIZE = 34;
sServiceMap = Maps.newHashMapWithExpectedSize(EXPECTED_SIZE);
sServiceMap.put("ACCESSIBILITY_SERVICE", "android.view.accessibility.AccessibilityManager");
sServiceMap.put("ACCOUNT_SERVICE", "android.accounts.AccountManager");
sServiceMap.put("ACTIVITY_SERVICE", "android.app.ActivityManager");
sServiceMap.put("ALARM_SERVICE", "android.app.AlarmManager");
sServiceMap.put("AUDIO_SERVICE", "android.media.AudioManager");
sServiceMap.put("CLIPBOARD_SERVICE", "android.text.ClipboardManager");
sServiceMap.put("CONNECTIVITY_SERVICE", "android.net.ConnectivityManager");
sServiceMap.put("CONNECTIVITY_SERVICE", "android.net.ConnectivityManager");
sServiceMap.put("DEVICE_POLICY_SERVICE", "android.app.admin.DevicePolicyManager");
sServiceMap.put("DISPLAY_SERVICE", "android.hardware.display.DisplayManager");
sServiceMap.put("DOWNLOAD_SERVICE", "android.app.DownloadManager");
sServiceMap.put("DROPBOX_SERVICE", "android.os.DropBoxManager");
sServiceMap.put("INPUT_METHOD_SERVICE", "android.view.inputmethod.InputMethodManager");
sServiceMap.put("INPUT_SERVICE", "android.hardware.input.InputManager");
sServiceMap.put("KEYGUARD_SERVICE", "android.app.KeyguardManager");
sServiceMap.put("LAYOUT_INFLATER_SERVICE", "android.view.LayoutInflater");
sServiceMap.put("LOCATION_SERVICE", "android.location.LocationManager");
sServiceMap.put("MEDIA_ROUTER_SERVICE", "android.media.MediaRouter");
sServiceMap.put("NFC_SERVICE", "android.nfc.NfcManager");
sServiceMap.put("NOTIFICATION_SERVICE", "android.app.NotificationManager");
sServiceMap.put("NSD_SERVICE", "android.net.nsd.NsdManager");
sServiceMap.put("POWER_SERVICE", "android.os.PowerManager");
sServiceMap.put("SEARCH_SERVICE", "android.app.SearchManager");
sServiceMap.put("SENSOR_SERVICE", "android.hardware.SensorManager");
sServiceMap.put("STORAGE_SERVICE", "android.os.storage.StorageManager");
sServiceMap.put("TELEPHONY_SERVICE", "android.telephony.TelephonyManager");
sServiceMap.put("TEXT_SERVICES_MANAGER_SERVICE", "android.view.textservice.TextServicesManager");
sServiceMap.put("UI_MODE_SERVICE", "android.app.UiModeManager");
sServiceMap.put("UI_MODE_SERVICE", "android.app.UiModeManager");
sServiceMap.put("USB_SERVICE", "android.hardware.usb.UsbManager");
sServiceMap.put("USER_SERVICE", "android.os.UserManager");
sServiceMap.put("VIBRATOR_SERVICE", "android.os.Vibrator");
sServiceMap.put("WALLPAPER_SERVICE", "com.android.server.WallpaperService");
sServiceMap.put("WIFI_P2P_SERVICE", "android.net.wifi.p2p.WifiP2pManager");
sServiceMap.put("WIFI_SERVICE", "android.net.wifi.WifiManager");
sServiceMap.put("WINDOW_SERVICE", "android.view.WindowManager");
assert sServiceMap.size() == EXPECTED_SIZE : sServiceMap.size();
}
return sServiceMap;
}Example 22
| Project: android-platform-tools-base-master File: ServiceCastDetector.java View source code |
@NonNull
private static Map<String, String> getServiceMap() {
if (sServiceMap == null) {
final int EXPECTED_SIZE = 49;
sServiceMap = Maps.newHashMapWithExpectedSize(EXPECTED_SIZE);
sServiceMap.put("ACCESSIBILITY_SERVICE", "android.view.accessibility.AccessibilityManager");
sServiceMap.put("ACCOUNT_SERVICE", "android.accounts.AccountManager");
sServiceMap.put("ACTIVITY_SERVICE", "android.app.ActivityManager");
sServiceMap.put("ALARM_SERVICE", "android.app.AlarmManager");
sServiceMap.put("APPWIDGET_SERVICE", "android.appwidget.AppWidgetManager");
sServiceMap.put("APP_OPS_SERVICE", "android.app.AppOpsManager");
sServiceMap.put("AUDIO_SERVICE", "android.media.AudioManager");
sServiceMap.put("BATTERY_SERVICE", "android.os.BatteryManager");
sServiceMap.put("BLUETOOTH_SERVICE", "android.bluetooth.BluetoothManager");
sServiceMap.put("CAMERA_SERVICE", "android.hardware.camera2.CameraManager");
sServiceMap.put("CAPTIONING_SERVICE", "android.view.accessibility.CaptioningManager");
sServiceMap.put("CLIPBOARD_SERVICE", "android.text.ClipboardManager");
sServiceMap.put("CONNECTIVITY_SERVICE", "android.net.ConnectivityManager");
sServiceMap.put("CONSUMER_IR_SERVICE", "android.hardware.ConsumerIrManager");
sServiceMap.put("DEVICE_POLICY_SERVICE", "android.app.admin.DevicePolicyManager");
sServiceMap.put("DISPLAY_SERVICE", "android.hardware.display.DisplayManager");
sServiceMap.put("DOWNLOAD_SERVICE", "android.app.DownloadManager");
sServiceMap.put("DROPBOX_SERVICE", "android.os.DropBoxManager");
sServiceMap.put("INPUT_METHOD_SERVICE", "android.view.inputmethod.InputMethodManager");
sServiceMap.put("INPUT_SERVICE", "android.hardware.input.InputManager");
sServiceMap.put("JOB_SCHEDULER_SERVICE", "android.app.job.JobScheduler");
sServiceMap.put("KEYGUARD_SERVICE", "android.app.KeyguardManager");
sServiceMap.put("LAUNCHER_APPS_SERVICE", "android.content.pm.LauncherApps");
sServiceMap.put("LAYOUT_INFLATER_SERVICE", "android.view.LayoutInflater");
sServiceMap.put("LOCATION_SERVICE", "android.location.LocationManager");
sServiceMap.put("MEDIA_PROJECTION_SERVICE", "android.media.projection.MediaProjectionManager");
sServiceMap.put("MEDIA_ROUTER_SERVICE", "android.media.MediaRouter");
sServiceMap.put("MEDIA_SESSION_SERVICE", "android.media.session.MediaSessionManager");
sServiceMap.put("NFC_SERVICE", "android.nfc.NfcManager");
sServiceMap.put("NOTIFICATION_SERVICE", "android.app.NotificationManager");
sServiceMap.put("NSD_SERVICE", "android.net.nsd.NsdManager");
sServiceMap.put("POWER_SERVICE", "android.os.PowerManager");
sServiceMap.put("PRINT_SERVICE", "android.print.PrintManager");
sServiceMap.put("RESTRICTIONS_SERVICE", "android.content.RestrictionsManager");
sServiceMap.put("SEARCH_SERVICE", "android.app.SearchManager");
sServiceMap.put("SENSOR_SERVICE", "android.hardware.SensorManager");
sServiceMap.put("STORAGE_SERVICE", "android.os.storage.StorageManager");
sServiceMap.put("TELECOM_SERVICE", "android.telecom.TelecomManager");
sServiceMap.put("TELEPHONY_SERVICE", "android.telephony.TelephonyManager");
sServiceMap.put("TEXT_SERVICES_MANAGER_SERVICE", "android.view.textservice.TextServicesManager");
sServiceMap.put("TV_INPUT_SERVICE", "android.media.tv.TvInputManager");
sServiceMap.put("UI_MODE_SERVICE", "android.app.UiModeManager");
sServiceMap.put("USB_SERVICE", "android.hardware.usb.UsbManager");
sServiceMap.put("USER_SERVICE", "android.os.UserManager");
sServiceMap.put("VIBRATOR_SERVICE", "android.os.Vibrator");
sServiceMap.put("WALLPAPER_SERVICE", "com.android.server.WallpaperService");
sServiceMap.put("WIFI_P2P_SERVICE", "android.net.wifi.p2p.WifiP2pManager");
sServiceMap.put("WIFI_SERVICE", "android.net.wifi.WifiManager");
sServiceMap.put("WINDOW_SERVICE", "android.view.WindowManager");
assert sServiceMap.size() == EXPECTED_SIZE : sServiceMap.size();
}
return sServiceMap;
}Example 23
| Project: android_frameworks_base-master File: DeviceIdleController.java View source code |
@Override
public void onBootPhase(int phase) {
if (phase == PHASE_SYSTEM_SERVICES_READY) {
synchronized (this) {
mAlarmManager = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE);
mBatteryStats = BatteryStatsService.getService();
mLocalPowerManager = getLocalService(PowerManagerInternal.class);
mPowerManager = getContext().getSystemService(PowerManager.class);
mActiveIdleWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "deviceidle_maint");
mActiveIdleWakeLock.setReferenceCounted(false);
mConnectivityService = (ConnectivityService) ServiceManager.getService(Context.CONNECTIVITY_SERVICE);
mLocalAlarmManager = getLocalService(AlarmManagerService.LocalService.class);
mNetworkPolicyManager = INetworkPolicyManager.Stub.asInterface(ServiceManager.getService(Context.NETWORK_POLICY_SERVICE));
mDisplayManager = (DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE);
mSensorManager = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
int sigMotionSensorId = getContext().getResources().getInteger(com.android.internal.R.integer.config_autoPowerModeAnyMotionSensor);
if (sigMotionSensorId > 0) {
mMotionSensor = mSensorManager.getDefaultSensor(sigMotionSensorId, true);
}
if (mMotionSensor == null && getContext().getResources().getBoolean(com.android.internal.R.bool.config_autoPowerModePreferWristTilt)) {
mMotionSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_WRIST_TILT_GESTURE, true);
}
if (mMotionSensor == null) {
// As a last ditch, fall back to SMD.
mMotionSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION, true);
}
if (getContext().getResources().getBoolean(com.android.internal.R.bool.config_autoPowerModePrefetchLocation)) {
mLocationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
mLocationRequest = new LocationRequest().setQuality(LocationRequest.ACCURACY_FINE).setInterval(0).setFastestInterval(0).setNumUpdates(1);
}
float angleThreshold = getContext().getResources().getInteger(com.android.internal.R.integer.config_autoPowerModeThresholdAngle) / 100f;
mAnyMotionDetector = new AnyMotionDetector((PowerManager) getContext().getSystemService(Context.POWER_SERVICE), mHandler, mSensorManager, this, angleThreshold);
mIdleIntent = new Intent(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
mIdleIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
mLightIdleIntent = new Intent(PowerManager.ACTION_LIGHT_DEVICE_IDLE_MODE_CHANGED);
mLightIdleIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
getContext().registerReceiver(mReceiver, filter);
filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addDataScheme("package");
getContext().registerReceiver(mReceiver, filter);
filter = new IntentFilter();
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
getContext().registerReceiver(mReceiver, filter);
mLocalPowerManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAllAppIdArray);
mLocalAlarmManager.setDeviceIdleUserWhitelist(mPowerSaveWhitelistUserAppIdArray);
mDisplayManager.registerDisplayListener(mDisplayListener, null);
updateDisplayLocked();
}
updateConnectivityState(null);
}
}Example 24
| Project: android_packages_apps_AeroControl-master File: PerAppService.java View source code |
private boolean isScreenOn() {
// Take special care for API20+
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
DisplayManager dm = (DisplayManager) mContext.getSystemService(mContext.DISPLAY_SERVICE);
// We iterate through all available displays
for (Display display : dm.getDisplays()) {
if (display.getState() != Display.STATE_OFF)
return false;
}
// If we are here, all displays are on;
return true;
} else {
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
return !pm.isScreenOn();
}
}Example 25
| Project: kotlin-master File: ServiceCastDetector.java View source code |
@NonNull
private static Map<String, String> getServiceMap() {
if (sServiceMap == null) {
final int EXPECTED_SIZE = 55;
sServiceMap = Maps.newHashMapWithExpectedSize(EXPECTED_SIZE);
sServiceMap.put("ACCESSIBILITY_SERVICE", "android.view.accessibility.AccessibilityManager");
sServiceMap.put("ACCOUNT_SERVICE", "android.accounts.AccountManager");
sServiceMap.put("ACTIVITY_SERVICE", "android.app.ActivityManager");
sServiceMap.put("ALARM_SERVICE", "android.app.AlarmManager");
sServiceMap.put("APPWIDGET_SERVICE", "android.appwidget.AppWidgetManager");
sServiceMap.put("APP_OPS_SERVICE", "android.app.AppOpsManager");
sServiceMap.put("AUDIO_SERVICE", "android.media.AudioManager");
sServiceMap.put("BATTERY_SERVICE", "android.os.BatteryManager");
sServiceMap.put("BLUETOOTH_SERVICE", "android.bluetooth.BluetoothManager");
sServiceMap.put("CAMERA_SERVICE", "android.hardware.camera2.CameraManager");
sServiceMap.put("CAPTIONING_SERVICE", "android.view.accessibility.CaptioningManager");
sServiceMap.put("CARRIER_CONFIG_SERVICE", "android.telephony.CarrierConfigManager");
// also allow @Deprecated android.content.ClipboardManager
sServiceMap.put("CLIPBOARD_SERVICE", "android.text.ClipboardManager");
sServiceMap.put("CONNECTIVITY_SERVICE", "android.net.ConnectivityManager");
sServiceMap.put("CONSUMER_IR_SERVICE", "android.hardware.ConsumerIrManager");
sServiceMap.put("DEVICE_POLICY_SERVICE", "android.app.admin.DevicePolicyManager");
sServiceMap.put("DISPLAY_SERVICE", "android.hardware.display.DisplayManager");
sServiceMap.put("DOWNLOAD_SERVICE", "android.app.DownloadManager");
sServiceMap.put("DROPBOX_SERVICE", "android.os.DropBoxManager");
sServiceMap.put("FINGERPRINT_SERVICE", "android.hardware.fingerprint.FingerprintManager");
sServiceMap.put("INPUT_METHOD_SERVICE", "android.view.inputmethod.InputMethodManager");
sServiceMap.put("INPUT_SERVICE", "android.hardware.input.InputManager");
sServiceMap.put("JOB_SCHEDULER_SERVICE", "android.app.job.JobScheduler");
sServiceMap.put("KEYGUARD_SERVICE", "android.app.KeyguardManager");
sServiceMap.put("LAUNCHER_APPS_SERVICE", "android.content.pm.LauncherApps");
sServiceMap.put("LAYOUT_INFLATER_SERVICE", "android.view.LayoutInflater");
sServiceMap.put("LOCATION_SERVICE", "android.location.LocationManager");
sServiceMap.put("MEDIA_PROJECTION_SERVICE", "android.media.projection.MediaProjectionManager");
sServiceMap.put("MEDIA_ROUTER_SERVICE", "android.media.MediaRouter");
sServiceMap.put("MEDIA_SESSION_SERVICE", "android.media.session.MediaSessionManager");
sServiceMap.put("MIDI_SERVICE", "android.media.midi.MidiManager");
sServiceMap.put("NETWORK_STATS_SERVICE", "android.app.usage.NetworkStatsManager");
sServiceMap.put("NFC_SERVICE", "android.nfc.NfcManager");
sServiceMap.put("NOTIFICATION_SERVICE", "android.app.NotificationManager");
sServiceMap.put("NSD_SERVICE", "android.net.nsd.NsdManager");
sServiceMap.put("POWER_SERVICE", "android.os.PowerManager");
sServiceMap.put("PRINT_SERVICE", "android.print.PrintManager");
sServiceMap.put("RESTRICTIONS_SERVICE", "android.content.RestrictionsManager");
sServiceMap.put("SEARCH_SERVICE", "android.app.SearchManager");
sServiceMap.put("SENSOR_SERVICE", "android.hardware.SensorManager");
sServiceMap.put("STORAGE_SERVICE", "android.os.storage.StorageManager");
sServiceMap.put("TELECOM_SERVICE", "android.telecom.TelecomManager");
sServiceMap.put("TELEPHONY_SERVICE", "android.telephony.TelephonyManager");
sServiceMap.put("TELEPHONY_SUBSCRIPTION_SERVICE", "android.telephony.SubscriptionManager");
sServiceMap.put("TEXT_SERVICES_MANAGER_SERVICE", "android.view.textservice.TextServicesManager");
sServiceMap.put("TV_INPUT_SERVICE", "android.media.tv.TvInputManager");
sServiceMap.put("UI_MODE_SERVICE", "android.app.UiModeManager");
sServiceMap.put("USAGE_STATS_SERVICE", "android.app.usage.UsageStatsManager");
sServiceMap.put("USB_SERVICE", "android.hardware.usb.UsbManager");
sServiceMap.put("USER_SERVICE", "android.os.UserManager");
sServiceMap.put("VIBRATOR_SERVICE", "android.os.Vibrator");
sServiceMap.put("WALLPAPER_SERVICE", "android.service.wallpaper.WallpaperService");
sServiceMap.put("WIFI_P2P_SERVICE", "android.net.wifi.p2p.WifiP2pManager");
sServiceMap.put("WIFI_SERVICE", "android.net.wifi.WifiManager");
sServiceMap.put("WINDOW_SERVICE", "android.view.WindowManager");
assert sServiceMap.size() == EXPECTED_SIZE : sServiceMap.size();
}
return sServiceMap;
}Example 26
| Project: platform_frameworks_base-master File: DeviceIdleController.java View source code |
@Override
public void onBootPhase(int phase) {
if (phase == PHASE_SYSTEM_SERVICES_READY) {
synchronized (this) {
mAlarmManager = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE);
mBatteryStats = BatteryStatsService.getService();
mLocalPowerManager = getLocalService(PowerManagerInternal.class);
mPowerManager = getContext().getSystemService(PowerManager.class);
mActiveIdleWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "deviceidle_maint");
mActiveIdleWakeLock.setReferenceCounted(false);
mGoingIdleWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "deviceidle_going_idle");
mGoingIdleWakeLock.setReferenceCounted(true);
mConnectivityService = (ConnectivityService) ServiceManager.getService(Context.CONNECTIVITY_SERVICE);
mLocalAlarmManager = getLocalService(AlarmManagerService.LocalService.class);
mNetworkPolicyManager = INetworkPolicyManager.Stub.asInterface(ServiceManager.getService(Context.NETWORK_POLICY_SERVICE));
mDisplayManager = (DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE);
mSensorManager = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
int sigMotionSensorId = getContext().getResources().getInteger(com.android.internal.R.integer.config_autoPowerModeAnyMotionSensor);
if (sigMotionSensorId > 0) {
mMotionSensor = mSensorManager.getDefaultSensor(sigMotionSensorId, true);
}
if (mMotionSensor == null && getContext().getResources().getBoolean(com.android.internal.R.bool.config_autoPowerModePreferWristTilt)) {
mMotionSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_WRIST_TILT_GESTURE, true);
}
if (mMotionSensor == null) {
// As a last ditch, fall back to SMD.
mMotionSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION, true);
}
if (getContext().getResources().getBoolean(com.android.internal.R.bool.config_autoPowerModePrefetchLocation)) {
mLocationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
mLocationRequest = new LocationRequest().setQuality(LocationRequest.ACCURACY_FINE).setInterval(0).setFastestInterval(0).setNumUpdates(1);
}
float angleThreshold = getContext().getResources().getInteger(com.android.internal.R.integer.config_autoPowerModeThresholdAngle) / 100f;
mAnyMotionDetector = new AnyMotionDetector((PowerManager) getContext().getSystemService(Context.POWER_SERVICE), mHandler, mSensorManager, this, angleThreshold);
mIdleIntent = new Intent(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
mIdleIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
mLightIdleIntent = new Intent(PowerManager.ACTION_LIGHT_DEVICE_IDLE_MODE_CHANGED);
mLightIdleIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
getContext().registerReceiver(mReceiver, filter);
filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addDataScheme("package");
getContext().registerReceiver(mReceiver, filter);
filter = new IntentFilter();
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
getContext().registerReceiver(mReceiver, filter);
mLocalPowerManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAllAppIdArray);
mLocalAlarmManager.setDeviceIdleUserWhitelist(mPowerSaveWhitelistUserAppIdArray);
mDisplayManager.registerDisplayListener(mDisplayListener, null);
updateDisplayLocked();
}
updateConnectivityState(null);
}
}Example 27
| Project: platform_frameworks_support-master File: MediaRouterJellybeanMr1.java View source code |
public void setActiveScanRouteTypes(int routeTypes) {
// enable active scanning on request.
if ((routeTypes & MediaRouterJellybean.ROUTE_TYPE_LIVE_VIDEO) != 0) {
if (!mActivelyScanningWifiDisplays) {
if (mScanWifiDisplaysMethod != null) {
mActivelyScanningWifiDisplays = true;
mHandler.post(this);
} else {
Log.w(TAG, "Cannot scan for wifi displays because the " + "DisplayManager.scanWifiDisplays() method is " + "not available on this device.");
}
}
} else {
if (mActivelyScanningWifiDisplays) {
mActivelyScanningWifiDisplays = false;
mHandler.removeCallbacks(this);
}
}
}Example 28
| Project: ScreenRecordingSample-master File: MediaScreenEncoder.java View source code |
@Override
protected void onStart() {
if (DEBUG)
Log.d(TAG, "mScreenCaptureTask#onStart:");
mDrawer = new GLDrawer2D(true);
mTexId = mDrawer.initTex();
mSourceTexture = new SurfaceTexture(mTexId);
// ã?“れを入れã?ªã?„ã?¨æ˜ åƒ?ã?Œå?–れã?ªã?„
mSourceTexture.setDefaultBufferSize(mWidth, mHeight);
mSourceSurface = new Surface(mSourceTexture);
mSourceTexture.setOnFrameAvailableListener(mOnFrameAvailableListener, mHandler);
mEncoderSurface = getEgl().createFromSurface(mSurface);
if (DEBUG)
Log.d(TAG, "setup VirtualDisplay");
intervals = (long) (1000f / fps);
display = mMediaProjection.createVirtualDisplay("Capturing Display", mWidth, mHeight, mDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mSourceSurface, mCallback, mHandler);
if (DEBUG)
Log.v(TAG, "screen capture loop:display=" + display);
// 録画タスクを起床
queueEvent(mDrawTask);
}Example 29
| Project: tabulae-master File: ScreenCaptureFragment.java View source code |
protected void go() {
if (DEBUG)
Log.d(TAG, "ScreenCaptureFragment.go mResultData=" + mResultData + ", mResultCode=" + mResultCode);
if (getActivity() != null) {
if (mResultData != null && mMediaProjection == null) {
mMediaProjection = mMediaProjectionManager.getMediaProjection(mResultCode, mResultData);
// mMediaProjection.registerCallback(...
}
if (DEBUG)
Log.d(TAG, "ScreenCaptureFragment.go mMediaProjection=" + mMediaProjection);
if (mMediaProjection != null && mVirtualDisplay == null) {
try {
if (DEBUG)
Log.d(TAG, "mScreenWidth=" + mScreenWidth + ", mScreenHeight=" + mScreenHeight);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
// mMediaRecorder.setVideoEncodingBitRate(128 * 1000);
// mMediaRecorder.setVideoFrameRate(12);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
// round up to multiple of 16
mScreenWidth = ((mScreenWidth + 15) / 16) * 16;
mMediaRecorder.setVideoSize(mScreenWidth, mScreenHeight);
mMediaRecorder.setOutputFile(getMovieName().getPath());
mMediaRecorder.prepare();
mMediaRecorder.start();
mVirtualDisplay = mMediaProjection.createVirtualDisplay(getClass().getSimpleName(), mScreenWidth, mScreenHeight, mScreenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mMediaRecorder.getSurface(), // Callbacks
null, // Handler
null);
if (DEBUG)
Log.d(TAG, "ScreenCaptureFragment.onActivityResult: recording started");
Toast.makeText(getActivity(), "Recording started", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
Log.e(TAG, "ScreenCaptureFragment.onActivityResult:", e);
stopRecording();
}
}
}
}Example 30
| Project: android_device_softwinner_cubieboard1-master File: DisplaySettings.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ContentResolver resolver = getActivity().getContentResolver();
addPreferencesFromResource(R.xml.display_settings);
mAccelerometer = (CheckBoxPreference) findPreference(KEY_ACCELEROMETER);
mAccelerometer.setPersistent(false);
if (RotationPolicy.isRotationLockToggleSupported(getActivity())) {
// If rotation lock is supported, then we do not provide this option in
// Display settings. However, is still available in Accessibility settings.
getPreferenceScreen().removePreference(mAccelerometer);
}
mScreenSaverPreference = findPreference(KEY_SCREEN_SAVER);
if (mScreenSaverPreference != null && getResources().getBoolean(com.android.internal.R.bool.config_dreamsSupported) == false) {
getPreferenceScreen().removePreference(mScreenSaverPreference);
}
mScreenTimeoutPreference = (ListPreference) findPreference(KEY_SCREEN_TIMEOUT);
final long currentTimeout = Settings.System.getLong(resolver, SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE);
mScreenTimeoutPreference.setValue(String.valueOf(currentTimeout));
mScreenTimeoutPreference.setOnPreferenceChangeListener(this);
disableUnusableTimeouts(mScreenTimeoutPreference);
updateTimeoutPreferenceDescription(currentTimeout);
mFontSizePref = (WarnedListPreference) findPreference(KEY_FONT_SIZE);
mFontSizePref.setOnPreferenceChangeListener(this);
mFontSizePref.setOnPreferenceClickListener(this);
mNotificationPulse = (CheckBoxPreference) findPreference(KEY_NOTIFICATION_PULSE);
if (mNotificationPulse != null && getResources().getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed) == false) {
getPreferenceScreen().removePreference(mNotificationPulse);
} else {
try {
mNotificationPulse.setChecked(Settings.System.getInt(resolver, Settings.System.NOTIFICATION_LIGHT_PULSE) == 1);
mNotificationPulse.setOnPreferenceChangeListener(this);
} catch (SettingNotFoundException snfe) {
Log.e(TAG, Settings.System.NOTIFICATION_LIGHT_PULSE + " not found");
}
}
mAccelerometerCoordinate = (ListPreference) findPreference(KEY_ACCELEROMETER_COORDINATE);
if (mAccelerometerCoordinate != null) {
mAccelerometerCoordinate.setOnPreferenceChangeListener(this);
String value = Settings.System.getString(getContentResolver(), Settings.System.ACCELEROMETER_COORDINATE);
if (value == null) {
value = "default";
}
mAccelerometerCoordinate.setValue(value);
updateAccelerometerCoordinateSummary(value);
}
mSmartBrightnessPreview = new CheckBoxPreference(this.getActivity());
mSmartBrightnessPreview.setTitle(R.string.smart_brightness_preview);
mSmartBrightnessPreview.setKey(KEY_SMART_BRIGHTNESS_PREVIEW);
mSmartBrightness = (CheckBoxPreference) findPreference(KEY_SMART_BRIGHTNESS);
mSmartBrightness.setOnPreferenceChangeListener(this);
if (!getResources().getBoolean(R.bool.has_smart_brightness)) {
getPreferenceScreen().removePreference(mSmartBrightness);
} else {
boolean enable = Settings.System.getInt(getContentResolver(), Settings.System.SMART_BRIGHTNESS_ENABLE, 0) != 0 ? true : false;
mSmartBrightness.setChecked(enable);
mSmartBrightnessPreview.setOnPreferenceChangeListener(this);
if (enable) {
getPreferenceScreen().addPreference(mSmartBrightnessPreview);
}
}
mDisplayManager = (DisplayManager) getActivity().getSystemService(Context.DISPLAY_SERVICE);
mWifiDisplayStatus = mDisplayManager.getWifiDisplayStatus();
mWifiDisplayPreference = (Preference) findPreference(KEY_WIFI_DISPLAY);
if (mWifiDisplayStatus.getFeatureState() == WifiDisplayStatus.FEATURE_STATE_UNAVAILABLE) {
getPreferenceScreen().removePreference(mWifiDisplayPreference);
mWifiDisplayPreference = null;
}
/* homlet å’Œ dongleä¸Šæ— ä¼‘çœ */
getPreferenceScreen().removePreference(mScreenTimeoutPreference);
mOutputMode = (ListPreference) findPreference(KEY_TV_OUTPUT_MODE);
if (mOutputMode != null) {
mOutputMode.setOnPreferenceChangeListener(this);
setOutputMode(mOutputMode);
}
}Example 31
| Project: Bigbang-master File: ScreenCapture.java View source code |
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void virtualDisplay() {
try {
mVirtualDisplay = mMediaProjection.createVirtualDisplay("screen-mirror", windowWidth, windowHeight, mScreenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mImageReader.getSurface(), null, null);
LogUtil.d(TAG, "virtual displayed");
} catch (Exception e) {
e.printStackTrace();
}
}Example 32
| Project: Project-M-1-master File: DisplaySettings.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ContentResolver resolver = getActivity().getContentResolver();
addPreferencesFromResource(R.xml.display_settings);
mDisplayRotationPreference = (PreferenceScreen) findPreference(KEY_DISPLAY_ROTATION);
mScreenSaverPreference = findPreference(KEY_SCREEN_SAVER);
if (mScreenSaverPreference != null && getResources().getBoolean(com.android.internal.R.bool.config_dreamsSupported) == false) {
getPreferenceScreen().removePreference(mScreenSaverPreference);
}
mScreenTimeoutPreference = (ListPreference) findPreference(KEY_SCREEN_TIMEOUT);
final long currentTimeout = Settings.System.getLong(resolver, SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE);
mScreenTimeoutPreference.setValue(String.valueOf(currentTimeout));
mScreenTimeoutPreference.setOnPreferenceChangeListener(this);
disableUnusableTimeouts(mScreenTimeoutPreference);
updateTimeoutPreferenceDescription(currentTimeout);
updateDisplayRotationPreferenceDescription();
mFontSizePref = (WarnedListPreference) findPreference(KEY_FONT_SIZE);
mFontSizePref.setOnPreferenceChangeListener(this);
mFontSizePref.setOnPreferenceClickListener(this);
mDisplayManager = (DisplayManager) getActivity().getSystemService(Context.DISPLAY_SERVICE);
mWifiDisplayStatus = mDisplayManager.getWifiDisplayStatus();
mWifiDisplayPreference = (Preference) findPreference(KEY_WIFI_DISPLAY);
if (mWifiDisplayStatus.getFeatureState() == WifiDisplayStatus.FEATURE_STATE_UNAVAILABLE) {
getPreferenceScreen().removePreference(mWifiDisplayPreference);
mWifiDisplayPreference = null;
}
mVolumeWake = (CheckBoxPreference) findPreference(KEY_VOLUME_WAKE);
if (mVolumeWake != null) {
if (!getResources().getBoolean(R.bool.config_show_volumeRockerWake) || !Utils.hasVolumeRocker(getActivity())) {
getPreferenceScreen().removePreference(mVolumeWake);
getPreferenceScreen().removePreference((PreferenceCategory) findPreference(KEY_WAKEUP_CATEGORY));
} else {
mVolumeWake.setChecked(Settings.System.getInt(resolver, Settings.System.VOLUME_WAKE_SCREEN, 0) == 1);
}
}
}Example 33
| Project: remote-master File: ServerService.java View source code |
@TargetApi(19)
public void startDisplayManager() {
DisplayManager mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
Surface encoderInputSurface = null;
try {
encoderInputSurface = createDisplaySurface();
} catch (IOException e) {
e.printStackTrace();
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
virtualDisplay = mDisplayManager.createVirtualDisplay("Remote Droid", CodecUtils.WIDTH, CodecUtils.HEIGHT, 50, encoderInputSurface, DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE);
} else {
if (MainActivity.mMediaProjection != null) {
virtualDisplay = MainActivity.mMediaProjection.createVirtualDisplay("Remote Droid", CodecUtils.WIDTH, CodecUtils.HEIGHT, 50, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, encoderInputSurface, null, null);
} else {
showToast("Something went wrong. Please restart the app.");
}
}
encoder.start();
}Example 34
| Project: skylink-android-screen-sharing-master File: MainActivity.java View source code |
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE) {
mediaProjection = projectionManager.getMediaProjection(resultCode, data);
if (mediaProjection != null) {
projectionStarted = true;
// Initialize the media projection
DisplayMetrics metrics = getResources().getDisplayMetrics();
int density = metrics.densityDpi;
int flags = DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY | DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC;
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
displayWidth = size.x;
displayHeight = size.y;
imageReader = ImageReader.newInstance(displayWidth, displayHeight, PixelFormat.RGBA_8888, 2);
mediaProjection.createVirtualDisplay("screencap", displayWidth, displayHeight, density, flags, imageReader.getSurface(), null, handler);
imageReader.setOnImageAvailableListener(new ImageAvailableListener(), handler);
}
}
}Example 35
| Project: actor-platform-master File: AndroidMessenger.java View source code |
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();
}
}Example 36
| Project: andevcon-2014-jl-master File: PresentationActivity.java View source code |
/**
* Initialization of the Activity after it is first created. Must at least
* call {@link android.app.Activity#setContentView setContentView()} to
* describe what is to be displayed in the screen.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
// Be sure to call the super class.
super.onCreate(savedInstanceState);
// Restore saved instance state.
if (savedInstanceState != null) {
mSavedPresentationContents = savedInstanceState.getSparseParcelableArray(PRESENTATION_KEY);
} else {
mSavedPresentationContents = new SparseArray<PresentationContents>();
}
// Get the display manager service.
mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
// See assets/res/any/layout/presentation_activity.xml for this
// view layout definition, which is being set here as
// the content of our screen.
setContentView(R.layout.presentation_activity);
// Set up checkbox to toggle between showing all displays or only presentation displays.
mShowAllDisplaysCheckbox = (CheckBox) findViewById(R.id.show_all_displays);
mShowAllDisplaysCheckbox.setOnCheckedChangeListener(this);
// Set up the list of displays.
mDisplayListAdapter = new DisplayListAdapter(this);
mListView = (ListView) findViewById(R.id.display_list);
mListView.setAdapter(mDisplayListAdapter);
}Example 37
| Project: android-apidemos-master File: PresentationActivity.java View source code |
/**
* Initialization of the Activity after it is first created. Must at least
* call {@link android.app.Activity#setContentView setContentView()} to
* describe what is to be displayed in the screen.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
// Be sure to call the super class.
super.onCreate(savedInstanceState);
// Restore saved instance state.
if (savedInstanceState != null) {
mSavedPresentationContents = savedInstanceState.getSparseParcelableArray(PRESENTATION_KEY);
} else {
mSavedPresentationContents = new SparseArray<PresentationContents>();
}
// Get the display manager service.
mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
// See assets/res/any/layout/presentation_activity.xml for this
// view layout definition, which is being set here as
// the content of our screen.
setContentView(R.layout.presentation_activity);
// Set up checkbox to toggle between showing all displays or only presentation displays.
mShowAllDisplaysCheckbox = (CheckBox) findViewById(R.id.show_all_displays);
mShowAllDisplaysCheckbox.setOnCheckedChangeListener(this);
// Set up the list of displays.
mDisplayListAdapter = new DisplayListAdapter(this);
mListView = (ListView) findViewById(R.id.display_list);
mListView.setAdapter(mDisplayListAdapter);
}Example 38
| Project: Android-SDK-Samples-master File: PresentationActivity.java View source code |
/**
* Initialization of the Activity after it is first created. Must at least
* call {@link android.app.Activity#setContentView setContentView()} to
* describe what is to be displayed in the screen.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
// Be sure to call the super class.
super.onCreate(savedInstanceState);
// Restore saved instance state.
if (savedInstanceState != null) {
mSavedPresentationContents = savedInstanceState.getSparseParcelableArray(PRESENTATION_KEY);
} else {
mSavedPresentationContents = new SparseArray<PresentationContents>();
}
// Get the display manager service.
mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
// See assets/res/any/layout/presentation_activity.xml for this
// view layout definition, which is being set here as
// the content of our screen.
setContentView(R.layout.presentation_activity);
// Set up checkbox to toggle between showing all displays or only presentation displays.
mShowAllDisplaysCheckbox = (CheckBox) findViewById(R.id.show_all_displays);
mShowAllDisplaysCheckbox.setOnCheckedChangeListener(this);
// Set up the list of displays.
mDisplayListAdapter = new DisplayListAdapter(this);
mListView = (ListView) findViewById(R.id.display_list);
mListView.setAdapter(mDisplayListAdapter);
}Example 39
| Project: apidemo-master File: PresentationActivity.java View source code |
/**
* Initialization of the Activity after it is first created. Must at least
* call {@link android.app.Activity#setContentView setContentView()} to
* describe what is to be displayed in the screen.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
// Be sure to call the super class.
super.onCreate(savedInstanceState);
// Restore saved instance state.
if (savedInstanceState != null) {
mSavedPresentationContents = savedInstanceState.getSparseParcelableArray(PRESENTATION_KEY);
} else {
mSavedPresentationContents = new SparseArray<PresentationContents>();
}
// Get the display manager service.
mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
// See assets/res/any/layout/presentation_activity.xml for this
// view layout definition, which is being set here as
// the content of our screen.
setContentView(R.layout.presentation_activity);
// Set up checkbox to toggle between showing all displays or only presentation displays.
mShowAllDisplaysCheckbox = (CheckBox) findViewById(R.id.show_all_displays);
mShowAllDisplaysCheckbox.setOnCheckedChangeListener(this);
// Set up the list of displays.
mDisplayListAdapter = new DisplayListAdapter(this);
mListView = (ListView) findViewById(R.id.display_list);
mListView.setAdapter(mDisplayListAdapter);
}Example 40
| Project: ApkLauncher-master File: PresentationActivity.java View source code |
/**
* Initialization of the Activity after it is first created. Must at least
* call {@link android.app.Activity#setContentView setContentView()} to
* describe what is to be displayed in the screen.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
// Be sure to call the super class.
super.onCreate(savedInstanceState);
// Restore saved instance state.
if (savedInstanceState != null) {
mSavedPresentationContents = savedInstanceState.getSparseParcelableArray(PRESENTATION_KEY);
} else {
mSavedPresentationContents = new SparseArray<PresentationContents>();
}
// Get the display manager service.
mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
// See assets/res/any/layout/presentation_activity.xml for this
// view layout definition, which is being set here as
// the content of our screen.
setContentView(R.layout.presentation_activity);
// Set up checkbox to toggle between showing all displays or only presentation displays.
mShowAllDisplaysCheckbox = (CheckBox) findViewById(R.id.show_all_displays);
mShowAllDisplaysCheckbox.setOnCheckedChangeListener(this);
// Set up the list of displays.
mDisplayListAdapter = new DisplayListAdapter(this);
mListView = (ListView) findViewById(R.id.display_list);
mListView.setAdapter(mDisplayListAdapter);
}Example 41
| Project: ApkLauncher_legacy-master File: PresentationActivity.java View source code |
/**
* Initialization of the Activity after it is first created. Must at least
* call {@link android.app.Activity#setContentView setContentView()} to
* describe what is to be displayed in the screen.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
// Be sure to call the super class.
super.onCreate(savedInstanceState);
// Restore saved instance state.
if (savedInstanceState != null) {
mSavedPresentationContents = savedInstanceState.getSparseParcelableArray(PRESENTATION_KEY);
} else {
mSavedPresentationContents = new SparseArray<PresentationContents>();
}
// Get the display manager service.
mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
// See assets/res/any/layout/presentation_activity.xml for this
// view layout definition, which is being set here as
// the content of our screen.
setContentView(R.layout.presentation_activity);
// Set up checkbox to toggle between showing all displays or only presentation displays.
mShowAllDisplaysCheckbox = (CheckBox) findViewById(R.id.show_all_displays);
mShowAllDisplaysCheckbox.setOnCheckedChangeListener(this);
// Set up the list of displays.
mDisplayListAdapter = new DisplayListAdapter(this);
mListView = (ListView) findViewById(R.id.display_list);
mListView.setAdapter(mDisplayListAdapter);
}Example 42
| Project: cnAndroidDocs-master File: MediaRouter.java View source code |
// Called after sStatic is initialized
void startMonitoringRoutes(Context appContext) {
mDefaultAudioVideo = new RouteInfo(mSystemCategory);
mDefaultAudioVideo.mNameResId = com.android.internal.R.string.default_audio_route_name;
mDefaultAudioVideo.mSupportedTypes = ROUTE_TYPE_LIVE_AUDIO | ROUTE_TYPE_LIVE_VIDEO;
mDefaultAudioVideo.mPresentationDisplay = choosePresentationDisplayForRoute(mDefaultAudioVideo, getAllPresentationDisplays());
addRouteStatic(mDefaultAudioVideo);
// This will select the active wifi display route if there is one.
updateWifiDisplayStatus(mDisplayService.getWifiDisplayStatus());
appContext.registerReceiver(new WifiDisplayStatusChangedReceiver(), new IntentFilter(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED));
appContext.registerReceiver(new VolumeChangeReceiver(), new IntentFilter(AudioManager.VOLUME_CHANGED_ACTION));
mDisplayService.registerDisplayListener(this, mHandler);
AudioRoutesInfo newAudioRoutes = null;
try {
newAudioRoutes = mAudioService.startWatchingRoutes(mAudioRoutesObserver);
} catch (RemoteException e) {
}
if (newAudioRoutes != null) {
// This will select the active BT route if there is one and the current
// selected route is the default system route, or if there is no selected
// route yet.
updateAudioRoutes(newAudioRoutes);
}
// appropriately with relevant system state.
if (mSelectedRoute == null) {
selectRouteStatic(mDefaultAudioVideo.getSupportedTypes(), mDefaultAudioVideo);
}
}Example 43
| Project: DeviceConnect-Android-master File: HostDeviceScreenCast.java View source code |
private void setupVirtualDisplay(final PictureSize size, final VirtualDisplay.Callback callback) {
int w = size.getWidth();
int h = size.getHeight();
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(dm);
if (dm.widthPixels > dm.heightPixels) {
if (w < h) {
w = size.getHeight();
h = size.getWidth();
}
} else {
if (w > h) {
w = size.getHeight();
h = size.getWidth();
}
}
mImageReader = ImageReader.newInstance(w, h, PixelFormat.RGBA_8888, 4);
mVirtualDisplay = mMediaProjection.createVirtualDisplay("Android Host Screen", w, h, mDisplayDensityDpi, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mImageReader.getSurface(), callback, null);
}Example 44
| Project: felix-on-android-master File: PresentationActivity.java View source code |
/**
* Initialization of the Activity after it is first created. Must at least
* call {@link android.app.Activity#setContentView setContentView()} to
* describe what is to be displayed in the screen.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
// Be sure to call the super class.
super.onCreate(savedInstanceState);
// Restore saved instance state.
if (savedInstanceState != null) {
mSavedPresentationContents = savedInstanceState.getSparseParcelableArray(PRESENTATION_KEY);
} else {
mSavedPresentationContents = new SparseArray<PresentationContents>();
}
// Get the display manager service.
mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
// See assets/res/any/layout/presentation_activity.xml for this
// view layout definition, which is being set here as
// the content of our screen.
setContentView(R.layout.presentation_activity);
// Set up checkbox to toggle between showing all displays or only presentation displays.
mShowAllDisplaysCheckbox = (CheckBox) findViewById(R.id.show_all_displays);
mShowAllDisplaysCheckbox.setOnCheckedChangeListener(this);
// Set up the list of displays.
mDisplayListAdapter = new DisplayListAdapter(this);
mListView = (ListView) findViewById(R.id.display_list);
mListView.setAdapter(mDisplayListAdapter);
}Example 45
| Project: GradleCodeLab-master File: PresentationActivity.java View source code |
/**
* Initialization of the Activity after it is first created. Must at least
* call {@link android.app.Activity#setContentView setContentView()} to
* describe what is to be displayed in the screen.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
// Be sure to call the super class.
super.onCreate(savedInstanceState);
// Restore saved instance state.
if (savedInstanceState != null) {
mSavedPresentationContents = savedInstanceState.getSparseParcelableArray(PRESENTATION_KEY);
} else {
mSavedPresentationContents = new SparseArray<PresentationContents>();
}
// Get the display manager service.
mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
// See assets/res/any/layout/presentation_activity.xml for this
// view layout definition, which is being set here as
// the content of our screen.
setContentView(R.layout.presentation_activity);
// Set up checkbox to toggle between showing all displays or only presentation displays.
mShowAllDisplaysCheckbox = (CheckBox) findViewById(R.id.show_all_displays);
mShowAllDisplaysCheckbox.setOnCheckedChangeListener(this);
// Set up the list of displays.
mDisplayListAdapter = new DisplayListAdapter(this);
mListView = (ListView) findViewById(R.id.display_list);
mListView.setAdapter(mDisplayListAdapter);
}Example 46
| Project: mobile-spec-master File: PresentationActivity.java View source code |
/**
* Initialization of the Activity after it is first created. Must at least
* call {@link android.app.Activity#setContentView setContentView()} to
* describe what is to be displayed in the screen.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
// Be sure to call the super class.
super.onCreate(savedInstanceState);
// Restore saved instance state.
if (savedInstanceState != null) {
mSavedPresentationContents = savedInstanceState.getSparseParcelableArray(PRESENTATION_KEY);
} else {
mSavedPresentationContents = new SparseArray<PresentationContents>();
}
// Get the display manager service.
mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
// See assets/res/any/layout/presentation_activity.xml for this
// view layout definition, which is being set here as
// the content of our screen.
setContentView(R.layout.presentation_activity);
// Set up checkbox to toggle between showing all displays or only presentation displays.
mShowAllDisplaysCheckbox = (CheckBox) findViewById(R.id.show_all_displays);
mShowAllDisplaysCheckbox.setOnCheckedChangeListener(this);
// Set up the list of displays.
mDisplayListAdapter = new DisplayListAdapter(this);
mListView = (ListView) findViewById(R.id.display_list);
mListView.setAdapter(mDisplayListAdapter);
}Example 47
| Project: property-db-master File: MediaRouter.java View source code |
// Called after sStatic is initialized
void startMonitoringRoutes(Context appContext) {
mDefaultAudioVideo = new RouteInfo(mSystemCategory);
mDefaultAudioVideo.mNameResId = com.android.internal.R.string.default_audio_route_name;
mDefaultAudioVideo.mSupportedTypes = ROUTE_TYPE_LIVE_AUDIO | ROUTE_TYPE_LIVE_VIDEO;
mDefaultAudioVideo.mPresentationDisplay = choosePresentationDisplayForRoute(mDefaultAudioVideo, getAllPresentationDisplays());
addRouteStatic(mDefaultAudioVideo);
// This will select the active wifi display route if there is one.
updateWifiDisplayStatus(mDisplayService.getWifiDisplayStatus());
appContext.registerReceiver(new WifiDisplayStatusChangedReceiver(), new IntentFilter(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED));
appContext.registerReceiver(new VolumeChangeReceiver(), new IntentFilter(AudioManager.VOLUME_CHANGED_ACTION));
mDisplayService.registerDisplayListener(this, mHandler);
AudioRoutesInfo newAudioRoutes = null;
try {
newAudioRoutes = mAudioService.startWatchingRoutes(mAudioRoutesObserver);
} catch (RemoteException e) {
}
if (newAudioRoutes != null) {
// This will select the active BT route if there is one and the current
// selected route is the default system route, or if there is no selected
// route yet.
updateAudioRoutes(newAudioRoutes);
}
// appropriately with relevant system state.
if (mSelectedRoute == null) {
selectRouteStatic(mDefaultAudioVideo.getSupportedTypes(), mDefaultAudioVideo);
}
}Example 48
| Project: tango-examples-java-master File: PointToPointActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSurfaceView = (SurfaceView) findViewById(R.id.ar_view);
mRenderer = new PointToPointRenderer(this);
mSurfaceView.setSurfaceRenderer(mRenderer);
mSurfaceView.setOnTouchListener(this);
mPointCloudManager = new TangoPointCloudManager();
mDistanceMeasure = (TextView) findViewById(R.id.distance_textview);
mBilateralBox = (CheckBox) findViewById(R.id.check_box);
mLinePoints[0] = null;
mLinePoints[1] = null;
DisplayManager displayManager = (DisplayManager) getSystemService(DISPLAY_SERVICE);
if (displayManager != null) {
displayManager.registerDisplayListener(new DisplayManager.DisplayListener() {
@Override
public void onDisplayAdded(int displayId) {
}
@Override
public void onDisplayChanged(int displayId) {
synchronized (this) {
setDisplayRotation();
}
}
@Override
public void onDisplayRemoved(int displayId) {
}
}, null);
}
}Example 49
| Project: ApiDemos-master File: PresentationActivity.java View source code |
/**
* Initialization of the Activity after it is first created. Must at least
* call {@link android.app.Activity#setContentView setContentView()} to
* describe what is to be displayed in the screen.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
// Be sure to call the super class.
super.onCreate(savedInstanceState);
// Restore saved instance state.
if (savedInstanceState != null) {
mSavedPresentationContents = savedInstanceState.getSparseParcelableArray(PRESENTATION_KEY);
} else {
mSavedPresentationContents = new SparseArray<>();
}
// Get the display manager service.
mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
// See assets/res/any/layout/presentation_activity.xml for this
// view layout definition, which is being set here as
// the content of our screen.
setContentView(R.layout.presentation_activity);
// Set up checkbox to toggle between showing all displays or only presentation displays.
mShowAllDisplaysCheckbox = (CheckBox) findViewById(R.id.show_all_displays);
mShowAllDisplaysCheckbox.setOnCheckedChangeListener(this);
// Set up the list of displays.
mDisplayListAdapter = new DisplayListAdapter(this);
mListView = (ListView) findViewById(R.id.display_list);
mListView.setAdapter(mDisplayListAdapter);
}Example 50
| Project: packages_apps_settings-master File: WifiDisplaySettings.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
final Context context = getActivity();
mRouter = (MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
mDisplayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
mWifiP2pManager = (WifiP2pManager) context.getSystemService(Context.WIFI_P2P_SERVICE);
mWifiP2pChannel = mWifiP2pManager.initialize(context, Looper.getMainLooper(), null);
addPreferencesFromResource(R.xml.wifi_display_settings);
setHasOptionsMenu(true);
}Example 51
| Project: platform_packages_apps_settings-master File: WifiDisplaySettings.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
final Context context = getActivity();
mRouter = (MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
mDisplayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
mWifiP2pManager = (WifiP2pManager) context.getSystemService(Context.WIFI_P2P_SERVICE);
mWifiP2pChannel = mWifiP2pManager.initialize(context, Looper.getMainLooper(), null);
addPreferencesFromResource(R.xml.wifi_display_settings);
setHasOptionsMenu(true);
}Example 52
| Project: SmarterStreaming-master File: BackgroudService.java View source code |
@SuppressLint("NewApi")
private void setupVirtualDisplay() {
mVirtualDisplay = mMediaProjection.createVirtualDisplay("ScreenCapture", sreenWindowWidth, screenWindowHeight, mScreenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mImageReader.getSurface(), null, null);
mImageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
@Override
public void onImageAvailable(ImageReader reader) {
Image image = mImageReader.acquireLatestImage();
if (image != null) {
processScreenImage(image);
image.close();
}
}
}, null);
}Example 53
| Project: telescope-master File: TelescopeLayout.java View source code |
@Override
public void run() {
DisplayMetrics displayMetrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getRealMetrics(displayMetrics);
final int width = displayMetrics.widthPixels;
final int height = displayMetrics.heightPixels;
ImageReader imageReader = ImageReader.newInstance(width, height, PixelFormat.RGBA_8888, 2);
Surface surface = imageReader.getSurface();
final VirtualDisplay display = projection.createVirtualDisplay("telescope", width, height, displayMetrics.densityDpi, DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION, surface, null, null);
imageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
@Override
public void onImageAvailable(ImageReader reader) {
Image image = null;
Bitmap bitmap = null;
try {
image = reader.acquireLatestImage();
post(new Runnable() {
@Override
public void run() {
capturingEnd();
}
});
if (image == null) {
return;
}
saving = true;
Image.Plane[] planes = image.getPlanes();
ByteBuffer buffer = planes[0].getBuffer();
int pixelStride = planes[0].getPixelStride();
int rowStride = planes[0].getRowStride();
int rowPadding = rowStride - pixelStride * width;
bitmap = Bitmap.createBitmap(width + rowPadding / pixelStride, height, Bitmap.Config.ARGB_8888);
bitmap.copyPixelsFromBuffer(buffer);
// Trim the screenshot to the correct size.
final Bitmap croppedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height);
checkLens();
lens.onCapture(croppedBitmap, new BitmapProcessorListener() {
@Override
public void onBitmapReady(Bitmap screenshot) {
new SaveScreenshotTask(croppedBitmap).execute();
}
});
} catch (UnsupportedOperationException e) {
Log.e(TAG, "Failed to capture system screenshot. Setting the screenshot mode to CANVAS.", e);
setScreenshotMode(ScreenshotMode.CANVAS);
post(new Runnable() {
@Override
public void run() {
captureCanvasScreenshot();
}
});
} finally {
if (bitmap != null) {
bitmap.recycle();
}
if (image != null) {
image.close();
}
reader.close();
display.release();
projection.stop();
}
}
}, getBackgroundHandler());
}Example 54
| Project: wheelmap-android-master File: TangoMeasureActivity.java View source code |
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.tango_activity);
renderer = new WheelmapTangoRajawaliRenderer(this);
tangoUx = setupTangoUx(savedInstanceState);
connectRenderer();
setupUiOverlay();
presenter = new TangoMeasurePresenter(this);
DisplayManager displayManager = (DisplayManager) getSystemService(DISPLAY_SERVICE);
if (displayManager != null) {
displayManager.registerDisplayListener(new DisplayManager.DisplayListener() {
@Override
public void onDisplayAdded(int displayId) {
}
@Override
public void onDisplayChanged(int displayId) {
synchronized (this) {
setDisplayRotation();
}
}
@Override
public void onDisplayRemoved(int displayId) {
}
}, null);
}
}Example 55
| Project: OpenSongTablet-master File: PresenterMode.java View source code |
public void updateDisplays() {
// This is called when display devices are changed (connected, disconnected, etc.)
displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
presentationDisplays = displayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);
// Get the media router service.
mMediaRouter = (MediaRouter) getSystemService(Context.MEDIA_ROUTER_SERVICE);
numdisplays = presentationDisplays.length;
if (numdisplays == 0) {
if (firsttime) {
firsttime = false;
FullscreenActivity.myToastMessage = getResources().getText(R.string.nodisplays).toString();
ShowToast.showToast(PresenterMode.this);
}
//Disable buttons that may throw an error....
// projectButton.setClickable(false);
} else {
if (firsttime) {
firsttime = false;
FullscreenActivity.myToastMessage = getResources().getText(R.string.extradisplay).toString();
ShowToast.showToast(PresenterMode.this);
}
//Activate present and logo button
//projectButton.setClickable(true);
}
for (Display display : presentationDisplays) {
MyPresentation mPresentation = new MyPresentation(this, display);
mPresentation.show();
}
}Example 56
| Project: android-support-library-archive-master File: DisplayManagerJellybeanMr1.java View source code |
public static Display getDisplay(Object displayManagerObj, int displayId) {
return ((android.hardware.display.DisplayManager) displayManagerObj).getDisplay(displayId);
}Example 57
| Project: bitcast-master File: DisplayManagerJellybeanMr1.java View source code |
public static Display getDisplay(Object displayManagerObj, int displayId) {
return ((android.hardware.display.DisplayManager) displayManagerObj).getDisplay(displayId);
}Example 58
| Project: CodenameOne-master File: DisplayManagerJellybeanMr1.java View source code |
public static Display getDisplay(Object displayManagerObj, int displayId) {
return ((android.hardware.display.DisplayManager) displayManagerObj).getDisplay(displayId);
}Example 59
| Project: guideshow-master File: DisplayManagerJellybeanMr1.java View source code |
public static Display getDisplay(Object displayManagerObj, int displayId) {
return ((android.hardware.display.DisplayManager) displayManagerObj).getDisplay(displayId);
}Example 60
| Project: MapsUtilityDemo-master File: DisplayManagerJellybeanMr1.java View source code |
public static Display getDisplay(Object displayManagerObj, int displayId) {
return ((android.hardware.display.DisplayManager) displayManagerObj).getDisplay(displayId);
}Example 61
| Project: MDPi-master File: DisplayManagerJellybeanMr1.java View source code |
public static Display getDisplay(Object displayManagerObj, int displayId) {
return ((android.hardware.display.DisplayManager) displayManagerObj).getDisplay(displayId);
}Example 62
| Project: tomboy.android-master File: DisplayManagerJellybeanMr1.java View source code |
public static Display getDisplay(Object displayManagerObj, int displayId) {
return ((android.hardware.display.DisplayManager) displayManagerObj).getDisplay(displayId);
}Example 63
| Project: V.FlyoutTest-master File: DisplayManagerJellybeanMr1.java View source code |
public static Display getDisplay(Object displayManagerObj, int displayId) {
return ((android.hardware.display.DisplayManager) displayManagerObj).getDisplay(displayId);
}Example 64
| Project: MiBandDecompiled-master File: c.java View source code |
public static Display a(Object obj, int i) {
return ((DisplayManager) obj).getDisplay(i);
}Example 65
| Project: WiFi-Automatic-master File: APILevel20Wrapper.java View source code |
static boolean isScreenOn(final Context context) {
DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
for (Display display : dm.getDisplays()) {
if (display.getState() != Display.STATE_OFF) {
return true;
}
}
return false;
}Example 66
| Project: nexus-camera-master File: CameraRootView.java View source code |
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
if (ApiHelper.HAS_DISPLAY_LISTENER) {
((DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE)).registerDisplayListener((DisplayListener) mDisplayListener, null);
}
}Example 67
| Project: ulti-master File: WatchFaceActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up the display manager and register a listener (this activity).
displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
// displayManager.registerDisplayListener(this, null);
}Example 68
| Project: UltimateAndroid-master File: WatchFaceActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up the display manager and register a listener (this activity).
displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
// displayManager.registerDisplayListener(this, null);
}Example 69
| Project: Yhb-2.0-master File: WatchFaceActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up the display manager and register a listener (this activity).
displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
// displayManager.registerDisplayListener(this, null);
}Example 70
| Project: Android4.4Camera-master File: CameraRootView.java View source code |
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
if (ApiHelper.HAS_DISPLAY_LISTENER) {
((DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE)).registerDisplayListener((DisplayListener) mDisplayListener, null);
}
}Example 71
| Project: AndroidBaseUtils-master File: ServiceUtil.java View source code |
@TargetApi(17) public static DisplayManager getDisplayManager() { return (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); }
Example 72
| Project: yotacast-master File: BSDrawer.java View source code |
private static Display getEpdDisplay(Context context) {
DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
for (Display d : dm.getDisplays()) {
if (getTypeDisplay(d) == TYPE_DISPLAY_EPD) {
return d;
}
}
return null;
}Example 73
| Project: Lanucher3-master File: WallpaperPickerActivity.java View source code |
public static boolean isSmartBookPluggedIn(Context mContext) {
if (FeatureOption.MTK_SMARTBOOK_SUPPORT) {
DisplayManager mDisplayManager = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE);
return mDisplayManager.isSmartBookPluggedIn();
} else {
return false;
}
}Example 74
| Project: packages-apps-Contacts-master File: MultiShrinkScroller.java View source code |
private float getRefreshRate() {
final DisplayManager displayManager = (DisplayManager) MultiShrinkScroller.this.getContext().getSystemService(Context.DISPLAY_SERVICE);
return displayManager.getDisplay(Display.DEFAULT_DISPLAY).getRefreshRate();
}Example 75
| Project: platform_packages_apps_contacts-master File: MultiShrinkScroller.java View source code |
private float getRefreshRate() {
final DisplayManager displayManager = (DisplayManager) MultiShrinkScroller.this.getContext().getSystemService(Context.DISPLAY_SERVICE);
return displayManager.getDisplay(Display.DEFAULT_DISPLAY).getRefreshRate();
}