summaryrefslogtreecommitdiff
path: root/WifiDialog/src
diff options
context:
space:
mode:
author Quang Luong <qal@google.com> 2022-02-28 13:32:50 -0800
committer Quang Luong <qal@google.com> 2022-03-02 15:56:38 -0800
commit2103b9ffde75e5f37060e5d60436b44d1cb02204 (patch)
tree2ca079d89b7f985585b661fe6144e72aa6ee30cf /WifiDialog/src
parent950c3273a1f1a1e922c683534427e0ba8c490aa6 (diff)
Use WifiDialogManager for P2P Invitation Sent dialog
Replace usage of FrameworkFacade.makeAlertDialogBuilder(...) with the new WifiDialogManager for the P2P Invitation Sent dialog. Bug: 209032090 Test: atest WifiP2pServiceImplTest, manually verify dialog is shown for CtsVerifier->Wi-Fi Direct Test->Group Client Test ->Join p2p group test (PIN) Change-Id: I3e4b89d26c89037059614e4ba97b13a73f123d69
Diffstat (limited to 'WifiDialog/src')
-rw-r--r--WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
index 035ad8be51..1c8ddf3c23 100644
--- a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
+++ b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
@@ -305,6 +305,12 @@ public class WifiDialogActivity extends Activity {
intent.getStringExtra(WifiManager.EXTRA_DIALOG_NEGATIVE_BUTTON_TEXT),
intent.getStringExtra(WifiManager.EXTRA_DIALOG_NEUTRAL_BUTTON_TEXT));
break;
+ case WifiManager.DIALOG_TYPE_P2P_INVITATION_SENT:
+ dialog = createP2pInvitationSentDialog(
+ dialogId,
+ intent.getStringExtra(WifiManager.EXTRA_P2P_DEVICE_NAME),
+ intent.getStringExtra(WifiManager.EXTRA_P2P_DISPLAY_PIN));
+ break;
case WifiManager.DIALOG_TYPE_P2P_INVITATION_RECEIVED:
dialog = createP2pInvitationReceivedDialog(
dialogId,
@@ -436,6 +442,54 @@ public class WifiDialogActivity extends Activity {
}
/**
+ * Returns a P2P Invitation Sent Dialog for the given Intent, or {@code null} if no Dialog
+ * could be created.
+ */
+ private @Nullable Dialog createP2pInvitationSentDialog(
+ final int dialogId,
+ final @NonNull String deviceName,
+ @Nullable String displayPin) {
+ if (TextUtils.isEmpty(deviceName)) {
+ if (mIsVerboseLoggingEnabled) {
+ Log.v(TAG, "Could not create P2P Invitation Sent dialog with null or empty"
+ + " device name."
+ + " id=" + dialogId
+ + " deviceName=" + deviceName
+ + " displayPin=" + displayPin);
+ }
+ return null;
+ }
+
+ final View textEntryView = LayoutInflater.from(this)
+ .inflate(getLayoutId("wifi_p2p_dialog"), null);
+ ViewGroup group = textEntryView.findViewById(getViewId("info"));
+ addRowToP2pDialog(group, getStringId("wifi_p2p_to_message"), deviceName);
+
+ if (displayPin != null) {
+ addRowToP2pDialog(group, getStringId("wifi_p2p_show_pin_message"), displayPin);
+ }
+
+ AlertDialog dialog = new AlertDialog.Builder(this)
+ .setTitle(getString(getStringId("wifi_p2p_invitation_sent_title")))
+ .setView(textEntryView)
+ .setPositiveButton(getStringId("ok"), (dialogPositive, which) -> {
+ // No-op
+ if (mIsVerboseLoggingEnabled) {
+ Log.v(TAG, "P2P Invitation Sent Dialog id=" + dialogId
+ + " accepted.");
+ }
+ })
+ .create();
+ if (mIsVerboseLoggingEnabled) {
+ Log.v(TAG, "Created P2P Invitation Sent dialog."
+ + " id=" + dialogId
+ + " deviceName=" + deviceName
+ + " displayPin=" + displayPin);
+ }
+ return dialog;
+ }
+
+ /**
* Returns a P2P Invitation Received Dialog for the given Intent, or {@code null} if no Dialog
* could be created.
*/