diff options
| author | 2024-09-07 01:11:19 +0000 | |
|---|---|---|
| committer | 2024-09-07 01:11:19 +0000 | |
| commit | 952d16a946806b182c530b22717819453dd71908 (patch) | |
| tree | d1db223626c86e1aed1930d82f4f6dc51d4eb49b /wifi/java/src | |
| parent | 312fe7c40ceb513709f63434f637fe3db3619bbf (diff) | |
| parent | 6f4fcdf625b9dd9e5f71535094095f5a7b2efe80 (diff) | |
Merge "Merge 24Q3 to AOSP main" into main
Diffstat (limited to 'wifi/java/src')
| -rw-r--r--[-rwxr-xr-x] | wifi/java/src/android/net/wifi/SoftApConfToXmlMigrationUtil.java | 0 | ||||
| -rw-r--r-- | wifi/java/src/android/net/wifi/WifiBlobStore.java | 49 | ||||
| -rw-r--r-- | wifi/java/src/android/net/wifi/WifiKeystore.java | 70 | ||||
| -rw-r--r--[-rwxr-xr-x] | wifi/java/src/android/net/wifi/WifiMigration.java | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | wifi/java/src/android/net/wifi/WifiNetworkScoreCache.java | 0 | ||||
| -rw-r--r-- | wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java | 32 | ||||
| -rw-r--r-- | wifi/java/src/android/net/wifi/sharedconnectivity/app/NetworkProviderInfo.java | 5 |
7 files changed, 134 insertions, 22 deletions
diff --git a/wifi/java/src/android/net/wifi/SoftApConfToXmlMigrationUtil.java b/wifi/java/src/android/net/wifi/SoftApConfToXmlMigrationUtil.java index c5472ce34478..c5472ce34478 100755..100644 --- a/wifi/java/src/android/net/wifi/SoftApConfToXmlMigrationUtil.java +++ b/wifi/java/src/android/net/wifi/SoftApConfToXmlMigrationUtil.java diff --git a/wifi/java/src/android/net/wifi/WifiBlobStore.java b/wifi/java/src/android/net/wifi/WifiBlobStore.java new file mode 100644 index 000000000000..8737c7e91454 --- /dev/null +++ b/wifi/java/src/android/net/wifi/WifiBlobStore.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.net.wifi; + +import android.os.ServiceManager; +import android.security.legacykeystore.ILegacyKeystore; + +import com.android.internal.net.ConnectivityBlobStore; + +/** + * Database blob store for Wifi. + * @hide + */ +public class WifiBlobStore extends ConnectivityBlobStore { + private static final String DB_NAME = "WifiBlobStore.db"; + private static final String LEGACY_KEYSTORE_SERVICE_NAME = "android.security.legacykeystore"; + private static WifiBlobStore sInstance; + private WifiBlobStore() { + super(DB_NAME); + } + + /** Returns an instance of WifiBlobStore. */ + public static WifiBlobStore getInstance() { + if (sInstance == null) { + sInstance = new WifiBlobStore(); + } + return sInstance; + } + + /** Returns an interface to access the Legacy Keystore service. */ + public static ILegacyKeystore getLegacyKeystore() { + return ILegacyKeystore.Stub.asInterface( + ServiceManager.checkService(LEGACY_KEYSTORE_SERVICE_NAME)); + } +} diff --git a/wifi/java/src/android/net/wifi/WifiKeystore.java b/wifi/java/src/android/net/wifi/WifiKeystore.java index 1cda0326bf6c..2ba7468a8c9c 100644 --- a/wifi/java/src/android/net/wifi/WifiKeystore.java +++ b/wifi/java/src/android/net/wifi/WifiKeystore.java @@ -18,12 +18,16 @@ package android.net.wifi; import android.annotation.NonNull; import android.annotation.SuppressLint; import android.annotation.SystemApi; +import android.os.Binder; import android.os.Process; -import android.os.ServiceManager; import android.os.ServiceSpecificException; import android.security.legacykeystore.ILegacyKeystore; import android.util.Log; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + /** * This class allows the storage and retrieval of non-standard Wifi certificate blobs. * @hide @@ -32,12 +36,6 @@ import android.util.Log; @SuppressLint("UnflaggedApi") // Promoting from @SystemApi(MODULE_LIBRARIES) public final class WifiKeystore { private static final String TAG = "WifiKeystore"; - private static final String LEGACY_KEYSTORE_SERVICE_NAME = "android.security.legacykeystore"; - - private static ILegacyKeystore getService() { - return ILegacyKeystore.Stub.asInterface( - ServiceManager.checkService(LEGACY_KEYSTORE_SERVICE_NAME)); - } /** @hide */ WifiKeystore() { @@ -54,13 +52,18 @@ public final class WifiKeystore { @SystemApi @SuppressLint("UnflaggedApi") public static boolean put(@NonNull String alias, @NonNull byte[] blob) { + // ConnectivityBlobStore uses the calling uid as a key into the DB. + // Clear identity to ensure that callers from system apps and the Wifi framework + // are able to access the same values. + final long identity = Binder.clearCallingIdentity(); try { Log.i(TAG, "put blob. alias " + alias); - getService().put(alias, Process.WIFI_UID, blob); - return true; + return WifiBlobStore.getInstance().put(alias, blob); } catch (Exception e) { Log.e(TAG, "Failed to put blob.", e); return false; + } finally { + Binder.restoreCallingIdentity(identity); } } @@ -69,23 +72,31 @@ public final class WifiKeystore { * @param alias Name of the blob to retrieve. * @return The unstructured blob, that is the blob that was stored using * {@link android.net.wifi.WifiKeystore#put}. - * Returns null if no blob was found. + * Returns empty byte[] if no blob was found. * @hide */ @SystemApi @SuppressLint("UnflaggedApi") public static @NonNull byte[] get(@NonNull String alias) { + final long identity = Binder.clearCallingIdentity(); try { Log.i(TAG, "get blob. alias " + alias); - return getService().get(alias, Process.WIFI_UID); + byte[] blob = WifiBlobStore.getInstance().get(alias); + if (blob != null) { + return blob; + } + Log.i(TAG, "Searching for blob in Legacy Keystore"); + return WifiBlobStore.getLegacyKeystore().get(alias, Process.WIFI_UID); } catch (ServiceSpecificException e) { if (e.errorCode != ILegacyKeystore.ERROR_ENTRY_NOT_FOUND) { Log.e(TAG, "Failed to get blob.", e); } } catch (Exception e) { Log.e(TAG, "Failed to get blob.", e); + } finally { + Binder.restoreCallingIdentity(identity); } - return null; + return new byte[0]; } /** @@ -97,17 +108,27 @@ public final class WifiKeystore { @SystemApi @SuppressLint("UnflaggedApi") public static boolean remove(@NonNull String alias) { + boolean blobStoreSuccess = false; + boolean legacyKsSuccess = false; + final long identity = Binder.clearCallingIdentity(); try { - getService().remove(alias, Process.WIFI_UID); - return true; + Log.i(TAG, "remove blob. alias " + alias); + blobStoreSuccess = WifiBlobStore.getInstance().remove(alias); + // Legacy Keystore will throw an exception if the alias is not found. + WifiBlobStore.getLegacyKeystore().remove(alias, Process.WIFI_UID); + legacyKsSuccess = true; } catch (ServiceSpecificException e) { if (e.errorCode != ILegacyKeystore.ERROR_ENTRY_NOT_FOUND) { Log.e(TAG, "Failed to remove blob.", e); } } catch (Exception e) { Log.e(TAG, "Failed to remove blob.", e); + } finally { + Binder.restoreCallingIdentity(identity); } - return false; + Log.i(TAG, "Removal status: wifiBlobStore=" + blobStoreSuccess + + ", legacyKeystore=" + legacyKsSuccess); + return blobStoreSuccess || legacyKsSuccess; } /** @@ -119,14 +140,25 @@ public final class WifiKeystore { @SystemApi @SuppressLint("UnflaggedApi") public static @NonNull String[] list(@NonNull String prefix) { + final long identity = Binder.clearCallingIdentity(); try { - final String[] aliases = getService().list(prefix, Process.WIFI_UID); - for (int i = 0; i < aliases.length; ++i) { - aliases[i] = aliases[i].substring(prefix.length()); + // Aliases from WifiBlobStore will be pre-trimmed. + final String[] blobStoreAliases = WifiBlobStore.getInstance().list(prefix); + final String[] legacyAliases = + WifiBlobStore.getLegacyKeystore().list(prefix, Process.WIFI_UID); + for (int i = 0; i < legacyAliases.length; ++i) { + legacyAliases[i] = legacyAliases[i].substring(prefix.length()); } - return aliases; + // Deduplicate aliases before returning. + Set<String> uniqueAliases = new HashSet<>(); + uniqueAliases.addAll(Arrays.asList(blobStoreAliases)); + uniqueAliases.addAll(Arrays.asList(legacyAliases)); + String[] uniqueAliasArray = new String[uniqueAliases.size()]; + return uniqueAliases.toArray(uniqueAliasArray); } catch (Exception e) { Log.e(TAG, "Failed to list blobs.", e); + } finally { + Binder.restoreCallingIdentity(identity); } return new String[0]; } diff --git a/wifi/java/src/android/net/wifi/WifiMigration.java b/wifi/java/src/android/net/wifi/WifiMigration.java index 4fabc0b0babc..4fabc0b0babc 100755..100644 --- a/wifi/java/src/android/net/wifi/WifiMigration.java +++ b/wifi/java/src/android/net/wifi/WifiMigration.java diff --git a/wifi/java/src/android/net/wifi/WifiNetworkScoreCache.java b/wifi/java/src/android/net/wifi/WifiNetworkScoreCache.java index 39036580e2ef..39036580e2ef 100755..100644 --- a/wifi/java/src/android/net/wifi/WifiNetworkScoreCache.java +++ b/wifi/java/src/android/net/wifi/WifiNetworkScoreCache.java diff --git a/wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java b/wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java index 58638e8e1af4..2ba5705a120b 100644 --- a/wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java +++ b/wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java @@ -718,6 +718,9 @@ public class WifiNl80211Manager { } catch (RemoteException e1) { Log.e(TAG, "Failed to get IClientInterface due to remote exception"); return false; + } catch (NullPointerException e2) { + Log.e(TAG, "setupInterfaceForClientMode NullPointerException"); + return false; } if (clientInterface == null) { @@ -785,6 +788,9 @@ public class WifiNl80211Manager { } catch (RemoteException e1) { Log.e(TAG, "Failed to teardown client interface due to remote exception"); return false; + } catch (NullPointerException e2) { + Log.e(TAG, "tearDownClientInterface NullPointerException"); + return false; } if (!success) { Log.e(TAG, "Failed to teardown client interface"); @@ -816,6 +822,9 @@ public class WifiNl80211Manager { } catch (RemoteException e1) { Log.e(TAG, "Failed to get IApInterface due to remote exception"); return false; + } catch (NullPointerException e2) { + Log.e(TAG, "setupInterfaceForSoftApMode NullPointerException"); + return false; } if (apInterface == null) { @@ -854,6 +863,9 @@ public class WifiNl80211Manager { } catch (RemoteException e1) { Log.e(TAG, "Failed to teardown AP interface due to remote exception"); return false; + } catch (NullPointerException e2) { + Log.e(TAG, "tearDownSoftApInterface NullPointerException"); + return false; } if (!success) { Log.e(TAG, "Failed to teardown AP interface"); @@ -981,6 +993,16 @@ public class WifiNl80211Manager { * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)} * or {@link #setupInterfaceForSoftApMode(String)}. * + * <p> + * When an Access Point’s beacon or probe response includes a Multi-BSSID Element, the + * returned scan results should include separate scan result for each BSSID within the + * Multi-BSSID Information Element. This includes both transmitted and non-transmitted BSSIDs. + * Original Multi-BSSID Element will be included in the Information Elements attached to + * each of the scan results. + * Note: This is the expected behavior for devices supporting 11ax (WiFi-6) and above, and an + * optional requirement for devices running with older WiFi generations. + * </p> + * * @param ifaceName Name of the interface. * @param scanType The type of scan result to be returned, can be * {@link #SCAN_TYPE_SINGLE_SCAN} or {@link #SCAN_TYPE_PNO_SCAN}. @@ -1328,6 +1350,8 @@ public class WifiNl80211Manager { } } catch (RemoteException e1) { Log.e(TAG, "Failed to request getChannelsForBand due to remote exception"); + } catch (NullPointerException e2) { + Log.e(TAG, "getChannelsMhzForBand NullPointerException"); } if (result == null) { result = new int[0]; @@ -1352,7 +1376,8 @@ public class WifiNl80211Manager { */ @Nullable public DeviceWiphyCapabilities getDeviceWiphyCapabilities(@NonNull String ifaceName) { if (mWificond == null) { - Log.e(TAG, "getDeviceWiphyCapabilities: mWificond binder is null! Did wificond die?"); + Log.e(TAG, "getDeviceWiphyCapabilities: mWificond binder is null! " + + "Did wificond die?"); return null; } @@ -1360,6 +1385,9 @@ public class WifiNl80211Manager { return mWificond.getDeviceWiphyCapabilities(ifaceName); } catch (RemoteException e) { return null; + } catch (NullPointerException e2) { + Log.e(TAG, "getDeviceWiphyCapabilities NullPointerException"); + return null; } } @@ -1409,6 +1437,8 @@ public class WifiNl80211Manager { Log.i(TAG, "Receive country code change to " + newCountryCode); } catch (RemoteException re) { re.rethrowFromSystemServer(); + } catch (NullPointerException e) { + new RemoteException("Wificond service doesn't exist!").rethrowFromSystemServer(); } } diff --git a/wifi/java/src/android/net/wifi/sharedconnectivity/app/NetworkProviderInfo.java b/wifi/java/src/android/net/wifi/sharedconnectivity/app/NetworkProviderInfo.java index 3d5a0f7a239f..395f744ef043 100644 --- a/wifi/java/src/android/net/wifi/sharedconnectivity/app/NetworkProviderInfo.java +++ b/wifi/java/src/android/net/wifi/sharedconnectivity/app/NetworkProviderInfo.java @@ -21,6 +21,7 @@ import android.annotation.IntDef; import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.SystemApi; +import android.net.wifi.flags.Flags; import android.net.wifi.sharedconnectivity.service.SharedConnectivityService; import android.os.Bundle; import android.os.Parcel; @@ -170,7 +171,7 @@ public final class NetworkProviderInfo implements Parcelable { * @return Returns the Builder object. */ @NonNull - @FlaggedApi("com.android.wifi.flags.network_provider_battery_charging_status") + @FlaggedApi(Flags.FLAG_NETWORK_PROVIDER_BATTERY_CHARGING_STATUS) public Builder setBatteryCharging(boolean isBatteryCharging) { mIsBatteryCharging = isBatteryCharging; return this; @@ -285,7 +286,7 @@ public final class NetworkProviderInfo implements Parcelable { * * @return Returns true if the battery of the remote device is charging. */ - @FlaggedApi("com.android.wifi.flags.network_provider_battery_charging_status") + @FlaggedApi(Flags.FLAG_NETWORK_PROVIDER_BATTERY_CHARGING_STATUS) public boolean isBatteryCharging() { return mIsBatteryCharging; } |