Search in sources :

Example 66 with Message

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

the class LayoutTestsExecutor method onCreate.

/** IMPLEMENTATION */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    /**
         * It detects the crash by catching all the uncaught exceptions. However, we
         * still have to kill the process, because after catching the exception the
         * activity remains in a strange state, where intents don't revive it.
         * However, we send the message to the service to speed up the rebooting
         * (we don't have to wait for time-out to kick in).
         */
    Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {

        @Override
        public void uncaughtException(Thread thread, Throwable e) {
            Log.w(LOG_TAG, "onTestCrashed(): " + mCurrentTestRelativePath + " thread=" + thread, e);
            try {
                Message serviceMsg = Message.obtain(null, ManagerService.MSG_CURRENT_TEST_CRASHED);
                mManagerServiceMessenger.send(serviceMsg);
            } catch (RemoteException e2) {
                Log.e(LOG_TAG, "mCurrentTestRelativePath=" + mCurrentTestRelativePath, e2);
            }
            Process.killProcess(Process.myPid());
        }
    });
    requestWindowFeature(Window.FEATURE_PROGRESS);
    Intent intent = getIntent();
    mTestsList = FsUtils.loadTestListFromStorage(intent.getStringExtra(EXTRA_TESTS_FILE));
    mCurrentTestIndex = intent.getIntExtra(EXTRA_TEST_INDEX, -1);
    mTotalTestCount = mCurrentTestIndex + mTestsList.size();
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mScreenDimLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "WakeLock in LayoutTester");
    mScreenDimLock.acquire();
    bindService(new Intent(this, ManagerService.class), mServiceConnection, Context.BIND_AUTO_CREATE);
}
Also used : PowerManager(android.os.PowerManager) ConsoleMessage(android.webkit.ConsoleMessage) Message(android.os.Message) Intent(android.content.Intent) UncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler) RemoteException(android.os.RemoteException)

Example 67 with Message

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

the class LayoutTestsExecutor method sendFirstTestMessage.

private void sendFirstTestMessage() {
    try {
        Message serviceMsg = Message.obtain(null, ManagerService.MSG_FIRST_TEST);
        Bundle bundle = new Bundle();
        bundle.putString("firstTest", mTestsList.get(0));
        bundle.putInt("index", mCurrentTestIndex);
        serviceMsg.setData(bundle);
        mManagerServiceMessenger.send(serviceMsg);
    } catch (RemoteException e) {
        Log.e(LOG_TAG, "Error sending message to manager service:", e);
    }
}
Also used : ConsoleMessage(android.webkit.ConsoleMessage) Message(android.os.Message) Bundle(android.os.Bundle) RemoteException(android.os.RemoteException)

Example 68 with Message

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

the class LayoutTestsExecutor method setXSSAuditorEnabled.

public void setXSSAuditorEnabled(boolean flag) {
    Log.i(LOG_TAG, mCurrentTestRelativePath + ": setXSSAuditorEnabled(" + flag + ") called");
    Message msg = mLayoutTestControllerHandler.obtainMessage(MSG_SET_XSS_AUDITOR_ENABLED);
    msg.arg1 = flag ? 1 : 0;
    msg.sendToTarget();
}
Also used : ConsoleMessage(android.webkit.ConsoleMessage) Message(android.os.Message)

Example 69 with Message

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

the class CallbackProxy method overridePreference.

public void overridePreference(String key, boolean value) {
    Message message = obtainMessage(OVERRIDE_PREFERENCE);
    message.getData().putString("key", key);
    message.getData().putBoolean("value", value);
    message.sendToTarget();
}
Also used : Message(android.os.Message)

Example 70 with Message

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

the class TestShellActivity method executeIntent.

private void executeIntent(Intent intent) {
    resetTestStatus();
    if (!Intent.ACTION_VIEW.equals(intent.getAction())) {
        return;
    }
    mTotalTestCount = intent.getIntExtra(TOTAL_TEST_COUNT, mTotalTestCount);
    mCurrentTestNumber = intent.getIntExtra(CURRENT_TEST_NUMBER, mCurrentTestNumber);
    mTestUrl = intent.getStringExtra(TEST_URL);
    if (mTestUrl == null) {
        mUiAutoTestPath = intent.getStringExtra(UI_AUTO_TEST);
        if (mUiAutoTestPath != null) {
            beginUiAutoTest();
        }
        return;
    }
    mResultFile = intent.getStringExtra(RESULT_FILE);
    mTimeoutInMillis = intent.getIntExtra(TIMEOUT_IN_MILLIS, 0);
    mStopOnRefError = intent.getBooleanExtra(STOP_ON_REF_ERROR, false);
    setTitle("Test " + mCurrentTestNumber + " of " + mTotalTestCount);
    float ratio = (float) mCurrentTestNumber / mTotalTestCount;
    int progress = (int) (ratio * Window.PROGRESS_END);
    getWindow().setFeatureInt(Window.FEATURE_PROGRESS, progress);
    Log.v(LOGTAG, "  Loading " + mTestUrl);
    if (mTestUrl.contains("/dumpAsText/")) {
        dumpAsText(false);
    }
    mWebView.loadUrl(mTestUrl);
    if (mTimeoutInMillis > 0) {
        // Create a timeout timer
        Message m = mHandler.obtainMessage(MSG_TIMEOUT);
        mHandler.sendMessageDelayed(m, mTimeoutInMillis);
    }
}
Also used : ConsoleMessage(android.webkit.ConsoleMessage) Message(android.os.Message)

Aggregations

Message (android.os.Message)3198 Handler (android.os.Handler)347 RemoteException (android.os.RemoteException)263 Bundle (android.os.Bundle)210 Test (org.junit.Test)144 Intent (android.content.Intent)130 IOException (java.io.IOException)124 Point (android.graphics.Point)86 HashMap (java.util.HashMap)77 SomeArgs (com.android.internal.os.SomeArgs)67 SmallTest (android.test.suitebuilder.annotation.SmallTest)64 Messenger (android.os.Messenger)63 ArrayList (java.util.ArrayList)59 View (android.view.View)52 File (java.io.File)50 MediumTest (android.test.suitebuilder.annotation.MediumTest)43 TextView (android.widget.TextView)41 IBinder (android.os.IBinder)38 Map (java.util.Map)37 PendingIntent (android.app.PendingIntent)33