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

Commit 137fd4d4 authored by Roman Birg's avatar Roman Birg Committed by Gerrit Code Review
Browse files

PhoneWindowManager: set focus flags on keyguard panels



Ticket: CYNGNOS-3251

Change-Id: I394514335bdaeafdc7b89918ece1fe3d2794647f
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 14679247
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -19,4 +19,5 @@ interface IKeyguardStateCallback {
    void onShowingStateChanged(boolean showing);
    void onShowingStateChanged(boolean showing);
    void onSimSecureStateChanged(boolean simSecure);
    void onSimSecureStateChanged(boolean simSecure);
    void onInputRestrictedStateChanged(boolean inputRestricted);
    void onInputRestrictedStateChanged(boolean inputRestricted);
    void onKeyguardPanelFocusChanged(boolean focused);
}
}
 No newline at end of file
+32 −0
Original line number Original line Diff line number Diff line
@@ -175,6 +175,7 @@ public class KeyguardViewMediator extends SystemUI {
    private static final int NOTIFY_SCREEN_TURNED_ON = 22;
    private static final int NOTIFY_SCREEN_TURNED_ON = 22;
    private static final int NOTIFY_SCREEN_TURNED_OFF = 23;
    private static final int NOTIFY_SCREEN_TURNED_OFF = 23;
    private static final int NOTIFY_STARTED_GOING_TO_SLEEP = 24;
    private static final int NOTIFY_STARTED_GOING_TO_SLEEP = 24;
    private static final int NOTIFY_KEYGUARD_PANEL_FOCUS_CHANGED = 25;


    /**
    /**
     * The default amount of time we stay awake (used for all key input)
     * The default amount of time we stay awake (used for all key input)
@@ -256,6 +257,8 @@ public class KeyguardViewMediator extends SystemUI {
    // true if the keyguard is hidden by another window
    // true if the keyguard is hidden by another window
    private boolean mOccluded = false;
    private boolean mOccluded = false;


    private boolean mKeyguardPanelFocused = false;

    /**
    /**
     * Helps remember whether the screen has turned on since the last time
     * Helps remember whether the screen has turned on since the last time
     * it turned off due to timeout. see {@link #onScreenTurnedOff(int)}
     * it turned off due to timeout. see {@link #onScreenTurnedOff(int)}
@@ -1518,6 +1521,9 @@ public class KeyguardViewMediator extends SystemUI {
                case ON_ACTIVITY_DRAWN:
                case ON_ACTIVITY_DRAWN:
                    handleOnActivityDrawn();
                    handleOnActivityDrawn();
                    break;
                    break;
                case NOTIFY_KEYGUARD_PANEL_FOCUS_CHANGED:
                    notifyKeyguardPanelFocusChanged(msg.arg1 != 0);
                    break;
            }
            }
        }
        }
    };
    };
@@ -1969,6 +1975,31 @@ public class KeyguardViewMediator extends SystemUI {
        }
        }
    }
    }


    public void setKeyguardPanelFocused(boolean focused) {
        if (DEBUG) Log.d(TAG, "setSlideOffset " + focused);
        mHandler.removeMessages(NOTIFY_KEYGUARD_PANEL_FOCUS_CHANGED);
        Message msg = mHandler.obtainMessage(NOTIFY_KEYGUARD_PANEL_FOCUS_CHANGED,
                focused ? 1 : 0, 0);
        mHandler.sendMessage(msg);
    }

    public void notifyKeyguardPanelFocusChanged(boolean focused) {
        if (focused != mKeyguardPanelFocused) {
            mKeyguardPanelFocused = focused;
            int size = mKeyguardStateCallbacks.size();
            for (int i = size - 1; i >= 0; i--) {
                try {
                    mKeyguardStateCallbacks.get(i).onKeyguardPanelFocusChanged(focused);
                } catch (RemoteException e) {
                    Slog.w(TAG, "Failed to call onShowingStateChanged", e);
                    if (e instanceof DeadObjectException) {
                        mKeyguardStateCallbacks.remove(i);
                    }
                }
            }
        }
    }

    public void addStateMonitorCallback(IKeyguardStateCallback callback) {
    public void addStateMonitorCallback(IKeyguardStateCallback callback) {
        synchronized (this) {
        synchronized (this) {
            mKeyguardStateCallbacks.add(callback);
            mKeyguardStateCallbacks.add(callback);
@@ -1976,6 +2007,7 @@ public class KeyguardViewMediator extends SystemUI {
                callback.onSimSecureStateChanged(mUpdateMonitor.isSimPinSecure());
                callback.onSimSecureStateChanged(mUpdateMonitor.isSimPinSecure());
                callback.onShowingStateChanged(mShowing);
                callback.onShowingStateChanged(mShowing);
                callback.onInputRestrictedStateChanged(mInputRestricted);
                callback.onInputRestrictedStateChanged(mInputRestricted);
                callback.onKeyguardPanelFocusChanged(mKeyguardPanelFocused);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Slog.w(TAG, "Failed to call onShowingStateChanged or onSimSecureStateChanged or onInputRestrictedStateChanged", e);
                Slog.w(TAG, "Failed to call onShowingStateChanged or onSimSecureStateChanged or onInputRestrictedStateChanged", e);
            }
            }
+8 −0
Original line number Original line Diff line number Diff line
@@ -11,7 +11,10 @@ import android.os.ServiceManager;
import android.util.EventLog;
import android.util.EventLog;


import android.view.View;
import android.view.View;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.EventLogTags;
import com.android.systemui.EventLogTags;
import com.android.systemui.SystemUIApplication;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.NotificationPanelView;
import com.android.systemui.statusbar.phone.NotificationPanelView;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
@@ -43,6 +46,8 @@ public class LiveLockScreenController {


    private boolean mScreenOnAndInteractive;
    private boolean mScreenOnAndInteractive;


    private KeyguardViewMediator mKeyguardViewMediator;

    public LiveLockScreenController(Context context, PhoneStatusBar bar,
    public LiveLockScreenController(Context context, PhoneStatusBar bar,
            NotificationPanelView panelView) {
            NotificationPanelView panelView) {
        mContext = context;
        mContext = context;
@@ -53,6 +58,8 @@ public class LiveLockScreenController {
        mBar = bar;
        mBar = bar;
        mPanelView = panelView;
        mPanelView = panelView;
        mPowerManager = context.getSystemService(PowerManager.class);
        mPowerManager = context.getSystemService(PowerManager.class);
        mKeyguardViewMediator = ((SystemUIApplication)
                mContext.getApplicationContext()).getComponent(KeyguardViewMediator.class);
        registerListener();
        registerListener();
        try {
        try {
            LiveLockScreenInfo llsInfo = mLLSM.getCurrentLiveLockScreen();
            LiveLockScreenInfo llsInfo = mLLSM.getCurrentLiveLockScreen();
@@ -237,6 +244,7 @@ public class LiveLockScreenController {
    }
    }


    public void onLiveLockScreenFocusChanged(boolean hasFocus) {
    public void onLiveLockScreenFocusChanged(boolean hasFocus) {
        mKeyguardViewMediator.notifyKeyguardPanelFocusChanged(hasFocus);
        if (mLiveLockScreenView != null) {
        if (mLiveLockScreenView != null) {
            // make sure the LLS knows where the notification panel is
            // make sure the LLS knows where the notification panel is
            mLiveLockScreenView.onLockscreenSlideOffsetChanged(hasFocus ? 0f : 1f);
            mLiveLockScreenView.onLockscreenSlideOffsetChanged(hasFocus ? 0f : 1f);
+10 −7
Original line number Original line Diff line number Diff line
@@ -1764,13 +1764,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                                mNavigationBarLeftInLandscape) {
                                mNavigationBarLeftInLandscape) {
                            requestTransientBars(mNavigationBar);
                            requestTransientBars(mNavigationBar);
                        }
                        }
                        boolean focusedWindowIsExternalKeyguard = false;
                        if (mFocusedWindow != null) {
                            focusedWindowIsExternalKeyguard = (mFocusedWindow.getAttrs().type
                                    & WindowManager.LayoutParams.TYPE_KEYGUARD_PANEL) != 0;
                        }
                        if (mShowKeyguardOnLeftSwipe && isKeyguardShowingOrOccluded()
                        if (mShowKeyguardOnLeftSwipe && isKeyguardShowingOrOccluded()
                                && focusedWindowIsExternalKeyguard) {
                                && mKeyguardDelegate.isKeyguardPanelFocused()) {
                            // Show keyguard
                            // Show keyguard
                            mKeyguardDelegate.showKeyguard();
                            mKeyguardDelegate.showKeyguard();
                        }
                        }
@@ -5065,6 +5060,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            if ((attrs.privateFlags & PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT) != 0) {
            if ((attrs.privateFlags & PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT) != 0) {
                mForceStatusBarTransparent = true;
                mForceStatusBarTransparent = true;
            }
            }
        } else if (attrs.type == TYPE_KEYGUARD_PANEL) {
            if (mKeyguardDelegate.isKeyguardPanelFocused()) {
                attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
                attrs.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
            } else {
                attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
                attrs.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
            }
       }
       }


        boolean appWindow = attrs.type >= FIRST_APPLICATION_WINDOW
        boolean appWindow = attrs.type >= FIRST_APPLICATION_WINDOW
+7 −0
Original line number Original line Diff line number Diff line
@@ -435,4 +435,11 @@ public class KeyguardServiceDelegate {
    public void showKeyguard() {
    public void showKeyguard() {
        mKeyguardService.showKeyguard();
        mKeyguardService.showKeyguard();
    }
    }

    public boolean isKeyguardPanelFocused() {
        if (mKeyguardService != null) {
           return mKeyguardService.isKeyguardPanelFocused();
        }
        return false;
    }
}
}
Loading