use of android.os.HandlerThread in project simple-stack by Zhuinden.
the class MainScopeListener method onCreate.
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
handlerThread = new HandlerThread("LOOPER_SCHEDULER");
handlerThread.start();
synchronized (handlerThread) {
looperScheduler.setScheduler(AndroidSchedulers.from(handlerThread.getLooper()));
}
databaseManager.openDatabase();
}
use of android.os.HandlerThread in project simple-stack by Zhuinden.
the class MainScopeListener method onCreate.
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
handlerThread = new HandlerThread("LOOPER_SCHEDULER");
handlerThread.start();
synchronized (handlerThread) {
looperScheduler.setScheduler(AndroidSchedulers.from(handlerThread.getLooper()));
}
databaseManager.openDatabase();
}
use of android.os.HandlerThread in project android_frameworks_base by ResurrectionRemix.
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);
}
use of android.os.HandlerThread in project android_frameworks_base by ResurrectionRemix.
the class HandlerThreadTest method testHandlerThread.
@MediumTest
public void testHandlerThread() throws Exception {
HandlerThread th1 = new HandlerThread("HandlerThreadTest") {
protected void onLooperPrepared() {
synchronized (HandlerThreadTest.this) {
mDidSetup = true;
mLooperTid = Process.myTid();
HandlerThreadTest.this.notify();
}
}
};
assertFalse(th1.isAlive());
assertNull(th1.getLooper());
th1.start();
assertTrue(th1.isAlive());
assertNotNull(th1.getLooper());
// and fill in the values we expect.
synchronized (this) {
while (!mDidSetup) {
try {
wait();
} catch (InterruptedException e) {
}
}
}
// Make sure that the process was set.
assertNotSame(-1, mLooperTid);
// Make sure that the onLooperPrepared() was called on a different thread.
assertNotSame(Process.myTid(), mLooperTid);
final Handler h1 = new Handler(th1.getLooper()) {
public void handleMessage(Message msg) {
assertEquals(TEST_WHAT, msg.what);
// Ensure that we are running on the same thread in which the looper was setup on.
assertEquals(mLooperTid, Process.myTid());
mGotMessageWhat = msg.what;
mGotMessage = true;
synchronized (this) {
notifyAll();
}
}
};
Message msg = h1.obtainMessage(TEST_WHAT);
synchronized (h1) {
// wait until we have the lock before sending the message.
h1.sendMessage(msg);
try {
// wait for the message to be handled
h1.wait();
} catch (InterruptedException e) {
}
}
assertTrue(mGotMessage);
assertEquals(TEST_WHAT, mGotMessageWhat);
}
use of android.os.HandlerThread in project android_frameworks_base by ResurrectionRemix.
the class CameraDeviceBinderTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
/**
* Workaround for mockito and JB-MR2 incompatibility
*
* Avoid java.lang.IllegalArgumentException: dexcache == null
* https://code.google.com/p/dexmaker/issues/detail?id=2
*/
System.setProperty("dexmaker.dexcache", getContext().getCacheDir().toString());
mUtils = new CameraBinderTestUtils(getContext());
// This cannot be set in the constructor, since the onCreate isn't
// called yet
mCameraId = MediaFrameworkIntegrationTestRunner.mCameraId;
ICameraDeviceCallbacks.Stub dummyCallbacks = new DummyCameraDeviceCallbacks();
String clientPackageName = getContext().getPackageName();
mMockCb = spy(dummyCallbacks);
mCameraUser = mUtils.getCameraService().connectDevice(mMockCb, mCameraId, clientPackageName, ICameraService.USE_CALLING_UID);
assertNotNull(String.format("Camera %s was null", mCameraId), mCameraUser);
mHandlerThread = new HandlerThread(TAG);
mHandlerThread.start();
mHandler = new Handler(mHandlerThread.getLooper());
createDefaultSurface();
Log.v(TAG, String.format("Camera %s connected", mCameraId));
}
Aggregations