Fix projection permission dialog layering
Bug: 18392920
Change-Id: I32c2c61339cbea9edd4a7a3f80365213fb4a69ac
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 0cbbf87..0e69f74 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -266,7 +266,7 @@
<activity
android:name=".media.MediaProjectionPermissionActivity"
android:exported="true"
- android:theme="@style/Theme.SystemUI.Dialog.Alert"
+ android:theme="@style/Theme.AlertDialogHost"
android:finishOnCloseSystemDialogs="true"
android:launchMode="singleTop"
android:excludeFromRecents="true" />
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index 8d1e967..09b240b 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -262,4 +262,14 @@
<style name="UserDetailView">
<item name="numColumns">3</item>
</style>
+
+ <style name="Theme.AlertDialogHost" parent="android:Theme.DeviceDefault">
+ <item name="android:windowIsTranslucent">true</item>
+ <item name="android:windowBackground">@android:color/transparent</item>
+ <item name="android:windowContentOverlay">@null</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:windowIsFloating">true</item>
+ <item name="android:backgroundDimEnabled">false</item>
+ <item name="android:alertDialogTheme">@style/Theme.SystemUI.Dialog.Alert</item>
+ </style>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaProjectionPermissionActivity.java b/packages/SystemUI/src/com/android/systemui/media/MediaProjectionPermissionActivity.java
index b441eaa..25bab17 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaProjectionPermissionActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaProjectionPermissionActivity.java
@@ -16,6 +16,7 @@
package com.android.systemui.media;
+import android.app.Activity;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.Context;
@@ -32,6 +33,7 @@
import android.os.ServiceManager;
import android.util.Log;
import android.view.LayoutInflater;
+import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
@@ -39,9 +41,11 @@
import com.android.internal.app.AlertActivity;
import com.android.internal.app.AlertController;
import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.SystemUIDialog;
-public class MediaProjectionPermissionActivity extends AlertActivity
- implements DialogInterface.OnClickListener, CheckBox.OnCheckedChangeListener {
+public class MediaProjectionPermissionActivity extends Activity
+ implements DialogInterface.OnClickListener, CheckBox.OnCheckedChangeListener,
+ DialogInterface.OnCancelListener {
private static final String TAG = "MediaProjectionPermissionActivity";
private boolean mPermanentGrant;
@@ -49,11 +53,12 @@
private int mUid;
private IMediaProjectionManager mService;
+ private AlertDialog mDialog;
+
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- Intent intent = getIntent();
mPackageName = getCallingPackage();
IBinder b = ServiceManager.getService(MEDIA_PROJECTION_SERVICE);
mService = IMediaProjectionManager.Stub.asInterface(b);
@@ -89,22 +94,27 @@
String appName = aInfo.loadLabel(packageManager).toString();
- final AlertController.AlertParams ap = mAlertParams;
- ap.mIcon = aInfo.loadIcon(packageManager);
- ap.mMessage = getString(R.string.media_projection_dialog_text, appName);
- ap.mPositiveButtonText = getString(R.string.media_projection_action_text);
- ap.mNegativeButtonText = getString(android.R.string.cancel);
- ap.mPositiveButtonListener = this;
- ap.mNegativeButtonListener = this;
+ mDialog = new AlertDialog.Builder(this)
+ .setIcon(aInfo.loadIcon(packageManager))
+ .setMessage(getString(R.string.media_projection_dialog_text, appName))
+ .setPositiveButton(R.string.media_projection_action_text, this)
+ .setNegativeButton(android.R.string.cancel, this)
+ .setView(R.layout.remember_permission_checkbox)
+ .setOnCancelListener(this)
+ .create();
- // add "always use" checkbox
- LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- ap.mView = inflater.inflate(R.layout.remember_permission_checkbox, null);
- CheckBox rememberPermissionCheckbox =
- (CheckBox)ap.mView.findViewById(R.id.remember);
- rememberPermissionCheckbox.setOnCheckedChangeListener(this);
+ mDialog.create();
- setupAlert();
+ ((CheckBox) mDialog.findViewById(R.id.remember)).setOnCheckedChangeListener(this);
+ mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
+
+ mDialog.show();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mDialog.dismiss();
}
@Override
@@ -118,6 +128,7 @@
Log.e(TAG, "Error granting projection permission", e);
setResult(RESULT_CANCELED);
} finally {
+ mDialog.dismiss();
finish();
}
}
@@ -135,4 +146,9 @@
intent.putExtra(MediaProjectionManager.EXTRA_MEDIA_PROJECTION, projection.asBinder());
return intent;
}
+
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ finish();
+ }
}