Skip to content

Commit 8f38f3c

Browse files
committed
Add appliance mode handling for WiFi Direct invitation dialog.
Add appliance mode handling for WiFi Direct invitation dialog. Otherwise, no way to accept connections. Change-Id: Ic31b5bb25fed02848cf7c9e6418e21e9ab8b0cdd
1 parent 441f067 commit 8f38f3c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

wifi/java/android/net/wifi/p2p/WifiP2pService.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import android.content.Intent;
3131
import android.content.IntentFilter;
3232
import android.content.pm.PackageManager;
33+
import android.content.res.Configuration;
3334
import android.content.res.Resources;
3435
import android.net.IConnectivityManager;
3536
import android.net.ConnectivityManager;
@@ -68,6 +69,7 @@
6869
import android.text.TextUtils;
6970
import android.util.Slog;
7071
import android.util.SparseArray;
72+
import android.view.KeyEvent;
7173
import android.view.LayoutInflater;
7274
import android.view.View;
7375
import android.view.ViewGroup;
@@ -1891,6 +1893,26 @@ public void onCancel(DialogInterface arg0) {
18911893
break;
18921894
}
18931895

1896+
if ((r.getConfiguration().uiMode & Configuration.UI_MODE_TYPE_APPLIANCE) ==
1897+
Configuration.UI_MODE_TYPE_APPLIANCE) {
1898+
// For appliance devices, add a key listener which accepts.
1899+
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
1900+
1901+
@Override
1902+
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
1903+
// TODO: make the actual key come from a config value.
1904+
if (keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
1905+
sendMessage(PEER_CONNECTION_USER_ACCEPT);
1906+
dialog.dismiss();
1907+
return true;
1908+
}
1909+
return false;
1910+
}
1911+
});
1912+
// TODO: add timeout for this dialog.
1913+
// TODO: update UI in appliance mode to tell user what to do.
1914+
}
1915+
18941916
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
18951917
dialog.show();
18961918
}

0 commit comments

Comments
 (0)