Search in sources :

Example 96 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 97 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 98 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)

Example 99 with PowerManager

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

the class UiModeManagerService method onStart.

@Override
public void onStart() {
    final Context context = getContext();
    final PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG);
    context.registerReceiver(mDockModeReceiver, new IntentFilter(Intent.ACTION_DOCK_EVENT));
    context.registerReceiver(mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
    mConfiguration.setToDefaults();
    final Resources res = context.getResources();
    mDefaultUiModeType = res.getInteger(com.android.internal.R.integer.config_defaultUiModeType);
    mCarModeKeepsScreenOn = (res.getInteger(com.android.internal.R.integer.config_carDockKeepsScreenOn) == 1);
    mDeskModeKeepsScreenOn = (res.getInteger(com.android.internal.R.integer.config_deskDockKeepsScreenOn) == 1);
    mEnableCarDockLaunch = res.getBoolean(com.android.internal.R.bool.config_enableCarDockHomeLaunch);
    mUiModeLocked = res.getBoolean(com.android.internal.R.bool.config_lockUiMode);
    mNightModeLocked = res.getBoolean(com.android.internal.R.bool.config_lockDayNightMode);
    final PackageManager pm = context.getPackageManager();
    mTelevision = pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION) || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK);
    mWatch = pm.hasSystemFeature(PackageManager.FEATURE_WATCH);
    final int defaultNightMode = res.getInteger(com.android.internal.R.integer.config_defaultNightMode);
    mNightMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.UI_NIGHT_MODE, defaultNightMode);
    // Update the initial, static configurations.
    synchronized (this) {
        updateConfigurationLocked();
        sendConfigurationLocked();
    }
    publishBinderService(Context.UI_MODE_SERVICE, mService);
}
Also used : Context(android.content.Context) PowerManager(android.os.PowerManager) IntentFilter(android.content.IntentFilter) PackageManager(android.content.pm.PackageManager) Resources(android.content.res.Resources)

Example 100 with PowerManager

use of android.os.PowerManager in project cw-advandroid by commonsguy.

the class WakefulIntentService method getLock.

private static synchronized PowerManager.WakeLock getLock(Context context) {
    if (lockStatic == null) {
        PowerManager mgr = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        lockStatic = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOCK_NAME_STATIC);
        lockStatic.setReferenceCounted(true);
    }
    return (lockStatic);
}
Also used : PowerManager(android.os.PowerManager)

Aggregations

PowerManager (android.os.PowerManager)289 IntentFilter (android.content.IntentFilter)50 Intent (android.content.Intent)44 Handler (android.os.Handler)33 RemoteException (android.os.RemoteException)31 PendingIntent (android.app.PendingIntent)29 HandlerThread (android.os.HandlerThread)26 Context (android.content.Context)24 IPowerManager (android.os.IPowerManager)21 View (android.view.View)19 Resources (android.content.res.Resources)15 AlarmManager (android.app.AlarmManager)11 SharedPreferences (android.content.SharedPreferences)11 TextView (android.widget.TextView)11 NotificationCompat (android.support.v4.app.NotificationCompat)10 ComponentName (android.content.ComponentName)9 KeyguardManager (android.app.KeyguardManager)8 Vibrator (android.os.Vibrator)8 MotionEvent (android.view.MotionEvent)8 ContentResolver (android.content.ContentResolver)7