make verbose logging a wifimanager hidden API
Change-Id: I092b7f507ad4dfdab16658929f02584a1fc22ba4
This commit is contained in:
@@ -3151,6 +3151,8 @@
|
|||||||
|
|
||||||
<!-- Setting Checkbox title whether to show options for wireless display certification -->
|
<!-- Setting Checkbox title whether to show options for wireless display certification -->
|
||||||
<string name="wifi_display_certification">Wireless display certification</string>
|
<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 -->
|
<!-- setting Checkbox summary whether to show options for wireless display certification -->
|
||||||
<string name="wifi_display_certification_summary">Show options for wireless display certification</string>
|
<string name="wifi_display_certification_summary">Show options for wireless display certification</string>
|
||||||
<!-- Setting Checkbox title whether to allow mock locations -->
|
<!-- Setting Checkbox title whether to allow mock locations -->
|
||||||
|
@@ -105,6 +105,11 @@
|
|||||||
android:key="wifi_display_certification"
|
android:key="wifi_display_certification"
|
||||||
android:title="@string/wifi_display_certification"
|
android:title="@string/wifi_display_certification"
|
||||||
android:summary="@string/wifi_display_certification_summary"/>
|
android:summary="@string/wifi_display_certification_summary"/>
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="wifi_verbose_logging"
|
||||||
|
android:title="@string/wifi_verbose_logging" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:key="debug_input_category"
|
<PreferenceCategory android:key="debug_input_category"
|
||||||
|
@@ -34,6 +34,7 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.hardware.usb.IUsbManager;
|
import android.hardware.usb.IUsbManager;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.os.Build;
|
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_DEBUGGING_CATEGORY_KEY = "debug_debugging_category";
|
||||||
private static final String DEBUG_APPLICATIONS_CATEGORY_KEY = "debug_applications_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_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";
|
private static final String OPENGL_TRACES_KEY = "enable_opengl_traces";
|
||||||
|
|
||||||
@@ -163,6 +165,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
|
|||||||
private IBackupManager mBackupManager;
|
private IBackupManager mBackupManager;
|
||||||
private DevicePolicyManager mDpm;
|
private DevicePolicyManager mDpm;
|
||||||
private UserManager mUm;
|
private UserManager mUm;
|
||||||
|
private WifiManager mWifiManager;
|
||||||
|
|
||||||
private SwitchBar mSwitchBar;
|
private SwitchBar mSwitchBar;
|
||||||
private Switch mEnabledSwitch;
|
private Switch mEnabledSwitch;
|
||||||
@@ -185,6 +188,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
|
|||||||
private CheckBoxPreference mWaitForDebugger;
|
private CheckBoxPreference mWaitForDebugger;
|
||||||
private CheckBoxPreference mVerifyAppsOverUsb;
|
private CheckBoxPreference mVerifyAppsOverUsb;
|
||||||
private CheckBoxPreference mWifiDisplayCertification;
|
private CheckBoxPreference mWifiDisplayCertification;
|
||||||
|
private CheckBoxPreference mWifiVerboseLogging;
|
||||||
|
|
||||||
private CheckBoxPreference mStrictMode;
|
private CheckBoxPreference mStrictMode;
|
||||||
private CheckBoxPreference mPointerLocation;
|
private CheckBoxPreference mPointerLocation;
|
||||||
@@ -244,6 +248,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
|
|||||||
mDpm = (DevicePolicyManager)getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
|
mDpm = (DevicePolicyManager)getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
mUm = (UserManager) getSystemService(Context.USER_SERVICE);
|
mUm = (UserManager) getSystemService(Context.USER_SERVICE);
|
||||||
|
|
||||||
|
mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
||||||
|
|
||||||
if (android.os.Process.myUserHandle().getIdentifier() != UserHandle.USER_OWNER
|
if (android.os.Process.myUserHandle().getIdentifier() != UserHandle.USER_OWNER
|
||||||
|| mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
|
|| mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
|
||||||
mUnavailable = true;
|
mUnavailable = true;
|
||||||
@@ -313,6 +319,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
|
|||||||
mForceRtlLayout = findAndInitCheckboxPref(FORCE_RTL_LAYOUT_KEY);
|
mForceRtlLayout = findAndInitCheckboxPref(FORCE_RTL_LAYOUT_KEY);
|
||||||
mDebugHwOverdraw = addListPreference(DEBUG_HW_OVERDRAW_KEY);
|
mDebugHwOverdraw = addListPreference(DEBUG_HW_OVERDRAW_KEY);
|
||||||
mWifiDisplayCertification = findAndInitCheckboxPref(WIFI_DISPLAY_CERTIFICATION_KEY);
|
mWifiDisplayCertification = findAndInitCheckboxPref(WIFI_DISPLAY_CERTIFICATION_KEY);
|
||||||
|
mWifiVerboseLogging = findAndInitCheckboxPref(WIFI_VERBOSE_LOGGING_KEY);
|
||||||
mWindowAnimationScale = addListPreference(WINDOW_ANIMATION_SCALE_KEY);
|
mWindowAnimationScale = addListPreference(WINDOW_ANIMATION_SCALE_KEY);
|
||||||
mTransitionAnimationScale = addListPreference(TRANSITION_ANIMATION_SCALE_KEY);
|
mTransitionAnimationScale = addListPreference(TRANSITION_ANIMATION_SCALE_KEY);
|
||||||
mAnimatorDurationScale = addListPreference(ANIMATOR_DURATION_SCALE_KEY);
|
mAnimatorDurationScale = addListPreference(ANIMATOR_DURATION_SCALE_KEY);
|
||||||
@@ -517,6 +524,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
|
|||||||
updateBugreportOptions();
|
updateBugreportOptions();
|
||||||
updateForceRtlOptions();
|
updateForceRtlOptions();
|
||||||
updateWifiDisplayCertificationOptions();
|
updateWifiDisplayCertificationOptions();
|
||||||
|
updateWifiVerboseLoggingOptions();
|
||||||
updateSimulateColorSpace();
|
updateSimulateColorSpace();
|
||||||
updateUseNuplayerOptions();
|
updateUseNuplayerOptions();
|
||||||
}
|
}
|
||||||
@@ -1023,6 +1031,15 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
|
|||||||
mWifiDisplayCertification.isChecked() ? 1 : 0);
|
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() {
|
private void updateLowPowerModeOptions() {
|
||||||
updateCheckBox(mLowPowerMode, Settings.Global.getInt(getActivity().getContentResolver(),
|
updateCheckBox(mLowPowerMode, Settings.Global.getInt(getActivity().getContentResolver(),
|
||||||
Settings.Global.LOW_POWER_MODE, 0) != 0);
|
Settings.Global.LOW_POWER_MODE, 0) != 0);
|
||||||
@@ -1339,6 +1356,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
|
|||||||
writeForceRtlOptions();
|
writeForceRtlOptions();
|
||||||
} else if (preference == mWifiDisplayCertification) {
|
} else if (preference == mWifiDisplayCertification) {
|
||||||
writeWifiDisplayCertificationOptions();
|
writeWifiDisplayCertificationOptions();
|
||||||
|
} else if (preference == mWifiVerboseLogging) {
|
||||||
|
writeWifiVerboseLoggingOptions();
|
||||||
} else if (preference == mUseNuplayer) {
|
} else if (preference == mUseNuplayer) {
|
||||||
writeUseNuplayerOptions();
|
writeUseNuplayerOptions();
|
||||||
} else {
|
} else {
|
||||||
|
@@ -69,6 +69,8 @@ class AccessPoint extends Preference {
|
|||||||
/* package */ScanResult mScanResult;
|
/* package */ScanResult mScanResult;
|
||||||
|
|
||||||
private int mRssi = Integer.MAX_VALUE;
|
private int mRssi = Integer.MAX_VALUE;
|
||||||
|
private long mSeen = 0;
|
||||||
|
|
||||||
private WifiInfo mInfo;
|
private WifiInfo mInfo;
|
||||||
private DetailedState mState;
|
private DetailedState mState;
|
||||||
|
|
||||||
@@ -262,6 +264,9 @@ class AccessPoint extends Preference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean update(ScanResult result) {
|
boolean update(ScanResult result) {
|
||||||
|
if (result.seen > mSeen) {
|
||||||
|
mSeen = result.seen;
|
||||||
|
}
|
||||||
if (ssid.equals(result.SSID) && security == getSecurity(result)) {
|
if (ssid.equals(result.SSID) && security == getSecurity(result)) {
|
||||||
if (WifiManager.compareSignalLevel(result.level, mRssi) > 0) {
|
if (WifiManager.compareSignalLevel(result.level, mRssi) > 0) {
|
||||||
int oldLevel = getLevel();
|
int oldLevel = getLevel();
|
||||||
@@ -333,29 +338,57 @@ class AccessPoint extends Preference {
|
|||||||
return "\"" + string + "\"";
|
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() */
|
/** Updates the title and summary; may indirectly call notifyChanged() */
|
||||||
private void refresh() {
|
private void refresh() {
|
||||||
setTitle(ssid);
|
setTitle(ssid);
|
||||||
|
StringBuilder summary = new StringBuilder();
|
||||||
|
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
if (mConfig != null && mConfig.status == WifiConfiguration.Status.DISABLED) {
|
if (mConfig != null && (mConfig.status == WifiConfiguration.Status.DISABLED
|
||||||
switch (mConfig.disableReason) {
|
|| mConfig.autoJoinStatus != WifiConfiguration.AUTO_JOIN_ENABLED)) {
|
||||||
case WifiConfiguration.DISABLED_AUTH_FAILURE:
|
if (mConfig.autoJoinStatus != WifiConfiguration.AUTO_JOIN_ENABLED) {
|
||||||
setSummary(context.getString(R.string.wifi_disabled_password_failure));
|
summary.append(context.getString(R.string.wifi_disabled_password_failure));
|
||||||
break;
|
} else {
|
||||||
case WifiConfiguration.DISABLED_DHCP_FAILURE:
|
switch (mConfig.disableReason) {
|
||||||
case WifiConfiguration.DISABLED_DNS_FAILURE:
|
case WifiConfiguration.DISABLED_AUTH_FAILURE:
|
||||||
setSummary(context.getString(R.string.wifi_disabled_network_failure));
|
summary.append(context.getString(R.string.wifi_disabled_password_failure));
|
||||||
break;
|
break;
|
||||||
case WifiConfiguration.DISABLED_UNKNOWN_REASON:
|
case WifiConfiguration.DISABLED_DHCP_FAILURE:
|
||||||
setSummary(context.getString(R.string.wifi_disabled_generic));
|
case WifiConfiguration.DISABLED_DNS_FAILURE:
|
||||||
|
summary.append(context.getString(R.string.wifi_disabled_network_failure));
|
||||||
|
break;
|
||||||
|
case WifiConfiguration.DISABLED_UNKNOWN_REASON:
|
||||||
|
summary.append(context.getString(R.string.wifi_disabled_generic));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (mRssi == Integer.MAX_VALUE) { // Wifi out of range
|
} 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
|
} 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.
|
} else { // In range, not disabled.
|
||||||
StringBuilder summary = new StringBuilder();
|
|
||||||
if (mConfig != null) { // Is saved network
|
if (mConfig != null) { // Is saved network
|
||||||
summary.append(context.getString(R.string.wifi_remembered));
|
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));
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -712,6 +712,8 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
return super.onCreateDialog(dialogId);
|
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
|
* Shows the latest access points available with supplimental information like
|
||||||
* the strength of network and the security for it.
|
* the strength of network and the security for it.
|
||||||
@@ -726,6 +728,9 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
}
|
}
|
||||||
final int wifiState = mWifiManager.getWifiState();
|
final int wifiState = mWifiManager.getWifiState();
|
||||||
|
|
||||||
|
//check if verbose logging has been turned on or off
|
||||||
|
mVerboseLogging = mWifiManager.getVerboseLoggingLevel();
|
||||||
|
|
||||||
switch (wifiState) {
|
switch (wifiState) {
|
||||||
case WifiManager.WIFI_STATE_ENABLED:
|
case WifiManager.WIFI_STATE_ENABLED:
|
||||||
// AccessPoints are automatically sorted with TreeSet.
|
// AccessPoints are automatically sorted with TreeSet.
|
||||||
|
Reference in New Issue
Block a user