Introduction
Android Power state can be found by using console/ADB command - adb shell dumpsys power, then the message would be printed as follows,
Power Manager State:
mIsPowered=true mPowerState=3 mScreenOffTime=958909 ms
mPartialCount=1
mWakeLockState=SCREEN_BRIGHT_BIT SCREEN_ON_BIT
mUserState=
mPowerState=SCREEN_BRIGHT_BIT SCREEN_ON_BIT
mLocks.gather=SCREEN_BRIGHT_BIT SCREEN_ON_BIT
mNextTimeout=66689 now=1022321 -955s from now
mDimScreen=true mStayOnConditions=3 mPreparingForScreenOn=false mSkippedScreenOn=false
mScreenOffReason=2 mUserState=0
mBroadcastQueue={-1,-1,-1}
mBroadcastWhy={0,0,0}
mPokey=0 mPokeAwakeonSet=false
mKeyboardVisible=false mUserActivityAllowed=false
mKeylightDelay=6000 mDimDelay=47000 mScreenOffDelay=7000
mPreventScreenOn=false mScreenBrightnessOverride=-1 mButtonBrightnessOverride=-1
mScreenOffTimeoutSetting=60000 mMaximumScreenOffTimeout=2147483647
mLastScreenOnTime=1019715
mBroadcastWakeLock=UnsynchronizedWakeLock(mFlags=0x1 mCount=0 mHeld=false)
mStayOnWhilePluggedInScreenDimLock=UnsynchronizedWakeLock(mFlags=0x6 mCount=0 mHeld=true)
mStayOnWhilePluggedInPartialLock=UnsynchronizedWakeLock(mFlags=0x1 mCount=0 mHeld=true)
mPreventScreenOnPartialLock=UnsynchronizedWakeLock(mFlags=0x1 mCount=0 mHeld=false)
mProximityPartialLock=UnsynchronizedWakeLock(mFlags=0x1 mCount=0 mHeld=false)
mProximityWakeLockCount=0
mProximitySensorEnabled=false
mProximitySensorActive=false
mProximityPendingValue=-1
mLastProximityEventTime=0
mLightSensorEnabled=false mLightSensorAdjustSetting=0.0
mLightSensorValue=-1.0 mLightSensorPendingValue=-1.0
mHighestLightSensorValue=-1 mWaitingForFirstLightSensor=false
mLightSensorPendingDecrease=false mLightSensorPendingIncrease=false
mLightSensorScreenBrightness=-1 mLightSensorButtonBrightness=-1 mLightSensorKeyboardBrightness=-1
mUseSoftwareAutoBrightness=true
mAutoBrightessEnabled=false
mScreenBrightnessAnimator:
animating: start:0, end:102, duration:960, current:102
startSensorValue:-1 endSensorValue:-1
startTimeMillis:1019791 now:1022324
currentMask:SCREEN_BRIGHT_BIT
mLocks.size=3:
SCREEN_DIM_WAKE_LOCK 'StayOnWhilePluggedIn Screen Dim' activated (minState=1, uid=1000, pid=622)
PARTIAL_WAKE_LOCK 'StayOnWhilePluggedIn Partial' activated (minState=0, uid=1000, pid=622)
FULL_WAKE_LOCK 'keyguard'ACQUIRE_CAUSES_WAKEUP activated (minState=3, uid=1000, pid=622)
mPokeLocks.size=0:
The power state is listed by parameter mPowerState which has the flag value as follows,
- // flags for setPowerState
- private static final int ALL_LIGHTS_OFF = 0x00000000;
- private static final int SCREEN_ON_BIT = 0x00000001;
- private static final int SCREEN_BRIGHT_BIT = 0x00000002;
- private static final int BUTTON_BRIGHT_BIT = 0x00000004;
- private static final int KEYBOARD_BRIGHT_BIT = 0x00000008;
- private static final int BATTERY_LOW_BIT = 0x00000010;
If device is on suspend mode, it would print 0 for mPowerState parameter.
When device is on screen on mode, the value 3 is shown for parameter mPowerState because of following reason.
- // SCREEN_BRIGHT == screen on, screen backlight bright
- private static final int SCREEN_BRIGHT = SCREEN_ON_BIT | SCREEN_BRIGHT_BIT;
where SCREEN_ON_BIT and SCREEN_BRIGHT_BIT are performed or operation.
References
https://android.googlesource.com/platform/frameworks/base/+/android-4.1.2_r1/services/java/com/android/server/PowerManagerService.java
沒有留言:
張貼留言