|
30 | 30 | import android.content.Intent; |
31 | 31 | import android.content.IntentFilter; |
32 | 32 | import android.content.pm.PackageManager; |
| 33 | +import android.content.res.Configuration; |
33 | 34 | import android.content.res.Resources; |
34 | 35 | import android.net.IConnectivityManager; |
35 | 36 | import android.net.ConnectivityManager; |
|
68 | 69 | import android.text.TextUtils; |
69 | 70 | import android.util.Slog; |
70 | 71 | import android.util.SparseArray; |
| 72 | +import android.view.KeyEvent; |
71 | 73 | import android.view.LayoutInflater; |
72 | 74 | import android.view.View; |
73 | 75 | import android.view.ViewGroup; |
@@ -1917,6 +1919,26 @@ public void onCancel(DialogInterface arg0) { |
1917 | 1919 | break; |
1918 | 1920 | } |
1919 | 1921 |
|
| 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 | + |
1920 | 1942 | dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); |
1921 | 1943 | dialog.show(); |
1922 | 1944 | } |
|
0 commit comments