Search in sources :

Example 51 with Handler

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

the class ExternalStorageProvider method onCreate.

@Override
public boolean onCreate() {
    mStorageManager = (StorageManager) getContext().getSystemService(Context.STORAGE_SERVICE);
    mHandler = new Handler();
    mArchiveHelper = new DocumentArchiveHelper(this, (char) 0);
    updateVolumes();
    return true;
}
Also used : Handler(android.os.Handler) DocumentArchiveHelper(android.support.provider.DocumentArchiveHelper)

Example 52 with Handler

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

the class DirectStatementService method onCreate.

/**
     * Creates a DirectStatementService with the dependencies passed in for easy testing.
     */
public void onCreate(AbstractStatementRetriever statementRetriever, Looper looper, File cacheDir) {
    super.onCreate();
    mStatementRetriever = statementRetriever;
    mHandler = new Handler(looper);
    try {
        File httpCacheDir = new File(cacheDir, CACHE_FILENAME);
        mHttpResponseCache = HttpResponseCache.install(httpCacheDir, HTTP_CACHE_SIZE_IN_BYTES);
    } catch (IOException e) {
        Log.i(TAG, "HTTPS response cache installation failed:" + e);
    }
}
Also used : Handler(android.os.Handler) IOException(java.io.IOException) File(java.io.File)

Example 53 with Handler

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

the class IntentFilterVerificationReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    final String action = intent.getAction();
    if (Intent.ACTION_INTENT_FILTER_NEEDS_VERIFICATION.equals(action)) {
        Bundle inputExtras = intent.getExtras();
        if (inputExtras != null) {
            Intent serviceIntent = new Intent(context, DirectStatementService.class);
            serviceIntent.setAction(DirectStatementService.CHECK_ALL_ACTION);
            int verificationId = inputExtras.getInt(PackageManager.EXTRA_INTENT_FILTER_VERIFICATION_ID);
            String scheme = inputExtras.getString(PackageManager.EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME);
            String hosts = inputExtras.getString(PackageManager.EXTRA_INTENT_FILTER_VERIFICATION_HOSTS);
            String packageName = inputExtras.getString(PackageManager.EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME);
            Bundle extras = new Bundle();
            extras.putString(DirectStatementService.EXTRA_RELATION, HANDLE_ALL_URLS_RELATION);
            String[] hostList = hosts.split(" ");
            if (hostList.length > MAX_HOSTS_PER_REQUEST) {
                Log.w(TAG, String.format(TOO_MANY_HOSTS_FORMAT, hostList.length, MAX_HOSTS_PER_REQUEST));
                sendErrorToPackageManager(context.getPackageManager(), verificationId);
                return;
            }
            ArrayList<String> finalHosts = new ArrayList<String>(hostList.length);
            try {
                ArrayList<String> sourceAssets = new ArrayList<String>();
                for (String host : hostList) {
                    // "*.example.tld" is validated via https://example.tld
                    if (host.startsWith("*.")) {
                        host = host.substring(2);
                    }
                    sourceAssets.add(createWebAssetString(scheme, host));
                    finalHosts.add(host);
                }
                extras.putStringArrayList(DirectStatementService.EXTRA_SOURCE_ASSET_DESCRIPTORS, sourceAssets);
            } catch (MalformedURLException e) {
                Log.w(TAG, "Error when processing input host: " + e.getMessage());
                sendErrorToPackageManager(context.getPackageManager(), verificationId);
                return;
            }
            try {
                extras.putString(DirectStatementService.EXTRA_TARGET_ASSET_DESCRIPTOR, createAndroidAssetString(context, packageName));
            } catch (NameNotFoundException e) {
                Log.w(TAG, "Error when processing input Android package: " + e.getMessage());
                sendErrorToPackageManager(context.getPackageManager(), verificationId);
                return;
            }
            extras.putParcelable(DirectStatementService.EXTRA_RESULT_RECEIVER, new IsAssociatedResultReceiver(new Handler(), context.getPackageManager(), verificationId));
            // Required for CTS: log a few details of the validcation operation to be performed
            logValidationParametersForCTS(verificationId, scheme, finalHosts, packageName);
            serviceIntent.putExtras(extras);
            context.startService(serviceIntent);
        }
    } else {
        Log.w(TAG, "Intent action not supported: " + action);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) Handler(android.os.Handler) Intent(android.content.Intent)

Example 54 with Handler

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

the class IoThread method ensureThreadLocked.

private static void ensureThreadLocked() {
    if (sInstance == null) {
        sInstance = new IoThread();
        sInstance.start();
        sInstance.getLooper().setTraceTag(Trace.TRACE_TAG_ACTIVITY_MANAGER);
        sHandler = new Handler(sInstance.getLooper());
    }
}
Also used : Handler(android.os.Handler)

Example 55 with Handler

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

the class DisplayThread method ensureThreadLocked.

private static void ensureThreadLocked() {
    if (sInstance == null) {
        sInstance = new DisplayThread();
        sInstance.start();
        sInstance.getLooper().setTraceTag(Trace.TRACE_TAG_ACTIVITY_MANAGER);
        sHandler = new Handler(sInstance.getLooper());
    }
}
Also used : Handler(android.os.Handler)

Aggregations

Handler (android.os.Handler)1906 Message (android.os.Message)254 View (android.view.View)207 Intent (android.content.Intent)174 HandlerThread (android.os.HandlerThread)156 TextView (android.widget.TextView)118 MediumTest (android.test.suitebuilder.annotation.MediumTest)116 ArrayList (java.util.ArrayList)97 Test (org.junit.Test)85 Context (android.content.Context)71 IntentFilter (android.content.IntentFilter)69 RemoteException (android.os.RemoteException)63 IOException (java.io.IOException)63 ComponentName (android.content.ComponentName)57 ImageView (android.widget.ImageView)57 Bundle (android.os.Bundle)56 RecyclerView (android.support.v7.widget.RecyclerView)54 Looper (android.os.Looper)53 File (java.io.File)46 ContentObserver (android.database.ContentObserver)44