summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values/strings.xml21
-rw-r--r--res/xml/development_prefs.xml4
-rw-r--r--src/com/android/settings/DevelopmentSettings.java18
-rwxr-xr-xsrc/com/android/settings/wfd/WifiDisplaySettings.java243
4 files changed, 285 insertions, 1 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6f242ca7d..ba186eaa6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1258,6 +1258,23 @@
<!-- Wifi Display settings. Summary shown in Display settings. Text used for 'Disabled' state. [CHAR LIMIT=40] -->
<string name="wifi_display_summary_disabled">Disabled</string>
+ <!-- Wifi Display settings. The sub heading for wireless display certification options. [CHAR LIMIT=40] -->
+ <string name="wifi_display_certification_heading">Certification</string>
+ <!-- Wifi Display settings. The section title for wireless display session info. [CHAR LIMIT=40] -->
+ <string name="wifi_display_session_info">Session info</string>
+ <!-- Wifi Display settings. The checkbox title for enabling listen mode during certification process. [CHAR LIMIT=40] -->
+ <string name="wifi_display_listen_mode">Enable listen mode</string>
+ <!-- Wifi Display settings. The checkbox title for enabling autonomous GO during certification process. [CHAR LIMIT=40] -->
+ <string name="wifi_display_autonomous_go">Enable autonomous GO</string>
+ <!-- Wifi Display settings. The button text for sending pause trigger during certification process. [CHAR LIMIT=40] -->
+ <string name="wifi_display_pause">Pause</string>
+ <!-- Wifi Display settings. The button text for sending play (resume) trigger during certification process. [CHAR LIMIT=40] -->
+ <string name="wifi_display_resume">Resume</string>
+ <!-- Wifi Display settings. The dropdown menu title for choosing listen channel during certification process. [CHAR LIMIT=40] -->
+ <string name="wifi_display_listen_channel">Listen channel</string>
+ <!-- Wifi Display settings. The dropdown menu title for choosing operating channel during certification process. [CHAR LIMIT=40] -->
+ <string name="wifi_display_operating_channel">Operating channel</string>
+
<!-- NFC settings -->
<!-- Used in the 1st-level settings screen to turn on NFC -->
<string name="nfc_quick_toggle_title">NFC</string>
@@ -3128,6 +3145,10 @@
<!-- Message of dialog confirming that user wants to restart their device with a new runtime -->
<string name="select_runtime_warning_message">Reboot to change runtime from <xliff:g id="old" example="libdvm.so">%1$s</xliff:g> to <xliff:g id="new" example="libart.so">%2$s</xliff:g>?</string>
+ <!-- Setting Checkbox title whether to show options for wireless display certification -->
+ <string name="wifi_display_certification">Wireless display certification</string>
+ <!-- setting Checkbox summary whether to show options for wireless display certification -->
+ <string name="wifi_display_certification_summary">Show options for wireless display certification</string>
<!-- Setting Checkbox title whether to allow mock locations -->
<string name="allow_mock_location">Allow mock locations</string>
<!-- setting Checkbox summary whether to allow mock locations -->
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index fa244956d..8362a8348 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -106,6 +106,10 @@
android:title="@string/verify_apps_over_usb_title"
android:summary="@string/verify_apps_over_usb_summary"/>
+ <CheckBoxPreference
+ android:key="wifi_display_certification"
+ android:title="@string/wifi_display_certification"
+ android:summary="@string/wifi_display_certification_summary"/>
</PreferenceCategory>
<PreferenceCategory android:key="debug_input_category"
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 11ffbf720..deb09732e 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -136,6 +136,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private static final String OVERLAY_DISPLAY_DEVICES_KEY = "overlay_display_devices";
private static final String DEBUG_DEBUGGING_CATEGORY_KEY = "debug_debugging_category";
private static final String DEBUG_APPLICATIONS_CATEGORY_KEY = "debug_applications_category";
+ private static final String WIFI_DISPLAY_CERTIFICATION_KEY = "wifi_display_certification";
private static final String OPENGL_TRACES_KEY = "enable_opengl_traces";
@@ -179,6 +180,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private Preference mDebugAppPref;
private CheckBoxPreference mWaitForDebugger;
private CheckBoxPreference mVerifyAppsOverUsb;
+ private CheckBoxPreference mWifiDisplayCertification;
private CheckBoxPreference mStrictMode;
private CheckBoxPreference mPointerLocation;
@@ -307,6 +309,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mDebugLayout = findAndInitCheckboxPref(DEBUG_LAYOUT_KEY);
mForceRtlLayout = findAndInitCheckboxPref(FORCE_RTL_LAYOUT_KEY);
mDebugHwOverdraw = addListPreference(DEBUG_HW_OVERDRAW_KEY);
+ mWifiDisplayCertification = findAndInitCheckboxPref(WIFI_DISPLAY_CERTIFICATION_KEY);
mWindowAnimationScale = addListPreference(WINDOW_ANIMATION_SCALE_KEY);
mTransitionAnimationScale = addListPreference(TRANSITION_ANIMATION_SCALE_KEY);
mAnimatorDurationScale = addListPreference(ANIMATOR_DURATION_SCALE_KEY);
@@ -527,6 +530,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
updateVerifyAppsOverUsbOptions();
updateBugreportOptions();
updateForceRtlOptions();
+ updateWifiDisplayCertificationOptions();
}
private void resetDangerousOptions() {
@@ -976,6 +980,18 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
LocalePicker.updateLocale(getActivity().getResources().getConfiguration().locale);
}
+ private void updateWifiDisplayCertificationOptions() {
+ updateCheckBox(mWifiDisplayCertification, Settings.Global.getInt(
+ getActivity().getContentResolver(),
+ Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON, 0) != 0);
+ }
+
+ private void writeWifiDisplayCertificationOptions() {
+ Settings.Global.putInt(getActivity().getContentResolver(),
+ Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON,
+ mWifiDisplayCertification.isChecked() ? 1 : 0);
+ }
+
private void updateCpuUsageOptions() {
updateCheckBox(mShowCpuUsage, Settings.Global.getInt(getActivity().getContentResolver(),
Settings.Global.SHOW_PROCESSES, 0) != 0);
@@ -1283,6 +1299,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
writeDebugLayoutOptions();
} else if (preference == mForceRtlLayout) {
writeForceRtlOptions();
+ } else if (preference == mWifiDisplayCertification) {
+ writeWifiDisplayCertificationOptions();
} else {
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
diff --git a/src/com/android/settings/wfd/WifiDisplaySettings.java b/src/com/android/settings/wfd/WifiDisplaySettings.java
index d04c3cb34..7f560b3ef 100755
--- a/src/com/android/settings/wfd/WifiDisplaySettings.java
+++ b/src/com/android/settings/wfd/WifiDisplaySettings.java
@@ -19,6 +19,7 @@ package com.android.settings.wfd;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
+import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
@@ -29,8 +30,14 @@ import android.hardware.display.DisplayManager;
import android.hardware.display.WifiDisplay;
import android.hardware.display.WifiDisplayStatus;
import android.net.Uri;
+import android.net.wifi.p2p.WifiP2pManager;
+import android.net.wifi.p2p.WifiP2pManager.ActionListener;
+import android.net.wifi.p2p.WifiP2pManager.Channel;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Looper;
+import android.preference.CheckBoxPreference;
+import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
@@ -38,12 +45,17 @@ import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.text.Html;
+import android.util.Slog;
import android.util.TypedValue;
import android.view.Gravity;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
@@ -59,6 +71,7 @@ import com.android.settings.SettingsPreferenceFragment;
*/
public final class WifiDisplaySettings extends SettingsPreferenceFragment {
private static final String TAG = "WifiDisplaySettings";
+ private static final boolean DEBUG = false;
private static final int MENU_ID_SCAN = Menu.FIRST;
@@ -74,6 +87,16 @@ public final class WifiDisplaySettings extends SettingsPreferenceFragment {
private Switch mActionBarSwitch;
+ /* certification */
+ private boolean mWifiDisplayCertificationOn;
+ private WifiP2pManager mWifiP2pManager;
+ private Channel mWifiP2pChannel;
+ private PreferenceGroup mCertCategory;
+ private boolean mListen;
+ private boolean mAutoGO;
+ private int mListenChannel;
+ private int mOperatingChannel;
+
public WifiDisplaySettings() {
}
@@ -82,6 +105,8 @@ public final class WifiDisplaySettings extends SettingsPreferenceFragment {
super.onCreate(icicle);
mDisplayManager = (DisplayManager)getActivity().getSystemService(Context.DISPLAY_SERVICE);
+ mWifiP2pManager = (WifiP2pManager)getActivity().getSystemService(Context.WIFI_P2P_SERVICE);
+ mWifiP2pChannel = mWifiP2pManager.initialize(getActivity(), Looper.getMainLooper(), null);
addPreferencesFromResource(R.xml.wifi_display_settings);
setHasOptionsMenu(true);
@@ -131,8 +156,10 @@ public final class WifiDisplaySettings extends SettingsPreferenceFragment {
filter.addAction(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED);
context.registerReceiver(mReceiver, filter);
- getContentResolver().registerContentObserver(Settings.Secure.getUriFor(
+ getContentResolver().registerContentObserver(Settings.Global.getUriFor(
Settings.Global.WIFI_DISPLAY_ON), false, mSettingsObserver);
+ getContentResolver().registerContentObserver(Settings.Global.getUriFor(
+ Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON), false, mSettingsObserver);
mDisplayManager.scanWifiDisplays();
@@ -193,6 +220,8 @@ public final class WifiDisplaySettings extends SettingsPreferenceFragment {
private void update() {
mWifiDisplayOnSetting = Settings.Global.getInt(getContentResolver(),
Settings.Global.WIFI_DISPLAY_ON, 0) != 0;
+ mWifiDisplayCertificationOn = Settings.Global.getInt(getContentResolver(),
+ Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON, 0) != 0;
mWifiDisplayStatus = mDisplayManager.getWifiDisplayStatus();
applyState();
@@ -209,6 +238,10 @@ public final class WifiDisplaySettings extends SettingsPreferenceFragment {
if (featureState == WifiDisplayStatus.FEATURE_STATE_ON) {
final WifiDisplay[] displays = mWifiDisplayStatus.getDisplays();
+ if (mWifiDisplayCertificationOn) {
+ buildCertificationMenu(preferenceScreen);
+ }
+
if (mPairedDevicesCategory == null) {
mPairedDevicesCategory = new PreferenceCategory(getActivity());
mPairedDevicesCategory.setTitle(R.string.wifi_display_paired_devices);
@@ -250,6 +283,214 @@ public final class WifiDisplaySettings extends SettingsPreferenceFragment {
getActivity().invalidateOptionsMenu();
}
+ private void buildCertificationMenu(final PreferenceScreen preferenceScreen) {
+ if (mCertCategory == null) {
+ mCertCategory = new PreferenceCategory(getActivity());
+ mCertCategory.setTitle(R.string.wifi_display_certification_heading);
+ } else {
+ mCertCategory.removeAll();
+ }
+ preferenceScreen.addPreference(mCertCategory);
+
+ // display session info if there is an active p2p session
+ if (!mWifiDisplayStatus.getSessionInfo().getGroupId().isEmpty()) {
+ Preference p = new Preference(getActivity());
+ p.setTitle(R.string.wifi_display_session_info);
+ p.setSummary(mWifiDisplayStatus.getSessionInfo().toString());
+ mCertCategory.addPreference(p);
+
+ // show buttons for Pause/Resume when a WFD session is established
+ if (mWifiDisplayStatus.getSessionInfo().getSessionId() != 0) {
+ mCertCategory.addPreference(new Preference(getActivity()) {
+ @Override
+ public View getView(View convertView, ViewGroup parent) {
+ final View v;
+ if (convertView == null) {
+ LayoutInflater li = (LayoutInflater) getActivity().
+ getSystemService(Service.LAYOUT_INFLATER_SERVICE);
+ v = li.inflate(R.layout.two_buttons_panel, null);
+ } else {
+ v = convertView;
+ }
+
+ Button b = (Button)v.findViewById(R.id.left_button);
+ b.setText(R.string.wifi_display_pause);
+ b.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mDisplayManager.pauseWifiDisplay();
+ }
+ });
+
+ b = (Button)v.findViewById(R.id.right_button);
+ b.setText(R.string.wifi_display_resume);
+ b.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mDisplayManager.resumeWifiDisplay();
+ }
+ });
+
+ return v;
+ }
+ });
+ }
+ }
+
+ // switch for Listen Mode
+ CheckBoxPreference cbp = new CheckBoxPreference(getActivity()) {
+ @Override
+ protected void onClick() {
+ mListen = !mListen;
+ setListenMode(mListen);
+ setChecked(mListen);
+ }
+ };
+ cbp.setTitle(R.string.wifi_display_listen_mode);
+ cbp.setChecked(mListen);
+ mCertCategory.addPreference(cbp);
+
+ // switch for Autonomous GO
+ cbp = new CheckBoxPreference(getActivity()) {
+ @Override
+ protected void onClick() {
+ mAutoGO = !mAutoGO;
+ if (mAutoGO) {
+ startAutoGO();
+ } else {
+ stopAutoGO();
+ }
+ setChecked(mAutoGO);
+ }
+ };
+ cbp.setTitle(R.string.wifi_display_autonomous_go);
+ cbp.setChecked(mAutoGO);
+ mCertCategory.addPreference(cbp);
+
+ // Drop down list for choosing listen channel
+ ListPreference lp = new ListPreference(getActivity()) {
+ @Override
+ protected void onDialogClosed(boolean positiveResult) {
+ super.onDialogClosed(positiveResult);
+ if (positiveResult) {
+ mListenChannel = Integer.parseInt(getValue());
+ setSummary("%1$s");
+ getActivity().invalidateOptionsMenu();
+ setWifiP2pChannels(mListenChannel, mOperatingChannel);
+ }
+ }
+ };
+ String[] lcEntries = { "Auto", "1", "6", "11" };
+ String[] lcValues = { "0", "1", "6", "11" };
+ lp.setTitle(R.string.wifi_display_listen_channel);
+ lp.setEntries(lcEntries);
+ lp.setEntryValues(lcValues);
+ lp.setValue("" + mListenChannel);
+ lp.setSummary("%1$s");
+ mCertCategory.addPreference(lp);
+
+ // Drop down list for choosing operating channel
+ lp = new ListPreference(getActivity()) {
+ @Override
+ protected void onDialogClosed(boolean positiveResult) {
+ super.onDialogClosed(positiveResult);
+ if (positiveResult) {
+ mOperatingChannel = Integer.parseInt(getValue());
+ setSummary("%1$s");
+ getActivity().invalidateOptionsMenu();
+ setWifiP2pChannels(mListenChannel, mOperatingChannel);
+ }
+ }
+ };
+ String[] ocEntries = { "Auto", "1", "6", "11", "36" };
+ String[] ocValues = { "0", "1", "6", "11", "36" };
+ lp.setTitle(R.string.wifi_display_operating_channel);
+ lp.setEntries(ocEntries);
+ lp.setEntryValues(ocValues);
+ lp.setValue("" + mOperatingChannel);
+ lp.setSummary("%1$s");
+ mCertCategory.addPreference(lp);
+ }
+
+ private void startAutoGO() {
+ if (DEBUG) {
+ Slog.d(TAG, "Starting Autonomous GO...");
+ }
+ mWifiP2pManager.createGroup(mWifiP2pChannel, new ActionListener() {
+ @Override
+ public void onSuccess() {
+ if (DEBUG) {
+ Slog.d(TAG, "Successfully started AutoGO.");
+ }
+ }
+
+ @Override
+ public void onFailure(int reason) {
+ Slog.e(TAG, "Failed to start AutoGO with reason " + reason + ".");
+ }
+ });
+ }
+
+ private void stopAutoGO() {
+ if (DEBUG) {
+ Slog.d(TAG, "Stopping Autonomous GO...");
+ }
+ mWifiP2pManager.removeGroup(mWifiP2pChannel, new ActionListener() {
+ @Override
+ public void onSuccess() {
+ if (DEBUG) {
+ Slog.d(TAG, "Successfully stopped AutoGO.");
+ }
+ }
+
+ @Override
+ public void onFailure(int reason) {
+ Slog.e(TAG, "Failed to stop AutoGO with reason " + reason + ".");
+ }
+ });
+ }
+
+ private void setListenMode(final boolean enable) {
+ if (DEBUG) {
+ Slog.d(TAG, "Setting listen mode to: " + enable);
+ }
+ mWifiP2pManager.listen(mWifiP2pChannel, enable, new ActionListener() {
+ @Override
+ public void onSuccess() {
+ if (DEBUG) {
+ Slog.d(TAG, "Successfully " + (enable ? "entered" : "exited")
+ +" listen mode.");
+ }
+ }
+
+ @Override
+ public void onFailure(int reason) {
+ Slog.e(TAG, "Failed to " + (enable ? "entered" : "exited")
+ +" listen mode with reason " + reason + ".");
+ }
+ });
+ }
+
+ private void setWifiP2pChannels(final int lc, final int oc) {
+ if (DEBUG) {
+ Slog.d(TAG, "Setting wifi p2p channel: lc=" + lc + ", oc=" + oc);
+ }
+ mWifiP2pManager.setWifiP2pChannels(mWifiP2pChannel,
+ lc, oc, new ActionListener() {
+ @Override
+ public void onSuccess() {
+ if (DEBUG) {
+ Slog.d(TAG, "Successfully set wifi p2p channels.");
+ }
+ }
+
+ @Override
+ public void onFailure(int reason) {
+ Slog.e(TAG, "Failed to set wifi p2p channels with reason " + reason + ".");
+ }
+ });
+ }
+
private Preference createWifiDisplayPreference(final WifiDisplay d) {
WifiDisplayPreference p = new WifiDisplayPreference(getActivity(), d);
if (d.equals(mWifiDisplayStatus.getActiveDisplay())) {