Fix RequestPermissionActivity crash
- Dialog needs to use AppCompat theme. - Activity needs to finish itself when user closed AlertDialog. If we don't fix it, you can see a window after AlertDialog was dismissed. Change-Id: Idfbd6b68bcdd3b577f1459657b635b7af9397276 Fixes: 112018696 Test: robo test, manual test
This commit is contained in:
@@ -161,7 +161,7 @@
|
|||||||
<item name="android:navigationBarColor">#00000000</item>
|
<item name="android:navigationBarColor">#00000000</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.BluetoothPermission" parent="@android:style/Theme.Material.Light.Dialog.Alert">
|
<style name="Theme.BluetoothPermission" parent="@style/Theme.AlertDialog">
|
||||||
<item name="android:windowNoTitle">true</item>
|
<item name="android:windowNoTitle">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
@@ -32,17 +32,17 @@ import android.os.Bundle;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settingslib.bluetooth.BluetoothDiscoverableTimeoutReceiver;
|
import com.android.settingslib.bluetooth.BluetoothDiscoverableTimeoutReceiver;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RequestPermissionActivity asks the user whether to enable discovery. This is
|
* RequestPermissionActivity asks the user whether to enable discovery. This is
|
||||||
* usually started by an application wanted to start bluetooth and or discovery
|
* usually started by an application wanted to start bluetooth and or discovery
|
||||||
*/
|
*/
|
||||||
public class RequestPermissionActivity extends Activity implements
|
public class RequestPermissionActivity extends Activity implements
|
||||||
DialogInterface.OnClickListener {
|
DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
|
||||||
// Command line to test this
|
// Command line to test this
|
||||||
// adb shell am start -a android.bluetooth.adapter.action.REQUEST_ENABLE
|
// adb shell am start -a android.bluetooth.adapter.action.REQUEST_ENABLE
|
||||||
// adb shell am start -a android.bluetooth.adapter.action.REQUEST_DISCOVERABLE
|
// adb shell am start -a android.bluetooth.adapter.action.REQUEST_DISCOVERABLE
|
||||||
@@ -188,6 +188,7 @@ public class RequestPermissionActivity extends Activity implements
|
|||||||
builder.setNegativeButton(getString(R.string.deny), this);
|
builder.setNegativeButton(getString(R.string.deny), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
builder.setOnDismissListener(this);
|
||||||
mDialog = builder.create();
|
mDialog = builder.create();
|
||||||
mDialog.show();
|
mDialog.show();
|
||||||
}
|
}
|
||||||
@@ -238,12 +239,16 @@ public class RequestPermissionActivity extends Activity implements
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE:
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
setResult(RESULT_CANCELED);
|
cancelAndFinish();
|
||||||
finish();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDismiss(final DialogInterface dialog) {
|
||||||
|
cancelAndFinish();
|
||||||
|
}
|
||||||
|
|
||||||
private void proceedAndFinish() {
|
private void proceedAndFinish() {
|
||||||
int returnCode;
|
int returnCode;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user