Fix crash in cast tile.
Change-Id: Idf2b35213d46b138b7ac866222950c6ddb48433f
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user