Search in sources :

Example 71 with HandlerThread

use of android.os.HandlerThread in project android_frameworks_base by ResurrectionRemix.

the class CallbackHandlerTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    mHandlerThread = new HandlerThread("TestThread");
    mHandlerThread.start();
    mHandler = new CallbackHandler(mHandlerThread.getLooper());
    MockitoAnnotations.initMocks(this);
    mHandler.setListening(mEmengencyListener, true);
    mHandler.setListening(mSignalCallback, true);
}
Also used : HandlerThread(android.os.HandlerThread)

Example 72 with HandlerThread

use of android.os.HandlerThread in project android_frameworks_base by ResurrectionRemix.

the class TileLifecycleManagerTests method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    mThread = new HandlerThread("TestThread");
    mThread.start();
    mHandler = new Handler(mThread.getLooper());
    ComponentName component = new ComponentName(mContext, FakeTileService.class);
    mStateManager = new TileLifecycleManager(mHandler, getContext(), Mockito.mock(IQSService.class), new Tile(), new Intent().setComponent(component), new UserHandle(UserHandle.myUserId()));
    mCallbacks.clear();
    getContext().registerReceiver(mReceiver, new IntentFilter(TILE_UPDATE_BROADCAST));
}
Also used : IntentFilter(android.content.IntentFilter) HandlerThread(android.os.HandlerThread) UserHandle(android.os.UserHandle) Handler(android.os.Handler) Tile(android.service.quicksettings.Tile) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Example 73 with HandlerThread

use of android.os.HandlerThread in project android_frameworks_base by ResurrectionRemix.

the class TileServiceManagerTests method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    mThread = new HandlerThread("TestThread");
    mThread.start();
    mHandler = new Handler(mThread.getLooper());
    mTileServices = Mockito.mock(TileServices.class);
    Mockito.when(mTileServices.getContext()).thenReturn(mContext);
    mTileLifecycle = Mockito.mock(TileLifecycleManager.class);
    Mockito.when(mTileLifecycle.isActiveTile()).thenReturn(false);
    ComponentName componentName = new ComponentName(mContext, TileServiceManagerTests.class);
    Mockito.when(mTileLifecycle.getComponent()).thenReturn(componentName);
    mTileServiceManager = new TileServiceManager(mTileServices, mHandler, mTileLifecycle);
}
Also used : HandlerThread(android.os.HandlerThread) Handler(android.os.Handler) ComponentName(android.content.ComponentName)

Example 74 with HandlerThread

use of android.os.HandlerThread in project android_frameworks_base by ResurrectionRemix.

the class NetworkStatsObservers method getHandlerLooperLocked.

@VisibleForTesting
protected Looper getHandlerLooperLocked() {
    HandlerThread handlerThread = new HandlerThread(TAG);
    handlerThread.start();
    return handlerThread.getLooper();
}
Also used : HandlerThread(android.os.HandlerThread) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Example 75 with HandlerThread

use of android.os.HandlerThread in project android_frameworks_base by ResurrectionRemix.

the class MediaPlayer method setSubtitleAnchor.

/**
     * The private version of setSubtitleAnchor is used internally to set mSubtitleController if
     * necessary when clients don't provide their own SubtitleControllers using the public version
     * {@link #setSubtitleAnchor(SubtitleController, Anchor)} (e.g. {@link VideoView} provides one).
     */
private synchronized void setSubtitleAnchor() {
    if (mSubtitleController == null) {
        final HandlerThread thread = new HandlerThread("SetSubtitleAnchorThread");
        thread.start();
        Handler handler = new Handler(thread.getLooper());
        handler.post(new Runnable() {

            @Override
            public void run() {
                Context context = ActivityThread.currentApplication();
                mSubtitleController = new SubtitleController(context, mTimeProvider, MediaPlayer.this);
                mSubtitleController.setAnchor(new Anchor() {

                    @Override
                    public void setSubtitleWidget(RenderingWidget subtitleWidget) {
                    }

                    @Override
                    public Looper getSubtitleLooper() {
                        return Looper.getMainLooper();
                    }
                });
                thread.getLooper().quitSafely();
            }
        });
        try {
            thread.join();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            Log.w(TAG, "failed to join SetSubtitleAnchorThread");
        }
    }
}
Also used : Context(android.content.Context) SubtitleController(android.media.SubtitleController) Anchor(android.media.SubtitleController.Anchor) HandlerThread(android.os.HandlerThread) Runnable(java.lang.Runnable) Handler(android.os.Handler) RenderingWidget(android.media.SubtitleTrack.RenderingWidget)

Aggregations

HandlerThread (android.os.HandlerThread)313 Handler (android.os.Handler)149 IntentFilter (android.content.IntentFilter)34 Message (android.os.Message)26 PowerManager (android.os.PowerManager)26 Intent (android.content.Intent)25 Context (android.content.Context)22 Test (org.junit.Test)20 Runnable (java.lang.Runnable)15 ComponentName (android.content.ComponentName)14 View (android.view.View)14 Looper (android.os.Looper)13 PendingIntent (android.app.PendingIntent)12 MediumTest (android.test.suitebuilder.annotation.MediumTest)12 RemoteException (android.os.RemoteException)11 MediaFormat (android.media.MediaFormat)10 Uri (android.net.Uri)10 Pair (android.util.Pair)10 SmallTest (android.test.suitebuilder.annotation.SmallTest)9 Bundle (android.os.Bundle)8