Java Code Examples for android.os.PowerManager#ACQUIRE_CAUSES_WAKEUP
The following examples show how to use
android.os.PowerManager#ACQUIRE_CAUSES_WAKEUP .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void applyWakeLockFlagsOnAcquireLocked(WakeLock wakeLock, int uid) { if ((wakeLock.mFlags & PowerManager.ACQUIRE_CAUSES_WAKEUP) != 0 && isScreenLock(wakeLock)) { String opPackageName; int opUid; if (wakeLock.mWorkSource != null && wakeLock.mWorkSource.getName(0) != null) { opPackageName = wakeLock.mWorkSource.getName(0); opUid = wakeLock.mWorkSource.get(0); } else { opPackageName = wakeLock.mPackageName; opUid = wakeLock.mWorkSource != null ? wakeLock.mWorkSource.get(0) : wakeLock.mOwnerUid; } wakeUpNoUpdateLocked(SystemClock.uptimeMillis(), wakeLock.mTag, opUid, opPackageName, opUid); } }
Example 2
Source File: BackgroundModeExt.java From cordova-plugin-background-mode with Apache License 2.0 | 6 votes |
/** * Acquires a wake lock to wake up the device. */ @SuppressWarnings("deprecation") private void acquireWakeLock() { PowerManager pm = (PowerManager) getService(POWER_SERVICE); releaseWakeLock(); if (!isDimmed()) return; int level = PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP; wakeLock = pm.newWakeLock(level, "backgroundmode:wakelock"); wakeLock.setReferenceCounted(false); wakeLock.acquire(1000); }
Example 3
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private String getLockFlagsString() { String result = ""; if ((mFlags & PowerManager.ACQUIRE_CAUSES_WAKEUP) != 0) { result += " ACQUIRE_CAUSES_WAKEUP"; } if ((mFlags & PowerManager.ON_AFTER_RELEASE) != 0) { result += " ON_AFTER_RELEASE"; } return result; }
Example 4
Source File: BasicMediaPlayerTestCase_SetWakeModeMethod.java From android-openslmediaplayer with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") private static final String wakeModeToString(int mode) { StringBuilder sb = new StringBuilder(); if ((mode & PowerManager.PARTIAL_WAKE_LOCK) != 0) { appendWithOR(sb, "PARTIAL_WAKE_LOCK"); } if ((mode & PowerManager.ACQUIRE_CAUSES_WAKEUP) != 0) { appendWithOR(sb, "ACQUIRE_CAUSES_WAKEUP"); } if ((mode & PowerManager.ON_AFTER_RELEASE) != 0) { appendWithOR(sb, "ON_AFTER_RELEASE"); } // deprecated values if ((mode & PowerManager.FULL_WAKE_LOCK) != 0) { appendWithOR(sb, "FULL_WAKE_LOCK"); } if ((mode & PowerManager.SCREEN_DIM_WAKE_LOCK) != 0) { appendWithOR(sb, "SCREEN_DIM_WAKE_LOCK"); } if ((mode & PowerManager.SCREEN_BRIGHT_WAKE_LOCK) != 0) { appendWithOR(sb, "SCREEN_BRIGHT_WAKE_LOCK"); } return sb.toString(); }
Example 5
Source File: KeyguardActivity.java From AcDisplay with GNU General Public License v2.0 | 5 votes |
/** * @see #releaseWakeUpLock() */ private void acquireWakeUpLock() { int flags = PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK; PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeUpLock = pm.newWakeLock(flags, "Turn the keyguard on."); mWakeUpLock.acquire(500); // 0.5 sec. }
Example 6
Source File: AppWakeUpManager.java From your-local-weather with GNU General Public License v3.0 | 4 votes |
public void wakeUp() { appendLog(getBaseContext(), TAG, "powerManager:", powerManager); boolean isInUse; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { isInUse = powerManager.isInteractive(); } else { isInUse = powerManager.isScreenOn(); } if (isInUse || ((wakeLock != null) && wakeLock.isHeld())) { appendLog(getBaseContext(), TAG, "lock is held"); return; } timerWakeUpHandler.postDelayed(timerWakeUpRunnable, WAKEUP_TIMEOUT_IN_MS); String wakeUpStrategy = PreferenceManager.getDefaultSharedPreferences(getBaseContext()) .getString(Constants.KEY_WAKE_UP_STRATEGY, "nowakeup"); appendLog(getBaseContext(), TAG, "wakeLock:wakeUpStrategy:", wakeUpStrategy); if (wakeLock != null) { try { wakeLock.release(); } catch (Throwable th) { // ignoring this exception, probably wakeLock was already released } } if ("nowakeup".equals(wakeUpStrategy)) { return; } int powerLockID; if ("wakeupfull".equals(wakeUpStrategy)) { powerLockID = PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP; } else { powerLockID = PowerManager.PARTIAL_WAKE_LOCK; } appendLog(getBaseContext(), TAG, "wakeLock:powerLockID:", powerLockID); wakeLock = powerManager.newWakeLock(powerLockID, "YourLocalWeather:PowerLock"); appendLog(getBaseContext(), TAG, "wakeLock:", wakeLock, ":", wakeLock.isHeld()); if (!wakeLock.isHeld()) { wakeLock.acquire(); } appendLog(getBaseContext(), TAG, "wakeLock acquired"); }