List of usage examples for android.content Context DISPLAY_SERVICE
String DISPLAY_SERVICE
To view the source code for android.content Context DISPLAY_SERVICE.
Click Source Link
From source file:com.mathi_amorim.emmanuel.metrictime.UpdateTimeService.java
public boolean isScreenOn() { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { DisplayManager dm = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); boolean screenOn = false; for (Display display : dm.getDisplays()) { if (display.getState() != Display.STATE_OFF) { screenOn = true;/*from www .ja v a 2s. co m*/ } } return screenOn; } else { PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); //noinspection deprecation return pm.isScreenOn(); } }
From source file:com.quectel.presentationtest.PresentationTest.java
/** * 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. *//* ww w.j a v a2 s. c o m*/ @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<DemoPresentationContents>(); } // 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); mDetector = new GestureDetectorCompat(this, new MyGestureListener()); // 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); }
From source file:com.sssemil.advancedsettings.MainService.java
@Override public void onCreate() { super.onCreate(); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); mDisplayManager.registerDisplayListener(this, null); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); registerReceiver(mReceiver, filter); filter = new IntentFilter(); filter.addAction("android.intent.action.ACTION_SHUTDOWN"); registerReceiver(mReceiverOnPowerOff, filter); int timeout = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(this) .getString("screen_timeout_settings", String.valueOf( Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 0)))); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, timeout); }/* w ww . j a va 2 s. c om*/ String app = mSharedPreferences.getString("on_theatre_mode_launch_app", "null"); if (!app.equals("null") && !Utils.isPackageInstalled(app, this, 0)) { mSharedPreferences.edit().putString("on_theatre_mode_launch_app", "null").apply(); } new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(30000); } catch (InterruptedException e) { e.printStackTrace(); } try { Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(MainService.this) .getString("screen_timeout_settings", String.valueOf(Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 0))))); } catch (SecurityException e) { e.printStackTrace(); } } }).start(); //language settings provider installer new Thread(new Runnable() { @Override public void run() { try { if (!Utils.isPackageInstalled("sssemil.com.languagesettingsprovider", MainService.this, LANG_PROVIDER_VERSION_CODE)) { File apk = new File(Environment.getExternalStorageDirectory(), "wear_languagesettingsprovider-release.apk"); if (apk.exists()) { Log.i(TAG, "apk exists"); apk.delete(); } InputStream inputStream = getAssets().open("wear_languagesettingsprovider-release.apk"); FileOutputStream file = new FileOutputStream(apk); byte buf[] = new byte[4096]; int len = inputStream.read(buf); while (len > 0) { file.write(buf, 0, len); len = inputStream.read(buf); } file.close(); if (apk.exists()) { Log.i(TAG, "installing...."); ShellUtils.CommandResult result = ShellUtils .execCommand("su -c pm install -r " + apk.getPath(), true); if (result.errorMsg == null) { Log.i(TAG, "done"); } else { Log.e(TAG, "failed?"); } } } } catch (IOException e) { e.printStackTrace(); } } }).start(); //vibration intensity stuff try { int amp = Integer.parseInt(mSharedPreferences.getString("vibration_intensity", String.valueOf(Utils.getDeviceCfg(MainService.this).vibroIntensetyDefault))); ProcessBuilder pb = new ProcessBuilder("su", "-c", "echo", amp + ">", Utils.getDeviceCfg(MainService.this).vibroIntensetyPath); pb.start().waitFor(); } catch (InterruptedException | IOException | NullPointerException e) { Log.d(TAG, "catch " + e.toString() + " hit in run", e); } /*new Thread(new Runnable() { @Override public void run() { while (true) { try { Thread.sleep(1000); int i = Settings.Global.getInt(getContentResolver(), "theater_mode_on"); Log.i("theater_mode_on", String.valueOf(i)); } catch (Settings.SettingNotFoundException | InterruptedException e) { e.printStackTrace(); } } } }).start();*/ GlobalContentObserver contentObserver = new GlobalContentObserver(new Handler()); this.getApplicationContext().getContentResolver() .registerContentObserver(android.provider.Settings.Global.CONTENT_URI, true, contentObserver); }
From source file:com.farmerbb.taskbar.adapter.StartMenuAdapter.java
@SuppressWarnings("deprecation") private void openContextMenu(final AppEntry entry, final int[] location) { LocalBroadcastManager.getInstance(getContext()) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); new Handler().postDelayed(() -> { SharedPreferences pref = U.getSharedPreferences(getContext()); Intent intent = null;// w w w.j av a2 s . com switch (pref.getString("theme", "light")) { case "light": intent = new Intent(getContext(), ContextMenuActivity.class); break; case "dark": intent = new Intent(getContext(), ContextMenuActivityDark.class); break; } if (intent != null) { intent.putExtra("package_name", entry.getPackageName()); intent.putExtra("app_name", entry.getLabel()); intent.putExtra("component_name", entry.getComponentName()); intent.putExtra("user_id", entry.getUserId(getContext())); intent.putExtra("launched_from_start_menu", true); intent.putExtra("x", location[0]); intent.putExtra("y", location[1]); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && FreeformHackHelper.getInstance().isInFreeformWorkspace()) { DisplayManager dm = (DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE); Display display = dm.getDisplay(Display.DEFAULT_DISPLAY); if (intent != null && U.isOPreview()) intent.putExtra("context_menu_fix", true); getContext().startActivity(intent, U.getActivityOptions(ApplicationType.CONTEXT_MENU) .setLaunchBounds(new Rect(0, 0, display.getWidth(), display.getHeight())).toBundle()); } else getContext().startActivity(intent); }, shouldDelay() ? 100 : 0); }
From source file:com.nick.scalpel.core.AutoFoundWirer.java
private void wireFromContext(Context context, AutoFound.Type type, int idRes, Resources.Theme theme, Field field, Object forWho) { Resources resources = context.getResources(); switch (type) { case STRING://w w w. j av a 2 s . co m setField(field, forWho, resources.getString(idRes)); break; case COLOR: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, resources.getColor(idRes, theme)); } else { //noinspection deprecation setField(field, forWho, resources.getColor(idRes)); } break; case INTEGER: setField(field, forWho, resources.getInteger(idRes)); break; case BOOL: setField(field, forWho, resources.getBoolean(idRes)); break; case STRING_ARRAY: setField(field, forWho, resources.getStringArray(idRes)); break; case INT_ARRAY: setField(field, forWho, resources.getIntArray(idRes)); break; case PM: setField(field, forWho, context.getSystemService(Context.POWER_SERVICE)); break; case ACCOUNT: setField(field, forWho, context.getSystemService(Context.ACCOUNT_SERVICE)); break; case ALARM: setField(field, forWho, context.getSystemService(Context.ALARM_SERVICE)); break; case AM: setField(field, forWho, context.getSystemService(Context.ACTIVITY_SERVICE)); break; case WM: setField(field, forWho, context.getSystemService(Context.WINDOW_SERVICE)); break; case NM: setField(field, forWho, context.getSystemService(Context.NOTIFICATION_SERVICE)); break; case TM: setField(field, forWho, context.getSystemService(Context.TELEPHONY_SERVICE)); break; case TCM: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.TELECOM_SERVICE)); } break; case SP: setField(field, forWho, PreferenceManager.getDefaultSharedPreferences(context)); break; case PKM: setField(field, forWho, context.getPackageManager()); break; case HANDLE: setField(field, forWho, new Handler(Looper.getMainLooper())); break; case ASM: setField(field, forWho, context.getSystemService(Context.ACCESSIBILITY_SERVICE)); break; case CAP: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setField(field, forWho, context.getSystemService(Context.CAPTIONING_SERVICE)); } break; case KGD: setField(field, forWho, context.getSystemService(Context.KEYGUARD_SERVICE)); break; case LOCATION: setField(field, forWho, context.getSystemService(Context.LOCATION_SERVICE)); break; case SEARCH: setField(field, forWho, context.getSystemService(Context.SEARCH_SERVICE)); break; case SENSOR: setField(field, forWho, context.getSystemService(Context.SENSOR_SERVICE)); break; case STORAGE: setField(field, forWho, context.getSystemService(Context.STORAGE_SERVICE)); break; case WALLPAPER: setField(field, forWho, context.getSystemService(Context.WALLPAPER_SERVICE)); break; case VIBRATOR: setField(field, forWho, context.getSystemService(Context.VIBRATOR_SERVICE)); break; case CONNECT: setField(field, forWho, context.getSystemService(Context.CONNECTIVITY_SERVICE)); break; case NETWORK_STATUS: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, context.getSystemService(Context.NETWORK_STATS_SERVICE)); } break; case WIFI: setField(field, forWho, context.getSystemService(Context.WIFI_SERVICE)); break; case AUDIO: setField(field, forWho, context.getSystemService(Context.AUDIO_SERVICE)); break; case FP: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, context.getSystemService(Context.FINGERPRINT_SERVICE)); } break; case MEDIA_ROUTER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { setField(field, forWho, context.getSystemService(Context.MEDIA_ROUTER_SERVICE)); } break; case SUB: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { setField(field, forWho, context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)); } break; case IME: setField(field, forWho, context.getSystemService(Context.INPUT_METHOD_SERVICE)); break; case CLIP_BOARD: setField(field, forWho, context.getSystemService(Context.CLIPBOARD_SERVICE)); break; case APP_WIDGET: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.APPWIDGET_SERVICE)); } break; case DEVICE_POLICY: setField(field, forWho, context.getSystemService(Context.DEVICE_POLICY_SERVICE)); break; case DOWNLOAD: setField(field, forWho, context.getSystemService(Context.DOWNLOAD_SERVICE)); break; case BATTERY: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.BATTERY_SERVICE)); } break; case NFC: setField(field, forWho, context.getSystemService(Context.NFC_SERVICE)); break; case DISPLAY: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setField(field, forWho, context.getSystemService(Context.DISPLAY_SERVICE)); } break; case USER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setField(field, forWho, context.getSystemService(Context.USER_SERVICE)); } break; case APP_OPS: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setField(field, forWho, context.getSystemService(Context.APP_OPS_SERVICE)); } break; case BITMAP: setField(field, forWho, BitmapFactory.decodeResource(resources, idRes, null)); break; } }
From source file:com.sssemil.advancedsettings.MainService.java
@Override public void onDisplayChanged(int displayId) { try {//from ww w . j av a2 s . co m mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); mDisplayManager.registerDisplayListener(MainService.this, null); switch (mDisplayManager.getDisplay(displayId).getState()) { case Display.STATE_DOZE_SUSPEND: case Display.STATE_DOZE: try { //TODO: Need to fix screen_saver_brightness_settings. SELinux problems? Thread.sleep(3); int brightness = Integer .parseInt(mSharedPreferences.getString("screen_saver_brightness_settings", String.valueOf(Utils.getDeviceCfg(MainService.this).brightnessDefault))); boolean do_brightness = mSharedPreferences.getBoolean("manage_screen_saver_brightness_settings", false); if (do_brightness) { Log.i(TAG, "echo \"" + brightness + "\" > " + Utils.getDeviceCfg(MainService.this).brightnessPath); Runtime rt = Runtime.getRuntime(); String[] commands = { "su", "-c", "echo \"" + brightness + "\" > " + Utils.getDeviceCfg(MainService.this).brightnessPath }; Process proc = rt.exec(commands); BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(proc.getErrorStream())); String s; while ((s = stdInput.readLine()) != null) { System.out.println(s); } while ((s = stdError.readLine()) != null) { System.out.println(s); } } } catch (IOException | InterruptedException e) { if (BuildConfig.DEBUG) { Log.d(TAG, "catch " + e.toString() + " hit in run", e); } } /*PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "WakeLock"); wakeLock.acquire();*/ break; default: break; } } catch (NullPointerException e) { e.printStackTrace(); } }
From source file:com.android.tv.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (DEBUG)/*ww w. ja v a 2 s. c om*/ Log.d(TAG, "onCreate()"); super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M && !PermissionUtils.hasAccessAllEpg(this)) { Toast.makeText(this, R.string.msg_not_supported_device, Toast.LENGTH_LONG).show(); finish(); return; } boolean skipToShowOnboarding = getIntent().getAction() == Intent.ACTION_VIEW && TvContract.isChannelUriForPassthroughInput(getIntent().getData()); if (Features.ONBOARDING_EXPERIENCE.isEnabled(this) && OnboardingUtils.needToShowOnboarding(this) && !skipToShowOnboarding && !TvCommonUtils.isRunningInTest()) { // TODO: The onboarding is turned off in test, because tests are broken by the // onboarding. We need to enable the feature for tests later. startActivity(OnboardingActivity.buildIntent(this, getIntent())); finish(); return; } TvApplication tvApplication = (TvApplication) getApplication(); tvApplication.getMainActivityWrapper().onMainActivityCreated(this); if (BuildConfig.ENG && SystemProperties.ALLOW_STRICT_MODE.getValue()) { Toast.makeText(this, "Using Strict Mode for eng builds", Toast.LENGTH_SHORT).show(); } mTracker = tvApplication.getTracker(); mTvInputManagerHelper = tvApplication.getTvInputManagerHelper(); mTvInputManagerHelper.addCallback(mTvInputCallback); mUsbTunerInputId = UsbTunerTvInputService.getInputId(this); mChannelDataManager = tvApplication.getChannelDataManager(); mProgramDataManager = tvApplication.getProgramDataManager(); mProgramDataManager.addOnCurrentProgramUpdatedListener(Channel.INVALID_ID, mOnCurrentProgramUpdatedListener); mProgramDataManager.setPrefetchEnabled(true); mChannelTuner = new ChannelTuner(mChannelDataManager, mTvInputManagerHelper); mChannelTuner.addListener(mChannelTunerListener); mChannelTuner.start(); mPipInputManager = new PipInputManager(this, mTvInputManagerHelper, mChannelTuner); mPipInputManager.start(); mMemoryManageables.add(mProgramDataManager); mMemoryManageables.add(ImageCache.getInstance()); mMemoryManageables.add(TvContentRatingCache.getInstance()); if (CommonFeatures.DVR.isEnabled(this) && BuildCompat.isAtLeastN()) { mDvrManager = tvApplication.getDvrManager(); mDvrDataManager = tvApplication.getDvrDataManager(); } DisplayManager displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY); Point size = new Point(); display.getSize(size); int screenWidth = size.x; int screenHeight = size.y; mDefaultRefreshRate = display.getRefreshRate(); mOverlayRootView = (OverlayRootView) getLayoutInflater().inflate(R.layout.overlay_root_view, null, false); setContentView(R.layout.activity_tv); mTvView = (TunableTvView) findViewById(R.id.main_tunable_tv_view); int shrunkenTvViewHeight = getResources().getDimensionPixelSize(R.dimen.shrunken_tvview_height); mTvView.initialize((AppLayerTvView) findViewById(R.id.main_tv_view), false, screenHeight, shrunkenTvViewHeight); mTvView.setOnUnhandledInputEventListener(new OnUnhandledInputEventListener() { @Override public boolean onUnhandledInputEvent(InputEvent event) { if (isKeyEventBlocked()) { return true; } if (event instanceof KeyEvent) { KeyEvent keyEvent = (KeyEvent) event; if (keyEvent.getAction() == KeyEvent.ACTION_DOWN && keyEvent.isLongPress()) { if (onKeyLongPress(keyEvent.getKeyCode(), keyEvent)) { return true; } } if (keyEvent.getAction() == KeyEvent.ACTION_UP) { return onKeyUp(keyEvent.getKeyCode(), keyEvent); } else if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) { return onKeyDown(keyEvent.getKeyCode(), keyEvent); } } return false; } }); mTimeShiftManager = new TimeShiftManager(this, mTvView, mProgramDataManager, mTracker, new OnCurrentProgramUpdatedListener() { @Override public void onCurrentProgramUpdated(long channelId, Program program) { updateMediaSession(); switch (mTimeShiftManager.getLastActionId()) { case TimeShiftManager.TIME_SHIFT_ACTION_ID_REWIND: case TimeShiftManager.TIME_SHIFT_ACTION_ID_FAST_FORWARD: case TimeShiftManager.TIME_SHIFT_ACTION_ID_JUMP_TO_PREVIOUS: case TimeShiftManager.TIME_SHIFT_ACTION_ID_JUMP_TO_NEXT: updateChannelBannerAndShowIfNeeded(UPDATE_CHANNEL_BANNER_REASON_FORCE_SHOW); break; default: updateChannelBannerAndShowIfNeeded(UPDATE_CHANNEL_BANNER_REASON_UPDATE_INFO); break; } } }); mPipView = (TunableTvView) findViewById(R.id.pip_tunable_tv_view); mPipView.initialize((AppLayerTvView) findViewById(R.id.pip_tv_view), true, screenHeight, shrunkenTvViewHeight); if (!PermissionUtils.hasAccessWatchedHistory(this)) { WatchedHistoryManager watchedHistoryManager = new WatchedHistoryManager(getApplicationContext()); watchedHistoryManager.start(); mTvView.setWatchedHistoryManager(watchedHistoryManager); } mTvViewUiManager = new TvViewUiManager(this, mTvView, mPipView, (FrameLayout) findViewById(android.R.id.content), mTvOptionsManager); mPipView.setFixedSurfaceSize(screenWidth / 2, screenHeight / 2); mPipView.setBlockScreenType(TunableTvView.BLOCK_SCREEN_TYPE_SHRUNKEN_TV_VIEW); ViewGroup sceneContainer = (ViewGroup) findViewById(R.id.scene_container); mChannelBannerView = (ChannelBannerView) getLayoutInflater().inflate(R.layout.channel_banner, sceneContainer, false); mKeypadChannelSwitchView = (KeypadChannelSwitchView) getLayoutInflater() .inflate(R.layout.keypad_channel_switch, sceneContainer, false); InputBannerView inputBannerView = (InputBannerView) getLayoutInflater().inflate(R.layout.input_banner, sceneContainer, false); SelectInputView selectInputView = (SelectInputView) getLayoutInflater().inflate(R.layout.select_input, sceneContainer, false); selectInputView.setOnInputSelectedCallback(new OnInputSelectedCallback() { @Override public void onTunerInputSelected() { Channel currentChannel = mChannelTuner.getCurrentChannel(); if (currentChannel != null && !currentChannel.isPassthrough()) { hideOverlays(); } else { tuneToLastWatchedChannelForTunerInput(); } } @Override public void onPassthroughInputSelected(TvInputInfo input) { Channel currentChannel = mChannelTuner.getCurrentChannel(); String currentInputId = currentChannel == null ? null : currentChannel.getInputId(); if (TextUtils.equals(input.getId(), currentInputId)) { hideOverlays(); } else { tuneToChannel(Channel.createPassthroughChannel(input.getId())); } } private void hideOverlays() { getOverlayManager().hideOverlays(TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_DIALOG | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_SIDE_PANELS | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_PROGRAM_GUIDE | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_MENU | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_FRAGMENT); } }); mSearchFragment = new ProgramGuideSearchFragment(); mOverlayManager = new TvOverlayManager(this, mChannelTuner, mKeypadChannelSwitchView, mChannelBannerView, inputBannerView, selectInputView, sceneContainer, mSearchFragment); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mAudioFocusStatus = AudioManager.AUDIOFOCUS_LOSS; mMediaSession = new MediaSession(this, MEDIA_SESSION_TAG); mMediaSession.setCallback(new MediaSession.Callback() { @Override public boolean onMediaButtonEvent(Intent mediaButtonIntent) { // Consume the media button event here. Should not send it to other apps. return true; } }); mMediaSession .setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS); mNowPlayingCardWidth = getResources().getDimensionPixelSize(R.dimen.notif_card_img_max_width); mNowPlayingCardHeight = getResources().getDimensionPixelSize(R.dimen.notif_card_img_height); mTvViewUiManager.restoreDisplayMode(false); if (!handleIntent(getIntent())) { finish(); return; } mAudioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, new AudioCapabilitiesReceiver.OnAc3PassthroughCapabilityChangeListener() { @Override public void onAc3PassthroughCapabilityChange(boolean capability) { mAc3PassthroughSupported = capability; } }); mAudioCapabilitiesReceiver.register(); mAccessibilityManager = (AccessibilityManager) getSystemService(Context.ACCESSIBILITY_SERVICE); mSendConfigInfoRecurringRunner = new RecurringRunner(this, TimeUnit.DAYS.toMillis(1), new SendConfigInfoRunnable(mTracker, mTvInputManagerHelper), null); mSendConfigInfoRecurringRunner.start(); mChannelStatusRecurringRunner = SendChannelStatusRunnable.startChannelStatusRecurringRunner(this, mTracker, mChannelDataManager); // To avoid not updating Rating systems when changing language. mTvInputManagerHelper.getContentRatingsManager().update(); initForTest(); }
From source file:com.android.tv.MainActivity.java
private void applyDisplayRefreshRate(float videoFrameRate) { boolean is24Fps = Math.abs(videoFrameRate - FRAME_RATE_FOR_FILM) < FRAME_RATE_EPSILON; if (mIsFilmModeSet && !is24Fps) { setPreferredRefreshRate(mDefaultRefreshRate); mIsFilmModeSet = false;/* w w w . j a v a 2 s . c om*/ } else if (!mIsFilmModeSet && is24Fps) { DisplayManager displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY); float[] refreshRates = display.getSupportedRefreshRates(); for (float refreshRate : refreshRates) { // Be conservative and set only when the display refresh rate supports 24fps. if (Math.abs(videoFrameRate - refreshRate) < REFRESH_RATE_EPSILON) { setPreferredRefreshRate(refreshRate); mIsFilmModeSet = true; return; } } } }