/** * Returns a unique instance of the ViewServer. This method should only be called from the main * thread of your application. The server will have the same lifetime as your process. * * <p>If your application does not have the <code>android:debuggable</code> flag set in its * manifest, the server returned by this method will be a dummy object that does not do anything. * This allows you to use the same code in debug and release versions of your application. * * @param context A Context used to check whether the application is debuggable, this can be the * application context */ public static ViewServer get(Context context) { ApplicationInfo info = context.getApplicationInfo(); if (BUILD_TYPE_USER.equals(Build.TYPE) && (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { if (sServer == null) { sServer = new ViewServer(ViewServer.VIEW_SERVER_DEFAULT_PORT); } if (!sServer.isRunning()) { try { sServer.start(); } catch (IOException e) { Log.d(LOG_TAG, "Error:", e); } } } else { sServer = new NoopViewServer(); } return sServer; }
public void onCreate() { activity.setRequestedOrientation( orientationStrategyProvider.getOrientationStrategy().getAppropriateOrientation()); if (androidDevice.isDebuggable()) { ViewServer.get(activity).addWindow(activity); } wasInAccessibilityMode = accessibilityUtil.isAccessibilityEnabled(); getTalkDelegate(); speechDelegate = new SpeechDelegate(activity); talkDelegate.ignoreAnnounceTitleOnce(); }
public void onResume() { if (androidDevice.isDebuggable()) { ViewServer.get(activity).setFocusedWindow(activity); } talkDelegate.announceTitle(); }
public void onDestroy() { if (androidDevice.isDebuggable()) { ViewServer.get(activity).removeWindow(activity); } talkDelegate.onDestroy(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); attachListFragment(); ViewServer.get(this).addWindow(this); }