Fix positive button when the click listener is not null.

Fixes changes made in ag/20171885:
https://screenshot.googleplex.com/4WeHHjy75A96wgf
https://screenshot.googleplex.com/3oQcLiY6AgYurB9

Bug: 252967902
Test: manual
Change-Id: I07985d540347c7b56982a90d386a5f93721344ea
This commit is contained in:
Jason Parks
2022-10-26 18:36:21 +00:00
parent 363d4b26b4
commit bd6af1a484

View File

@@ -24,6 +24,7 @@ import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Process;
import android.os.UserHandle;
import android.view.LayoutInflater;
@@ -88,10 +89,11 @@ public final class ActionDisabledByAdminDialogHelper {
public AlertDialog.Builder prepareDialogBuilder(String restriction,
EnforcedAdmin enforcedAdmin) {
DialogInterface.OnClickListener listener = mActionDisabledByAdminController
.getPositiveButtonListener(mActivity, enforcedAdmin);
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
.setPositiveButton(R.string.suggestion_button_close,
mActionDisabledByAdminController
.getPositiveButtonListener(mActivity, enforcedAdmin))
.setPositiveButton(listener == null
? R.string.suggestion_button_close : R.string.okay, listener)
.setView(mDialogView);
prepareDialogBuilder(builder, restriction, enforcedAdmin);
return builder;