summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java94
-rw-r--r--service/ServiceWifiResources/res/values/config.xml2
-rw-r--r--service/ServiceWifiResources/res/values/overlayable.xml1
-rw-r--r--service/java/com/android/server/wifi/WifiDialogManager.java57
-rw-r--r--service/java/com/android/server/wifi/WifiShellCommand.java39
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java6
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/WifiDialogManagerTest.java281
-rw-r--r--service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java33
8 files changed, 151 insertions, 362 deletions
diff --git a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
index 4dab628bbc..043e430d71 100644
--- a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
+++ b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
@@ -33,9 +33,6 @@ import android.net.wifi.WifiContext;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.CountDownTimer;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.SystemClock;
import android.os.Vibrator;
import android.text.Editable;
import android.text.SpannableString;
@@ -72,12 +69,9 @@ import java.util.Set;
public class WifiDialogActivity extends Activity {
private static final String TAG = "WifiDialog";
private static final String KEY_DIALOG_INTENTS = "KEY_DIALOG_INTENTS";
- private static final String EXTRA_DIALOG_EXPIRATION_TIME_MS =
- "com.android.wifi.dialog.DIALOG_START_TIME_MS";
private static final String EXTRA_DIALOG_P2P_PIN_INPUT =
"com.android.wifi.dialog.DIALOG_P2P_PIN_INPUT";
- private @NonNull Handler mHandler = new Handler(Looper.getMainLooper());
private @Nullable WifiContext mWifiContext;
private @Nullable WifiManager mWifiManager;
private boolean mIsVerboseLoggingEnabled;
@@ -354,7 +348,8 @@ public class WifiDialogActivity extends Activity {
dialogId,
intent.getStringExtra(WifiManager.EXTRA_P2P_DEVICE_NAME),
intent.getBooleanExtra(WifiManager.EXTRA_P2P_PIN_REQUESTED, false),
- intent.getStringExtra(WifiManager.EXTRA_P2P_DISPLAY_PIN));
+ intent.getStringExtra(WifiManager.EXTRA_P2P_DISPLAY_PIN),
+ intent.getIntExtra(WifiManager.EXTRA_DIALOG_TIMEOUT_MS, 0));
break;
default:
if (mIsVerboseLoggingEnabled) {
@@ -378,50 +373,6 @@ public class WifiDialogActivity extends Activity {
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
}
mActiveDialogsPerId.put(dialogId, dialog);
- long timeoutMs = intent.getLongExtra(WifiManager.EXTRA_DIALOG_TIMEOUT_MS, 0);
- if (timeoutMs > 0) {
- // Use the original expiration time in case we've reloaded this dialog after a
- // configuration change.
- long expirationTimeMs = intent.getLongExtra(EXTRA_DIALOG_EXPIRATION_TIME_MS, 0);
- if (expirationTimeMs > 0) {
- timeoutMs = expirationTimeMs - SystemClock.uptimeMillis();
- if (timeoutMs < 0) {
- timeoutMs = 0;
- }
- } else {
- intent.putExtra(
- EXTRA_DIALOG_EXPIRATION_TIME_MS, SystemClock.uptimeMillis() + timeoutMs);
- }
- CountDownTimer countDownTimer = new CountDownTimer(timeoutMs, 100) {
- @Override
- public void onTick(long millisUntilFinished) {
- if (dialogType == WifiManager.DIALOG_TYPE_P2P_INVITATION_RECEIVED) {
- int secondsRemaining = (int) millisUntilFinished / 1000;
- if (millisUntilFinished % 1000 != 0) {
- // Round up to the nearest whole second.
- secondsRemaining++;
- }
- TextView timeRemaining = dialog.getWindow().findViewById(
- getWifiViewId("time_remaining"));
- timeRemaining.setText(MessageFormat.format(
- getWifiString("wifi_p2p_invitation_seconds_remaining"),
- secondsRemaining));
- timeRemaining.setVisibility(View.VISIBLE);
- }
- }
-
- @Override
- public void onFinish() {
- removeIntentAndPossiblyFinish(dialogId);
- }
- }.start();
- mActiveCountDownTimersPerId.put(dialogId, countDownTimer);
- } else {
- if (dialogType == WifiManager.DIALOG_TYPE_P2P_INVITATION_RECEIVED) {
- // Set the message back to null if we aren't using a timeout.
- dialog.setMessage(null);
- }
- }
dialog.show();
if (mIsVerboseLoggingEnabled) {
Log.v(TAG, "Showing dialog " + dialogId);
@@ -583,12 +534,14 @@ public class WifiDialogActivity extends Activity {
final int dialogId,
@Nullable final String deviceName,
final boolean isPinRequested,
- @Nullable final String displayPin) {
+ @Nullable final String displayPin,
+ 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);
+ + " displayPin=" + displayPin
+ + " timeoutMs=" + timeoutMs);
}
final View textEntryView = getWifiLayoutInflater()
.inflate(getWifiLayoutId("wifi_p2p_dialog"), null);
@@ -702,6 +655,41 @@ public class WifiDialogActivity extends Activity {
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++;
+ }
+ TextView timeRemaining = textEntryView.findViewById(
+ getWifiViewId("time_remaining"));
+ timeRemaining.setText(MessageFormat.format(
+ getWifiString("wifi_p2p_invitation_seconds_remaining"),
+ secondsRemaining));
+ timeRemaining.setVisibility(View.VISIBLE);
+ }
+
+ @Override
+ public void onFinish() {
+ removeIntentAndPossiblyFinish(dialogId);
+ }
+ }.start();
+ mActiveCountDownTimersPerId.put(dialogId, countDownTimer);
+ }
if (mIsVerboseLoggingEnabled) {
Log.v(TAG, "Created P2P Invitation Received dialog."
+ " id=" + dialogId
diff --git a/service/ServiceWifiResources/res/values/config.xml b/service/ServiceWifiResources/res/values/config.xml
index 7f5b3a25ff..c6068b0ab9 100644
--- a/service/ServiceWifiResources/res/values/config.xml
+++ b/service/ServiceWifiResources/res/values/config.xml
@@ -1060,6 +1060,8 @@
<!-- Indicate the time in milliseconds to wait before auto-cancelling a P2P invitation received
dialog that the user has not responded to. A value of 0 indicates no timeout. -->
<integer translatable="false" name="config_p2pInvitationReceivedDialogTimeoutMs">0</integer>
+ <!-- Whether to show the timeout in the P2P invitation received dialog -->
+ <bool translatable="false" name="config_p2pInvitationReceivedDialogShowRemainingTime">true</bool>
<!-- Indicates whether or not to play a notification sound upon displaying a P2P invitation
received dialog that the user has not responded to. If the device is in vibrate mode, then
the device will vibrate instead of playing a sound. -->
diff --git a/service/ServiceWifiResources/res/values/overlayable.xml b/service/ServiceWifiResources/res/values/overlayable.xml
index d3b7a7640a..7409ad1414 100644
--- a/service/ServiceWifiResources/res/values/overlayable.xml
+++ b/service/ServiceWifiResources/res/values/overlayable.xml
@@ -297,6 +297,7 @@
<item type="bool" name="config_wifiDialogCanceledOnTouchOutside" />
<item type="bool" name="config_showConfirmationDialogForThirdPartyAppsEnablingWifi" />
<item type="integer" name="config_p2pInvitationReceivedDialogTimeoutMs"/>
+ <item type="bool" name="config_p2pInvitationReceivedDialogShowRemainingTime" />
<item type="bool" name="config_p2pInvitationReceivedDialogNotificationSound"/>
<item type="integer" name="config_wifiP2pJoinRequestAuthorizingTimeoutMs" />
<item type="bool" name="config_wifiForcedSoftApRestartWhenCountryCodeChanged" />
diff --git a/service/java/com/android/server/wifi/WifiDialogManager.java b/service/java/com/android/server/wifi/WifiDialogManager.java
index cc175b61c7..15485e9c80 100644
--- a/service/java/com/android/server/wifi/WifiDialogManager.java
+++ b/service/java/com/android/server/wifi/WifiDialogManager.java
@@ -232,31 +232,15 @@ public class WifiDialogManager {
@AnyThread
public void launchDialog() {
if (mInternalHandle != null) {
- mWifiThreadRunner.post(() -> mInternalHandle.launchDialog(0),
+ mWifiThreadRunner.post(() -> mInternalHandle.launchDialog(),
TAG + "#launchDialog");
} else if (mLegacyHandle != null) {
- mWifiThreadRunner.post(() -> mLegacyHandle.launchDialog(0),
+ mWifiThreadRunner.post(() -> mLegacyHandle.launchDialog(),
TAG + "#launchDialog");
}
}
/**
- * Launches the dialog with a timeout before it is auto-cancelled.
- * @param timeoutMs timeout in milliseconds before the dialog is auto-cancelled. A value <=0
- * indicates no timeout.
- */
- @AnyThread
- public void launchDialog(long timeoutMs) {
- if (mInternalHandle != null) {
- mWifiThreadRunner.post(() -> mInternalHandle.launchDialog(timeoutMs),
- TAG + "#launchDialogTimeout");
- } else if (mLegacyHandle != null) {
- mWifiThreadRunner.post(() -> mLegacyHandle.launchDialog(timeoutMs),
- TAG + "#launchDialogTimeout");
- }
- }
-
- /**
* Dismisses the dialog. Dialogs will automatically be dismissed once the user replies, but
* this method may be used to dismiss unanswered dialogs that are no longer needed.
*/
@@ -291,9 +275,9 @@ public class WifiDialogManager {
}
/**
- * @see {@link DialogHandle#launchDialog(long)}
+ * @see DialogHandle#launchDialog()
*/
- void launchDialog(long timeoutMs) {
+ void launchDialog() {
if (mIntent == null) {
Log.e(TAG, "Cannot launch dialog with null Intent!");
return;
@@ -303,7 +287,6 @@ public class WifiDialogManager {
return;
}
registerDialog();
- mIntent.putExtra(WifiManager.EXTRA_DIALOG_TIMEOUT_MS, timeoutMs);
mIntent.putExtra(WifiManager.EXTRA_DIALOG_ID, mDialogId);
boolean launched = false;
// Collapse the QuickSettings since we can't show WifiDialog dialogs over it.
@@ -474,10 +457,8 @@ public class WifiDialogManager {
final String mNeutralButtonText;
@Nullable final SimpleDialogCallback mCallback;
@Nullable final WifiThreadRunner mCallbackThreadRunner;
- private Runnable mTimeoutRunnable;
private AlertDialog mAlertDialog;
int mWindowType = WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
- long mTimeoutMs = 0;
LegacySimpleDialogHandle(
final String title,
@@ -525,18 +506,12 @@ public class WifiDialogManager {
mCallbackThreadRunner = callbackThreadRunner;
}
- void launchDialog(long timeoutMs) {
+ void launchDialog() {
if (mAlertDialog != null && mAlertDialog.isShowing()) {
// Dialog is already launched. Dismiss and create a new one.
mAlertDialog.setOnDismissListener(null);
mAlertDialog.dismiss();
}
- if (mTimeoutRunnable != null) {
- // Reset the timeout runnable if one has already been created.
- mWifiThreadRunner.removeCallbacks(mTimeoutRunnable);
- mTimeoutRunnable = null;
- }
- mTimeoutMs = timeoutMs;
mAlertDialog = mFrameworkFacade.makeAlertDialogBuilder(
new ContextThemeWrapper(mContext, R.style.wifi_dialog))
.setTitle(mTitle)
@@ -579,10 +554,6 @@ public class WifiDialogManager {
})
.setOnDismissListener((dialogDismiss) -> {
mWifiThreadRunner.post(() -> {
- if (mTimeoutRunnable != null) {
- mWifiThreadRunner.removeCallbacks(mTimeoutRunnable);
- mTimeoutRunnable = null;
- }
mAlertDialog = null;
mActiveLegacySimpleDialogs.remove(this);
}, mTitle + "#onDismiss");
@@ -609,11 +580,6 @@ public class WifiDialogManager {
if (messageView != null) {
messageView.setMovementMethod(LinkMovementMethod.getInstance());
}
- if (mTimeoutMs > 0) {
- mTimeoutRunnable = mAlertDialog::cancel;
- mWifiThreadRunner.postDelayed(mTimeoutRunnable, mTimeoutMs,
- TAG + "#cancelDialog");
- }
mActiveLegacySimpleDialogs.add(this);
}
@@ -632,7 +598,7 @@ public class WifiDialogManager {
void changeWindowType(int windowType) {
mWindowType = windowType;
if (mActiveLegacySimpleDialogs.contains(this)) {
- launchDialog(mTimeoutMs);
+ launchDialog();
}
}
}
@@ -657,7 +623,7 @@ public class WifiDialogManager {
void onNeutralButtonClicked();
/**
- * The dialog was cancelled (back button or home button or timeout).
+ * The dialog was cancelled (back button or home button).
*/
void onCancelled();
}
@@ -897,6 +863,7 @@ public class WifiDialogManager {
final @Nullable String deviceName,
final boolean isPinRequested,
@Nullable String displayPin,
+ int timeoutMs,
int displayId,
@Nullable P2pInvitationReceivedDialogCallback callback,
@Nullable WifiThreadRunner callbackThreadRunner) {
@@ -904,7 +871,8 @@ public class WifiDialogManager {
if (intent != null) {
intent.putExtra(WifiManager.EXTRA_P2P_DEVICE_NAME, deviceName)
.putExtra(WifiManager.EXTRA_P2P_PIN_REQUESTED, isPinRequested)
- .putExtra(WifiManager.EXTRA_P2P_DISPLAY_PIN, displayPin);
+ .putExtra(WifiManager.EXTRA_P2P_DISPLAY_PIN, displayPin)
+ .putExtra(WifiManager.EXTRA_DIALOG_TIMEOUT_MS, timeoutMs);
setIntent(intent);
}
setDisplayId(displayId);
@@ -952,13 +920,14 @@ public class WifiDialogManager {
* @param deviceName Name of the device sending the invitation.
* @param isPinRequested True if a PIN was requested and a PIN input UI should be shown.
* @param displayPin Display PIN, or {@code null} if no PIN should be displayed
+ * @param timeoutMs Timeout for the dialog in milliseconds. 0 indicates no timeout.
* @param displayId The ID of the Display on which to place the dialog
* (Display.DEFAULT_DISPLAY
* refers to the default display)
* @param callback Callback to receive the dialog response.
* @param callbackThreadRunner WifiThreadRunner to run the callback on.
* @return DialogHandle Handle for the dialog, or {@code null} if no dialog could
- * be created.
+ * be created.
*/
@AnyThread
@NonNull
@@ -966,6 +935,7 @@ public class WifiDialogManager {
@Nullable String deviceName,
boolean isPinRequested,
@Nullable String displayPin,
+ int timeoutMs,
int displayId,
@Nullable P2pInvitationReceivedDialogCallback callback,
@Nullable WifiThreadRunner callbackThreadRunner) {
@@ -974,6 +944,7 @@ public class WifiDialogManager {
deviceName,
isPinRequested,
displayPin,
+ timeoutMs,
displayId,
callback,
callbackThreadRunner)
diff --git a/service/java/com/android/server/wifi/WifiShellCommand.java b/service/java/com/android/server/wifi/WifiShellCommand.java
index 0481cb1fcc..887351e98e 100644
--- a/service/java/com/android/server/wifi/WifiShellCommand.java
+++ b/service/java/com/android/server/wifi/WifiShellCommand.java
@@ -1505,7 +1505,7 @@ public class WifiShellCommand extends BasicShellCommandHandler {
String neutralButtonText = null;
String dialogOption = getNextOption();
boolean simpleTimeoutSpecified = false;
- long simpleTimeoutMs = 0;
+ long simpleTimeoutMs = 15 * 1000;
boolean useLegacy = false;
while (dialogOption != null) {
switch (dialogOption) {
@@ -1591,29 +1591,16 @@ public class WifiShellCommand extends BasicShellCommandHandler {
wifiEnableRequestCallback,
mWifiThreadRunner);
}
- if (simpleTimeoutSpecified) {
- simpleDialogHandle.launchDialog(simpleTimeoutMs);
- pw.println("Launched dialog with " + simpleTimeoutMs + " millisecond"
- + " timeout. Waiting for user response...");
- pw.flush();
- String dialogResponse = simpleQueue.take();
- if (dialogResponse == null) {
- pw.println("No response received.");
- } else {
- pw.println(dialogResponse);
- }
+ simpleDialogHandle.launchDialog();
+ pw.println("Launched dialog. Waiting up to " + simpleTimeoutMs + " ms for"
+ + " user response before dismissing...");
+ String simpleDialogResponse = simpleQueue.poll(simpleTimeoutMs,
+ TimeUnit.MILLISECONDS);
+ if (simpleDialogResponse == null) {
+ pw.println("No response received. Dismissing dialog.");
+ simpleDialogHandle.dismissDialog();
} else {
- simpleDialogHandle.launchDialog();
- pw.println("Launched dialog. Waiting up to 15 seconds for user response"
- + " before dismissing...");
- pw.flush();
- String dialogResponse = simpleQueue.poll(15, TimeUnit.SECONDS);
- if (dialogResponse == null) {
- pw.println("No response received. Dismissing dialog.");
- simpleDialogHandle.dismissDialog();
- } else {
- pw.println(dialogResponse);
- }
+ pw.println(simpleDialogResponse);
}
return 0;
case "launch-dialog-p2p-invitation-sent": {
@@ -1651,7 +1638,7 @@ public class WifiShellCommand extends BasicShellCommandHandler {
String pinOption = getNextOption();
int displayId = Display.DEFAULT_DISPLAY;
boolean p2pInvRecTimeoutSpecified = false;
- long p2pInvRecTimeout = 0;
+ int p2pInvRecTimeout = 0;
while (pinOption != null) {
if (pinOption.equals("-p")) {
isPinRequested = true;
@@ -1701,11 +1688,12 @@ public class WifiShellCommand extends BasicShellCommandHandler {
deviceName,
isPinRequested,
displayPin,
+ p2pInvRecTimeout,
displayId,
callback,
mWifiThreadRunner);
+ p2pInvitationReceivedDialogHandle.launchDialog();
if (p2pInvRecTimeoutSpecified) {
- p2pInvitationReceivedDialogHandle.launchDialog(p2pInvRecTimeout);
pw.println("Launched dialog with " + p2pInvRecTimeout + " millisecond"
+ " timeout. Waiting for user response...");
pw.flush();
@@ -1716,7 +1704,6 @@ public class WifiShellCommand extends BasicShellCommandHandler {
pw.println(dialogResponse);
}
} else {
- p2pInvitationReceivedDialogHandle.launchDialog();
pw.println("Launched dialog. Waiting up to 15 seconds for user response"
+ " before dismissing...");
pw.flush();
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
index 589f2d84b3..d35d6736ba 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
@@ -6907,6 +6907,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
deviceName,
false /* isPinRequested */,
pin,
+ 0,
displayId,
new WifiDialogManager.P2pInvitationReceivedDialogCallback() {
@Override
@@ -7073,11 +7074,12 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
deviceName,
isPinRequested,
displayPin,
+ mContext.getResources().getInteger(
+ R.integer.config_p2pInvitationReceivedDialogTimeoutMs),
displayId,
callback,
new WifiThreadRunner(getHandler()));
- mInvitationDialogHandle.launchDialog(mContext.getResources().getInteger(
- R.integer.config_p2pInvitationReceivedDialogTimeoutMs));
+ mInvitationDialogHandle.launchDialog();
}
private void notifyInvitationReceived(
diff --git a/service/tests/wifitests/src/com/android/server/wifi/WifiDialogManagerTest.java b/service/tests/wifitests/src/com/android/server/wifi/WifiDialogManagerTest.java
index 58ff485f74..362fc6aab8 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/WifiDialogManagerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/WifiDialogManagerTest.java
@@ -70,13 +70,13 @@ import org.mockito.MockitoAnnotations;
*/
@SmallTest
public class WifiDialogManagerTest extends WifiBaseTest {
- private static final int TIMEOUT_MILLIS = 30_000;
private static final String TEST_TITLE = "Title";
private static final String TEST_MESSAGE = "Message";
private static final String TEST_POSITIVE_BUTTON_TEXT = "Yes";
private static final String TEST_NEGATIVE_BUTTON_TEXT = "No";
private static final String TEST_NEUTRAL_BUTTON_TEXT = "Maybe";
private static final String TEST_DEVICE_NAME = "TEST_DEVICE_NAME";
+ private static final int TEST_P2P_TIMEOUT_MS = 15 * 60 * 1000;
private static final String WIFI_DIALOG_APK_PKG_NAME = "WifiDialogApkPkgName";
@Mock WifiContext mWifiContext;
@@ -115,14 +115,12 @@ public class WifiDialogManagerTest extends WifiBaseTest {
/**
* Helper method to synchronously call {@link DialogHandle#launchDialog(long)}.
* @param dialogHandle Dialog handle to call on.
- * @param timeoutMs Timeout for {@link DialogHandle#launchDialog(long)}.
* @param wifiThreadRunner Main Wi-Fi thread runner of the WifiDialogManager.
*/
private void launchDialogSynchronous(
@NonNull DialogHandle dialogHandle,
- long timeoutMs,
@NonNull WifiThreadRunner wifiThreadRunner) {
- dialogHandle.launchDialog(timeoutMs);
+ dialogHandle.launchDialog();
ArgumentCaptor<Runnable> launchRunnableArgumentCaptor =
ArgumentCaptor.forClass(Runnable.class);
verify(wifiThreadRunner, atLeastOnce()).post(launchRunnableArgumentCaptor.capture(),
@@ -250,7 +248,7 @@ public class WifiDialogManagerTest extends WifiBaseTest {
DialogHandle dialogHandle = mDialogManager.createSimpleDialog(TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
Intent intent = verifyStartActivityAsUser(1, mWifiContext);
int dialogId = verifySimpleDialogLaunchIntent(intent, TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT);
@@ -273,7 +271,7 @@ public class WifiDialogManagerTest extends WifiBaseTest {
dialogHandle = mDialogManager.createSimpleDialog(TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
intent = verifyStartActivityAsUser(2, mWifiContext);
dialogId = verifySimpleDialogLaunchIntent(intent, TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT);
@@ -288,7 +286,7 @@ public class WifiDialogManagerTest extends WifiBaseTest {
dialogHandle = mDialogManager.createSimpleDialog(
TEST_TITLE, TEST_MESSAGE, TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT,
TEST_NEUTRAL_BUTTON_TEXT, callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
intent = verifyStartActivityAsUser(3, mWifiContext);
dialogId = verifySimpleDialogLaunchIntent(intent, TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT);
@@ -303,7 +301,7 @@ public class WifiDialogManagerTest extends WifiBaseTest {
dialogHandle = mDialogManager.createSimpleDialog(TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
intent = verifyStartActivityAsUser(4, mWifiContext);
dialogId = verifySimpleDialogLaunchIntent(intent, TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT);
@@ -330,7 +328,7 @@ public class WifiDialogManagerTest extends WifiBaseTest {
DialogHandle dialogHandle = mDialogManager.createSimpleDialog(TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
Intent intent = verifyStartActivityAsUser(1, mWifiContext);
int dialogId = verifySimpleDialogLaunchIntent(intent, TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT);
@@ -352,7 +350,7 @@ public class WifiDialogManagerTest extends WifiBaseTest {
dialogHandle = mDialogManager.createSimpleDialog(TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
intent = verifyStartActivityAsUser(3, mWifiContext);
dialogId = verifySimpleDialogLaunchIntent(intent, TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT);
@@ -377,7 +375,7 @@ public class WifiDialogManagerTest extends WifiBaseTest {
DialogHandle dialogHandle1 = mDialogManager.createSimpleDialog(TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT,
callback1, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle1, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle1, mWifiThreadRunner);
Intent intent = verifyStartActivityAsUser(1, mWifiContext);
int dialogId1 = verifySimpleDialogLaunchIntent(intent, TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT);
@@ -387,7 +385,7 @@ public class WifiDialogManagerTest extends WifiBaseTest {
DialogHandle dialogHandle2 = mDialogManager.createSimpleDialog(TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT,
callback2, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle2, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle2, mWifiThreadRunner);
intent = verifyStartActivityAsUser(2, mWifiContext);
int dialogId2 = verifySimpleDialogLaunchIntent(intent, TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT);
@@ -434,7 +432,7 @@ public class WifiDialogManagerTest extends WifiBaseTest {
DialogHandle dialogHandle = mDialogManager.createSimpleDialog(TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
ArgumentCaptor<DialogInterface.OnClickListener> positiveButtonListenerCaptor =
ArgumentCaptor.forClass(DialogInterface.OnClickListener.class);
@@ -479,90 +477,6 @@ public class WifiDialogManagerTest extends WifiBaseTest {
}
@Test
- public void testSimpleDialog_timeoutCancelsDialog_preT() {
- Assume.assumeTrue(!SdkLevel.isAtLeastT());
- SimpleDialogCallback callback = mock(SimpleDialogCallback.class);
- WifiThreadRunner callbackThreadRunner = mock(WifiThreadRunner.class);
-
-
- AlertDialog.Builder builder = mock(AlertDialog.Builder.class);
- AlertDialog dialog = mock(AlertDialog.class);
- when(builder.setTitle(any())).thenReturn(builder);
- when(builder.setMessage(any())).thenReturn(builder);
- when(builder.setPositiveButton(any(), any())).thenReturn(builder);
- when(builder.setNegativeButton(any(), any())).thenReturn(builder);
- when(builder.setNeutralButton(any(), any())).thenReturn(builder);
- when(builder.setOnCancelListener(any())).thenReturn(builder);
- when(builder.setOnDismissListener(any())).thenReturn(builder);
- when(builder.create()).thenReturn(dialog);
- Window window = mock(Window.class);
- WindowManager.LayoutParams layoutParams = mock(WindowManager.LayoutParams.class);
- when(window.getAttributes()).thenReturn(layoutParams);
- when(dialog.getWindow()).thenReturn(window);
- when(mFrameworkFacade.makeAlertDialogBuilder(any())).thenReturn(builder);
- DialogHandle dialogHandle = mDialogManager.createSimpleDialog(TEST_TITLE, TEST_MESSAGE,
- TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT,
- callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, TIMEOUT_MILLIS, mWifiThreadRunner);
-
- // Verify the timeout runnable was posted and run it.
- ArgumentCaptor<Runnable> runnableArgumentCaptor = ArgumentCaptor.forClass(Runnable.class);
- verify(mWifiThreadRunner, times(1))
- .postDelayed(runnableArgumentCaptor.capture(), eq((long) TIMEOUT_MILLIS),
- anyString());
- runnableArgumentCaptor.getValue().run();
-
- // Verify that the dialog was cancelled.
- verify(dialog).cancel();
- }
-
- @Test
- public void testSimpleDialog_dismissedBeforeTimeout_preT() {
- Assume.assumeTrue(!SdkLevel.isAtLeastT());
- SimpleDialogCallback callback = mock(SimpleDialogCallback.class);
- WifiThreadRunner callbackThreadRunner = mock(WifiThreadRunner.class);
-
-
- AlertDialog.Builder builder = mock(AlertDialog.Builder.class);
- AlertDialog dialog = mock(AlertDialog.class);
- when(builder.setTitle(any())).thenReturn(builder);
- when(builder.setMessage(any())).thenReturn(builder);
- when(builder.setPositiveButton(any(), any())).thenReturn(builder);
- when(builder.setNegativeButton(any(), any())).thenReturn(builder);
- when(builder.setNeutralButton(any(), any())).thenReturn(builder);
- when(builder.setOnCancelListener(any())).thenReturn(builder);
- when(builder.setOnDismissListener(any())).thenReturn(builder);
- when(builder.create()).thenReturn(dialog);
- Window window = mock(Window.class);
- WindowManager.LayoutParams layoutParams = mock(WindowManager.LayoutParams.class);
- when(window.getAttributes()).thenReturn(layoutParams);
- when(dialog.getWindow()).thenReturn(window);
- when(mFrameworkFacade.makeAlertDialogBuilder(any())).thenReturn(builder);
-
- DialogHandle dialogHandle = mDialogManager.createSimpleDialog(TEST_TITLE, TEST_MESSAGE,
- TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT,
- callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, TIMEOUT_MILLIS, mWifiThreadRunner);
-
- // Verify the timeout runnable was posted.
- ArgumentCaptor<Runnable> runnableArgumentCaptor = ArgumentCaptor.forClass(Runnable.class);
- verify(mWifiThreadRunner, times(1))
- .postDelayed(runnableArgumentCaptor.capture(), eq((long) TIMEOUT_MILLIS),
- anyString());
- runnableArgumentCaptor.getValue().run();
-
- // Dismiss the dialog before the timeout runnable executes.
- ArgumentCaptor<DialogInterface.OnDismissListener> dismissListenerCaptor =
- ArgumentCaptor.forClass(DialogInterface.OnDismissListener.class);
- verify(builder).setOnDismissListener(dismissListenerCaptor.capture());
- dismissListenerCaptor.getValue().onDismiss(dialog);
- dispatchMockWifiThreadRunner(mWifiThreadRunner);
-
- // Verify that the timeout runnable was removed.
- verify(mWifiThreadRunner).removeCallbacks(runnableArgumentCaptor.getValue());
- }
-
- @Test
public void testSimpleDialog_nullWifiResourceApkName_doesNotLaunchDialog() {
Assume.assumeTrue(SdkLevel.isAtLeastT());
when(mWifiContext.getWifiDialogApkPkgName()).thenReturn(null);
@@ -573,7 +487,7 @@ public class WifiDialogManagerTest extends WifiBaseTest {
DialogHandle dialogHandle = mDialogManager.createSimpleDialog(TEST_TITLE, TEST_MESSAGE,
TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT, TEST_NEUTRAL_BUTTON_TEXT,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
verify(mWifiContext, never()).startActivityAsUser(any(), eq(UserHandle.CURRENT));
}
@@ -607,7 +521,7 @@ public class WifiDialogManagerTest extends WifiBaseTest {
TEST_MESSAGE, TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT,
TEST_NEUTRAL_BUTTON_TEXT,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
ArgumentCaptor<DialogInterface.OnClickListener> positiveButtonListenerCaptor =
ArgumentCaptor.forClass(DialogInterface.OnClickListener.class);
@@ -652,90 +566,6 @@ public class WifiDialogManagerTest extends WifiBaseTest {
}
@Test
- public void testLegacySimpleDialog_timeoutCancelsDialog() {
- SimpleDialogCallback callback = mock(SimpleDialogCallback.class);
- WifiThreadRunner callbackThreadRunner = mock(WifiThreadRunner.class);
-
-
- AlertDialog.Builder builder = mock(AlertDialog.Builder.class);
- AlertDialog dialog = mock(AlertDialog.class);
- when(builder.setTitle(any())).thenReturn(builder);
- when(builder.setMessage(any())).thenReturn(builder);
- when(builder.setPositiveButton(any(), any())).thenReturn(builder);
- when(builder.setNegativeButton(any(), any())).thenReturn(builder);
- when(builder.setNeutralButton(any(), any())).thenReturn(builder);
- when(builder.setOnCancelListener(any())).thenReturn(builder);
- when(builder.setOnDismissListener(any())).thenReturn(builder);
- when(builder.create()).thenReturn(dialog);
- Window window = mock(Window.class);
- WindowManager.LayoutParams layoutParams = mock(WindowManager.LayoutParams.class);
- when(window.getAttributes()).thenReturn(layoutParams);
- when(dialog.getWindow()).thenReturn(window);
- when(mFrameworkFacade.makeAlertDialogBuilder(any())).thenReturn(builder);
- DialogHandle dialogHandle = mDialogManager.createLegacySimpleDialog(TEST_TITLE,
- TEST_MESSAGE, TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT,
- TEST_NEUTRAL_BUTTON_TEXT,
- callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, TIMEOUT_MILLIS, mWifiThreadRunner);
-
- // Verify the timeout runnable was posted and run it.
- ArgumentCaptor<Runnable> runnableArgumentCaptor = ArgumentCaptor.forClass(Runnable.class);
- verify(mWifiThreadRunner, times(1))
- .postDelayed(runnableArgumentCaptor.capture(), eq((long) TIMEOUT_MILLIS),
- anyString());
- runnableArgumentCaptor.getValue().run();
-
- // Verify that the dialog was cancelled.
- verify(dialog).cancel();
- }
-
- @Test
- public void testLegacySimpleDialog_dismissedBeforeTimeout() {
- SimpleDialogCallback callback = mock(SimpleDialogCallback.class);
- WifiThreadRunner callbackThreadRunner = mock(WifiThreadRunner.class);
-
-
- AlertDialog.Builder builder = mock(AlertDialog.Builder.class);
- AlertDialog dialog = mock(AlertDialog.class);
- when(builder.setTitle(any())).thenReturn(builder);
- when(builder.setMessage(any())).thenReturn(builder);
- when(builder.setPositiveButton(any(), any())).thenReturn(builder);
- when(builder.setNegativeButton(any(), any())).thenReturn(builder);
- when(builder.setNeutralButton(any(), any())).thenReturn(builder);
- when(builder.setOnCancelListener(any())).thenReturn(builder);
- when(builder.setOnDismissListener(any())).thenReturn(builder);
- when(builder.create()).thenReturn(dialog);
- Window window = mock(Window.class);
- WindowManager.LayoutParams layoutParams = mock(WindowManager.LayoutParams.class);
- when(window.getAttributes()).thenReturn(layoutParams);
- when(dialog.getWindow()).thenReturn(window);
- when(mFrameworkFacade.makeAlertDialogBuilder(any())).thenReturn(builder);
-
- DialogHandle dialogHandle = mDialogManager.createLegacySimpleDialog(TEST_TITLE,
- TEST_MESSAGE, TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT,
- TEST_NEUTRAL_BUTTON_TEXT,
- callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, TIMEOUT_MILLIS, mWifiThreadRunner);
-
- // Verify the timeout runnable was posted.
- ArgumentCaptor<Runnable> runnableArgumentCaptor = ArgumentCaptor.forClass(Runnable.class);
- verify(mWifiThreadRunner, times(1))
- .postDelayed(runnableArgumentCaptor.capture(), eq((long) TIMEOUT_MILLIS),
- anyString());
- runnableArgumentCaptor.getValue().run();
-
- // Dismiss the dialog before the timeout runnable executes.
- ArgumentCaptor<DialogInterface.OnDismissListener> dismissListenerCaptor =
- ArgumentCaptor.forClass(DialogInterface.OnDismissListener.class);
- verify(builder).setOnDismissListener(dismissListenerCaptor.capture());
- dismissListenerCaptor.getValue().onDismiss(dialog);
- dispatchMockWifiThreadRunner(mWifiThreadRunner);
-
- // Verify that the timeout runnable was removed.
- verify(mWifiThreadRunner).removeCallbacks(runnableArgumentCaptor.getValue());
- }
-
- @Test
public void testLegacySimpleDialog_cancelledDueToActionCloseSystemDialogs() {
SimpleDialogCallback callback = mock(SimpleDialogCallback.class);
WifiThreadRunner callbackThreadRunner = mock(WifiThreadRunner.class);
@@ -761,7 +591,7 @@ public class WifiDialogManagerTest extends WifiBaseTest {
TEST_MESSAGE, TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT,
TEST_NEUTRAL_BUTTON_TEXT,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, TIMEOUT_MILLIS, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
// ACTION_CLOSE_SYSTEM_DIALOGS with EXTRA_CLOSE_SYSTEM_DIALOGS_EXCEPT_WIFI should be
// ignored.
@@ -807,7 +637,7 @@ public class WifiDialogManagerTest extends WifiBaseTest {
TEST_MESSAGE, TEST_POSITIVE_BUTTON_TEXT, TEST_NEGATIVE_BUTTON_TEXT,
TEST_NEUTRAL_BUTTON_TEXT,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, TIMEOUT_MILLIS, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
verify(window).setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
// Receive screen off event.
@@ -833,7 +663,8 @@ public class WifiDialogManagerTest extends WifiBaseTest {
@NonNull Intent launchIntent,
String expectedDeviceName,
boolean expectedIsPinRequested,
- @Nullable String expectedDisplayPin) {
+ @Nullable String expectedDisplayPin,
+ long expectedTimeoutMs) {
assertThat(launchIntent.getAction()).isEqualTo(WifiManager.ACTION_LAUNCH_DIALOG);
ComponentName component = launchIntent.getComponent();
assertThat(component.getPackageName()).isEqualTo(WIFI_DIALOG_APK_PKG_NAME);
@@ -855,6 +686,9 @@ public class WifiDialogManagerTest extends WifiBaseTest {
assertThat(launchIntent.hasExtra(WifiManager.EXTRA_P2P_DISPLAY_PIN)).isTrue();
assertThat(launchIntent.getStringExtra(WifiManager.EXTRA_P2P_DISPLAY_PIN))
.isEqualTo(expectedDisplayPin);
+ assertThat(launchIntent.hasExtra(WifiManager.EXTRA_DIALOG_TIMEOUT_MS)).isTrue();
+ assertThat(launchIntent.getIntExtra(WifiManager.EXTRA_DIALOG_TIMEOUT_MS, -1))
+ .isEqualTo(expectedTimeoutMs);
return dialogId;
}
@@ -871,12 +705,12 @@ public class WifiDialogManagerTest extends WifiBaseTest {
// Accept without PIN
DialogHandle dialogHandle = mDialogManager.createP2pInvitationReceivedDialog(
- TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY,
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS, Display.DEFAULT_DISPLAY,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
Intent intent = verifyStartActivityAsUser(1, mWifiContext);
int dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent,
- TEST_DEVICE_NAME, false, null);
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS);
mDialogManager.replyToP2pInvitationReceivedDialog(dialogId, true, null);
dispatchMockWifiThreadRunner(callbackThreadRunner);
verify(callback, times(1)).onAccepted(null);
@@ -887,86 +721,87 @@ public class WifiDialogManagerTest extends WifiBaseTest {
// Accept with PIN
dialogHandle = mDialogManager.createP2pInvitationReceivedDialog(
- TEST_DEVICE_NAME, true, null, Display.DEFAULT_DISPLAY,
+ TEST_DEVICE_NAME, true, null, TEST_P2P_TIMEOUT_MS, Display.DEFAULT_DISPLAY,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
intent = verifyStartActivityAsUser(2, mWifiContext);
dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent,
- TEST_DEVICE_NAME, true, null);
+ TEST_DEVICE_NAME, true, null, TEST_P2P_TIMEOUT_MS);
mDialogManager.replyToP2pInvitationReceivedDialog(dialogId, true, "012345");
dispatchMockWifiThreadRunner(callbackThreadRunner);
verify(callback, times(1)).onAccepted("012345");
// Accept with PIN but PIN was not requested
dialogHandle = mDialogManager.createP2pInvitationReceivedDialog(
- TEST_DEVICE_NAME, false, null, 123, callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS, 123, callback,
+ callbackThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
if (SdkLevel.isAtLeastT()) {
verifyStartActivityAsUser(1, 123, mWifiContext);
}
intent = verifyStartActivityAsUser(3, mWifiContext);
dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent,
- TEST_DEVICE_NAME, false, null);
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS);
mDialogManager.replyToP2pInvitationReceivedDialog(dialogId, true, "012345");
dispatchMockWifiThreadRunner(callbackThreadRunner);
verify(callback, times(2)).onAccepted("012345");
// Accept without PIN but PIN was requested
dialogHandle = mDialogManager.createP2pInvitationReceivedDialog(
- TEST_DEVICE_NAME, true, null, Display.DEFAULT_DISPLAY,
+ TEST_DEVICE_NAME, true, null, TEST_P2P_TIMEOUT_MS, Display.DEFAULT_DISPLAY,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
intent = verifyStartActivityAsUser(4, mWifiContext);
dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent,
- TEST_DEVICE_NAME, true, null);
+ TEST_DEVICE_NAME, true, null, TEST_P2P_TIMEOUT_MS);
mDialogManager.replyToP2pInvitationReceivedDialog(dialogId, true, null);
dispatchMockWifiThreadRunner(callbackThreadRunner);
verify(callback, times(2)).onAccepted(null);
// Decline without PIN
dialogHandle = mDialogManager.createP2pInvitationReceivedDialog(
- TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY,
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS, Display.DEFAULT_DISPLAY,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
intent = verifyStartActivityAsUser(5, mWifiContext);
dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent,
- TEST_DEVICE_NAME, false, null);
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS);
mDialogManager.replyToP2pInvitationReceivedDialog(dialogId, false, null);
dispatchMockWifiThreadRunner(callbackThreadRunner);
verify(callback, times(1)).onDeclined();
// Decline with PIN
dialogHandle = mDialogManager.createP2pInvitationReceivedDialog(
- TEST_DEVICE_NAME, true, null, Display.DEFAULT_DISPLAY,
+ TEST_DEVICE_NAME, true, null, TEST_P2P_TIMEOUT_MS, Display.DEFAULT_DISPLAY,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
intent = verifyStartActivityAsUser(6, mWifiContext);
dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent,
- TEST_DEVICE_NAME, true, null);
+ TEST_DEVICE_NAME, true, null, TEST_P2P_TIMEOUT_MS);
mDialogManager.replyToP2pInvitationReceivedDialog(dialogId, false, "012345");
dispatchMockWifiThreadRunner(callbackThreadRunner);
verify(callback, times(2)).onDeclined();
// Decline with PIN but PIN was not requested
dialogHandle = mDialogManager.createP2pInvitationReceivedDialog(
- TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY,
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS, Display.DEFAULT_DISPLAY,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
intent = verifyStartActivityAsUser(7, mWifiContext);
dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent,
- TEST_DEVICE_NAME, false, null);
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS);
mDialogManager.replyToP2pInvitationReceivedDialog(dialogId, false, "012345");
dispatchMockWifiThreadRunner(callbackThreadRunner);
verify(callback, times(3)).onDeclined();
// Decline without PIN but PIN was requested
dialogHandle = mDialogManager.createP2pInvitationReceivedDialog(
- TEST_DEVICE_NAME, true, null, Display.DEFAULT_DISPLAY,
+ TEST_DEVICE_NAME, true, null, TEST_P2P_TIMEOUT_MS, Display.DEFAULT_DISPLAY,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
intent = verifyStartActivityAsUser(8, mWifiContext);
dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent,
- TEST_DEVICE_NAME, true, null);
+ TEST_DEVICE_NAME, true, null, TEST_P2P_TIMEOUT_MS);
mDialogManager.replyToP2pInvitationReceivedDialog(dialogId, false, null);
dispatchMockWifiThreadRunner(callbackThreadRunner);
verify(callback, times(4)).onDeclined();
@@ -985,12 +820,12 @@ public class WifiDialogManagerTest extends WifiBaseTest {
// Launch and dismiss dialog.
DialogHandle dialogHandle = mDialogManager.createP2pInvitationReceivedDialog(
- TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY,
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS, Display.DEFAULT_DISPLAY,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
Intent intent = verifyStartActivityAsUser(1, mWifiContext);
int dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent,
- TEST_DEVICE_NAME, false, null);
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS);
dismissDialogSynchronous(dialogHandle, mWifiThreadRunner);
intent = verifyStartActivityAsUser(2, mWifiContext);
verifyDismissIntent(intent);
@@ -1007,12 +842,12 @@ public class WifiDialogManagerTest extends WifiBaseTest {
// Launch dialog again
dialogHandle = mDialogManager.createP2pInvitationReceivedDialog(
- TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY,
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS, Display.DEFAULT_DISPLAY,
callback, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
intent = verifyStartActivityAsUser(3, mWifiContext);
dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent,
- TEST_DEVICE_NAME, false, null);
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS);
// Callback should receive replies to the corresponding dialogId now.
mDialogManager.replyToP2pInvitationReceivedDialog(dialogId, true, null);
@@ -1032,23 +867,23 @@ public class WifiDialogManagerTest extends WifiBaseTest {
mock(P2pInvitationReceivedDialogCallback.class);
WifiThreadRunner callbackThreadRunner = mock(WifiThreadRunner.class);
DialogHandle dialogHandle1 = mDialogManager.createP2pInvitationReceivedDialog(
- TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY,
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS, Display.DEFAULT_DISPLAY,
callback1, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle1, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle1, mWifiThreadRunner);
Intent intent1 = verifyStartActivityAsUser(1, mWifiContext);
int dialogId1 = verifyP2pInvitationReceivedDialogLaunchIntent(intent1,
- TEST_DEVICE_NAME, false, null);
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS);
// Launch Dialog2
P2pInvitationReceivedDialogCallback callback2 =
mock(P2pInvitationReceivedDialogCallback.class);
DialogHandle dialogHandle2 = mDialogManager.createP2pInvitationReceivedDialog(
- TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY,
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS, Display.DEFAULT_DISPLAY,
callback2, callbackThreadRunner);
- launchDialogSynchronous(dialogHandle2, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle2, mWifiThreadRunner);
Intent intent2 = verifyStartActivityAsUser(2, mWifiContext);
int dialogId2 = verifyP2pInvitationReceivedDialogLaunchIntent(intent2,
- TEST_DEVICE_NAME, false, null);
+ TEST_DEVICE_NAME, false, null, TEST_P2P_TIMEOUT_MS);
// callback1 notified
mDialogManager.replyToP2pInvitationReceivedDialog(dialogId1, true, null);
@@ -1103,7 +938,7 @@ public class WifiDialogManagerTest extends WifiBaseTest {
// Launch and dismiss dialog.
DialogHandle dialogHandle = mDialogManager.createP2pInvitationSentDialog(
TEST_DEVICE_NAME, null, Display.DEFAULT_DISPLAY);
- launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner);
+ launchDialogSynchronous(dialogHandle, mWifiThreadRunner);
verifyP2pInvitationSentDialogLaunchIntent(verifyStartActivityAsUser(1, mWifiContext),
TEST_DEVICE_NAME, null);
dismissDialogSynchronous(dialogHandle, mWifiThreadRunner);
diff --git a/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java b/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
index 213757cedb..6b2b59eb8a 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
@@ -1456,7 +1456,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
when(mWifiInjector.getWifiP2pConnection()).thenReturn(mWifiP2pConnection);
when(mWifiDialogManager.createP2pInvitationReceivedDialog(any(), anyBoolean(), any(),
- anyInt(), any(), any())).thenReturn(mDialogHandle);
+ anyInt(), anyInt(), any(), any())).thenReturn(mDialogHandle);
when(mWifiDialogManager.createP2pInvitationSentDialog(any(), any(), anyInt()))
.thenReturn(mDialogHandle);
when(mWifiInjector.getClock()).thenReturn(mClock);
@@ -6782,7 +6782,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
} else {
verify(mWifiDialogManager).createP2pInvitationReceivedDialog(
eq(pdEvent.device.deviceName), eq(false), eq(pdEvent.pin),
- anyInt(), any(), any());
+ anyInt(), anyInt(), any(), any());
verify(mDialogHandle).launchDialog();
}
}
@@ -7306,8 +7306,9 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
verify(mAlertDialog).show();
} else {
verify(mWifiDialogManager).createP2pInvitationReceivedDialog(anyString(), anyBoolean(),
- any(), eq(Display.DEFAULT_DISPLAY), any(), any());
- verify(mDialogHandle).launchDialog(P2P_INVITATION_RECEIVED_TIMEOUT_MS);
+ any(), eq(P2P_INVITATION_RECEIVED_TIMEOUT_MS), eq(Display.DEFAULT_DISPLAY),
+ any(), any());
+ verify(mDialogHandle).launchDialog();
}
}
@@ -7334,8 +7335,9 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
sendNegotiationRequestEvent(config);
verify(mWifiDialogManager).createP2pInvitationReceivedDialog(anyString(),
- anyBoolean(), any(), eq(someNonDefaultDisplayId), any(), any());
- verify(mDialogHandle).launchDialog(P2P_INVITATION_RECEIVED_TIMEOUT_MS);
+ anyBoolean(), any(), eq(P2P_INVITATION_RECEIVED_TIMEOUT_MS),
+ eq(someNonDefaultDisplayId), any(), any());
+ verify(mDialogHandle).launchDialog();
}
/**
@@ -7362,8 +7364,9 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
// "simple" client connect (no display ID)
sendNegotiationRequestEvent(config);
verify(mWifiDialogManager).createP2pInvitationReceivedDialog(anyString(), anyBoolean(),
- any(), eq(Display.DEFAULT_DISPLAY), any(), any());
- verify(mDialogHandle).launchDialog(P2P_INVITATION_RECEIVED_TIMEOUT_MS);
+ any(), eq(P2P_INVITATION_RECEIVED_TIMEOUT_MS), eq(Display.DEFAULT_DISPLAY), any(),
+ any());
+ verify(mDialogHandle).launchDialog();
}
private void verifySetVendorElement(boolean isP2pActivated, boolean shouldSucceed,
@@ -8138,7 +8141,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
mockEnterGroupCreatedState();
- // The first provision discvoery request triggers the dialog.
+ // The first provision discovery request triggers the dialog.
WifiP2pProvDiscEvent pdEvent = new WifiP2pProvDiscEvent();
pdEvent.device = mTestWifiP2pDevice;
sendSimpleMsg(null, WifiP2pMonitor.P2P_PROV_DISC_PBC_REQ_EVENT,
@@ -8146,8 +8149,8 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
verify(mWifiDialogManager).createP2pInvitationReceivedDialog(
eq(mTestWifiP2pDevice.deviceAddress), anyBoolean(),
- any(), anyInt(), any(), any());
- verify(mDialogHandle).launchDialog(P2P_INVITATION_RECEIVED_TIMEOUT_MS);
+ any(), eq(P2P_INVITATION_RECEIVED_TIMEOUT_MS), anyInt(), any(), any());
+ verify(mDialogHandle).launchDialog();
// Handle it programmatically.
sendSimpleMsg(null, WifiP2pServiceImpl.PEER_CONNECTION_USER_REJECT);
@@ -8160,10 +8163,10 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
reset(mWifiDialogManager);
reset(mDialogHandle);
verify(mWifiDialogManager, never()).createP2pInvitationReceivedDialog(
- any(), anyBoolean(), any(), anyInt(), any(), any());
+ any(), anyBoolean(), any(), anyInt(), anyInt(), any(), any());
when(mWifiDialogManager.createP2pInvitationReceivedDialog(any(), anyBoolean(), any(),
- anyInt(), any(), any())).thenReturn(mDialogHandle);
+ anyInt(), anyInt(), any(), any())).thenReturn(mDialogHandle);
when(mWifiDialogManager.createP2pInvitationSentDialog(any(), any(), anyInt()))
.thenReturn(mDialogHandle);
when(mClock.getElapsedSinceBootMillis()).thenReturn(P2P_PEER_AUTH_TIMEOUT_MS + 1L);
@@ -8175,8 +8178,8 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
// Another dialog should be triggered.
verify(mWifiDialogManager).createP2pInvitationReceivedDialog(
eq(mTestWifiP2pDevice.deviceAddress), anyBoolean(),
- any(), anyInt(), any(), any());
- verify(mDialogHandle).launchDialog(P2P_INVITATION_RECEIVED_TIMEOUT_MS);
+ any(), eq(P2P_INVITATION_RECEIVED_TIMEOUT_MS), anyInt(), any(), any());
+ verify(mDialogHandle).launchDialog();
}
@Test