Java Code Examples for android.os.PowerManager#SCREEN_DIM_WAKE_LOCK

The following examples show how to use android.os.PowerManager#SCREEN_DIM_WAKE_LOCK . 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 vote down vote up
@SuppressWarnings("deprecation")
private boolean isWakeLockLevelSupportedInternal(int level) {
    synchronized (mLock) {
        switch (level) {
            case PowerManager.PARTIAL_WAKE_LOCK:
            case PowerManager.SCREEN_DIM_WAKE_LOCK:
            case PowerManager.SCREEN_BRIGHT_WAKE_LOCK:
            case PowerManager.FULL_WAKE_LOCK:
            case PowerManager.DOZE_WAKE_LOCK:
            case PowerManager.DRAW_WAKE_LOCK:
                return true;

            case PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK:
                return mSystemReady && mDisplayManagerInternal.isProximitySensorAvailable();

            default:
                return false;
        }
    }
}
 
Example 2
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** Get wake lock summary flags that correspond to the given wake lock. */
private int getWakeLockSummaryFlags(WakeLock wakeLock) {
    switch (wakeLock.mFlags & PowerManager.WAKE_LOCK_LEVEL_MASK) {
        case PowerManager.PARTIAL_WAKE_LOCK:
            if (!wakeLock.mDisabled) {
                // We only respect this if the wake lock is not disabled.
                return WAKE_LOCK_CPU;
            }
            break;
        case PowerManager.FULL_WAKE_LOCK:
            return WAKE_LOCK_SCREEN_BRIGHT | WAKE_LOCK_BUTTON_BRIGHT;
        case PowerManager.SCREEN_BRIGHT_WAKE_LOCK:
            return WAKE_LOCK_SCREEN_BRIGHT;
        case PowerManager.SCREEN_DIM_WAKE_LOCK:
            return WAKE_LOCK_SCREEN_DIM;
        case PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK:
            return WAKE_LOCK_PROXIMITY_SCREEN_OFF;
        case PowerManager.DOZE_WAKE_LOCK:
            return WAKE_LOCK_DOZE;
        case PowerManager.DRAW_WAKE_LOCK:
            return WAKE_LOCK_DRAW;
    }
    return 0;
}
 
Example 3
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private String getLockLevelString() {
    switch (mFlags & PowerManager.WAKE_LOCK_LEVEL_MASK) {
        case PowerManager.FULL_WAKE_LOCK:
            return "FULL_WAKE_LOCK                ";
        case PowerManager.SCREEN_BRIGHT_WAKE_LOCK:
            return "SCREEN_BRIGHT_WAKE_LOCK       ";
        case PowerManager.SCREEN_DIM_WAKE_LOCK:
            return "SCREEN_DIM_WAKE_LOCK          ";
        case PowerManager.PARTIAL_WAKE_LOCK:
            return "PARTIAL_WAKE_LOCK             ";
        case PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK:
            return "PROXIMITY_SCREEN_OFF_WAKE_LOCK";
        case PowerManager.DOZE_WAKE_LOCK:
            return "DOZE_WAKE_LOCK                ";
        case PowerManager.DRAW_WAKE_LOCK:
            return "DRAW_WAKE_LOCK                ";
        default:
            return "???                           ";
    }
}
 
