Search in sources :

Example 71 with ConditionVariable

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

the class MediaPlayerPerformance method initializeMessageLooper.

private void initializeMessageLooper() {
    final ConditionVariable startDone = new ConditionVariable();
    new Thread() {

        @Override
        public void run() {
            Looper.prepare();
            Log.v(TAG, "start loopRun");
            mLooper = Looper.myLooper();
            mCamera = Camera.open(CAMERA_ID);
            startDone.open();
            Looper.loop();
            Log.v(TAG, "initializeMessageLooper: quit.");
        }
    }.start();
    if (!startDone.block(WAIT_FOR_COMMAND_TO_COMPLETE)) {
        fail("initializeMessageLooper: start timeout");
    }
}
Also used : ConditionVariable(android.os.ConditionVariable)

Example 72 with ConditionVariable

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

the class SyncRunner method scheduleFilterWake.

protected void scheduleFilterWake(Filter filter, int delay) {
    // Close the wake condition
    mWakeCondition.close();
    // Schedule the wake-up
    final Filter filterToSchedule = filter;
    final ConditionVariable conditionToWake = mWakeCondition;
    mWakeExecutor.schedule(new Runnable() {

        @Override
        public void run() {
            filterToSchedule.unsetStatus(Filter.STATUS_SLEEPING);
            conditionToWake.open();
        }
    }, delay, TimeUnit.MILLISECONDS);
}
Also used : ConditionVariable(android.os.ConditionVariable)

Example 73 with ConditionVariable

use of android.os.ConditionVariable in project platform_frameworks_base by android.

the class MediaPlayerPerformance method initializeMessageLooper.

private void initializeMessageLooper() {
    final ConditionVariable startDone = new ConditionVariable();
    new Thread() {

        @Override
        public void run() {
            Looper.prepare();
            Log.v(TAG, "start loopRun");
            mLooper = Looper.myLooper();
            mCamera = Camera.open(CAMERA_ID);
            startDone.open();
            Looper.loop();
            Log.v(TAG, "initializeMessageLooper: quit.");
        }
    }.start();
    if (!startDone.block(WAIT_FOR_COMMAND_TO_COMPLETE)) {
        fail("initializeMessageLooper: start timeout");
    }
}
Also used : ConditionVariable(android.os.ConditionVariable)

Example 74 with ConditionVariable

use of android.os.ConditionVariable in project platform_frameworks_base by android.

the class GLThreadManager method setConfigurationAndWait.

/**
     * Configure the GL renderer for the given set of output surfaces, and block until
     * this configuration has been applied.
     *
     * @param surfaces a collection of pairs of {@link android.view.Surface}s and their
     *                 corresponding sizes to configure.
     * @param collector a {@link CaptureCollector} to retrieve requests from.
     */
public void setConfigurationAndWait(Collection<Pair<Surface, Size>> surfaces, CaptureCollector collector) {
    checkNotNull(collector, "collector must not be null");
    Handler handler = mGLHandlerThread.getHandler();
    final ConditionVariable condition = new ConditionVariable(/*closed*/
    false);
    ConfigureHolder configure = new ConfigureHolder(condition, surfaces, collector);
    Message m = handler.obtainMessage(MSG_NEW_CONFIGURATION, /*arg1*/
    0, /*arg2*/
    0, configure);
    handler.sendMessage(m);
    // Block until configuration applied.
    condition.block();
}
Also used : ConditionVariable(android.os.ConditionVariable) Message(android.os.Message) Handler(android.os.Handler)

Example 75 with ConditionVariable

use of android.os.ConditionVariable in project platform_frameworks_base by android.

the class RequestThreadManager method configure.

/**
     * Configure with the current list of output Surfaces.
     *
     * <p>
     * This operation blocks until the configuration is complete.
     * </p>
     *
     * <p>Using a {@code null} or empty {@code outputs} list is the equivalent of unconfiguring.</p>
     *
     * @param outputs a {@link java.util.Collection} of outputs to configure.
     */
public void configure(Collection<Pair<Surface, Size>> outputs) {
    Handler handler = mRequestThread.waitAndGetHandler();
    final ConditionVariable condition = new ConditionVariable(/*closed*/
    false);
    ConfigureHolder holder = new ConfigureHolder(condition, outputs);
    handler.sendMessage(handler.obtainMessage(MSG_CONFIGURE_OUTPUTS, 0, 0, holder));
    condition.block();
}
Also used : ConditionVariable(android.os.ConditionVariable) Handler(android.os.Handler)

Aggregations

ConditionVariable (android.os.ConditionVariable)122 LargeTest (android.test.suitebuilder.annotation.LargeTest)36 NetworkRequest (android.net.NetworkRequest)24 SmallTest (android.test.suitebuilder.annotation.SmallTest)17 Handler (android.os.Handler)16 Messenger (android.os.Messenger)8 Test (org.junit.Test)6 Network (android.net.Network)5 Message (android.os.Message)5 PendingIntent (android.app.PendingIntent)4 BroadcastReceiver (android.content.BroadcastReceiver)4 Context (android.content.Context)4 Intent (android.content.Intent)4 IntentFilter (android.content.IntentFilter)4 ConnectivityManager (android.net.ConnectivityManager)4 NetworkCallback (android.net.ConnectivityManager.NetworkCallback)4 DataUsageRequest (android.net.DataUsageRequest)4 NetworkCapabilities (android.net.NetworkCapabilities)4 NetworkStats (android.net.NetworkStats)4 HandlerThread (android.os.HandlerThread)4