Search in sources :

Example 51 with HandlerThread

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

the class NativeDaemonConnector method run.

@Override
public void run() {
    HandlerThread thread = new HandlerThread(TAG + ".CallbackHandler");
    thread.start();
    mCallbackHandler = new Handler(thread.getLooper(), this);
    while (true) {
        try {
            listenToSocket();
        } catch (Exception e) {
            loge("Error in NativeDaemonConnector: " + e);
            SystemClock.sleep(5000);
        }
    }
}
Also used : HandlerThread(android.os.HandlerThread) Handler(android.os.Handler) IOException(java.io.IOException)

Example 52 with HandlerThread

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

the class PowerManagerService method init.

/**
     * Initialize the power manager.
     * Must be called before any other functions within the power manager are called.
     */
public void init(Context context, LightsService ls, ActivityManagerService am, BatteryService bs, IBatteryStats bss, DisplayManagerService dm) {
    mContext = context;
    mLightsService = ls;
    mBatteryService = bs;
    mBatteryStats = bss;
    mDisplayManagerService = dm;
    mHandlerThread = new HandlerThread(TAG);
    mHandlerThread.start();
    mHandler = new PowerManagerHandler(mHandlerThread.getLooper());
    Watchdog.getInstance().addMonitor(this);
    // Forcibly turn the screen on at boot so that it is in a known power state.
    // We do this in init() rather than in the constructor because setting the
    // screen state requires a call into surface flinger which then needs to call back
    // into the activity manager to check permissions.  Unfortunately the
    // activity manager is not running when the constructor is called, so we
    // have to defer setting the screen state until this point.
    mDisplayBlanker.unblankAllDisplays();
}
Also used : HandlerThread(android.os.HandlerThread)

Example 53 with HandlerThread

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

the class WifiManager method init.

private void init() {
    synchronized (sThreadRefLock) {
        if (++sThreadRefCount == 1) {
            Messenger messenger = getWifiServiceMessenger();
            if (messenger == null) {
                sAsyncChannel = null;
                return;
            }
            sHandlerThread = new HandlerThread("WifiManager");
            sAsyncChannel = new AsyncChannel();
            sConnected = new CountDownLatch(1);
            sHandlerThread.start();
            Handler handler = new ServiceHandler(sHandlerThread.getLooper());
            sAsyncChannel.connect(mContext, handler, messenger);
            try {
                sConnected.await();
            } catch (InterruptedException e) {
                Log.e(TAG, "interrupted wait at init");
            }
        }
    }
}
Also used : HandlerThread(android.os.HandlerThread) Handler(android.os.Handler) AsyncChannel(com.android.internal.util.AsyncChannel) Messenger(android.os.Messenger) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 54 with HandlerThread

use of android.os.HandlerThread in project robotium by RobotiumTech.

the class ScreenshotTaker method initScreenShotSaver.

/**
	 * This method initializes the aysnc screenshot saving logic
	 */
private void initScreenShotSaver() {
    if (screenShotSaverThread == null || screenShotSaver == null) {
        screenShotSaverThread = new HandlerThread("ScreenShotSaver");
        screenShotSaverThread.start();
        screenShotSaver = new ScreenShotSaver(screenShotSaverThread);
    }
}
Also used : HandlerThread(android.os.HandlerThread)

Example 55 with HandlerThread

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

the class IntentService method onCreate.

@Override
public void onCreate() {
    // TODO: It would be nice to have an option to hold a partial wakelock
    // during processing, and to have a static startService(Context, Intent)
    // method that would launch the service & hand off a wakelock.
    super.onCreate();
    HandlerThread thread = new HandlerThread("IntentService[" + mName + "]");
    thread.start();
    mServiceLooper = thread.getLooper();
    mServiceHandler = new ServiceHandler(mServiceLooper);
}
Also used : HandlerThread(android.os.HandlerThread)

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