Android O 进入SystemUI Keyguard界面下半部分黑屏1s问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/CodingNotes/article/details/81281399

Android O版本进入SystemUI Keyguard界面下部分黑屏1s 问题

修改:

--- a/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/ImageWallpaper.java
+++ b/alps/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/ImageWallpaper.java
@@ -84,6 +84,7 @@ public class ImageWallpaper extends WallpaperService {
     DrawableEngine mEngine;
 
     boolean mIsHwAccelerated;
+    boolean loadWallpaperPending = false;//KCM added by kamari
 
     @Override
     public void onCreate() {
@@ -507,87 +508,144 @@ public class ImageWallpaper extends WallpaperService {
          *
          * If {@param needsReset} is set also clears the cache in WallpaperManager first.
          */
+               //modified start for Boot into the black screen in the lower half of Keyguard
+        //private void loadWallpaper(boolean needsDraw, boolean needsReset) {
+        //    mNeedsDrawAfterLoadingWallpaper |= needsDraw;
+        //    if (mLoader != null) {
+        //        if (needsReset) {
+        //            mLoader.cancel(false /* interrupt */);
+        //            mLoader = null;
+        //        } else {
+        //            if (DEBUG) {
+        //                Log.d(TAG, "Skipping loadWallpaper, already in flight ");
+        //            }
+        //            return;
+        //        }
+        //    }
+        //    mLoader = new AsyncTask<Void, Void, Bitmap>() {
+        //        @Override
+        //        protected Bitmap doInBackground(Void... params) {
+        //            Throwable exception;
+        //            try {
+        //                if (needsReset) {
+        //                    mWallpaperManager.forgetLoadedWallpaper();
+        //                }
+        //                return mWallpaperManager.getBitmap();
+        //            } catch (RuntimeException | OutOfMemoryError e) {
+        //                exception = e;
+        //            }
+        //
+        //            if (isCancelled()) {
+        //                return null;
+        //            }
+        //
+        //            if (exception != null) {
+        //                // Note that if we do fail at this, and the default wallpaper can't
+        //                // be loaded, we will go into a cycle.  Don't do a build where the
+        //                // default wallpaper can't be loaded.
+        //                Log.w(TAG, "Unable to load wallpaper!", exception);
+        //                try {
+        //                    mWallpaperManager.clear();
+        //                } catch (IOException ex) {
+        //                    // now we're really screwed.
+        //                    Log.w(TAG, "Unable reset to default wallpaper!", ex);
+        //                }
+        //
+        //                if (isCancelled()) {
+        //                    return null;
+        //                }
+        //
+        //                try {
+        //                    return mWallpaperManager.getBitmap();
+        //                } catch (RuntimeException | OutOfMemoryError e) {
+        //                    Log.w(TAG, "Unable to load default wallpaper!", e);
+        //                }
+        //            }
+        //            return null;
+        //        }
+        //
+        //        @Override
+        //        protected void onPostExecute(Bitmap b) {
+        //            mBackground = null;
+        //            mBackgroundWidth = -1;
+        //            mBackgroundHeight = -1;
+        //
+        //            if (b != null) {
+        //                mBackground = b;
+        //                mBackgroundWidth = mBackground.getWidth();
+        //                mBackgroundHeight = mBackground.getHeight();
+        //            }
+        //
+        //            if (DEBUG) {
+        //                Log.d(TAG, "Wallpaper loaded: " + mBackground);
+        //            }
+        //            updateSurfaceSize(getSurfaceHolder(), getDefaultDisplayInfo(),
+        //                    false /* forDraw */);
+        //            if (mNeedsDrawAfterLoadingWallpaper) {
+        //                drawFrame();
+        //            }
+        //
+        //            mLoader = null;
+        //            mNeedsDrawAfterLoadingWallpaper = false;
+        //        }
+        //    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+        //}
+               
+               private void loadWallpaper(boolean needsDraw, boolean needsReset) {
+                       mNeedsDrawAfterLoadingWallpaper |= needsDraw;
+                       if(!loadWallpaperPending){
+                               loadWallpaperPending = true;
+                               mBackground = null;
+                               mBackgroundWidth = -1;
+                               mBackgroundHeight = -1;
+                               Bitmap bt = null;
+                               Throwable exception = null;
+                               try {
+                                       if (needsReset) {
+                                       mWallpaperManager.forgetLoadedWallpaper();
+                                       }
+                                       bt = mWallpaperManager.getBitmap();
+                               } catch (RuntimeException | OutOfMemoryError e) {
+                                       exception = e;
+                               }
+                               if (exception != null) {
+                                       // Note that if we do fail at this, and the default wallpaper can't
+                                       // be loaded, we will go into a cycle. Don't do a build where the
+                                       // default wallpaper can't be loaded.
+                                       Log.w(TAG, "Unable to load wallpaper!", exception);
+                                       try {
+                                               mWallpaperManager.clear();
+                                       } catch (IOException ex) {
+                                               // now we're really screwed.
+                                               Log.w(TAG, "Unable reset to default wallpaper!", ex);
+                                       }
+                                       try {
+                                               bt = mWallpaperManager.getBitmap();
+                                       } catch (RuntimeException | OutOfMemoryError e) {
+                                               Log.w(TAG, "Unable to load default wallpaper!", e);
+                                       }
+                               }
+                               if (bt != null) {
+                                       mBackground = bt;
+                                       mBackgroundWidth = mBackground.getWidth();
+                                       mBackgroundHeight = mBackground.getHeight();
+                               }
+                               loadWallpaperPending = false;
+
+                               if (DEBUG) {
+                                       Log.d(TAG, "Wallpaper loaded: " + mBackground);
+                               }
+                               updateSurfaceSize(getSurfaceHolder(), getDefaultDisplayInfo(),false /* forDraw */);
+                               if (needsDraw) {
+                                       drawFrame();
+                               }
+                       }else{
+                               if (DEBUG) {
+                                       Log.d(TAG, "Skipping loadWallpaper, already in flight ");
+                               }
+                               return;
+                       }
+               }
 
         private void unloadWallpaper(boolean forgetSize) {
             if (mLoader != null) {
@@ -608,6 +666,7 @@ public class ImageWallpaper extends WallpaperService {
                 }
             }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
         }
+               //modified eng for Boot into the black screen in the lower half of Keyguard

猜你喜欢

转载自blog.csdn.net/CodingNotes/article/details/81281399