summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2014-05-13 21:10:51 -0400
committerJohn Spurlock <jspurlock@google.com>2014-05-13 21:12:18 -0400
commit76c43b9ee1fb91016265b3758d3d635105091fbe (patch)
tree920934471ccf69cd8b9ca4ad80dc3e9c24c1008b /packages/SystemUI/src
parent7fd239cf0a1ddc0500b51d97e0e6c3539b42639f (diff)
downloadframeworks_base-76c43b9ee1fb91016265b3758d3d635105091fbe.zip
frameworks_base-76c43b9ee1fb91016265b3758d3d635105091fbe.tar.gz
frameworks_base-76c43b9ee1fb91016265b3758d3d635105091fbe.tar.bz2
Fix crash in cast tile.
Change-Id: Idf2b35213d46b138b7ac866222950c6ddb48433f
Diffstat (limited to 'packages/SystemUI/src')
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSTile.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/BugreportTile.java59
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java32
3 files changed, 51 insertions, 41 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
index 39c8515..a2a7bc3 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
@@ -52,6 +52,7 @@ public abstract class QSTile<TState extends State> implements Disposable {
protected final Host mHost;
protected final Context mContext;
protected final H mHandler;
+ protected final Handler mUiHandler = new Handler(Looper.getMainLooper());
private Callback mCallback;
protected final TState mState = newTileState();
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BugreportTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BugreportTile.java
index 1a7b880..0e9b9a7 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BugreportTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BugreportTile.java
@@ -58,7 +58,7 @@ public class BugreportTile extends QSTile<QSTile.State> {
@Override
protected void handleClick() {
mHost.collapsePanels();
- showBugreportDialog();
+ mUiHandler.post(mShowDialog);
}
@Override
@@ -69,35 +69,38 @@ public class BugreportTile extends QSTile<QSTile.State> {
state.label = mContext.getString(com.android.internal.R.string.bugreport_title);
}
- private void showBugreportDialog() {
- final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
- builder.setPositiveButton(com.android.internal.R.string.report, new OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (which == DialogInterface.BUTTON_POSITIVE) {
- // Add a little delay before executing, to give the
- // dialog a chance to go away before it takes a
- // screenshot.
- mHandler.postDelayed(new Runnable() {
- @Override public void run() {
- try {
- ActivityManagerNative.getDefault().requestBugReport();
- } catch (RemoteException e) {
+ private final Runnable mShowDialog = new Runnable() {
+ @Override
+ public void run() {
+ final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
+ builder.setPositiveButton(com.android.internal.R.string.report, new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == DialogInterface.BUTTON_POSITIVE) {
+ // Add a little delay before executing, to give the
+ // dialog a chance to go away before it takes a
+ // screenshot.
+ mHandler.postDelayed(new Runnable() {
+ @Override public void run() {
+ try {
+ ActivityManagerNative.getDefault().requestBugReport();
+ } catch (RemoteException e) {
+ }
}
- }
- }, 500);
+ }, 500);
+ }
}
+ });
+ builder.setMessage(com.android.internal.R.string.bugreport_message);
+ builder.setTitle(com.android.internal.R.string.bugreport_title);
+ builder.setCancelable(true);
+ final Dialog dialog = builder.create();
+ dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
+ try {
+ WindowManagerGlobal.getWindowManagerService().dismissKeyguard();
+ } catch (RemoteException e) {
}
- });
- builder.setMessage(com.android.internal.R.string.bugreport_message);
- builder.setTitle(com.android.internal.R.string.bugreport_title);
- builder.setCancelable(true);
- final Dialog dialog = builder.create();
- dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
- try {
- WindowManagerGlobal.getWindowManagerService().dismissKeyguard();
- } catch (RemoteException e) {
+ dialog.show();
}
- dialog.show();
- }
+ };
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java
index e75bb17..a3eaa2c 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java
@@ -74,19 +74,7 @@ public class CastTile extends QSTile<QSTile.BooleanState> {
@Override
protected void handleClick() {
mHost.collapsePanels();
-
- final Dialog[] dialog = new Dialog[1];
- dialog[0] = MediaRouteDialogPresenter.createDialog(mContext,
- MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY,
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog[0].dismiss();
- mHost.startSettingsActivity(WIFI_DISPLAY_SETTINGS);
- }
- });
- dialog[0].getWindow().setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY);
- dialog[0].show();
+ mUiHandler.post(mShowDialog);
}
@Override
@@ -120,4 +108,22 @@ public class CastTile extends QSTile<QSTile.BooleanState> {
refreshState(info);
}
};
+
+ private final Runnable mShowDialog = new Runnable() {
+ private Dialog mDialog;
+ @Override
+ public void run() {
+ mDialog = MediaRouteDialogPresenter.createDialog(mContext,
+ MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY,
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mDialog.dismiss();
+ mHost.startSettingsActivity(WIFI_DISPLAY_SETTINGS);
+ }
+ });
+ mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY);
+ mDialog.show();
+ }
+ };
}