diff options
| author | 2015-04-17 01:20:09 +0000 | |
|---|---|---|
| committer | 2015-04-17 01:20:09 +0000 | |
| commit | cba75f315967bba103805046b122e9a58687b85d (patch) | |
| tree | 148acfd5284755e92637afb9c599861e796dbe25 | |
| parent | 1ba9585506521a2bb722ef692dc7152291306898 (diff) | |
| parent | 47e743b9e276d89ded2b9c50af61db2ce5529706 (diff) | |
am 47e743b9: am 4544b927: Hold a wake lock while dozing when wallpaper draws.
* commit '47e743b9e276d89ded2b9c50af61db2ce5529706':
Hold a wake lock while dozing when wallpaper draws.
| -rw-r--r-- | core/java/android/service/wallpaper/WallpaperService.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 1674950e66ce..016541fe3e90 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -17,6 +17,7 @@ package android.service.wallpaper; import android.content.res.TypedArray; +import android.graphics.Canvas; import android.os.SystemProperties; import android.view.WindowInsets; @@ -185,6 +186,7 @@ public abstract class WallpaperService extends Service { DisplayManager mDisplayManager; Display mDisplay; + private int mDisplayState; final BaseSurfaceHolder mSurfaceHolder = new BaseSurfaceHolder() { { @@ -228,7 +230,19 @@ public abstract class WallpaperService extends Service { throw new UnsupportedOperationException( "Wallpapers do not support keep screen on"); } - + + @Override + public Canvas lockCanvas() { + if (mDisplayState == Display.STATE_DOZE + || mDisplayState == Display.STATE_DOZE_SUSPEND) { + try { + mSession.pokeDrawLock(mWindow); + } catch (RemoteException e) { + // System server died, can be ignored. + } + } + return super.lockCanvas(); + } }; final class WallpaperInputEventReceiver extends InputEventReceiver { @@ -831,9 +845,12 @@ public abstract class WallpaperService extends Service { mWindow.setSession(mSession); + mLayout.packageName = getPackageName(); + mDisplayManager = (DisplayManager)getSystemService(Context.DISPLAY_SERVICE); mDisplayManager.registerDisplayListener(mDisplayListener, mCaller.getHandler()); mDisplay = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY); + mDisplayState = mDisplay.getState(); if (DEBUG) Log.v(TAG, "onCreate(): " + this); onCreate(mSurfaceHolder); @@ -873,8 +890,8 @@ public abstract class WallpaperService extends Service { void reportVisibility() { if (!mDestroyed) { - boolean visible = mVisible - & mDisplay != null && mDisplay.getState() != Display.STATE_OFF; + mDisplayState = mDisplay == null ? Display.STATE_UNKNOWN : mDisplay.getState(); + boolean visible = mVisible && mDisplayState != Display.STATE_OFF; if (mReportedVisible != visible) { mReportedVisible = visible; if (DEBUG) Log.v(TAG, "onVisibilityChanged(" + visible |