<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                按鍵處理屬于本書后續將會分析的輸入系統的范圍,此處摘出和Power鍵相關的代碼進行分析,代碼如下: **com_android_server_InputManager.cpp::handleInterceptActions** ~~~ voidNativeInputManager::handleInterceptActions(jint wmActions, nsecs_t when, uint32_t& policyFlags) { //按下Power鍵并松開后,將設置wmActions為WM_ACTION_GO_TO_SLEEP,表示需要休眠 if(wmActions & WM_ACTION_GO_TO_SLEEP) { //利用JNI調用PMS的goToSleep函數 android_server_PowerManagerService_goToSleep(when); } //一般的輸入事件將觸發userActivity函數被調用,此時將喚醒手機 if(wmActions & WM_ACTION_POKE_USER_ACTIVITY) { //利用JNI調用PMS的userActivity函數。相關內容在前一節已經分析過了 android_server_PowerManagerService_userActivity(when, POWER_MANAGER_BUTTON_EVENT); } ......//其他處理 } ~~~ 由以上代碼中的注釋可知,當按下Power鍵并松開時[^write],將觸發PMS的goToSleep函數被調用。下面來看goToSleep函數的代碼: **PowerManagerService.java::goToSleep** ~~~ public void goToSleep(long time) { goToSleepWithReason(time,WindowManagerPolicy.OFF_BECAUSE_OF_USER); } public void goToSleepWithReason(long time, intreason) { mContext.enforceCallingOrSelfPermission(//檢查調用進程是否有DEVICE_POWER權限 android.Manifest.permission.DEVICE_POWER,null); synchronized (mLocks) { goToSleepLocked(time, reason);//調用goToSleepLocked函數 } } ~~~ **PowerManagerService.java::goToSleepLocked** ~~~ private void goToSleepLocked(long time, intreason) { if(mLastEventTime <= time) { mLastEventTime = time; mWakeLockState = SCREEN_OFF; int N= mLocks.size(); intnumCleared = 0; boolean proxLock = false; for(int i=0; i<N; i++) { WakeLock wl = mLocks.get(i); if(isScreenLock(wl.flags)) { if(((wl.flags & LOCK_MASK) == PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK) && reason == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR) { proxLock = true;//判斷goToSleep的原因是否與接近傳感器有關 } else{ mLocks.get(i).activated = false;//禁止和屏幕相關的WakeLock numCleared++; } }// isScreenLock判斷結束 }//for循環結束 if(!proxLock) { mProxIgnoredBecauseScreenTurnedOff = true; } mStillNeedSleepNotification = true; mUserState = SCREEN_OFF; setPowerState(SCREEN_OFF, false, reason);//關閉屏幕 cancelTimerLocked();//從mHandler中撤銷mTimeoutTask任務 } } ~~~ 掌握了前面的基礎知識就會感到Power鍵的處理流程真的是很簡單,讀者是否也有同感呢? [^write]: 必須在一定時間內完成按下和松開Power鍵的操作,否則系統會認為是關機操作。詳情將在卷Ⅲ輸入系統一章的分析。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看