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 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) { } } }