Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7007411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:36:14+00:00 2026-05-27T21:36:14+00:00

so I am looking into PowerManager to prevent phone from going to sleep. Two

  • 0

so I am looking into PowerManager to prevent phone from going to sleep.

Two questions:

1) My phone is currently set to turn the display off after X seconds, will the PowerManager.Wakelock functions override this?

2) My phone has a top button which can be used to turn off the display, or shut the phone off. Will PowerManager.WakeLock override this functionality as well?

insight appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:36:14+00:00Added an answer on May 27, 2026 at 9:36 pm
    1. I’m not sure but I think so. And it’s hard to me to find this
      functionality in the sources.
    2. There is a function in PowerManager.java goToSleep(time). This
      function simply calls method of PowerManagerService goToSleepLocked:

      private void goToSleepLocked(long time, int reason) {
      
      if (mLastEventTime <= time) {
      mLastEventTime = time;
      // cancel all of the wake locks
      mWakeLockState = SCREEN_OFF;
      int N = mLocks.size();
      int numCleared = 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;
              } else {
                  mLocks.get(i).activated = false;
                  numCleared++;
              }
          }
      }
      if (!proxLock) {
          mProxIgnoredBecauseScreenTurnedOff = true;
          if (mDebugProximitySensor) {
              Slog.d(TAG, "setting mProxIgnoredBecauseScreenTurnedOff");
          }
      }
      EventLog.writeEvent(EventLogTags.POWER_SLEEP_REQUESTED, numCleared);
      mStillNeedSleepNotification = true;
      mUserState = SCREEN_OFF;
      setPowerState(SCREEN_OFF, false, reason);
      cancelTimerLocked();
      }
      }
      

    So you can see that all wakelocks are shutdowned in this method.

    The method goToSleep can be called only by system components (protected with signature permission). And I think that it is called during the press of your power button. So it rewrites all the wakelocks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently looking into learn new technology and silverlight is on the potential list. However,
Currently looking into distributed memory cache solutions, such as Memcached and Microsoft's AppFabric caching.
I'm currently looking into automating a flex build so that we can get it
Was looking into some GPU CUDA samples and trying some samples out from Nvidia's
I'm currently looking into using C++/CLI to bridge the gap between managed C# and
I'm looking into buying an Android phone and I'd like to do some development
I'm looking into changing the ASP.NET session state mode of our application from SQLServer
I've been looking into a number of ways to display a large number of
I'm currently looking into options for process monitoring of Rails/Ruby Projects and quite like
I am looking into multiplayer connectivity options for a two player game and wondering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.