Skip to content

Commit 4e81bd4

Browse files
author
Jim Miller
committed
Attempt to fix missing transport control in keyguard
This attempts to fix a bug where the transport control would sometimes be inoperative. The problem is that we had two transport control layouts on some devices because they were being declared in the layout file. The fix is to only inflate the layout once when KeyguardHostView is created. Also removes redundant KeyguardStatusView. Fixes bug 7254833 Change-Id: Iab84e8326ff745ee57be5177ab2561114c8dc6f0
1 parent 0944d62 commit 4e81bd4

File tree

3 files changed

+51
-44
lines changed

3 files changed

+51
-44
lines changed

core/res/res/layout/keyguard_widget_region.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
android:layout_weight="1"
3333
android:clipChildren="false"
3434
android:clipToPadding="false">
35-
<!-- TODO: Remove this when supported as a widget -->
36-
<include layout="@layout/keyguard_status_view"/>
37-
<include layout="@layout/keyguard_transport_control_view"/>
3835
</com.android.internal.policy.impl.keyguard.KeyguardWidgetPager>
3936
<LinearLayout
4037
android:layout_width="match_parent"
@@ -69,4 +66,4 @@
6966
prvandroid:leftToRight="true"
7067
prvandroid:glowDot="@*android:drawable/ic_lockscreen_glowdot" />
7168
</LinearLayout>
72-
</com.android.internal.policy.impl.keyguard.KeyguardWidgetRegion>
69+
</com.android.internal.policy.impl.keyguard.KeyguardWidgetRegion>

core/res/res/values/symbols.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,8 @@
13301330
<java-symbol type="layout" name="screen_title" />
13311331
<java-symbol type="layout" name="screen_title_icons" />
13321332
<java-symbol type="layout" name="keyguard_host_view" />
1333+
<java-symbol type="layout" name="keyguard_transport_control_view" />
1334+
<java-symbol type="layout" name="keyguard_status_view" />
13331335
<java-symbol type="string" name="abbrev_wday_month_day_no_year" />
13341336
<java-symbol type="string" name="android_upgrading_title" />
13351337
<java-symbol type="string" name="bugreport_title" />

policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public class KeyguardHostView extends KeyguardViewBase {
6767
private AppWidgetHost mAppWidgetHost;
6868
private KeyguardWidgetPager mAppWidgetContainer;
6969
private ViewFlipper mSecurityViewContainer;
70+
private KeyguardTransportControlView mTransportControl;
7071
private boolean mEnableMenuKey;
7172
private boolean mIsVerifyUnlockOnly;
7273
private boolean mEnableFallback; // TODO: This should get the value from KeyguardPatternView
@@ -80,7 +81,6 @@ public class KeyguardHostView extends KeyguardViewBase {
8081
private KeyguardSecurityModel mSecurityModel;
8182

8283
private Rect mTempRect = new Rect();
83-
private KeyguardTransportControlView mTransportControl;
8484

8585
/*package*/ interface TransportCallback {
8686
void hide();
@@ -145,45 +145,7 @@ protected void onFinishInflate() {
145145
kgwr.setVisibility(VISIBLE);
146146
mSecurityViewContainer = (ViewFlipper) findViewById(R.id.view_flipper);
147147

148-
// This code manages showing/hiding the transport control. We keep it around and only
149-
// add it to the hierarchy if it needs to be present.
150-
mTransportControl =
151-
(KeyguardTransportControlView) findViewById(R.id.keyguard_transport_control);
152-
if (mTransportControl != null) {
153-
mTransportControl.setKeyguardCallback(new TransportCallback() {
154-
boolean mSticky = false;
155-
@Override
156-
public void hide() {
157-
int page = getWidgetPosition(R.id.keyguard_transport_control);
158-
if (page != -1 && !mSticky) {
159-
if (page == mAppWidgetContainer.getCurrentPage()) {
160-
// Switch back to clock view if music was showing.
161-
mAppWidgetContainer
162-
.setCurrentPage(getWidgetPosition(R.id.keyguard_status_view));
163-
}
164-
mAppWidgetContainer.removeView(mTransportControl);
165-
// XXX keep view attached to hierarchy so we still get show/hide events
166-
// from AudioManager
167-
KeyguardHostView.this.addView(mTransportControl);
168-
mTransportControl.setVisibility(View.GONE);
169-
showAppropriateWidgetPage();
170-
}
171-
}
172-
173-
@Override
174-
public void show() {
175-
if (getWidgetPosition(R.id.keyguard_transport_control) == -1) {
176-
KeyguardHostView.this.removeView(mTransportControl);
177-
mAppWidgetContainer.addView(mTransportControl,
178-
getWidgetPosition(R.id.keyguard_status_view) + 1);
179-
mTransportControl.setVisibility(View.VISIBLE);
180-
// Once shown, leave it showing
181-
mSticky = true;
182-
showAppropriateWidgetPage();
183-
}
184-
}
185-
});
186-
}
148+
addDefaultWidgets();
187149
updateSecurityViews();
188150
setSystemUiVisibility(getSystemUiVisibility() | View.STATUS_BAR_DISABLE_BACK);
189151
}
@@ -702,6 +664,52 @@ private void addWidget(int appId) {
702664
}
703665
}
704666

667+
private void addDefaultWidgets() {
668+
LayoutInflater inflater = LayoutInflater.from(mContext);
669+
inflater.inflate(R.layout.keyguard_status_view, mAppWidgetContainer, true);
670+
inflater.inflate(R.layout.keyguard_transport_control_view, mAppWidgetContainer, true);
671+
672+
mTransportControl =
673+
(KeyguardTransportControlView) findViewById(R.id.keyguard_transport_control);
674+
675+
676+
// This code manages showing/hiding the transport control. We keep it around and only
677+
// add it to the hierarchy if it needs to be present.
678+
if (mTransportControl != null) {
679+
mTransportControl.setKeyguardCallback(new TransportCallback() {
680+
boolean mSticky = false;
681+
@Override
682+
public void hide() {
683+
int page = getWidgetPosition(R.id.keyguard_transport_control);
684+
if (page != -1 && !mSticky) {
685+
if (page == mAppWidgetContainer.getCurrentPage()) {
686+
// Switch back to clock view if music was showing.
687+
mAppWidgetContainer
688+
.setCurrentPage(getWidgetPosition(R.id.keyguard_status_view));
689+
}
690+
mAppWidgetContainer.removeView(mTransportControl);
691+
// XXX keep view attached to hierarchy so we still get show/hide events
692+
// from AudioManager
693+
KeyguardHostView.this.addView(mTransportControl);
694+
mTransportControl.setVisibility(View.GONE);
695+
}
696+
}
697+
698+
@Override
699+
public void show() {
700+
if (getWidgetPosition(R.id.keyguard_transport_control) == -1) {
701+
KeyguardHostView.this.removeView(mTransportControl);
702+
mAppWidgetContainer.addView(mTransportControl,
703+
getWidgetPosition(R.id.keyguard_status_view) + 1);
704+
mTransportControl.setVisibility(View.VISIBLE);
705+
// Once shown, leave it showing
706+
mSticky = true;
707+
}
708+
}
709+
});
710+
}
711+
}
712+
705713
private void maybePopulateWidgets() {
706714
DevicePolicyManager dpm =
707715
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);

0 commit comments

Comments
 (0)