Skip to content

Commit 2f35281

Browse files
Jim MillerAndroid (Google) Code Review
authored andcommitted
Merge "Fix 5485925: Fix crash in transport control view" into ics-mr0
2 parents f806871 + a5ff5b4 commit 2f35281

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

core/java/com/android/internal/widget/TransportControlView.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@ public class TransportControlView extends FrameLayout implements OnClickListener
8686
*/
8787
private Bundle mPopulateMetadataWhenAttached = null;
8888

89-
/**
90-
* Whether to clear the interface next time it is shown (i.e. the generation id changed)
91-
*/
92-
private boolean mClearOnNextShow;
93-
9489
// This handler is required to ensure messages from IRCD are handled in sequence and on
9590
// the UI thread.
9691
private Handler mHandler = new Handler() {
@@ -121,7 +116,10 @@ public void handleMessage(Message msg) {
121116

122117
case MSG_SET_GENERATION_ID:
123118
if (msg.arg2 != 0) {
124-
mClearOnNextShow = true; // TODO: handle this
119+
// This means nobody is currently registered. Hide the view.
120+
if (mWidgetCallbacks != null) {
121+
mWidgetCallbacks.requestHide(TransportControlView.this);
122+
}
125123
}
126124
if (DEBUG) Log.v(TAG, "New genId = " + msg.arg1 + ", clearing = " + msg.arg2);
127125
mClientGeneration = msg.arg1;
@@ -412,7 +410,7 @@ public Parcelable onSaveInstanceState() {
412410
if (DEBUG) Log.v(TAG, "onSaveInstanceState()");
413411
Parcelable superState = super.onSaveInstanceState();
414412
SavedState ss = new SavedState(superState);
415-
ss.wasShowing = mWidgetCallbacks.isVisible(this);
413+
ss.wasShowing = mWidgetCallbacks != null && mWidgetCallbacks.isVisible(this);
416414
return ss;
417415
}
418416

@@ -425,7 +423,7 @@ public void onRestoreInstanceState(Parcelable state) {
425423
}
426424
SavedState ss = (SavedState) state;
427425
super.onRestoreInstanceState(ss.getSuperState());
428-
if (ss.wasShowing) {
426+
if (ss.wasShowing && mWidgetCallbacks != null) {
429427
mWidgetCallbacks.requestShow(this);
430428
}
431429
}
@@ -449,6 +447,11 @@ public void onClick(View v) {
449447
}
450448

451449
private void sendMediaButtonClick(int keyCode) {
450+
if (mClientIntent == null) {
451+
// Shouldn't be possible because this view should be hidden in this case.
452+
Log.e(TAG, "sendMediaButtonClick(): No client is currently registered");
453+
return;
454+
}
452455
// use the registered PendingIntent that will be processed by the registered
453456
// media button event receiver, which is the component of mClientIntent
454457
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);

0 commit comments

Comments
 (0)