Merge "Add appliance mode handling for WiFi Direct invitation dialog." into jb-mr1-aah-dev

This commit is contained in:
Justin Koh
2012-10-19 10:13:34 -07:00
committed by Android (Google) Code Review

View File

@@ -30,6 +30,7 @@ import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.IConnectivityManager;
import android.net.ConnectivityManager;
@@ -68,6 +69,7 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.Slog;
import android.util.SparseArray;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -1917,6 +1919,26 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
break;
}
if ((r.getConfiguration().uiMode & Configuration.UI_MODE_TYPE_APPLIANCE) ==
Configuration.UI_MODE_TYPE_APPLIANCE) {
// For appliance devices, add a key listener which accepts.
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
// TODO: make the actual key come from a config value.
if (keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
sendMessage(PEER_CONNECTION_USER_ACCEPT);
dialog.dismiss();
return true;
}
return false;
}
});
// TODO: add timeout for this dialog.
// TODO: update UI in appliance mode to tell user what to do.
}
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
dialog.show();
}