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