Merge "make verbose logging a wifimanager hidden API"

This commit is contained in:
vandwalle
2014-05-22 03:36:48 +00:00
committed by Android (Google) Code Review
5 changed files with 84 additions and 15 deletions

View File

@@ -3151,6 +3151,8 @@
<!-- Setting Checkbox title whether to show options for wireless display certification -->
<string name="wifi_display_certification">Wireless display certification</string>
<!-- Setting Checkbox title whether to show options for WiFi Verbose Logging -->
<string name="wifi_verbose_logging">Enable WiFi Verbose Logging</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 -->

View File

@@ -105,6 +105,11 @@
android:key="wifi_display_certification"
android:title="@string/wifi_display_certification"
android:summary="@string/wifi_display_certification_summary"/>
<CheckBoxPreference
android:key="wifi_verbose_logging"
android:title="@string/wifi_verbose_logging" />
</PreferenceCategory>
<PreferenceCategory android:key="debug_input_category"

View File

@@ -34,6 +34,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.hardware.usb.IUsbManager;
import android.net.wifi.WifiManager;
import android.os.AsyncTask;
import android.os.BatteryManager;
import android.os.Build;
@@ -138,6 +139,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
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 WIFI_VERBOSE_LOGGING_KEY = "wifi_verbose_logging";
private static final String OPENGL_TRACES_KEY = "enable_opengl_traces";
@@ -163,6 +165,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
private IBackupManager mBackupManager;
private DevicePolicyManager mDpm;
private UserManager mUm;
private WifiManager mWifiManager;
private SwitchBar mSwitchBar;
private Switch mEnabledSwitch;
@@ -185,6 +188,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
private CheckBoxPreference mWaitForDebugger;
private CheckBoxPreference mVerifyAppsOverUsb;
private CheckBoxPreference mWifiDisplayCertification;
private CheckBoxPreference mWifiVerboseLogging;
private CheckBoxPreference mStrictMode;
private CheckBoxPreference mPointerLocation;
@@ -244,6 +248,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
mDpm = (DevicePolicyManager)getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
mUm = (UserManager) getSystemService(Context.USER_SERVICE);
mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
if (android.os.Process.myUserHandle().getIdentifier() != UserHandle.USER_OWNER
|| mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
mUnavailable = true;
@@ -313,6 +319,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
mForceRtlLayout = findAndInitCheckboxPref(FORCE_RTL_LAYOUT_KEY);
mDebugHwOverdraw = addListPreference(DEBUG_HW_OVERDRAW_KEY);
mWifiDisplayCertification = findAndInitCheckboxPref(WIFI_DISPLAY_CERTIFICATION_KEY);
mWifiVerboseLogging = findAndInitCheckboxPref(WIFI_VERBOSE_LOGGING_KEY);
mWindowAnimationScale = addListPreference(WINDOW_ANIMATION_SCALE_KEY);
mTransitionAnimationScale = addListPreference(TRANSITION_ANIMATION_SCALE_KEY);
mAnimatorDurationScale = addListPreference(ANIMATOR_DURATION_SCALE_KEY);
@@ -517,6 +524,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
updateBugreportOptions();
updateForceRtlOptions();
updateWifiDisplayCertificationOptions();
updateWifiVerboseLoggingOptions();
updateSimulateColorSpace();
updateUseNuplayerOptions();
}
@@ -1023,6 +1031,15 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
mWifiDisplayCertification.isChecked() ? 1 : 0);
}
private void updateWifiVerboseLoggingOptions() {
boolean enabled = mWifiManager.getVerboseLoggingLevel() > 0;
updateCheckBox(mWifiVerboseLogging, enabled);
}
private void writeWifiVerboseLoggingOptions() {
mWifiManager.enableVerboseLogging(mWifiVerboseLogging.isChecked() ? 1 : 0);
}
private void updateLowPowerModeOptions() {
updateCheckBox(mLowPowerMode, Settings.Global.getInt(getActivity().getContentResolver(),
Settings.Global.LOW_POWER_MODE, 0) != 0);
@@ -1339,6 +1356,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
writeForceRtlOptions();
} else if (preference == mWifiDisplayCertification) {
writeWifiDisplayCertificationOptions();
} else if (preference == mWifiVerboseLogging) {
writeWifiVerboseLoggingOptions();
} else if (preference == mUseNuplayer) {
writeUseNuplayerOptions();
} else {

View File

@@ -69,6 +69,8 @@ class AccessPoint extends Preference {
/* package */ScanResult mScanResult;
private int mRssi = Integer.MAX_VALUE;
private long mSeen = 0;
private WifiInfo mInfo;
private DetailedState mState;
@@ -262,6 +264,9 @@ class AccessPoint extends Preference {
}
boolean update(ScanResult result) {
if (result.seen > mSeen) {
mSeen = result.seen;
}
if (ssid.equals(result.SSID) && security == getSecurity(result)) {
if (WifiManager.compareSignalLevel(result.level, mRssi) > 0) {
int oldLevel = getLevel();
@@ -333,29 +338,57 @@ class AccessPoint extends Preference {
return "\"" + string + "\"";
}
/** visibility status of the WifiConfiguration
* @return RSSI and update indicator
* TODO: indicate both 2.4 and 5GHz RSSI as well as number of results
* ["rssi 5Ghz", "num results on 5GHz" / "rssi 5Ghz", "num results on 5GHz"]
* For instance [-40,5/-30,2]
*/
private String getVisibilityStatus() {
String visibility ;
long now = System.currentTimeMillis();
long age = (now - mSeen);
if (age < 1000000) {
//show age in seconds, in the form xx
visibility = Long.toString((age / 1000) % 1000);
} else {
//not seen for more than 1000 seconds
visibility = "!";
}
if (mRssi != Integer.MAX_VALUE) {
visibility = visibility + ", " + Integer.toString(mRssi);
}
return visibility;
}
/** Updates the title and summary; may indirectly call notifyChanged() */
private void refresh() {
setTitle(ssid);
StringBuilder summary = new StringBuilder();
Context context = getContext();
if (mConfig != null && mConfig.status == WifiConfiguration.Status.DISABLED) {
if (mConfig != null && (mConfig.status == WifiConfiguration.Status.DISABLED
|| mConfig.autoJoinStatus != WifiConfiguration.AUTO_JOIN_ENABLED)) {
if (mConfig.autoJoinStatus != WifiConfiguration.AUTO_JOIN_ENABLED) {
summary.append(context.getString(R.string.wifi_disabled_password_failure));
} else {
switch (mConfig.disableReason) {
case WifiConfiguration.DISABLED_AUTH_FAILURE:
setSummary(context.getString(R.string.wifi_disabled_password_failure));
summary.append(context.getString(R.string.wifi_disabled_password_failure));
break;
case WifiConfiguration.DISABLED_DHCP_FAILURE:
case WifiConfiguration.DISABLED_DNS_FAILURE:
setSummary(context.getString(R.string.wifi_disabled_network_failure));
summary.append(context.getString(R.string.wifi_disabled_network_failure));
break;
case WifiConfiguration.DISABLED_UNKNOWN_REASON:
setSummary(context.getString(R.string.wifi_disabled_generic));
summary.append(context.getString(R.string.wifi_disabled_generic));
}
}
} else if (mRssi == Integer.MAX_VALUE) { // Wifi out of range
setSummary(context.getString(R.string.wifi_not_in_range));
summary.append(context.getString(R.string.wifi_not_in_range));
} else if (mState != null) { // This is the active connection
setSummary(Summary.get(context, mState));
summary.append(Summary.get(context, mState));
} else { // In range, not disabled.
StringBuilder summary = new StringBuilder();
if (mConfig != null) { // Is saved network
summary.append(context.getString(R.string.wifi_remembered));
}
@@ -377,8 +410,13 @@ class AccessPoint extends Preference {
summary.append(context.getString(R.string.wifi_wps_available_second_item));
}
}
setSummary(summary.toString());
}
if (WifiSettings.mVerboseLogging > 0) {
//add RSSI/band information for this config, what was seen up to 6 seconds ago
//verbose WiFi Logging is only turned on thru developers settings
summary.append(" " + getVisibilityStatus());
}
setSummary(summary.toString());
}
/**

View File

@@ -712,6 +712,8 @@ public class WifiSettings extends RestrictedSettingsFragment
return super.onCreateDialog(dialogId);
}
/** verbose logging flag is set only thru developer debugging options */
public static int mVerboseLogging = 0;
/**
* Shows the latest access points available with supplimental information like
* the strength of network and the security for it.
@@ -726,6 +728,9 @@ public class WifiSettings extends RestrictedSettingsFragment
}
final int wifiState = mWifiManager.getWifiState();
//check if verbose logging has been turned on or off
mVerboseLogging = mWifiManager.getVerboseLoggingLevel();
switch (wifiState) {
case WifiManager.WIFI_STATE_ENABLED:
// AccessPoints are automatically sorted with TreeSet.