@Override public void onCreate() { // Pick status bar or system bar. IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService(Context.WINDOW_SERVICE)); try { SERVICES[0] = wm.canStatusBarHide() // ? R.string.config_statusBarComponent ? R.string.config_systemBarComponent : R.string.config_systemBarComponent; } catch (RemoteException e) { Slog.w(TAG, "Failing checking whether status bar can hide", e); } final int N = SERVICES.length; mServices = new SystemUI[N]; for (int i = 0; i < N; i++) { Class cl = chooseClass(SERVICES[i]); Slog.d(TAG, "loading: " + cl); try { mServices[i] = (SystemUI) cl.newInstance(); } catch (IllegalAccessException ex) { throw new RuntimeException(ex); } catch (InstantiationException ex) { throw new RuntimeException(ex); } mServices[i].mContext = this; Slog.d(TAG, "running: " + mServices[i]); mServices[i].start(); } }
private int getCurrentDensity() { IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.checkService(Context.WINDOW_SERVICE)); try { return wm.getBaseDisplayDensity(Display.DEFAULT_DISPLAY); } catch (RemoteException e) { e.printStackTrace(); } return DisplayMetrics.DENSITY_DEVICE; }
private void storeRotationStateLocked() { try { if (mWindowManager.isRotationFrozen()) { // Calling out with a lock held is fine since if the system // process is gone the client calling in will be killed. mInitialFrozenRotation = mWindowManager.getRotation(); } } catch (RemoteException re) { /* ignore */ } }
private void restoreRotationStateLocked() { try { if (mInitialFrozenRotation != INITIAL_FROZEN_ROTATION_UNSPECIFIED) { // Calling out with a lock held is fine since if the system // process is gone the client calling in will be killed. mWindowManager.freezeRotation(mInitialFrozenRotation); } else { // Calling out with a lock held is fine since if the system // process is gone the client calling in will be killed. mWindowManager.thawRotation(); } } catch (RemoteException re) { /* ignore */ } }
private void writeAnimationScaleOption(int which, ListPreference pref, Object newValue) { try { float scale = Float.parseFloat(newValue.toString()); mWindowManager.setAnimationScale(which, scale); updateAnimationScaleValue(which, pref); } catch (RemoteException e) { } }
private void handleToggleAutoRotateScreenPreferenceClick() { boolean enableDefaultRotation = getResources().getBoolean(R.bool.config_enableDefaultRotation); try { IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService(Context.WINDOW_SERVICE)); if (mToggleAutoRotateScreenPreference.isChecked()) { wm.thawRotation(); } else { if (enableDefaultRotation) { wm.freezeRotation(-1); } else { wm.freezeRotation(Surface.ROTATION_0); } } } catch (RemoteException exc) { Log.w(TAG, "Unable to save auto-rotate setting"); } }
@Override public void onCreate() { mTvOut = new TvOut(); mPref = PreferenceManager.getDefaultSharedPreferences(this); IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window")); try { wm.watchRotation( new IRotationWatcher.Stub() { @Override public void onRotationChanged(int rotation) { TvOutService.this.onRotationChanged(rotation); } }); } catch (RemoteException e) { } IntentFilter filter = new IntentFilter(Intent.ACTION_HEADSET_PLUG); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_ON); registerReceiver(mReceiver, filter); }
@Override public boolean setRotation(int rotation) { synchronized (mLock) { throwIfCalledByNotTrustedUidLocked(); throwIfShutdownLocked(); throwIfNotConnectedLocked(); } final long identity = Binder.clearCallingIdentity(); try { if (rotation == UiAutomation.ROTATION_UNFREEZE) { mWindowManager.thawRotation(); } else { mWindowManager.freezeRotation(rotation); } return true; } catch (RemoteException re) { /* ignore */ } finally { Binder.restoreCallingIdentity(identity); } return false; }
private void updateAnimationScaleValue(int which, ListPreference pref) { try { float scale = mWindowManager.getAnimationScale(which); CharSequence[] values = pref.getEntryValues(); for (int i = 0; i < values.length; i++) { float val = Float.parseFloat(values[i].toString()); if (scale <= val) { pref.setValueIndex(i); pref.setSummary(pref.getEntries()[i]); return; } } pref.setValueIndex(values.length - 1); pref.setSummary(pref.getEntries()[0]); } catch (RemoteException e) { } }
@Override public WindowContentFrameStats getWindowContentFrameStats(int windowId) throws RemoteException { synchronized (mLock) { throwIfCalledByNotTrustedUidLocked(); throwIfShutdownLocked(); throwIfNotConnectedLocked(); } final long identity = Binder.clearCallingIdentity(); try { IBinder token = mAccessibilityManager.getWindowToken(windowId); if (token == null) { return null; } return mWindowManager.getWindowContentFrameStats(token); } finally { Binder.restoreCallingIdentity(identity); } }
private void runInstrument() { String profileFile = null; boolean wait = false; boolean rawMode = false; boolean no_window_animation = false; Bundle args = new Bundle(); String argKey = null, argValue = null; IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window")); try { String opt; while ((opt = nextOption()) != null) { if (opt.equals("-p")) { profileFile = nextOptionData(); } else if (opt.equals("-w")) { wait = true; } else if (opt.equals("-r")) { rawMode = true; } else if (opt.equals("-e")) { argKey = nextOptionData(); argValue = nextOptionData(); args.putString(argKey, argValue); } else if (opt.equals("--no_window_animation")) { no_window_animation = true; } else { System.err.println("Error: Unknown option: " + opt); showUsage(); return; } } } catch (RuntimeException ex) { System.err.println("Error: " + ex.toString()); showUsage(); return; } String cnArg = nextArg(); if (cnArg == null) { System.err.println("Error: No instrumentation component supplied"); showUsage(); return; } ComponentName cn = ComponentName.unflattenFromString(cnArg); if (cn == null) { System.err.println("Error: Bad component name: " + cnArg); showUsage(); return; } InstrumentationWatcher watcher = null; if (wait) { watcher = new InstrumentationWatcher(); watcher.setRawOutput(rawMode); } float[] oldAnims = null; if (no_window_animation) { try { oldAnims = wm.getAnimationScales(); wm.setAnimationScale(0, 0.0f); wm.setAnimationScale(1, 0.0f); } catch (RemoteException e) { } } try { if (!mAm.startInstrumentation(cn, profileFile, 0, args, watcher)) { System.out.println("INSTRUMENTATION_FAILED: " + cn.flattenToString()); showUsage(); return; } } catch (RemoteException e) { } if (watcher != null) { if (!watcher.waitForFinish()) { System.out.println("INSTRUMENTATION_ABORTED: System has crashed."); } } if (oldAnims != null) { try { wm.setAnimationScales(oldAnims); } catch (RemoteException e) { } } }
private void writeStrictModeVisualOptions() { try { mWindowManager.setStrictModeVisualIndicatorPreference(mStrictMode.isChecked() ? "1" : ""); } catch (RemoteException e) { } }