summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-09-15 14:45:40 -0700
committerRoshan Pius <rpius@google.com>2017-09-26 13:17:08 -0700
commitb73e0a91dcf3fa04cf07c2d096fb20c229d6cd28 (patch)
tree05e26d7943715f2be4c99d348be83dce82a7f8c4 /service
parenta32e2000025fb2df125c3d14c2fa55ddecd4b790 (diff)
NetworkListStoreData: Set creatorUid for all networks on load
Some network configurations saved during N have the creatorUid set to -1. (Not sure what was the root cause in N which introduced this issue in saved networks) Ensure that we set |creatorUid| for such networks with invalid uid to SYSTEM_UID on loading. The networks with invalid creatorUid can anyway only be modified only by settings/sysui (because they possess NETWORK_SETTINGS permission). Bug: 65623732 Test: Unit tests Change-Id: Ib6f61b81e19877cdf0c42d29c9f5ae3869725517
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/NetworkListStoreData.java21
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java2
2 files changed, 21 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/NetworkListStoreData.java b/service/java/com/android/server/wifi/NetworkListStoreData.java
index 5ddfd4dfb..f287d4b98 100644
--- a/service/java/com/android/server/wifi/NetworkListStoreData.java
+++ b/service/java/com/android/server/wifi/NetworkListStoreData.java
@@ -16,10 +16,12 @@
package com.android.server.wifi;
+import android.content.Context;
import android.net.IpConfiguration;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiConfiguration.NetworkSelectionStatus;
import android.net.wifi.WifiEnterpriseConfig;
+import android.os.Process;
import android.util.Log;
import android.util.Pair;
@@ -52,6 +54,8 @@ public class NetworkListStoreData implements WifiConfigStore.StoreData {
private static final String XML_TAG_SECTION_HEADER_WIFI_ENTERPRISE_CONFIGURATION =
"WifiEnterpriseConfiguration";
+ private final Context mContext;
+
/**
* List of saved shared networks visible to all the users to be stored in the shared store file.
*/
@@ -62,7 +66,9 @@ public class NetworkListStoreData implements WifiConfigStore.StoreData {
*/
private List<WifiConfiguration> mUserConfigurations;
- NetworkListStoreData() {}
+ NetworkListStoreData(Context context) {
+ mContext = context;
+ }
@Override
public void serializeData(XmlSerializer out, boolean shared)
@@ -282,6 +288,19 @@ public class NetworkListStoreData implements WifiConfigStore.StoreData {
"Configuration key does not match. Retrieved: " + configKeyParsed
+ ", Calculated: " + configKeyCalculated);
}
+ // Set creatorUid/creatorName for networks which don't have it set to valid value.
+ String creatorName = mContext.getPackageManager().getNameForUid(configuration.creatorUid);
+ if (creatorName == null) {
+ Log.e(TAG, "Invalid creatorUid for saved network " + configuration.configKey()
+ + ", creatorUid=" + configuration.creatorUid);
+ configuration.creatorUid = Process.SYSTEM_UID;
+ configuration.creatorName = creatorName;
+ } else if (!creatorName.equals(configuration.creatorName)) {
+ Log.w(TAG, "Invalid creatorName for saved network " + configuration.configKey()
+ + ", creatorUid=" + configuration.creatorUid
+ + ", creatorName=" + configuration.creatorName);
+ configuration.creatorName = creatorName;
+ }
configuration.setNetworkSelectionStatus(status);
configuration.setIpConfiguration(ipConfiguration);
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index fc3af83e5..923983958 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -197,7 +197,7 @@ public class WifiInjector {
mWifiConfigManager = new WifiConfigManager(mContext, mClock,
UserManager.get(mContext), TelephonyManager.from(mContext),
mWifiKeyStore, mWifiConfigStore, mWifiPermissionsUtil,
- mWifiPermissionsWrapper, new NetworkListStoreData(),
+ mWifiPermissionsWrapper, new NetworkListStoreData(mContext),
new DeletedEphemeralSsidsStoreData());
mWifiMetrics.setWifiConfigManager(mWifiConfigManager);
mWifiConnectivityHelper = new WifiConnectivityHelper(mWifiNative);