summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Quang Anh Luong <qal@google.com> 2024-10-24 15:03:50 +0900
committer Quang Luong <qal@google.com> 2024-11-14 00:07:20 +0000
commitf3effc2ee0df1465647c00277c81ddd3b9e6ad02 (patch)
treeca9dd1f4232be2944f6617554f3da6d301fcab6f
parent791976156514c58385d7dc352cedfad55ea1de7e (diff)
Update P2P dialog
Update P2P dialog strings to be more user friendly and show the peer device name in the dialog message instead of a separate line. Flag: com.android.wifi.flags.p2p_dialog2 Bug: 349253691 Test: Manual verification via shell cmd that P2P dialog styles are correct Change-Id: Iaa719420deed4472be4b4b8060ec987a9cd9092f
-rw-r--r--WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java261
-rw-r--r--flags/wifi_flags.aconfig9
-rw-r--r--service/ServiceWifiResources/res/layout/wifi_p2p_dialog2_display_pin.xml25
-rw-r--r--service/ServiceWifiResources/res/layout/wifi_p2p_dialog2_enter_pin.xml25
-rw-r--r--service/ServiceWifiResources/res/values-night/styles.xml14
-rw-r--r--service/ServiceWifiResources/res/values/overlayable.xml31
-rw-r--r--service/ServiceWifiResources/res/values/strings.xml42
-rw-r--r--service/ServiceWifiResources/res/values/styles.xml34
-rw-r--r--service/java/com/android/server/wifi/WifiShellCommand.java44
9 files changed, 460 insertions, 25 deletions
diff --git a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
index 043e430d71..cf1b4cc884 100644
--- a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
+++ b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
@@ -59,8 +59,12 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.os.BuildCompat;
+import com.android.wifi.x.com.android.wifi.flags.Flags;
+
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
/**
@@ -98,6 +102,10 @@ public class WifiDialogActivity extends Activity {
return getWifiContext().getString(getWifiResourceId(name, "string"));
}
+ private String getWifiString(@NonNull String name, @Nullable String arg) {
+ return getWifiContext().getString(getWifiResourceId(name, "string"), arg);
+ }
+
private int getWifiInteger(@NonNull String name) {
return getWifiContext().getResources().getInteger(getWifiResourceId(name, "integer"));
}
@@ -491,6 +499,10 @@ public class WifiDialogActivity extends Activity {
final int dialogId,
@Nullable final String deviceName,
@Nullable final String displayPin) {
+ if (Flags.p2pDialog2()) {
+ return createP2pInvitationSentDialog2(dialogId, deviceName, displayPin);
+ }
+
final View textEntryView = getWifiLayoutInflater()
.inflate(getWifiLayoutId("wifi_p2p_dialog"), null);
ViewGroup group = textEntryView.findViewById(getWifiViewId("info"));
@@ -528,6 +540,59 @@ public class WifiDialogActivity extends Activity {
}
/**
+ * Returns a P2P Invitation Sent Dialog2 for the given Intent.
+ */
+ private @NonNull AlertDialog createP2pInvitationSentDialog2(
+ final int dialogId,
+ @Nullable final String deviceName,
+ @Nullable final String displayPin) {
+ if (TextUtils.isEmpty(deviceName)) {
+ Log.w(TAG, "P2P Invitation Sent dialog device name is null or empty."
+ + " id=" + dialogId
+ + " deviceName=" + deviceName
+ + " displayPin=" + displayPin);
+ }
+ final View customView;
+ final String title;
+ final String message;
+ if (displayPin != null) {
+ customView = getWifiLayoutInflater()
+ .inflate(getWifiLayoutId("wifi_p2p_dialog2_display_pin"), null);
+ ((TextView) customView.findViewById(getWifiViewId("wifi_p2p_dialog2_display_pin")))
+ .setText(displayPin);
+ title = getWifiString("wifi_p2p_dialog2_sent_title_display_pin", deviceName);
+ message = getWifiString("wifi_p2p_dialog2_sent_message_display_pin", deviceName);
+ } else {
+ customView = null;
+ title = getWifiString("wifi_p2p_dialog2_sent_title", deviceName);
+ message = getWifiString("wifi_p2p_dialog2_sent_message", deviceName);
+ }
+
+ AlertDialog.Builder builder = getWifiAlertDialogBuilder("wifi_p2p_dialog2")
+ .setTitle(title)
+ .setMessage(message)
+ .setPositiveButton(getWifiString("wifi_p2p_dialog2_sent_positive_button"),
+ (dialogPositive, which) -> {
+ // No-op
+ if (mIsVerboseLoggingEnabled) {
+ Log.v(TAG, "P2P Invitation Sent Dialog id=" + dialogId
+ + " accepted.");
+ }
+ });
+ if (customView != null) {
+ builder.setView(customView);
+ }
+ AlertDialog dialog = builder.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.
*/
private @NonNull AlertDialog createP2pInvitationReceivedDialog(
@@ -536,6 +601,11 @@ public class WifiDialogActivity extends Activity {
final boolean isPinRequested,
@Nullable final String displayPin,
int timeoutMs) {
+ if (Flags.p2pDialog2()) {
+ return createP2pInvitationReceivedDialog2(dialogId, deviceName, isPinRequested,
+ displayPin, timeoutMs);
+ }
+
if (TextUtils.isEmpty(deviceName)) {
Log.w(TAG, "P2P Invitation Received dialog device name is null or empty."
+ " id=" + dialogId
@@ -710,4 +780,195 @@ public class WifiDialogActivity extends Activity {
((TextView) row.findViewById(getWifiViewId("value"))).setText(value);
group.addView(row);
}
+
+ /**
+ * Returns a P2P Invitation Received Dialog2 for the given Intent.
+ */
+ private @NonNull AlertDialog createP2pInvitationReceivedDialog2(
+ final int dialogId,
+ @Nullable final String deviceName,
+ final boolean isPinRequested,
+ @Nullable final String displayPin,
+ final int timeoutMs) {
+ if (TextUtils.isEmpty(deviceName)) {
+ Log.w(TAG, "P2P Invitation Received dialog device name is null or empty."
+ + " id=" + dialogId
+ + " deviceName=" + deviceName
+ + " displayPin=" + displayPin);
+ }
+ final View customView;
+ String title = getWifiString("wifi_p2p_dialog2_received_title", deviceName);
+ final String message;
+ final String timeoutMessage;
+ final EditText pinEditText;
+ if (isPinRequested) {
+ customView = getWifiLayoutInflater()
+ .inflate(getWifiLayoutId("wifi_p2p_dialog2_enter_pin"), null);
+ pinEditText = customView.findViewById(getWifiViewId("wifi_p2p_dialog2_enter_pin"));
+ title = getWifiString("wifi_p2p_dialog2_received_title_enter_pin", deviceName);
+ message = getWifiString("wifi_p2p_dialog2_received_message_enter_pin", deviceName);
+ timeoutMessage = getWifiString("wifi_p2p_dialog2_received_message_enter_pin_countdown",
+ deviceName);
+ } else {
+ pinEditText = null;
+ if (!TextUtils.isEmpty(displayPin)) {
+ customView = getWifiLayoutInflater()
+ .inflate(getWifiLayoutId("wifi_p2p_dialog2_display_pin"), null);
+ ((TextView) customView.findViewById(getWifiViewId("wifi_p2p_dialog2_display_pin")))
+ .setText(displayPin);
+ title = getWifiString("wifi_p2p_dialog2_received_title_display_pin", deviceName);
+ message = getWifiString("wifi_p2p_dialog2_received_message_display_pin",
+ deviceName);
+ timeoutMessage = getWifiString(
+ "wifi_p2p_dialog2_received_message_display_pin_countdown", deviceName);
+ } else {
+ customView = null;
+ message = getWifiString("wifi_p2p_dialog2_received_message", deviceName);
+ timeoutMessage = getWifiString("wifi_p2p_dialog2_received_message_countdown",
+ deviceName);
+ }
+ }
+
+ AlertDialog.Builder builder = getWifiAlertDialogBuilder("wifi_p2p_dialog2")
+ .setTitle(title)
+ .setMessage(message)
+ .setPositiveButton(getWifiString("wifi_p2p_dialog2_received_positive_button"),
+ (dialogPositive, which) -> {
+ String pin = null;
+ if (pinEditText != null) {
+ pin = pinEditText.getText().toString();
+ }
+ if (mIsVerboseLoggingEnabled) {
+ Log.v(TAG, "P2P Invitation Received Dialog id=" + dialogId
+ + " accepted with pin=" + pin);
+ }
+ getWifiManager().replyToP2pInvitationReceivedDialog(dialogId, true,
+ pin);
+ })
+ .setNegativeButton(getWifiString("wifi_p2p_dialog2_received_negative_button"),
+ (dialogNegative, which) -> {
+ if (mIsVerboseLoggingEnabled) {
+ Log.v(TAG, "P2P Invitation Received dialog id=" + dialogId
+ + " declined.");
+ }
+ getWifiManager().replyToP2pInvitationReceivedDialog(dialogId, false,
+ null);
+ })
+ .setOnCancelListener((dialogCancel) -> {
+ if (mIsVerboseLoggingEnabled) {
+ Log.v(TAG, "P2P Invitation Received dialog id=" + dialogId
+ + " cancelled.");
+ }
+ getWifiManager().replyToP2pInvitationReceivedDialog(dialogId, false, null);
+ });
+ if (customView != null) {
+ builder.setView(customView);
+ }
+ AlertDialog dialog = builder.create();
+ if (isPinRequested) {
+ dialog.getWindow().setSoftInputMode(
+ WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+ dialog.setOnShowListener(dialogShow -> {
+ Intent intent = mLaunchIntentsPerId.get(dialogId);
+ if (intent != null) {
+ // Populate the pin EditText with the previous user input if we're recreating
+ // the dialog after a configuration change.
+ CharSequence previousPin =
+ intent.getCharSequenceExtra(EXTRA_DIALOG_P2P_PIN_INPUT);
+ if (previousPin != null) {
+ pinEditText.setText(previousPin);
+ }
+ }
+ if (getResources().getConfiguration().orientation
+ == Configuration.ORIENTATION_PORTRAIT
+ || (getResources().getConfiguration().screenLayout
+ & Configuration.SCREENLAYOUT_SIZE_MASK)
+ >= Configuration.SCREENLAYOUT_SIZE_LARGE) {
+ pinEditText.requestFocus();
+ pinEditText.setSelection(pinEditText.getText().length());
+ }
+ dialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(
+ pinEditText.length() == 4 || pinEditText.length() == 8);
+ });
+ pinEditText.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ // No-op.
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ // No-op.
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ Intent intent = mLaunchIntentsPerId.get(dialogId);
+ if (intent != null) {
+ // Store the current input in the Intent in case we need to reload from a
+ // configuration change.
+ intent.putExtra(EXTRA_DIALOG_P2P_PIN_INPUT, s);
+ }
+ dialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(
+ s.length() == 4 || s.length() == 8);
+ }
+ });
+ } else {
+ dialog.setOnShowListener(dialogShow -> {
+ dialog.getButton(Dialog.BUTTON_NEGATIVE).requestFocus();
+ });
+ }
+ if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_TYPE_APPLIANCE)
+ == Configuration.UI_MODE_TYPE_APPLIANCE) {
+ // For appliance devices, add a key listener which accepts.
+ dialog.setOnKeyListener((dialogKey, keyCode, event) -> {
+ if (keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
+ dialog.dismiss();
+ getWifiManager().replyToP2pInvitationReceivedDialog(dialogId, true, null);
+ }
+ return true;
+ });
+ }
+ if (timeoutMs > 0) {
+ CountDownTimer countDownTimer = new CountDownTimer(timeoutMs, 100) {
+ @Override
+ public void onTick(long millisUntilFinished) {
+ Intent intent = mLaunchIntentsPerId.get(dialogId);
+ if (intent != null) {
+ // Store the updated timeout to use if we reload this dialog after a
+ // configuration change
+ intent.putExtra(WifiManager.EXTRA_DIALOG_TIMEOUT_MS,
+ (int) millisUntilFinished);
+ }
+
+ if (!getWifiBoolean("config_p2pInvitationReceivedDialogShowRemainingTime")) {
+ return;
+ }
+ int secondsRemaining = (int) millisUntilFinished / 1000;
+ if (millisUntilFinished % 1000 != 0) {
+ // Round up to the nearest whole second.
+ secondsRemaining++;
+ }
+ Map<String, Object> messageArgs = new HashMap<>();
+ messageArgs.put("device", deviceName);
+ messageArgs.put("countdown", secondsRemaining);
+ dialog.setMessage(MessageFormat.format(timeoutMessage, messageArgs));
+ }
+
+ @Override
+ public void onFinish() {
+ removeIntentAndPossiblyFinish(dialogId);
+ }
+ }.start();
+ mActiveCountDownTimersPerId.put(dialogId, countDownTimer);
+ }
+ if (mIsVerboseLoggingEnabled) {
+ Log.v(TAG, "Created P2P Invitation Received dialog."
+ + " id=" + dialogId
+ + " deviceName=" + deviceName
+ + " isPinRequested=" + isPinRequested
+ + " displayPin=" + displayPin);
+ }
+ return dialog;
+ }
}
diff --git a/flags/wifi_flags.aconfig b/flags/wifi_flags.aconfig
index 8cac28d958..581e4e6e43 100644
--- a/flags/wifi_flags.aconfig
+++ b/flags/wifi_flags.aconfig
@@ -268,3 +268,12 @@ flag {
bug: "349530934"
is_fixed_read_only: true
}
+
+flag {
+ name: "p2p_dialog2"
+ is_exported: true
+ namespace: "wifi"
+ description: "Updated P2P dialogs"
+ bug: "349253691"
+ is_fixed_read_only: true
+}
diff --git a/service/ServiceWifiResources/res/layout/wifi_p2p_dialog2_display_pin.xml b/service/ServiceWifiResources/res/layout/wifi_p2p_dialog2_display_pin.xml
new file mode 100644
index 0000000000..020f987d8d
--- /dev/null
+++ b/service/ServiceWifiResources/res/layout/wifi_p2p_dialog2_display_pin.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ style="@style/wifi_p2p_dialog2_display_pin_section">
+ <TextView
+ android:text="@string/wifi_p2p_dialog2_display_pin_label"
+ style="@style/wifi_p2p_dialog2_display_pin_label"/>
+
+ <TextView android:id="@+id/wifi_p2p_dialog2_display_pin"
+ style="@style/wifi_p2p_dialog2_display_pin" />
+</LinearLayout>
diff --git a/service/ServiceWifiResources/res/layout/wifi_p2p_dialog2_enter_pin.xml b/service/ServiceWifiResources/res/layout/wifi_p2p_dialog2_enter_pin.xml
new file mode 100644
index 0000000000..32da7b78a1
--- /dev/null
+++ b/service/ServiceWifiResources/res/layout/wifi_p2p_dialog2_enter_pin.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ style="@style/wifi_p2p_dialog2_enter_pin_section">
+ <TextView
+ android:text="@string/wifi_p2p_dialog2_enter_pin_label"
+ style="@style/wifi_p2p_dialog2_enter_pin_label"/>
+
+ <EditText android:id="@+id/wifi_p2p_dialog2_enter_pin"
+ style="@style/wifi_p2p_dialog2_enter_pin" />
+</LinearLayout>
diff --git a/service/ServiceWifiResources/res/values-night/styles.xml b/service/ServiceWifiResources/res/values-night/styles.xml
index 9279ee3780..a97049517e 100644
--- a/service/ServiceWifiResources/res/values-night/styles.xml
+++ b/service/ServiceWifiResources/res/values-night/styles.xml
@@ -23,4 +23,18 @@
<item name="android:inputType">number</item>
<item name="android:textColor">@android:color/primary_text_dark</item>
</style>
+
+ <style name="wifi_p2p_dialog2" parent="@android:style/Theme.DeviceDefault.Dialog.Alert" />
+ <style name="wifi_p2p_dialog2_pin_label">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textColor">@android:color/secondary_text_dark</item>
+ <item name="android:textSize">14sp</item>
+ </style>
+ <style name="wifi_p2p_dialog2_pin">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textSize">18sp</item>
+ <item name="android:textColor">@android:color/primary_text_dark</item>
+ </style>
</resources>
diff --git a/service/ServiceWifiResources/res/values/overlayable.xml b/service/ServiceWifiResources/res/values/overlayable.xml
index 7409ad1414..a64f330b05 100644
--- a/service/ServiceWifiResources/res/values/overlayable.xml
+++ b/service/ServiceWifiResources/res/values/overlayable.xml
@@ -390,13 +390,19 @@
<item type="string" name="accept" />
<item type="string" name="decline" />
<item type="string" name="ok" />
- <item type="string" name="wifi_p2p_invitation_sent_title" />
- <item type="string" name="wifi_p2p_invitation_to_connect_title" />
- <item type="string" name="wifi_p2p_invitation_seconds_remaining" />
- <item type="string" name="wifi_p2p_from_message" />
- <item type="string" name="wifi_p2p_to_message" />
- <item type="string" name="wifi_p2p_enter_pin_message" />
- <item type="string" name="wifi_p2p_show_pin_message" />
+ <item type="string" name="wifi_p2p_dialog2_sent_title" />
+ <item type="string" name="wifi_p2p_dialog2_sent_title_display_pin" />
+ <item type="string" name="wifi_p2p_dialog2_sent_message" />
+ <item type="string" name="wifi_p2p_dialog2_sent_message_display_pin" />
+ <item type="string" name="wifi_p2p_dialog2_sent_positive_button" />
+ <item type="string" name="wifi_p2p_dialog2_received_title" />
+ <item type="string" name="wifi_p2p_dialog2_received_message" />
+ <item type="string" name="wifi_p2p_dialog2_received_message_enter_pin" />
+ <item type="string" name="wifi_p2p_dialog2_received_message_display_pin" />
+ <item type="string" name="wifi_p2p_dialog2_received_positive_button" />
+ <item type="string" name="wifi_p2p_dialog2_received_negative_button" />
+ <item type="string" name="wifi_p2p_dialog2_enter_pin_label" />
+ <item type="string" name="wifi_p2p_dialog2_display_pin_label" />
<item type="string" name="wifi_p2p_frequency_conflict_message" />
<item type="string" name="dlg_ok" />
<item type="string" name="wifi_cannot_connect_with_randomized_mac_title" />
@@ -505,6 +511,17 @@
<item type="style" name="wifi_p2p_dialog_row_content" />
<item type="style" name="wifi_p2p_dialog_enter_pin_message" />
<item type="style" name="wifi_p2p_dialog_pin_input" />
+
+ <item type="style" name="wifi_p2p_dialog2" />
+ <item type="style" name="wifi_p2p_dialog2_pin_section" />
+ <item type="style" name="wifi_p2p_dialog2_pin_label" />
+ <item type="style" name="wifi_p2p_dialog2_pin" />
+ <item type="style" name="wifi_p2p_dialog2_enter_pin_section" />
+ <item type="style" name="wifi_p2p_dialog2_enter_pin_label" />
+ <item type="style" name="wifi_p2p_dialog2_enter_pin" />
+ <item type="style" name="wifi_p2p_dialog2_display_pin_section" />
+ <item type="style" name="wifi_p2p_dialog2_display_pin_label" />
+ <item type="style" name="wifi_p2p_dialog2_display_pin" />
<!-- Params from styles.xml that can be overlayed -->
<!-- Params from drawable/ that can be overlayed -->
diff --git a/service/ServiceWifiResources/res/values/strings.xml b/service/ServiceWifiResources/res/values/strings.xml
index 26624b023e..3660d752b8 100644
--- a/service/ServiceWifiResources/res/values/strings.xml
+++ b/service/ServiceWifiResources/res/values/strings.xml
@@ -100,6 +100,7 @@
<string name="wifi_p2p_invitation_sent_title">Invitation sent</string>
<string name="wifi_p2p_invitation_to_connect_title">Invitation to connect</string>
+ <!-- Start of strings for legacy P2P Dialog -->
<!-- The message of the P2P Invitation Received dialog indicating the seconds left to accept before auto rejection [CHAR_LIMIT=NONE] [ICU SYNTAX] -->
<string name="wifi_p2p_invitation_seconds_remaining">
{0, plural,
@@ -111,6 +112,47 @@
<string name="wifi_p2p_to_message">To: </string>
<string name="wifi_p2p_enter_pin_message">Type the required PIN: </string>
<string name="wifi_p2p_show_pin_message">PIN: </string>
+ <!-- End of strings for legacy P2P Dialog -->
+
+ <!-- Start of strings for P2P Dialog 2 -->
+ <string name="wifi_p2p_dialog2_sent_title">Device connection</string>
+ <string name="wifi_p2p_dialog2_sent_title_display_pin">Device connection</string>
+ <string name="wifi_p2p_dialog2_sent_message">Invitation sent to <xliff:g id="device_name">%1$s</xliff:g>.</string>
+ <string name="wifi_p2p_dialog2_sent_message_display_pin">Enter this PIN on <xliff:g id="device_name">%1$s</xliff:g> to connect.</string>
+ <string name="wifi_p2p_dialog2_sent_positive_button">OK</string>
+
+ <string name="wifi_p2p_dialog2_received_title">Device connection</string>
+ <string name="wifi_p2p_dialog2_received_title_enter_pin">Device connection</string>
+ <string name="wifi_p2p_dialog2_received_title_display_pin">Device connection</string>
+ <string name="wifi_p2p_dialog2_received_message"><xliff:g id="device_name">%1$s</xliff:g> wants to connect to your device.</string>
+ <string name="wifi_p2p_dialog2_received_message_enter_pin">Enter the PIN shown on <xliff:g id="device_name">%1$s</xliff:g> to connect.</string>
+ <string name="wifi_p2p_dialog2_received_message_display_pin"><xliff:g id="device_name">%1$s</xliff:g> wants to connect to your device with the following PIN.</string>
+
+ <string name="wifi_p2p_dialog2_received_message_countdown">
+ {countdown, plural,
+ =1 {{device} wants to connect to your device. Accept in {countdown} second.}
+ other {{device} wants to connect to your device. Accept in {countdown} seconds.}
+ }
+ </string>
+ <string name="wifi_p2p_dialog2_received_message_enter_pin_countdown">
+ {countdown, plural,
+ =1 {Enter the PIN shown on {device} within {countdown} second to connect.}
+ other {Enter the PIN shown on {device} within {countdown} seconds to connect.}
+ }
+ </string>
+ <string name="wifi_p2p_dialog2_received_message_display_pin_countdown">
+ {countdown, plural,
+ =1 {{device} wants to connect to your device with the following PIN. Accept in {countdown} second.}
+ other {{device} wants to connect to your device with the following PIN. Accept in {countdown} seconds.}
+ }
+ </string>
+
+ <string name="wifi_p2p_dialog2_received_positive_button">Connect</string>
+ <string name="wifi_p2p_dialog2_received_negative_button">Cancel</string>
+
+ <string name="wifi_p2p_dialog2_enter_pin_label">PIN</string>
+ <string name="wifi_p2p_dialog2_display_pin_label">PIN</string>
+ <!-- End of strings for P2P Dialog 2 -->
<string name="wifi_p2p_frequency_conflict_message">Your device will temporarily disconnect from Wi-Fi while it\'s connected to <xliff:g id="device_name">%1$s</xliff:g></string>
<!-- Dialog ok button-->
diff --git a/service/ServiceWifiResources/res/values/styles.xml b/service/ServiceWifiResources/res/values/styles.xml
index 714d10fe0f..e86aee8417 100644
--- a/service/ServiceWifiResources/res/values/styles.xml
+++ b/service/ServiceWifiResources/res/values/styles.xml
@@ -63,4 +63,38 @@
<item name="android:inputType">number</item>
<item name="android:textColor">@android:color/primary_text_light</item>
</style>
+
+ <style name="wifi_p2p_dialog2" parent="@android:style/Theme.DeviceDefault.Light.Dialog.Alert" />
+
+ <style name="wifi_p2p_dialog2_pin_section">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:orientation">vertical</item>
+ <item name="android:paddingLeft">24dp</item>
+ <item name="android:paddingRight">24dp</item>
+ </style>
+ <style name="wifi_p2p_dialog2_pin_label" >
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textColor">@android:color/secondary_text_light</item>
+ <item name="android:textSize">14sp</item>
+ </style>
+ <style name="wifi_p2p_dialog2_pin">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textColor">@android:color/primary_text_light</item>
+ <item name="android:textSize">18sp</item>
+ </style>
+
+ <style name="wifi_p2p_dialog2_enter_pin_section" parent="@style/wifi_p2p_dialog2_pin_section" />
+ <style name="wifi_p2p_dialog2_enter_pin_label" parent="@style/wifi_p2p_dialog2_pin_label" />
+ <style name="wifi_p2p_dialog2_enter_pin" parent="@style/wifi_p2p_dialog2_pin">
+ <item name="android:singleLine">true</item>
+ <item name="android:maxLength">8</item>
+ <item name="android:inputType">number</item>
+ </style>
+
+ <style name="wifi_p2p_dialog2_display_pin_section" parent="@style/wifi_p2p_dialog2_pin_section" />
+ <style name="wifi_p2p_dialog2_display_pin_label" parent="@style/wifi_p2p_dialog2_pin_label" />
+ <style name="wifi_p2p_dialog2_display_pin" parent="@style/wifi_p2p_dialog2_pin" />
</resources>
diff --git a/service/java/com/android/server/wifi/WifiShellCommand.java b/service/java/com/android/server/wifi/WifiShellCommand.java
index 9e7999593d..fe23f18d12 100644
--- a/service/java/com/android/server/wifi/WifiShellCommand.java
+++ b/service/java/com/android/server/wifi/WifiShellCommand.java
@@ -1611,25 +1611,32 @@ public class WifiShellCommand extends BasicShellCommandHandler {
case "launch-dialog-p2p-invitation-sent": {
int displayId = Display.DEFAULT_DISPLAY;
String deviceName = getNextArgRequired();
- String displayPin = getNextArgRequired();
String cmdOption = getNextOption();
- if (cmdOption != null && cmdOption.equals("-i")) {
- String displayIdStr = getNextArgRequired();
- try {
- displayId = Integer.parseInt(displayIdStr);
- } catch (NumberFormatException e) {
- pw.println("Invalid <display-id> argument to "
- + "'launch-dialog-p2p-invitation-sent' "
- + "- must be an integer: "
- + displayIdStr);
- return -1;
- }
- DisplayManager dm = mContext.getSystemService(DisplayManager.class);
- Display[] displays = dm.getDisplays();
- for (Display display : displays) {
- pw.println("Display: id=" + display.getDisplayId() + ", info="
- + display.getDeviceProductInfo());
+ String displayPin = null;
+ while (cmdOption != null) {
+ if (cmdOption.equals("-d")) {
+ displayPin = getNextArgRequired();
+ } else if (cmdOption.equals("-i")) {
+ String displayIdStr = getNextArgRequired();
+ try {
+ displayId = Integer.parseInt(displayIdStr);
+ } catch (NumberFormatException e) {
+ pw.println("Invalid <display-id> argument to "
+ + "'launch-dialog-p2p-invitation-sent' "
+ + "- must be an integer: "
+ + displayIdStr);
+ return -1;
+ }
+ DisplayManager dm = mContext.getSystemService(DisplayManager.class);
+ Display[] displays = dm.getDisplays();
+ for (Display display : displays) {
+ pw.println("Display: id=" + display.getDisplayId() + ", info="
+ + display.getDeviceProductInfo());
+ }
+ } else {
+ pw.println("Ignoring unknown option " + cmdOption);
}
+ cmdOption = getNextOption();
}
mWifiDialogManager.createP2pInvitationSentDialog(deviceName, displayPin,
displayId).launchDialog();
@@ -3043,7 +3050,8 @@ public class WifiShellCommand extends BasicShellCommandHandler {
pw.println(" -x - Neutral Button Text");
pw.println(" -c - Optional timeout in milliseconds");
pw.println(" -s - Use the legacy dialog implementation on the system process");
- pw.println(" launch-dialog-p2p-invitation-sent <device_name> <pin> [-i <display_id>]");
+ pw.println(" launch-dialog-p2p-invitation-sent <device_name> [-d <pin>]"
+ + " [-i <display_id>]");
pw.println(" Launches a P2P Invitation Sent dialog.");
pw.println(" <device_name> - Name of the device the invitation was sent to");
pw.println(" <pin> - PIN for the invited device to input");