gpt4 book ai didi

android - 100% 唤醒我的设备的正确方法?

转载 作者:行者123 更新时间:2023-11-30 04:16:42 24 4
gpt4 key购买 nike

你有更好的方法让设备 100% 唤醒吗?我反复调用 acquire() 但我不确定这是否正确。或者我应该只调用一次 acquire() 吗?还是应该使用 Intent.ACTION_SCREEN_OFF?

public class MyServiceThatKeepsTheDeviceAwake extends IntentService {   
TAG = "com.android.browser.test.launcher.BrowsePageService";
...
@Override
public void onCreate() {
super.onCreate();
mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK |PowerManager.ACQUIRE_CAUSES_WAKEUP |PowerManager.ON_AFTER_RELEASE, TAG);
}

@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
mWakeLock.acquire();
}

// No release

*此服务使用 AlarmManager 每 20 秒运行一次

---添加:

*这给了我 ff。重复运行时输出。这应该有什么问题吗?重复调用会有问题吗?

C:\Windows\System32>adb shell dumpsys power
Power Manager State:
mIsPowered=false mPowerState=3 mScreenOffTime=463571 ms
mPartialCount=9
mWakeLockState=SCREEN_BRIGHT_BIT SCREEN_ON_BIT
mUserState=
mPowerState=SCREEN_BRIGHT_BIT SCREEN_ON_BIT
mLocks.gather=SCREEN_BRIGHT_BIT SCREEN_ON_BIT
mNextTimeout=355968 now=463589 -107s from now
mDimScreen=true mStayOnConditions=0
mScreenOffReason=0 mUserState=0
mBroadcastQueue={-1,-1,-1}
mBroadcastWhy={0,0,0}
mPokey=0 mPokeAwakeonSet=false
mKeyboardVisible=false mUserActivityAllowed=true
mKeylightDelay=6000 mDimDelay=2000 mScreenOffDelay=7000
mPreventScreenOn=false mScreenBrightnessOverride=-1 mButtonBrightnessOverride=-1
mScreenOffTimeoutSetting=15000 mMaximumScreenOffTimeout=2147483647
mLastScreenOnTime=19531
mBroadcastWakeLock=UnsynchronizedWakeLock(mFlags=0x1 mCount=0 mHeld=false)
mStayOnWhilePluggedInScreenDimLock=UnsynchronizedWakeLock(mFlags=0x6 mCount=0 mHeld=false)
mStayOnWhilePluggedInPartialLock=UnsynchronizedWakeLock(mFlags=0x1 mCount=0 mHeld=false)
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=true
mLightSensorValue=1219.0 mLightSensorPendingValue=1173.0
mLightSensorPendingDecrease=true mLightSensorPendingIncrease=false
mLightSensorScreenBrightness=122 mLightSensorButtonBrightness=0 mLightSensorKeyboardBrightness=0
mUseSoftwareAutoBrightness=true
mAutoBrightessEnabled=true
mScreenBrightness: animating=false targetValue=122 curValue=122.0 delta=0.45

mLocks.size=16:
FULL_WAKE_LOCK 'com.android.browser.test.launcher.BrowsePageService'ACQUIRE_CAUSES_WAKEUP activated (minState=3, uid=10040, pid=722)
FULL_WAKE_LOCK 'com.android.browser.test.launcher.BrowsePageService'ACQUIRE_CAUSES_WAKEUP activated (minState=3, uid=10040, pid=722)
FULL_WAKE_LOCK 'com.android.browser.test.launcher.BrowsePageService'ACQUIRE_CAUSES_WAKEUP activated (minState=3, uid=10040, pid=722)
FULL_WAKE_LOCK 'com.android.browser.test.launcher.BrowsePageService'ACQUIRE_CAUSES_WAKEUP activated (minState=3, uid=10040, pid=722)
FULL_WAKE_LOCK 'com.android.browser.test.launcher.BrowsePageService'ACQUIRE_CAUSES_WAKEUP activated (minState=3, uid=10040, pid=722)
FULL_WAKE_LOCK 'com.android.browser.test.launcher.BrowsePageService'ACQUIRE_CAUSES_WAKEUP activated (minState=3, uid=10040, pid=722)
FULL_WAKE_LOCK 'com.android.browser.test.launcher.BrowsePageService'ACQUIRE_CAUSES_WAKEUP activated (minState=3, uid=10040, pid=722)
PARTIAL_WAKE_LOCK 'WSBase.lastChance' activated (minState=0, uid=10007, pid=243)
PARTIAL_WAKE_LOCK 'WSBase.lastChance' activated (minState=0, uid=10007, pid=243)
PARTIAL_WAKE_LOCK 'WSBase.lastChance' activated (minState=0, uid=10007, pid=243)
PARTIAL_WAKE_LOCK 'WSBase.lastChance' activated (minState=0, uid=10007, pid=243)
PARTIAL_WAKE_LOCK 'WSBase.lastChance' activated (minState=0, uid=10007, pid=243)
PARTIAL_WAKE_LOCK 'WSBase.lastChance' activated (minState=0, uid=10007, pid=243)
PARTIAL_WAKE_LOCK 'WSBase.lastChance' activated (minState=0, uid=10007, pid=243)
PARTIAL_WAKE_LOCK 'WSBase.lastChance' activated (minState=0, uid=10007, pid=243)
PARTIAL_WAKE_LOCK 'WSBase' activated (minState=0, uid=10007, pid=243)

mPokeLocks.size=0:

最佳答案

无需重复调用acquire()。只需在onCreate()中获取锁。它会一直工作,直到您不调用release()。只需在 Activity 的onDestroy()中调用release() , 因为它是电池消耗任务。

有关更多详细信息,请查看此 Detail Discussion on Wake up of Screen

关于android - 100% 唤醒我的设备的正确方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9867010/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com