Skip to content

Commit 633a906

Browse files
romanbbGerrit Code Review
authored andcommitted
PhoneWindowManager: set focus flags on keyguard panels
Ticket: CYNGNOS-3251 Change-Id: I394514335bdaeafdc7b89918ece1fe3d2794647f Signed-off-by: Roman Birg <roman@cyngn.com>
1 parent e0f87f1 commit 633a906

7 files changed

Lines changed: 72 additions & 7 deletions

File tree

core/java/com/android/internal/policy/IKeyguardStateCallback.aidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ interface IKeyguardStateCallback {
1919
void onShowingStateChanged(boolean showing);
2020
void onSimSecureStateChanged(boolean simSecure);
2121
void onInputRestrictedStateChanged(boolean inputRestricted);
22+
void onKeyguardPanelFocusChanged(boolean focused);
2223
}

packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ public class KeyguardViewMediator extends SystemUI {
175175
private static final int NOTIFY_SCREEN_TURNED_ON = 22;
176176
private static final int NOTIFY_SCREEN_TURNED_OFF = 23;
177177
private static final int NOTIFY_STARTED_GOING_TO_SLEEP = 24;
178+
private static final int NOTIFY_KEYGUARD_PANEL_FOCUS_CHANGED = 25;
178179

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

260+
private boolean mKeyguardPanelFocused = false;
261+
259262
/**
260263
* Helps remember whether the screen has turned on since the last time
261264
* it turned off due to timeout. see {@link #onScreenTurnedOff(int)}
@@ -1518,6 +1521,9 @@ public void handleMessage(Message msg) {
15181521
case ON_ACTIVITY_DRAWN:
15191522
handleOnActivityDrawn();
15201523
break;
1524+
case NOTIFY_KEYGUARD_PANEL_FOCUS_CHANGED:
1525+
notifyKeyguardPanelFocusChanged(msg.arg1 != 0);
1526+
break;
15211527
}
15221528
}
15231529
};
@@ -1969,13 +1975,39 @@ private void setShowingLocked(boolean showing) {
19691975
}
19701976
}
19711977

1978+
public void setKeyguardPanelFocused(boolean focused) {
1979+
if (DEBUG) Log.d(TAG, "setSlideOffset " + focused);
1980+
mHandler.removeMessages(NOTIFY_KEYGUARD_PANEL_FOCUS_CHANGED);
1981+
Message msg = mHandler.obtainMessage(NOTIFY_KEYGUARD_PANEL_FOCUS_CHANGED,
1982+
focused ? 1 : 0, 0);
1983+
mHandler.sendMessage(msg);
1984+
}
1985+
1986+
public void notifyKeyguardPanelFocusChanged(boolean focused) {
1987+
if (focused != mKeyguardPanelFocused) {
1988+
mKeyguardPanelFocused = focused;
1989+
int size = mKeyguardStateCallbacks.size();
1990+
for (int i = size - 1; i >= 0; i--) {
1991+
try {
1992+
mKeyguardStateCallbacks.get(i).onKeyguardPanelFocusChanged(focused);
1993+
} catch (RemoteException e) {
1994+
Slog.w(TAG, "Failed to call onShowingStateChanged", e);
1995+
if (e instanceof DeadObjectException) {
1996+
mKeyguardStateCallbacks.remove(i);
1997+
}
1998+
}
1999+
}
2000+
}
2001+
}
2002+
19722003
public void addStateMonitorCallback(IKeyguardStateCallback callback) {
19732004
synchronized (this) {
19742005
mKeyguardStateCallbacks.add(callback);
19752006
try {
19762007
callback.onSimSecureStateChanged(mUpdateMonitor.isSimPinSecure());
19772008
callback.onShowingStateChanged(mShowing);
19782009
callback.onInputRestrictedStateChanged(mInputRestricted);
2010+
callback.onKeyguardPanelFocusChanged(mKeyguardPanelFocused);
19792011
} catch (RemoteException e) {
19802012
Slog.w(TAG, "Failed to call onShowingStateChanged or onSimSecureStateChanged or onInputRestrictedStateChanged", e);
19812013
}

packages/SystemUI/src/com/android/systemui/statusbar/policy/LiveLockScreenController.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
import android.util.EventLog;
1414

1515
import android.view.View;
16+
import com.android.keyguard.KeyguardUpdateMonitor;
1617
import com.android.systemui.EventLogTags;
18+
import com.android.systemui.SystemUIApplication;
19+
import com.android.systemui.keyguard.KeyguardViewMediator;
1720
import com.android.systemui.statusbar.StatusBarState;
1821
import com.android.systemui.statusbar.phone.NotificationPanelView;
1922
import com.android.systemui.statusbar.phone.PhoneStatusBar;
@@ -46,6 +49,7 @@ public class LiveLockScreenController {
4649
private boolean mScreenOnAndInteractive;
4750

4851
private String mLlsName;
52+
private KeyguardViewMediator mKeyguardViewMediator;
4953

5054
public LiveLockScreenController(Context context, PhoneStatusBar bar,
5155
NotificationPanelView panelView) {
@@ -57,6 +61,8 @@ public LiveLockScreenController(Context context, PhoneStatusBar bar,
5761
mBar = bar;
5862
mPanelView = panelView;
5963
mPowerManager = context.getSystemService(PowerManager.class);
64+
mKeyguardViewMediator = ((SystemUIApplication)
65+
mContext.getApplicationContext()).getComponent(KeyguardViewMediator.class);
6066
registerListener();
6167
try {
6268
LiveLockScreenInfo llsInfo = mLLSM.getCurrentLiveLockScreen();
@@ -241,6 +247,7 @@ public void onScreenTurnedOff() {
241247
}
242248

243249
public void onLiveLockScreenFocusChanged(boolean hasFocus) {
250+
mKeyguardViewMediator.notifyKeyguardPanelFocusChanged(hasFocus);
244251
if (mLiveLockScreenView != null) {
245252
// make sure the LLS knows where the notification panel is
246253
mLiveLockScreenView.onLockscreenSlideOffsetChanged(hasFocus ? 0f : 1f);

services/core/java/com/android/server/policy/PhoneWindowManager.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,13 +1765,8 @@ public void onSwipeFromLeft() {
17651765
mNavigationBarLeftInLandscape) {
17661766
requestTransientBars(mNavigationBar);
17671767
}
1768-
boolean focusedWindowIsExternalKeyguard = false;
1769-
if (mFocusedWindow != null) {
1770-
focusedWindowIsExternalKeyguard = (mFocusedWindow.getAttrs().type
1771-
& WindowManager.LayoutParams.TYPE_KEYGUARD_PANEL) != 0;
1772-
}
17731768
if (mShowKeyguardOnLeftSwipe && isKeyguardShowingOrOccluded()
1774-
&& focusedWindowIsExternalKeyguard) {
1769+
&& mKeyguardDelegate.isKeyguardPanelFocused()) {
17751770
// Show keyguard
17761771
mKeyguardDelegate.showKeyguard();
17771772
}
@@ -5066,7 +5061,15 @@ public void applyPostLayoutPolicyLw(WindowState win, WindowManager.LayoutParams
50665061
if ((attrs.privateFlags & PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT) != 0) {
50675062
mForceStatusBarTransparent = true;
50685063
}
5069-
}
5064+
} else if (attrs.type == TYPE_KEYGUARD_PANEL) {
5065+
if (mKeyguardDelegate.isKeyguardPanelFocused()) {
5066+
attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
5067+
attrs.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
5068+
} else {
5069+
attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
5070+
attrs.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
5071+
}
5072+
}
50705073

50715074
boolean appWindow = attrs.type >= FIRST_APPLICATION_WINDOW
50725075
&& attrs.type < FIRST_SYSTEM_WINDOW;

services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,4 +435,11 @@ public void dump(String prefix, PrintWriter pw) {
435435
public void showKeyguard() {
436436
mKeyguardService.showKeyguard();
437437
}
438+
439+
public boolean isKeyguardPanelFocused() {
440+
if (mKeyguardService != null) {
441+
return mKeyguardService.isKeyguardPanelFocused();
442+
}
443+
return false;
444+
}
438445
}

services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,4 +253,8 @@ public void showKeyguard() {
253253
Slog.w(TAG, "Remote Exception", e);
254254
}
255255
}
256+
257+
public boolean isKeyguardPanelFocused() {
258+
return mKeyguardStateMonitor.isKeyguardPanelFocused();
259+
}
256260
}

services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
4343
private volatile boolean mIsShowing = true;
4444
private volatile boolean mSimSecure = true;
4545
private volatile boolean mInputRestricted = true;
46+
private volatile boolean mKeyguardPanelFocused = false;
4647

4748
private int mCurrentUserId;
4849

@@ -70,6 +71,10 @@ public boolean isInputRestricted() {
7071
return mInputRestricted;
7172
}
7273

74+
public boolean isKeyguardPanelFocused() {
75+
return mKeyguardPanelFocused;
76+
}
77+
7378
@Override // Binder interface
7479
public void onShowingStateChanged(boolean showing) {
7580
mIsShowing = showing;
@@ -80,6 +85,11 @@ public void onSimSecureStateChanged(boolean simSecure) {
8085
mSimSecure = simSecure;
8186
}
8287

88+
@Override // Binder interface
89+
public void onKeyguardPanelFocusChanged(boolean focused) {
90+
mKeyguardPanelFocused = focused;
91+
}
92+
8393
public synchronized void setCurrentUser(int userId) {
8494
mCurrentUserId = userId;
8595
}
@@ -100,5 +110,6 @@ public void dump(String prefix, PrintWriter pw) {
100110
pw.println(prefix + "mSimSecure=" + mSimSecure);
101111
pw.println(prefix + "mInputRestricted=" + mInputRestricted);
102112
pw.println(prefix + "mCurrentUserId=" + mCurrentUserId);
113+
pw.println(prefix + "mKeyguardPanelFocused=" + mKeyguardPanelFocused);
103114
}
104115
}

0 commit comments

Comments
 (0)