0

I have an application where in onCreate() function heavy operation is performed. Thus when we launched an application, it displays white screen and then display the webview.

Now client pressed the home screen when white screen is displayed. In this scenario, launcher is not displayed. The page is still in white screen.

In log,

05-04 17:36:06.237  2841 16533 I WindowManager: Not displayed: s=Surface(name=com.android.launcher/com.android.launcher3.Launcher)/@0x228707a pv=true mDrawState=1 ph=false th=false a=true     

I have framework source code,

path: frameworks/base/services/core/java/com/android/server/wm/AppWindowToken.java                  
                    
                   
  boolean updateDrawnWindowStates(WindowState w) {                  
..............                  
                    
  if (!allDrawn && w.mightAffectAllDrawn()) {                   
            if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) {                    
                Slog.v(TAG, "Eval win " + w + ": isDrawn=" + w.isDrawnLw()                  
                        + ", isAnimationSet=" + isSelfAnimating());                 
                if (!w.isDrawnLw()) {                   
                    Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurfaceController                    
                            + " pv=" + w.isVisibleByPolicy()                    
                            + " mDrawState=" + winAnimator.drawStateToString()                  
                            + " ph=" + w.isParentWindowHidden() + " th=" + hiddenRequested                  
                            + " a=" + isSelfAnimating());                   
                }                   
            }                   
        

Kindly let me know how to redirect to homescreen when home button is pressed during blank screen or white screen.

Shadow
  • 6,864
  • 6
  • 44
  • 93
  • You do not have a control over home button interactions inside from your code. I would suggest you to place the heavy operation inside a background thread and use some kind of UI trick to show that something is happening without blocking the main thread. – hardartcore Jul 05 '23 at 11:44
  • I have aosp source code. is it possible to change in aosp? @hardartcore – Shadow Jul 05 '23 at 11:46
  • 1
    it is a bad idea to run long running tasks in the ui thread. you should create a coroutine or use WorkManager for such tasks (https://developer.android.com/topic/libraries/architecture/workmanager) What do you excatly do in the onCreate function? The Activity should be used for UI topics. According to your description you violate against any architecture pattern like MVVM or MVC or any else... – Tobias Lukoschek Jul 05 '23 at 11:47
  • Actually it's client added source code. So should not change the code in application side but can change in frameworks code in aosp – Shadow Jul 05 '23 at 13:51
  • 1
    @Shadow the main problem is as mentioned that you try to do long running tasks that should not be done on the ui thread but in any background thread. This is also a fact that you have to keep in mind when you change source code in the aosp. – Tobias Lukoschek Jul 06 '23 at 05:36

0 Answers0