Search in sources :

Example 86 with HandlerThread

use of android.os.HandlerThread in project DanmakuFlameMaster by Bilibili.

the class DanmakuView method stopDraw.

private synchronized void stopDraw() {
    DrawHandler handler = this.handler;
    this.handler = null;
    unlockCanvasAndPost();
    if (handler != null) {
        handler.quit();
    }
    HandlerThread handlerThread = this.mHandlerThread;
    mHandlerThread = null;
    if (handlerThread != null) {
        try {
            handlerThread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        handlerThread.quit();
    }
}
Also used : HandlerThread(android.os.HandlerThread) DrawHandler(master.flame.danmaku.controller.DrawHandler)

Example 87 with HandlerThread

use of android.os.HandlerThread in project DanmakuFlameMaster by Bilibili.

the class DanmakuSurfaceView method getLooper.

protected synchronized Looper getLooper(int type) {
    if (mHandlerThread != null) {
        mHandlerThread.quit();
        mHandlerThread = null;
    }
    int priority;
    switch(type) {
        case THREAD_TYPE_MAIN_THREAD:
            return Looper.getMainLooper();
        case THREAD_TYPE_HIGH_PRIORITY:
            priority = android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY;
            break;
        case THREAD_TYPE_LOW_PRIORITY:
            priority = android.os.Process.THREAD_PRIORITY_LOWEST;
            break;
        case THREAD_TYPE_NORMAL_PRIORITY:
        default:
            priority = android.os.Process.THREAD_PRIORITY_DEFAULT;
            break;
    }
    String threadName = "DFM Handler Thread #" + priority;
    mHandlerThread = new HandlerThread(threadName, priority);
    mHandlerThread.start();
    return mHandlerThread.getLooper();
}
Also used : HandlerThread(android.os.HandlerThread)

Example 88 with HandlerThread

use of android.os.HandlerThread in project DanmakuFlameMaster by Bilibili.

the class DanmakuSurfaceView method stopDraw.

private synchronized void stopDraw() {
    if (handler != null) {
        handler.quit();
        handler = null;
    }
    HandlerThread handlerThread = this.mHandlerThread;
    mHandlerThread = null;
    if (handlerThread != null) {
        try {
            handlerThread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        handlerThread.quit();
    }
}
Also used : HandlerThread(android.os.HandlerThread)

Example 89 with HandlerThread

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

the class FlashlightController method ensureHandler.

private synchronized void ensureHandler() {
    if (mHandler == null) {
        HandlerThread thread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND);
        thread.start();
        mHandler = new Handler(thread.getLooper());
    }
}
Also used : HandlerThread(android.os.HandlerThread) Handler(android.os.Handler)

Example 90 with HandlerThread

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

the class UiAutomatorTestRunner method start.

/**
     * Called after all test classes are in place, ready to test
     */
protected void start() {
    TestCaseCollector collector = getTestCaseCollector(this.getClass().getClassLoader());
    try {
        collector.addTestClasses(mTestClasses);
    } catch (ClassNotFoundException e) {
        // will be caught by uncaught handler
        throw new RuntimeException(e.getMessage(), e);
    }
    if (mDebug) {
        Debug.waitForDebugger();
    }
    mHandlerThread = new HandlerThread(HANDLER_THREAD_NAME);
    mHandlerThread.setDaemon(true);
    mHandlerThread.start();
    UiAutomationShellWrapper automationWrapper = new UiAutomationShellWrapper();
    automationWrapper.connect();
    long startTime = SystemClock.uptimeMillis();
    TestResult testRunResult = new TestResult();
    ResultReporter resultPrinter;
    String outputFormat = mParams.getString("outputFormat");
    List<TestCase> testCases = collector.getTestCases();
    Bundle testRunOutput = new Bundle();
    if ("simple".equals(outputFormat)) {
        resultPrinter = new SimpleResultPrinter(System.out, true);
    } else {
        resultPrinter = new WatcherResultPrinter(testCases.size());
    }
    try {
        automationWrapper.setRunAsMonkey(mMonkey);
        mUiDevice = UiDevice.getInstance();
        mUiDevice.initialize(new ShellUiAutomatorBridge(automationWrapper.getUiAutomation()));
        String traceType = mParams.getString("traceOutputMode");
        if (traceType != null) {
            Tracer.Mode mode = Tracer.Mode.valueOf(Tracer.Mode.class, traceType);
            if (mode == Tracer.Mode.FILE || mode == Tracer.Mode.ALL) {
                String filename = mParams.getString("traceLogFilename");
                if (filename == null) {
                    throw new RuntimeException("Name of log file not specified. " + "Please specify it using traceLogFilename parameter");
                }
                Tracer.getInstance().setOutputFilename(filename);
            }
            Tracer.getInstance().setOutputMode(mode);
        }
        // add test listeners
        testRunResult.addListener(resultPrinter);
        // add all custom listeners
        for (TestListener listener : mTestListeners) {
            testRunResult.addListener(listener);
        }
        // run tests for realz!
        for (TestCase testCase : testCases) {
            prepareTestCase(testCase);
            testCase.run(testRunResult);
        }
    } catch (Throwable t) {
        // catch all exceptions so a more verbose error message can be outputted
        resultPrinter.printUnexpectedError(t);
        testRunOutput.putString("shortMsg", t.getMessage());
    } finally {
        long runTime = SystemClock.uptimeMillis() - startTime;
        resultPrinter.print(testRunResult, runTime, testRunOutput);
        automationWrapper.disconnect();
        automationWrapper.setRunAsMonkey(false);
        mHandlerThread.quit();
    }
}
Also used : Bundle(android.os.Bundle) Tracer(com.android.uiautomator.core.Tracer) TestResult(junit.framework.TestResult) UiAutomationShellWrapper(com.android.uiautomator.core.UiAutomationShellWrapper) HandlerThread(android.os.HandlerThread) TestCase(junit.framework.TestCase) ShellUiAutomatorBridge(com.android.uiautomator.core.ShellUiAutomatorBridge) TestListener(junit.framework.TestListener)

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