Search in sources :

Example 56 with Handler

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

the class DropBoxManagerService method onStart.

@Override
public void onStart() {
    // Set up intent receivers
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW);
    getContext().registerReceiver(mReceiver, filter);
    mContentResolver.registerContentObserver(Settings.Global.CONTENT_URI, true, new ContentObserver(new Handler()) {

        @Override
        public void onChange(boolean selfChange) {
            mReceiver.onReceive(getContext(), (Intent) null);
        }
    });
    publishBinderService(Context.DROPBOX_SERVICE, mStub);
// The real work gets done lazily in init() -- that way service creation always
// succeeds, and things like disk problems cause individual method failures.
}
Also used : IntentFilter(android.content.IntentFilter) Handler(android.os.Handler) Intent(android.content.Intent) ContentObserver(android.database.ContentObserver)

Example 57 with Handler

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

the class FgThread method ensureThreadLocked.

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

Example 58 with Handler

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

the class NetworkStatsService method create.

public static NetworkStatsService create(Context context, INetworkManagementService networkManager) {
    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
    NetworkStatsService service = new NetworkStatsService(context, networkManager, alarmManager, wakeLock, NtpTrustedTime.getInstance(context), TelephonyManager.getDefault(), new DefaultNetworkStatsSettings(context), new NetworkStatsObservers(), getDefaultSystemDir(), getDefaultBaseDir());
    HandlerThread handlerThread = new HandlerThread(TAG);
    Handler.Callback callback = new HandlerCallback(service);
    handlerThread.start();
    Handler handler = new Handler(handlerThread.getLooper(), callback);
    service.setHandler(handler, callback);
    return service;
}
Also used : PowerManager(android.os.PowerManager) HandlerThread(android.os.HandlerThread) INetworkStatsService(android.net.INetworkStatsService) IAlarmManager(android.app.IAlarmManager) AlarmManager(android.app.AlarmManager) Handler(android.os.Handler)

Example 59 with Handler

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

the class CameraFunctionalTest method setUp.

protected void setUp() throws Exception {
    final Semaphore sem = new Semaphore(0);
    mLooperThread = new Thread() {

        @Override
        public void run() {
            Log.v(TAG, "starting looper");
            Looper.prepare();
            mHandler = new Handler();
            sem.release();
            Looper.loop();
            Log.v(TAG, "quit looper");
        }
    };
    mLooperThread.start();
    if (!sem.tryAcquire(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)) {
        fail("Failed to start the looper.");
    }
    getActivity();
    super.setUp();
    mCameraTestHelper = new CameraTestHelper();
}
Also used : CameraTestHelper(com.android.mediaframeworktest.helpers.CameraTestHelper) Handler(android.os.Handler) Semaphore(java.util.concurrent.Semaphore)

Example 60 with Handler

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

the class FusedPrintersProvider method onStartLoading.

@Override
protected void onStartLoading() {
    if (DEBUG) {
        Log.i(LOG_TAG, "onStartLoading() " + FusedPrintersProvider.this.hashCode());
    }
    mLocationManager.requestLocationUpdates(LocationRequest.create().setQuality(LocationRequest.POWER_LOW).setInterval(LOCATION_UPDATE_MS), this, Looper.getMainLooper());
    Location lastLocation = mLocationManager.getLastLocation();
    if (lastLocation != null) {
        onLocationChanged(lastLocation);
    }
    // Jumpstart location with a single forced update
    Criteria oneTimeCriteria = new Criteria();
    oneTimeCriteria.setAccuracy(Criteria.ACCURACY_FINE);
    mLocationManager.requestSingleUpdate(oneTimeCriteria, this, Looper.getMainLooper());
    // The contract is that if we already have a valid,
    // result the we have to deliver it immediately.
    (new Handler(Looper.getMainLooper())).post(new Runnable() {

        @Override
        public void run() {
            deliverResult(new ArrayList<>(mPrinters));
        }
    });
    // Always load the data to ensure discovery period is
    // started and to make sure obsolete printers are updated.
    onForceLoad();
}
Also used : ArrayList(java.util.ArrayList) Handler(android.os.Handler) Criteria(android.location.Criteria) Location(android.location.Location)

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