Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2b95ce9a authored by Yunfan Chen's avatar Yunfan Chen
Browse files

Load immersive confirm settings at start

It is necessary to load the settings when the ImmersiveModeConfirmation
started, otherwise the value won't be correct before the first
interaction related to immersive mode and the immersive dialog may
appear unexpectedly.

Bug: 363074067
Test: Enable debug and boot to check the settings value
Flag: com.android.window.flags.system_ui_immersive_confirmation_dialog
Change-Id: Ia7215bbf7f60de9d92dc39a63604c589cfdc1034
parent 372598b2
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ import android.widget.RelativeLayout;
import com.android.app.viewcapture.ViewCapture;
import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
import com.android.systemui.CoreStartable;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.res.R;
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.shared.system.TaskStackChangeListeners;
@@ -107,6 +108,7 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca
    private Context mDisplayContext;
    private final Context mSysUiContext;
    private final Handler mHandler = new H(Looper.getMainLooper());
    private final Handler mBackgroundHandler;
    private long mShowDelayMs = 0L;
    private final IBinder mWindowToken = new Binder();
    private final CommandQueue mCommandQueue;
@@ -139,7 +141,8 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca
    @Inject
    public ImmersiveModeConfirmation(Context context, CommandQueue commandQueue,
                                     SecureSettings secureSettings,
                                     dagger.Lazy<ViewCapture> daggerLazyViewCapture) {
                                     dagger.Lazy<ViewCapture> daggerLazyViewCapture,
                                     @Background Handler backgroundHandler) {
        mSysUiContext = context;
        final Display display = mSysUiContext.getDisplay();
        mDisplayContext = display.getDisplayId() == DEFAULT_DISPLAY
@@ -147,6 +150,7 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca
        mCommandQueue = commandQueue;
        mSecureSettings = secureSettings;
        mLazyViewCapture = toKotlinLazy(daggerLazyViewCapture);
        mBackgroundHandler = backgroundHandler;
    }

    boolean loadSetting(int currentUserId) {
@@ -329,7 +333,7 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca
                }
            }
            TaskStackChangeListeners.getInstance().registerTaskStackListener(this);
            mContentObserver = new ContentObserver(mHandler) {
            mContentObserver = new ContentObserver(mBackgroundHandler) {
                @Override
                public void onChange(boolean selfChange) {
                    onSettingChanged(mSysUiContext.getUserId());
@@ -343,6 +347,9 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca
            mSecureSettings.registerContentObserverForUserSync(
                    Settings.Secure.USER_SETUP_COMPLETE, mContentObserver,
                    UserHandle.USER_CURRENT);
            mBackgroundHandler.post(() -> {
                loadSetting(UserHandle.USER_CURRENT);
            });
        }
    }