From 6118069b1dc4c487d02d3df5b883e756dc42b605 Mon Sep 17 00:00:00 2001 From: Irfan Sheriff Date: Wed, 18 Aug 2010 16:07:39 -0700 Subject: [PATCH] Fix WRITE_SECURE_SETTINGS permission issue The refactor with the new state machine had introduced a bug with writes to secure settings in public API for which apps might not have permission. Bug: 2895750 Change-Id: I7d236253201a47b836996859aa3de2806ad8a800 --- services/java/com/android/server/WifiService.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java index 064d47f639c83..59846b96d9b7d 100644 --- a/services/java/com/android/server/WifiService.java +++ b/services/java/com/android/server/WifiService.java @@ -405,7 +405,14 @@ public class WifiService extends IWifiManager.Stub { } mWifiStateMachine.setWifiEnabled(enable); + + /* + * Caller might not have WRITE_SECURE_SETTINGS, + * only CHANGE_WIFI_STATE is enforced + */ + long ident = Binder.clearCallingIdentity(); persistWifiEnabled(enable); + Binder.restoreCallingIdentity(ident); if (enable) { if (!mIsReceiverRegistered) { @@ -451,7 +458,13 @@ public class WifiService extends IWifiManager.Stub { wifiConfig.SSID = mContext.getString(R.string.wifi_tether_configure_ssid_default); wifiConfig.allowedKeyManagement.set(KeyMgmt.NONE); } + /* + * Caller might not have WRITE_SECURE_SETTINGS, + * only CHANGE_WIFI_STATE is enforced + */ + long ident = Binder.clearCallingIdentity(); setWifiApConfiguration(wifiConfig); + Binder.restoreCallingIdentity(ident); } mWifiStateMachine.setWifiApEnabled(wifiConfig, enabled);