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;
}
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);
}
}
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);
}
}
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());
}
}
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());
}
}
Aggregations