diff options
author | 2022-02-28 00:33:19 +0000 | |
---|---|---|
committer | 2022-03-10 18:10:59 +0000 | |
commit | 704bc86418c2624bcb71d1bdaba8329112b564a9 (patch) | |
tree | 915be7d16a61a7c4955dbaeb85dfcce3fb6dde94 | |
parent | 456aed0fe5455b2c3cdbdaa3e3252544cc4c50c8 (diff) |
Launch the activity on the correct display
Launch the activity on the correct display as opposed to trying to
launch the dialog on the display.
Using shell commands to display dialog to specific display:
Start with fake command to get a list of displays:
% adb shell cmd wifi launch-dialog-p2p-invitation-received AAAA -i 10
Then select a display and run command again:
% adb shell cmd wifi launch-dialog-p2p-invitation-received AAAA -i <ID>
Bug: 199829817
Test: manual using adb shell commands
Test: atest WifiDialogManagerTest
Change-Id: Iaf8746d9bf1d9eb7b47748dc72746bc2828a0bda
7 files changed, 116 insertions, 73 deletions
diff --git a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java index 1c8ddf3c23..c8856f7b06 100644 --- a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java +++ b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java @@ -25,7 +25,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.res.Configuration; import android.content.res.Resources; -import android.hardware.display.DisplayManager; import android.media.AudioManager; import android.media.Ringtone; import android.media.RingtoneManager; @@ -43,7 +42,6 @@ import android.text.style.URLSpan; import android.util.ArraySet; import android.util.Log; import android.util.SparseArray; -import android.view.Display; import android.view.Gravity; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -316,9 +314,7 @@ 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.getIntExtra(WifiManager.EXTRA_P2P_DISPLAY_ID, - Display.DEFAULT_DISPLAY)); + intent.getStringExtra(WifiManager.EXTRA_P2P_DISPLAY_PIN)); break; default: if (mIsVerboseLoggingEnabled) { @@ -497,8 +493,7 @@ public class WifiDialogActivity extends Activity { final int dialogId, final @NonNull String deviceName, final boolean isPinRequested, - @Nullable String displayPin, - int displayId) { + @Nullable String displayPin) { if (TextUtils.isEmpty(deviceName)) { if (mIsVerboseLoggingEnabled) { Log.v(TAG, "Could not create P2P Invitation Received dialog with null or empty" @@ -506,8 +501,7 @@ public class WifiDialogActivity extends Activity { + " id=" + dialogId + " deviceName=" + deviceName + " isPinRequested=" + isPinRequested - + " displayPin=" + displayPin - + " displayId=" + displayId); + + " displayPin=" + displayPin); } return null; } @@ -529,7 +523,7 @@ public class WifiDialogActivity extends Activity { addRowToP2pDialog(group, getStringId("wifi_p2p_show_pin_message"), displayPin); } - AlertDialog dialog = new AlertDialog.Builder(getDisplayContextFromId(this, displayId)) + AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(getString(getStringId("wifi_p2p_invitation_to_connect_title"))) .setView(textEntryView) .setPositiveButton(getStringId("accept"), (dialogPositive, which) -> { @@ -590,21 +584,4 @@ public class WifiDialogActivity extends Activity { ((TextView) row.findViewById(getViewId("value"))).setText(value); group.addView(row); } - - private Context getDisplayContextFromId(Context context, int displayId) { - if (displayId == Display.DEFAULT_DISPLAY) { - return context; - } - - DisplayManager dm = getSystemService(DisplayManager.class); - Display[] displays = dm.getDisplays(); - for (Display display: displays) { - if (display.getDisplayId() == displayId) { - return context.createDisplayContext(display); - } - } - - Log.e(TAG, "Can't find a display matching the specified ID = " + displayId); - return context; - } } diff --git a/framework/java/android/net/wifi/WifiManager.java b/framework/java/android/net/wifi/WifiManager.java index f1d308c168..b4360dc322 100644 --- a/framework/java/android/net/wifi/WifiManager.java +++ b/framework/java/android/net/wifi/WifiManager.java @@ -9514,13 +9514,6 @@ public class WifiManager { public static final String EXTRA_P2P_DISPLAY_PIN = "android.net.wifi.extra.P2P_DISPLAY_PIN"; /** - * Extra String indicating the Display ID to be used for the dialog. Default display is - * Display.DEFAULT_DISPLAY. - * @hide - */ - public static final String EXTRA_P2P_DISPLAY_ID = "android.net.wifi.extra.P2P_DISPLAY_ID"; - - /** * Returns a set of packages that aren't DO or PO but should be able to manage WiFi networks. * @hide */ diff --git a/service/java/com/android/server/wifi/WifiDialogManager.java b/service/java/com/android/server/wifi/WifiDialogManager.java index accd9412f2..6832999372 100644 --- a/service/java/com/android/server/wifi/WifiDialogManager.java +++ b/service/java/com/android/server/wifi/WifiDialogManager.java @@ -16,6 +16,7 @@ package com.android.server.wifi; +import android.app.ActivityOptions; import android.content.Intent; import android.net.wifi.WifiContext; import android.net.wifi.WifiManager; @@ -23,12 +24,15 @@ import android.os.UserHandle; import android.util.ArraySet; import android.util.Log; import android.util.SparseArray; +import android.view.Display; import androidx.annotation.AnyThread; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; +import com.android.modules.utils.build.SdkLevel; + import java.util.Set; import javax.annotation.concurrent.ThreadSafe; @@ -151,14 +155,16 @@ public class WifiDialogManager { */ private class DialogHandleInternal { private int mDialogId = WifiManager.INVALID_DIALOG_ID; - private @NonNull Intent mIntent; + private final @NonNull Intent mIntent; private Runnable mTimeoutRunnable; + private final int mDisplayId; - DialogHandleInternal(@NonNull Intent intent) + DialogHandleInternal(@NonNull Intent intent, int displayId) throws IllegalArgumentException { if (intent == null) { throw new IllegalArgumentException("Intent cannot be null!"); } + mDisplayId = displayId; mIntent = intent; } @@ -172,7 +178,20 @@ public class WifiDialogManager { } registerDialog(); mIntent.putExtra(WifiManager.EXTRA_DIALOG_ID, mDialogId); - mContext.startActivityAsUser(mIntent, UserHandle.CURRENT); + boolean launched = false; + if (SdkLevel.isAtLeastT() && mDisplayId != Display.DEFAULT_DISPLAY) { + try { + mContext.startActivityAsUser(mIntent, + ActivityOptions.makeBasic().setLaunchDisplayId(mDisplayId).toBundle(), + UserHandle.CURRENT); + launched = true; + } catch (Exception e) { + Log.e(TAG, "Error startActivityAsUser - " + e); + } + } + if (!launched) { + mContext.startActivityAsUser(mIntent, UserHandle.CURRENT); + } if (mVerboseLoggingEnabled) { Log.v(TAG, "Launching dialog with id=" + mDialogId); } @@ -271,7 +290,8 @@ public class WifiDialogManager { .putExtra(WifiManager.EXTRA_DIALOG_MESSAGE_URL_END, messageUrlEnd) .putExtra(WifiManager.EXTRA_DIALOG_POSITIVE_BUTTON_TEXT, positiveButtonText) .putExtra(WifiManager.EXTRA_DIALOG_NEGATIVE_BUTTON_TEXT, negativeButtonText) - .putExtra(WifiManager.EXTRA_DIALOG_NEUTRAL_BUTTON_TEXT, neutralButtonText)); + .putExtra(WifiManager.EXTRA_DIALOG_NEUTRAL_BUTTON_TEXT, neutralButtonText), + Display.DEFAULT_DISPLAY); if (messageUrl != null) { if (message == null) { throw new IllegalArgumentException("Cannot set span for null message!"); @@ -497,8 +517,7 @@ public class WifiDialogManager { super(getBaseLaunchIntent(WifiManager.DIALOG_TYPE_P2P_INVITATION_RECEIVED) .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_ID, displayId)); + .putExtra(WifiManager.EXTRA_P2P_DISPLAY_PIN, displayPin), displayId); if (deviceName == null) { throw new IllegalArgumentException("Device name cannot be null!"); } @@ -627,10 +646,12 @@ public class WifiDialogManager { private class P2pInvitationSentDialogHandle extends DialogHandleInternal { P2pInvitationSentDialogHandle( final @NonNull String deviceName, - final @NonNull String displayPin) throws IllegalArgumentException { + final @NonNull String displayPin, + int displayId) throws IllegalArgumentException { super(getBaseLaunchIntent(WifiManager.DIALOG_TYPE_P2P_INVITATION_SENT) .putExtra(WifiManager.EXTRA_P2P_DEVICE_NAME, deviceName) - .putExtra(WifiManager.EXTRA_P2P_DISPLAY_PIN, displayPin)); + .putExtra(WifiManager.EXTRA_P2P_DISPLAY_PIN, displayPin), + displayId); if (deviceName == null) { throw new IllegalArgumentException("Device name cannot be null!"); } @@ -645,15 +666,18 @@ public class WifiDialogManager { * * @param deviceName Name of the device the invitation was sent to. * @param displayPin display PIN + * @param displayId display ID * @return DialogHandle Handle for the dialog, or {@code null} if no dialog could * be created. */ @AnyThread public DialogHandle createP2pInvitationSentDialog( @NonNull String deviceName, - @Nullable String displayPin) { + @Nullable String displayPin, + int displayId) { try { - return new DialogHandle(new P2pInvitationSentDialogHandle(deviceName, displayPin)); + return new DialogHandle(new P2pInvitationSentDialogHandle(deviceName, displayPin, + displayId)); } catch (IllegalArgumentException e) { Log.e(TAG, "Could not create DialogHandle for P2P Invitation Sent dialog: " + e); return null; diff --git a/service/java/com/android/server/wifi/WifiShellCommand.java b/service/java/com/android/server/wifi/WifiShellCommand.java index 34693f0c45..a47691f54b 100644 --- a/service/java/com/android/server/wifi/WifiShellCommand.java +++ b/service/java/com/android/server/wifi/WifiShellCommand.java @@ -1269,11 +1269,34 @@ public class WifiShellCommand extends BasicShellCommandHandler { } } return 0; - case "launch-dialog-p2p-invitation-sent": - mWifiDialogManager.createP2pInvitationSentDialog( - getNextArgRequired(), getNextArgRequired()).launchDialog(); + 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()); + } + } + mWifiDialogManager.createP2pInvitationSentDialog(deviceName, displayPin, + displayId).launchDialog(); pw.println("Launched dialog."); return 0; + } case "launch-dialog-p2p-invitation-received": { String deviceName = getNextArgRequired(); boolean isPinRequested = false; @@ -2115,7 +2138,7 @@ public class WifiShellCommand extends BasicShellCommandHandler { pw.println(" -n - Negative Button Text"); pw.println(" -x - Neutral Button Text"); pw.println(" -c - Optional timeout in milliseconds"); - pw.println(" launch-dialog-p2p-invitation-sent <device_name> <pin>"); + pw.println(" launch-dialog-p2p-invitation-sent <device_name> <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"); diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java index 7d70413892..1bbea2f344 100644 --- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java +++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java @@ -4452,8 +4452,14 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { extras); return; } + int displayId = mDeathDataByBinder.values().stream() + .filter(d -> d.mDisplayId != Display.DEFAULT_DISPLAY) + .findAny() + .map((dhd) -> dhd.mDisplayId) + .orElse(Display.DEFAULT_DISPLAY); + WifiDialogManager.DialogHandle dialogHandle = mWifiInjector.getWifiDialogManager() - .createP2pInvitationSentDialog(getDeviceName(peerAddress), pin); + .createP2pInvitationSentDialog(getDeviceName(peerAddress), pin, displayId); if (dialogHandle == null) { loge("Could not create invitation sent dialog!"); return; 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 6191b5b6cb..f2f4510073 100644 --- a/service/tests/wifitests/src/com/android/server/wifi/WifiDialogManagerTest.java +++ b/service/tests/wifitests/src/com/android/server/wifi/WifiDialogManagerTest.java @@ -18,20 +18,24 @@ package com.android.server.wifi; import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import android.app.ActivityOptions; import android.content.ComponentName; import android.content.Intent; import android.net.wifi.WifiContext; import android.net.wifi.WifiManager; +import android.os.Bundle; import android.os.UserHandle; import android.view.Display; @@ -70,6 +74,8 @@ public class WifiDialogManagerTest extends WifiBaseTest { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(mWifiContext.getWifiDialogApkPkgName()).thenReturn(WIFI_DIALOG_APK_PKG_NAME); + doThrow(SecurityException.class).when(mWifiContext).startActivityAsUser(any(), any(), + any()); } private void dispatchMockWifiThreadRunner(WifiThreadRunner wifiThreadRunner) { @@ -125,6 +131,25 @@ public class WifiDialogManagerTest extends WifiBaseTest { } /** + * Helper method to verify display-specific startActivityAsUser was called a given amount of + * times and return the last Intent that was sent. + */ + @NonNull + private Intent verifyStartActivityAsUser( + int times, + int displayId, + @NonNull WifiContext wifiContext) { + ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class); + ArgumentCaptor<Bundle> bundleArgumentCaptor = ArgumentCaptor.forClass(Bundle.class); + verify(wifiContext, times(times)).startActivityAsUser(intentArgumentCaptor.capture(), + bundleArgumentCaptor.capture(), eq(UserHandle.CURRENT)); + assertEquals(ActivityOptions.makeBasic().setLaunchDisplayId( + displayId).toBundle().toString(), + bundleArgumentCaptor.getValue().toString()); // since can't compare Bundles + return intentArgumentCaptor.getValue(); + } + + /** * Helper method to verify the contents of a dismiss Intent */ private void verifyDismissIntent(@NonNull Intent dismissIntent) { @@ -358,8 +383,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { @NonNull Intent launchIntent, String expectedDeviceName, boolean expectedIsPinRequested, - @Nullable String expectedDisplayPin, - int expectedDisplayId) { + @Nullable String expectedDisplayPin) { assertThat(launchIntent.getAction()).isEqualTo(WifiManager.ACTION_LAUNCH_DIALOG); ComponentName component = launchIntent.getComponent(); assertThat(component.getPackageName()).isEqualTo(WIFI_DIALOG_APK_PKG_NAME); @@ -381,11 +405,6 @@ 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_P2P_DISPLAY_ID)).isTrue(); - // the -1000 should always be an incorrect value - i.e. don't default (not really - // necessary since validation that extra exists - but a backup). - assertThat(launchIntent.getIntExtra(WifiManager.EXTRA_P2P_DISPLAY_ID, -1000)) - .isEqualTo(expectedDisplayId); return dialogId; } @@ -408,7 +427,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner); Intent intent = verifyStartActivityAsUser(1, mWifiContext); int dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent, - TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY); + TEST_DEVICE_NAME, false, null); wifiDialogManager.replyToP2pInvitationReceivedDialog(dialogId, true, null); dispatchMockWifiThreadRunner(callbackThreadRunner); verify(callback, times(1)).onAccepted(null); @@ -424,7 +443,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner); intent = verifyStartActivityAsUser(2, mWifiContext); dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent, - TEST_DEVICE_NAME, true, null, Display.DEFAULT_DISPLAY); + TEST_DEVICE_NAME, true, null); wifiDialogManager.replyToP2pInvitationReceivedDialog(dialogId, true, "012345"); dispatchMockWifiThreadRunner(callbackThreadRunner); verify(callback, times(1)).onAccepted("012345"); @@ -433,9 +452,10 @@ public class WifiDialogManagerTest extends WifiBaseTest { dialogHandle = wifiDialogManager.createP2pInvitationReceivedDialog( TEST_DEVICE_NAME, false, null, 123, callback, callbackThreadRunner); launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner); + verifyStartActivityAsUser(1, 123, mWifiContext); intent = verifyStartActivityAsUser(3, mWifiContext); dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent, - TEST_DEVICE_NAME, false, null, 123); + TEST_DEVICE_NAME, false, null); wifiDialogManager.replyToP2pInvitationReceivedDialog(dialogId, true, "012345"); dispatchMockWifiThreadRunner(callbackThreadRunner); verify(callback, times(2)).onAccepted("012345"); @@ -447,7 +467,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner); intent = verifyStartActivityAsUser(4, mWifiContext); dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent, - TEST_DEVICE_NAME, true, null, Display.DEFAULT_DISPLAY); + TEST_DEVICE_NAME, true, null); wifiDialogManager.replyToP2pInvitationReceivedDialog(dialogId, true, null); dispatchMockWifiThreadRunner(callbackThreadRunner); verify(callback, times(2)).onAccepted(null); @@ -459,7 +479,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner); intent = verifyStartActivityAsUser(5, mWifiContext); dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent, - TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY); + TEST_DEVICE_NAME, false, null); wifiDialogManager.replyToP2pInvitationReceivedDialog(dialogId, false, null); dispatchMockWifiThreadRunner(callbackThreadRunner); verify(callback, times(1)).onDeclined(); @@ -471,7 +491,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner); intent = verifyStartActivityAsUser(6, mWifiContext); dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent, - TEST_DEVICE_NAME, true, null, Display.DEFAULT_DISPLAY); + TEST_DEVICE_NAME, true, null); wifiDialogManager.replyToP2pInvitationReceivedDialog(dialogId, false, "012345"); dispatchMockWifiThreadRunner(callbackThreadRunner); verify(callback, times(2)).onDeclined(); @@ -483,7 +503,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner); intent = verifyStartActivityAsUser(7, mWifiContext); dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent, - TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY); + TEST_DEVICE_NAME, false, null); wifiDialogManager.replyToP2pInvitationReceivedDialog(dialogId, false, "012345"); dispatchMockWifiThreadRunner(callbackThreadRunner); verify(callback, times(3)).onDeclined(); @@ -495,7 +515,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner); intent = verifyStartActivityAsUser(8, mWifiContext); dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent, - TEST_DEVICE_NAME, true, null, Display.DEFAULT_DISPLAY); + TEST_DEVICE_NAME, true, null); wifiDialogManager.replyToP2pInvitationReceivedDialog(dialogId, false, null); dispatchMockWifiThreadRunner(callbackThreadRunner); verify(callback, times(4)).onDeclined(); @@ -520,7 +540,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner); Intent intent = verifyStartActivityAsUser(1, mWifiContext); int dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent, - TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY); + TEST_DEVICE_NAME, false, null); dismissDialogSynchronous(dialogHandle, mWifiThreadRunner); intent = verifyStartActivityAsUser(2, mWifiContext); verifyDismissIntent(intent); @@ -541,7 +561,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner); intent = verifyStartActivityAsUser(3, mWifiContext); dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent, - TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY); + TEST_DEVICE_NAME, false, null); // Callback should receive replies to the corresponding dialogId now. wifiDialogManager.replyToP2pInvitationReceivedDialog(dialogId, true, null); @@ -567,7 +587,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { launchDialogSynchronous(dialogHandle1, 0, mWifiThreadRunner); Intent intent1 = verifyStartActivityAsUser(1, mWifiContext); int dialogId1 = verifyP2pInvitationReceivedDialogLaunchIntent(intent1, - TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY); + TEST_DEVICE_NAME, false, null); // Launch Dialog2 P2pInvitationReceivedDialogCallback callback2 = @@ -578,7 +598,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { launchDialogSynchronous(dialogHandle2, 0, mWifiThreadRunner); Intent intent2 = verifyStartActivityAsUser(2, mWifiContext); int dialogId2 = verifyP2pInvitationReceivedDialogLaunchIntent(intent2, - TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY); + TEST_DEVICE_NAME, false, null); // callback1 notified wifiDialogManager.replyToP2pInvitationReceivedDialog(dialogId1, true, null); @@ -611,7 +631,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { launchDialogSynchronous(dialogHandle, 0, mWifiThreadRunner); Intent intent = verifyStartActivityAsUser(1, mWifiContext); int dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent, - TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY); + TEST_DEVICE_NAME, false, null); // Verify cancel runnable wasn't posted. verify(mWifiThreadRunner, never()).postDelayed(any(Runnable.class), anyInt()); @@ -624,7 +644,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { launchDialogSynchronous(dialogHandle, TIMEOUT_MILLIS, mWifiThreadRunner); intent = verifyStartActivityAsUser(2, mWifiContext); dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent, - TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY); + TEST_DEVICE_NAME, false, null); // Verify the timeout runnable was posted and run it. ArgumentCaptor<Runnable> runnableArgumentCaptor = ArgumentCaptor.forClass(Runnable.class); @@ -652,7 +672,7 @@ public class WifiDialogManagerTest extends WifiBaseTest { launchDialogSynchronous(dialogHandle, TIMEOUT_MILLIS, mWifiThreadRunner); intent = verifyStartActivityAsUser(4, mWifiContext); dialogId = verifyP2pInvitationReceivedDialogLaunchIntent(intent, - TEST_DEVICE_NAME, false, null, Display.DEFAULT_DISPLAY); + TEST_DEVICE_NAME, false, null); // Reply before the timeout is over wifiDialogManager.replyToP2pInvitationReceivedDialog(dialogId, true, null); dispatchMockWifiThreadRunner(callbackThreadRunner); 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 2f41850318..ea58f10e62 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 @@ -1159,7 +1159,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest { when(mWifiInjector.getWifiDialogManager()).thenReturn(mWifiDialogManager); when(mWifiDialogManager.createP2pInvitationReceivedDialog(any(), anyBoolean(), any(), anyInt(), any(), any())).thenReturn(mDialogHandle); - when(mWifiDialogManager.createP2pInvitationSentDialog(any(), any())) + when(mWifiDialogManager.createP2pInvitationSentDialog(any(), any(), anyInt())) .thenReturn(mDialogHandle); when(mWifiInjector.getClock()).thenReturn(mClock); when(mWifiInjector.getInterfaceConflictManager()).thenReturn(mInterfaceConflictManager); @@ -5242,7 +5242,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest { verify(mWifiNative).p2pConnect(any(), anyBoolean()); verify(mWifiDialogManager).createP2pInvitationSentDialog( - pdEvent.device.deviceName, pdEvent.pin); + pdEvent.device.deviceName, pdEvent.pin, Display.DEFAULT_DISPLAY); verify(mDialogHandle).launchDialog(); } |