private Api() { HandlerThread bgThread = new HandlerThread("api_thread"); bgThread.start(); bgHandler = new Handler(bgThread.getLooper()); mainHandler = new Handler(Looper.getMainLooper()); // Do nothing. }
public AndroidWatchExecutor(long initialDelayMillis) { mainHandler = new Handler(Looper.getMainLooper()); HandlerThread handlerThread = new HandlerThread(LEAK_CANARY_THREAD_NAME); handlerThread.start(); backgroundHandler = new Handler(handlerThread.getLooper()); this.initialDelayMillis = initialDelayMillis; maxBackoffFactor = Long.MAX_VALUE / initialDelayMillis; }
public DummyMainThread() { thread = new HandlerThread("DummyMainThread"); thread.start(); handler = new Handler(thread.getLooper()); }
private static synchronized Looper getDefaultLayoutThreadLooper() { if (sDefaultLayoutThreadLooper == null) { final HandlerThread defaultThread = new HandlerThread(DEFAULT_LAYOUT_THREAD_NAME, DEFAULT_BACKGROUND_THREAD_PRIORITY); defaultThread.start(); sDefaultLayoutThreadLooper = defaultThread.getLooper(); } return sDefaultLayoutThreadLooper; }
private static synchronized Looper getDefaultPreallocateMountContentThreadLooper() { if (sDefaultPreallocateMountContentThreadLooper == null) { final HandlerThread defaultThread = new HandlerThread(DEFAULT_PMC_THREAD_NAME); defaultThread.start(); sDefaultPreallocateMountContentThreadLooper = defaultThread.getLooper(); } return sDefaultPreallocateMountContentThreadLooper; }
void onMultiConnection() { handlerThread = new HandlerThread("source-status-callback"); handlerThread.start(); handler = new Handler(handlerThread.getLooper(), this); }
public void startPauseAllLooperCheck() { pauseAllChecker = new HandlerThread("PauseAllChecker"); pauseAllChecker.start(); pauseAllHandler = new Handler(pauseAllChecker.getLooper(), this); pauseAllHandler.sendEmptyMessageDelayed(PAUSE_ALL_CHECKER_WHAT, PAUSE_ALL_CHECKER_PERIOD); }
private VSyncSampler() { sampledVsyncTimeNs = C.TIME_UNSET; choreographerOwnerThread = new HandlerThread("ChoreographerOwner:Handler"); choreographerOwnerThread.start(); handler = Util.createHandler(choreographerOwnerThread.getLooper(), /* callback= */ this); handler.sendEmptyMessage(CREATE_CHOREOGRAPHER); }
public void startScreencast(JsonRpcPeer peer, Page.StartScreencastRequest request) { LogUtil.d("Starting screencast"); mRequest = request; mHandlerThread = new HandlerThread("Screencast Thread"); mHandlerThread.start(); mPeer = peer; mIsRunning = true; mStream = new ByteArrayOutputStream(); mBackgroundHandler = new Handler(mHandlerThread.getLooper()); mMainHandler.postDelayed(mBitmapFetchRunnable, FRAME_DELAY); }
Stats(PlatformLruCache cache) { this.cache = cache; this.statsThread = new HandlerThread(STATS_THREAD_NAME, THREAD_PRIORITY_BACKGROUND); this.statsThread.start(); Utils.flushStackLocalLeaks(statsThread.getLooper()); this.handler = new StatsHandler(statsThread.getLooper(), this); }
public JZMediaManager() { mMediaHandlerThread = new HandlerThread(TAG); mMediaHandlerThread.start(); mMediaHandler = new MediaHandler(mMediaHandlerThread.getLooper()); mainThreadHandler = new Handler(); if (jzMediaInterface == null) jzMediaInterface = new JZMediaSystem(); }
public void begin() { mEndFlag = false; if (mThread == null) { mThread = new HandlerThread("DFM Cache-Building Thread"); mThread.start(); } if (mHandler == null) mHandler = new CacheHandler(mThread.getLooper()); mHandler.begin(); }
private VPackageInstallerService() { mContext = VirtualCore.get().getContext(); mInstallThread = new HandlerThread("PackageInstaller"); mInstallThread.start(); mInstallHandler = new Handler(mInstallThread.getLooper()); mCallbacks = new Callbacks(mInstallThread.getLooper()); }
public DummyMainThread() { thread = new HandlerThread("DummyMainThread"); thread.start(); handler = new Handler(thread.getLooper()); }
public FileDownloadSerialQueue() { mHandlerThread = new HandlerThread( FileDownloadUtils.getThreadPoolName("SerialDownloadManager")); mHandlerThread.start(); mHandler = new Handler(mHandlerThread.getLooper(), new SerialLoop()); finishCallback = new SerialFinishCallback(new WeakReference<>(this)); sendNext(); }
private HandlerThread getHandlerThread() { HandlerThread ht = new HandlerThread(testName.getMethodName()); ht.start(); return ht; }
@Test public void resetThreadLoopers_clears_messages() { HandlerThread backgroundThread = new HandlerThread("resetTest"); backgroundThread.start(); Looper backgroundLooper = backgroundThread.getLooper(); Handler handler = new Handler(backgroundLooper); for (int i = 0; i < 5; i++) { handler.sendEmptyMessageDelayed(1, 100); ShadowLooper.resetThreadLoopers(); assertThat(handler.hasMessages(1)).isFalse(); } }
@Test public void shouldReturnLooper() throws Exception { handlerThread = new HandlerThread("test"); handlerThread.start(); assertNotNull(handlerThread.getLooper()); assertNotSame( handlerThread.getLooper(), ApplicationProvider.getApplicationContext().getMainLooper()); }
@Test public void shouldStopThreadIfLooperIsQuit() throws Exception { handlerThread = new HandlerThread("test1"); handlerThread.start(); Looper looper = handlerThread.getLooper(); assertFalse(shadowOf(looper).quit); looper.quit(); handlerThread.join(); assertFalse(handlerThread.isAlive()); assertTrue(shadowOf(looper).quit); handlerThread = null; }
@Test public void shouldQuitLooperAndThread() throws Exception { handlerThread = new HandlerThread("test"); Thread.setDefaultUncaughtExceptionHandler(new MyUncaughtExceptionHandler()); handlerThread.setUncaughtExceptionHandler(new MyUncaughtExceptionHandler()); handlerThread.start(); assertTrue(handlerThread.isAlive()); assertTrue(handlerThread.quit()); handlerThread.join(); assertFalse(handlerThread.isAlive()); handlerThread = null; }