Search in sources :

Example 41 with PowerManager

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

the class GeofenceHardwareImpl method acquireWakeLock.

private void acquireWakeLock() {
    if (mWakeLock == null) {
        PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
    }
    mWakeLock.acquire();
}
Also used : PowerManager(android.os.PowerManager)

Example 42 with PowerManager

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

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 43 with PowerManager

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

the class GestureLauncherService method onBootPhase.

public void onBootPhase(int phase) {
    if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
        Resources resources = mContext.getResources();
        if (!isGestureLauncherEnabled(resources)) {
            if (DBG)
                Slog.d(TAG, "Gesture launcher is disabled in system properties.");
            return;
        }
        PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "GestureLauncherService");
        updateCameraRegistered();
        updateCameraDoubleTapPowerEnabled();
        mUserId = ActivityManager.getCurrentUser();
        mContext.registerReceiver(mUserReceiver, new IntentFilter(Intent.ACTION_USER_SWITCHED));
        registerContentObservers();
    }
}
Also used : PowerManager(android.os.PowerManager) IntentFilter(android.content.IntentFilter) Resources(android.content.res.Resources)

Example 44 with PowerManager

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

the class ActivityStackSupervisor method initPowerManagement.

/**
     * At the time when the constructor runs, the power manager has not yet been
     * initialized.  So we initialize our wakelocks afterwards.
     */
void initPowerManagement() {
    PowerManager pm = (PowerManager) mService.mContext.getSystemService(Context.POWER_SERVICE);
    mGoingToSleep = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ActivityManager-Sleep");
    mLaunchingActivity = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "*launch*");
    mLaunchingActivity.setReferenceCounted(false);
}
Also used : PowerManager(android.os.PowerManager)

Example 45 with PowerManager

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

the class ConnectivityManagerTestBase method turnScreenOff.

// Turn screen off
protected void turnScreenOff() {
    logv("Turn screen off");
    PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
    pm.goToSleep(SystemClock.uptimeMillis());
}
Also used : PowerManager(android.os.PowerManager)

Aggregations

PowerManager (android.os.PowerManager)598 Context (android.content.Context)112 Handler (android.os.Handler)112 Intent (android.content.Intent)93 IntentFilter (android.content.IntentFilter)72 PendingIntent (android.app.PendingIntent)46 RemoteException (android.os.RemoteException)37 IPowerManager (android.os.IPowerManager)33 SuppressLint (android.annotation.SuppressLint)30 View (android.view.View)27 IOException (java.io.IOException)27 ContentResolver (android.content.ContentResolver)26 HandlerThread (android.os.HandlerThread)26 SharedPreferences (android.content.SharedPreferences)23 KeyguardManager (android.app.KeyguardManager)18 ComponentName (android.content.ComponentName)18 Resources (android.content.res.Resources)18 TextView (android.widget.TextView)18 PackageManager (android.content.pm.PackageManager)17 Uri (android.net.Uri)16