diff options
author | 2022-02-28 00:33:19 +0000 | |
---|---|---|
committer | 2022-03-10 18:10:59 +0000 | |
commit | 704bc86418c2624bcb71d1bdaba8329112b564a9 (patch) | |
tree | 915be7d16a61a7c4955dbaeb85dfcce3fb6dde94 /WifiDialog/src | |
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
Diffstat (limited to 'WifiDialog/src')
-rw-r--r-- | WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java | 31 |
1 files changed, 4 insertions, 27 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; - } } |