Skip to content

Commit 75c61d8

Browse files
scrubskipAndroid (Google) Code Review
authored andcommitted
Merge "Add appliance mode handling for WiFi Direct invitation dialog." into jb-mr1-aah-dev
2 parents 444354d + 8f38f3c commit 75c61d8

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;
@@ -1917,6 +1919,26 @@ public void onCancel(DialogInterface arg0) {
19171919
break;
19181920
}
19191921

1922+
if ((r.getConfiguration().uiMode & Configuration.UI_MODE_TYPE_APPLIANCE) ==
1923+
Configuration.UI_MODE_TYPE_APPLIANCE) {
1924+
// For appliance devices, add a key listener which accepts.
1925+
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
1926+
1927+
@Override
1928+
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
1929+
// TODO: make the actual key come from a config value.
1930+
if (keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
1931+
sendMessage(PEER_CONNECTION_USER_ACCEPT);
1932+
dialog.dismiss();
1933+
return true;
1934+
}
1935+
return false;
1936+
}
1937+
});
1938+
// TODO: add timeout for this dialog.
1939+
// TODO: update UI in appliance mode to tell user what to do.
1940+
}
1941+
19201942
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
19211943
dialog.show();
19221944
}

0 commit comments

Comments
 (0)