diff options
Diffstat (limited to 'services/java/com/android/server')
-rw-r--r-- | services/java/com/android/server/NetworkManagementService.java | 16 | ||||
-rw-r--r-- | services/java/com/android/server/ThrottleService.java | 13 |
2 files changed, 22 insertions, 7 deletions
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java index 552bed4..cbbc7be 100644 --- a/services/java/com/android/server/NetworkManagementService.java +++ b/services/java/com/android/server/NetworkManagementService.java @@ -494,15 +494,23 @@ class NetworkManagementService extends INetworkManagementService.Stub { * argv8 - Max SCB */ String str = String.format("softap set " + wlanIface + " " + softapIface + - " \"%s\" %s %s", wifiConfig.SSID, + " %s %s %s", convertQuotedString(wifiConfig.SSID), wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? "wpa2-psk" : "open", - wifiConfig.preSharedKey); + convertQuotedString(wifiConfig.preSharedKey)); mConnector.doCommand(str); } mConnector.doCommand(String.format("softap startap")); } + private String convertQuotedString(String s) { + if (s == null) { + return s; + } + /* Replace \ with \\, then " with \" and add quotes at end */ + return '"' + s.replaceAll("\\\\","\\\\\\\\").replaceAll("\"","\\\\\"") + '"'; + } + public void stopAccessPoint() throws IllegalStateException { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService"); @@ -521,10 +529,10 @@ class NetworkManagementService extends INetworkManagementService.Stub { mConnector.doCommand(String.format("softap set " + wlanIface + " " + softapIface)); } else { String str = String.format("softap set " + wlanIface + " " + softapIface + - " \"%s\" %s %s", wifiConfig.SSID, + " %s %s %s", convertQuotedString(wifiConfig.SSID), wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? "wpa2-psk" : "open", - wifiConfig.preSharedKey); + convertQuotedString(wifiConfig.preSharedKey)); mConnector.doCommand(str); } } diff --git a/services/java/com/android/server/ThrottleService.java b/services/java/com/android/server/ThrottleService.java index 23c1adc..f0b2210 100644 --- a/services/java/com/android/server/ThrottleService.java +++ b/services/java/com/android/server/ThrottleService.java @@ -197,6 +197,8 @@ public class ThrottleService extends IThrottleManager.Stub { Settings.Secure.THROTTLE_NOTIFICATION_TYPE), false, this); resolver.registerContentObserver(Settings.Secure.getUriFor( Settings.Secure.THROTTLE_HELP_URI), false, this); + resolver.registerContentObserver(Settings.Secure.getUriFor( + Settings.Secure.THROTTLE_MAX_NTP_CACHE_AGE_SEC), false, this); } @Override @@ -432,10 +434,13 @@ public class ThrottleService extends IThrottleManager.Stub { mPolicyNotificationsAllowedMask = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.THROTTLE_NOTIFICATION_TYPE, defaultNotificationType); + mMaxNtpCacheAgeSec = Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.THROTTLE_MAX_NTP_CACHE_AGE_SEC, MAX_NTP_CACHE_AGE_SEC); + Slog.d(TAG, "onPolicyChanged testing=" + testing +", period=" + mPolicyPollPeriodSec + ", threshold=" + mPolicyThreshold + ", value=" + mPolicyThrottleValue + ", resetDay=" + mPolicyResetDay + ", noteType=" + - mPolicyNotificationsAllowedMask); + mPolicyNotificationsAllowedMask + ", maxNtpCacheAge=" + mMaxNtpCacheAgeSec); // force updates mThrottleIndex = THROTTLE_INDEX_UNINITIALIZED; @@ -715,8 +720,9 @@ public class ThrottleService extends IThrottleManager.Stub { getBestTime(); } - private static final int MAX_NTP_CACHE_AGE = 30 * 1000; + private static final int MAX_NTP_CACHE_AGE_SEC = 60 * 60 * 24; // 1 day private static final int MAX_NTP_FETCH_WAIT = 10 * 1000; + private int mMaxNtpCacheAgeSec = MAX_NTP_CACHE_AGE_SEC; private long cachedNtp; private long cachedNtpTimestamp; @@ -724,7 +730,7 @@ public class ThrottleService extends IThrottleManager.Stub { if (mNtpServer != null) { if (mNtpActive) { long ntpAge = SystemClock.elapsedRealtime() - cachedNtpTimestamp; - if (ntpAge < MAX_NTP_CACHE_AGE) { + if (ntpAge < mMaxNtpCacheAgeSec * 1000) { if (VDBG) Slog.v(TAG, "using cached time"); return cachedNtp + ntpAge; } @@ -1091,6 +1097,7 @@ public class ThrottleService extends IThrottleManager.Stub { " seconds."); pw.println("Polling every " + mPolicyPollPeriodSec + " seconds"); pw.println("Current Throttle Index is " + mThrottleIndex); + pw.println("Max NTP Cache Age is " + mMaxNtpCacheAgeSec); for (int i = 0; i < mRecorder.getPeriodCount(); i++) { pw.println(" Period[" + i + "] - read:" + mRecorder.getPeriodRx(i) + ", written:" + |