Example 4
Source File: BackgroundModeExt.java    From cordova-plugin-background-mode with Apache License 2.0 6 votes vote down vote up
/**
 * 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 5
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private static boolean isScreenLock(final WakeLock wakeLock) {
    switch (wakeLock.mFlags & PowerManager.WAKE_LOCK_LEVEL_MASK) {
        case PowerManager.FULL_WAKE_LOCK:
        case PowerManager.SCREEN_BRIGHT_WAKE_LOCK:
        case PowerManager.SCREEN_DIM_WAKE_LOCK:
            return true;
    }
    return false;
}
 
Example 6
Source File: Notifier.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private int getBatteryStatsWakeLockMonitorType(int flags) {
    switch (flags & PowerManager.WAKE_LOCK_LEVEL_MASK) {
        case PowerManager.PARTIAL_WAKE_LOCK:
            return BatteryStats.WAKE_TYPE_PARTIAL;

        case PowerManager.SCREEN_DIM_WAKE_LOCK:
        case PowerManager.SCREEN_BRIGHT_WAKE_LOCK:
            return BatteryStats.WAKE_TYPE_FULL;

        case PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK:
            if (mSuspendWhenScreenOffDueToProximityConfig) {
                return -1;
            }
            return BatteryStats.WAKE_TYPE_PARTIAL;

        case PowerManager.DRAW_WAKE_LOCK:
            return BatteryStats.WAKE_TYPE_DRAW;

        case PowerManager.DOZE_WAKE_LOCK:
            // Doze wake locks are an internal implementation detail of the
            // communication between dream manager service and power manager
            // service.  They have no additive battery impact.
            return -1;

        default:
            return -1;
    }
}
 
Example 7
Source File: BasicMediaPlayerTestCase_SetWakeModeMethod.java    From android-openslmediaplayer with Apache License 2.0 5 votes vote down vote up
@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 8
Source File: KeyguardActivity.java    From AcDisplay with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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 9
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private boolean goToSleepNoUpdateLocked(long eventTime, int reason, int flags, int uid) {
    if (DEBUG_SPEW) {
        Slog.d(TAG, "goToSleepNoUpdateLocked: eventTime=" + eventTime
                + ", reason=" + reason + ", flags=" + flags + ", uid=" + uid);
    }

    if (eventTime < mLastWakeTime
            || mWakefulness == WAKEFULNESS_ASLEEP
            || mWakefulness == WAKEFULNESS_DOZING
            || !mBootCompleted || !mSystemReady) {
        return false;
    }

    Trace.traceBegin(Trace.TRACE_TAG_POWER, "goToSleep");
    try {
        switch (reason) {
            case PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN:
                Slog.i(TAG, "Going to sleep due to device administration policy "
                        + "(uid " + uid +")...");
                break;
            case PowerManager.GO_TO_SLEEP_REASON_TIMEOUT:
                Slog.i(TAG, "Going to sleep due to screen timeout (uid " + uid +")...");
                break;
            case PowerManager.GO_TO_SLEEP_REASON_LID_SWITCH:
                Slog.i(TAG, "Going to sleep due to lid switch (uid " + uid +")...");
                break;
            case PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON:
                Slog.i(TAG, "Going to sleep due to power button (uid " + uid +")...");
                break;
            case PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON:
                Slog.i(TAG, "Going to sleep due to sleep button (uid " + uid +")...");
                break;
            case PowerManager.GO_TO_SLEEP_REASON_HDMI:
                Slog.i(TAG, "Going to sleep due to HDMI standby (uid " + uid +")...");
                break;
            case PowerManager.GO_TO_SLEEP_REASON_ACCESSIBILITY:
                Slog.i(TAG, "Going to sleep by an accessibility service request (uid "
                        + uid +")...");
                break;
            default:
                Slog.i(TAG, "Going to sleep by application request (uid " + uid +")...");
                reason = PowerManager.GO_TO_SLEEP_REASON_APPLICATION;
                break;
        }

        mLastSleepTime = eventTime;
        mSandmanSummoned = true;
        setWakefulnessLocked(WAKEFULNESS_DOZING, reason);

        // Report the number of wake locks that will be cleared by going to sleep.
        int numWakeLocksCleared = 0;
        final int numWakeLocks = mWakeLocks.size();
        for (int i = 0; i < numWakeLocks; i++) {
            final WakeLock wakeLock = mWakeLocks.get(i);
            switch (wakeLock.mFlags & PowerManager.WAKE_LOCK_LEVEL_MASK) {
                case PowerManager.FULL_WAKE_LOCK:
                case PowerManager.SCREEN_BRIGHT_WAKE_LOCK:
                case PowerManager.SCREEN_DIM_WAKE_LOCK:
                    numWakeLocksCleared += 1;
                    break;
            }
        }
        EventLogTags.writePowerSleepRequested(numWakeLocksCleared);

        // Skip dozing if requested.
        if ((flags & PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE) != 0) {
            reallyGoToSleepNoUpdateLocked(eventTime, uid);
        }
    } finally {
        Trace.traceEnd(Trace.TRACE_TAG_POWER);
    }
    return true;
}
 
Example 10
Source File: CommCareSetupActivity.java    From commcare-android with Apache License 2.0 4 votes vote down vote up
@Override
public int getWakeLockLevel() {
    return PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE;
}