summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author maheshkkv <maheshkkv@google.com> 2024-12-04 10:37:05 -0800
committer maheshkkv <maheshkkv@google.com> 2024-12-04 10:47:51 -0800
commit381c696e9194ee945babde01b9a15c6b78058201 (patch)
tree593548b1919ceae060df0fad32ea6f17e94b2e7d
parent72eb5dfd388f6fde027f7969ed08d370281540b7 (diff)
Move APIs to check USD support to WifiManager
The current method for checking USD publisher/subscriber support relies on the UsdManager API, which assumes the USD service is always active. However, on devices with limited memory where USD functionality might not be essential, the USD service can be disabled. To address this, it's proposed to relocate the USD support check APIs to the WiFiManager. This change would allow for USD support verification even when the USD service isn't running. This approach provides greater flexibility and efficiency for platforms where USD services might be optional. Flag: android.net.wifi.flags.usd Bug: 340878198 Test: atest FrameworksWifiApiTest Change-Id: I073c1ba8ea8098c50b805d5a3ac9175fadef6ab8
-rw-r--r--framework/api/system-current.txt4
-rw-r--r--framework/java/android/net/wifi/IWifiManager.aidl2
-rw-r--r--framework/java/android/net/wifi/WifiManager.java46
-rw-r--r--framework/java/android/net/wifi/usd/IUsdManager.aidl2
-rw-r--r--framework/java/android/net/wifi/usd/UsdManager.java38
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java32
-rw-r--r--service/java/com/android/server/wifi/usd/UsdServiceImpl.java26
7 files changed, 82 insertions, 68 deletions
diff --git a/framework/api/system-current.txt b/framework/api/system-current.txt
index fd4ab0f291..b9947ff77d 100644
--- a/framework/api/system-current.txt
+++ b/framework/api/system-current.txt
@@ -817,6 +817,8 @@ package android.net.wifi {
method public boolean isPortableHotspotSupported();
method public boolean isStaConcurrencyForRestrictedConnectionsSupported();
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public boolean isThirdPartyAppEnablingWifiConfirmationDialogEnabled();
+ method @FlaggedApi("android.net.wifi.flags.usd") @RequiresPermission(android.Manifest.permission.MANAGE_WIFI_NETWORK_SELECTION) public boolean isUsdPublisherSupported();
+ method @FlaggedApi("android.net.wifi.flags.usd") @RequiresPermission(android.Manifest.permission.MANAGE_WIFI_NETWORK_SELECTION) public boolean isUsdSubscriberSupported();
method public boolean isVerboseLoggingEnabled();
method @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public boolean isWifiApEnabled();
method public boolean isWifiScannerSupported();
@@ -1976,9 +1978,7 @@ package android.net.wifi.usd {
@FlaggedApi("android.net.wifi.flags.usd") public class UsdManager {
method @Nullable @RequiresPermission(android.Manifest.permission.MANAGE_WIFI_NETWORK_SELECTION) public android.net.wifi.usd.Characteristics getCharacteristics();
method @RequiresPermission(android.Manifest.permission.MANAGE_WIFI_NETWORK_SELECTION) public boolean isPublisherAvailable();
- method @RequiresPermission(android.Manifest.permission.MANAGE_WIFI_NETWORK_SELECTION) public boolean isPublisherSupported();
method @RequiresPermission(android.Manifest.permission.MANAGE_WIFI_NETWORK_SELECTION) public boolean isSubscriberAvailable();
- method @RequiresPermission(android.Manifest.permission.MANAGE_WIFI_NETWORK_SELECTION) public boolean isSubscriberSupported();
method @RequiresPermission(android.Manifest.permission.MANAGE_WIFI_NETWORK_SELECTION) public void publish(@NonNull android.net.wifi.usd.PublishConfig, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.usd.PublishSessionCallback);
method @RequiresPermission(android.Manifest.permission.MANAGE_WIFI_NETWORK_SELECTION) public void registerAvailabilityCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.usd.UsdManager.AvailabilityCallback);
method @RequiresPermission(android.Manifest.permission.MANAGE_WIFI_NETWORK_SELECTION) public void subscribe(@NonNull android.net.wifi.usd.SubscribeConfig, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.usd.SubscribeSessionCallback);
diff --git a/framework/java/android/net/wifi/IWifiManager.aidl b/framework/java/android/net/wifi/IWifiManager.aidl
index 18576c894e..2382f94382 100644
--- a/framework/java/android/net/wifi/IWifiManager.aidl
+++ b/framework/java/android/net/wifi/IWifiManager.aidl
@@ -555,4 +555,6 @@ interface IWifiManager {
void storeCapturedData(int triggerType, boolean isFullCapture, long triggerStartTimeMillis,
long triggerStopTimeMillis, in IIntegerListener listener);
+ boolean isUsdSubscriberSupported();
+ boolean isUsdPublisherSupported();
}
diff --git a/framework/java/android/net/wifi/WifiManager.java b/framework/java/android/net/wifi/WifiManager.java
index ce7a3f0807..c1e6646eeb 100644
--- a/framework/java/android/net/wifi/WifiManager.java
+++ b/framework/java/android/net/wifi/WifiManager.java
@@ -13241,4 +13241,50 @@ public class WifiManager {
throw e.rethrowFromSystemServer();
}
}
+
+ /**
+ * Return whether Unsynchronized Service Discovery (USD) subscriber is supported or not.
+ * @hide
+ */
+ @android.annotation.RequiresApi(Build.VERSION_CODES.BAKLAVA)
+ @SystemApi
+ @FlaggedApi(android.net.wifi.flags.Flags.FLAG_USD)
+ @RequiresPermission(MANAGE_WIFI_NETWORK_SELECTION)
+ public boolean isUsdSubscriberSupported() {
+ if (!Environment.isSdkAtLeastB()) {
+ throw new UnsupportedOperationException();
+ }
+ try {
+ return mService.isUsdSubscriberSupported();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Return whether Unsynchronized Service Discovery (USD) publisher is supported or not.
+ * <p>
+ * The USD publisher support is controlled by an overlay config_wifiUsdPublisherSupported.
+ * By default, the feature will be disabled because the publisher operation impacts other
+ * concurrency operation such as Station. The USD publisher switches channels and dwells a
+ * longer time (500 milliseconds to 1 second) on non-home channel which disrupts other
+ * concurrency operation.
+ *
+ * @return true if publisher feature is supported, otherwise false.
+ * @hide
+ */
+ @android.annotation.RequiresApi(Build.VERSION_CODES.BAKLAVA)
+ @SystemApi
+ @FlaggedApi(android.net.wifi.flags.Flags.FLAG_USD)
+ @RequiresPermission(MANAGE_WIFI_NETWORK_SELECTION)
+ public boolean isUsdPublisherSupported() {
+ if (!Environment.isSdkAtLeastB()) {
+ throw new UnsupportedOperationException();
+ }
+ try {
+ return mService.isUsdPublisherSupported();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
}
diff --git a/framework/java/android/net/wifi/usd/IUsdManager.aidl b/framework/java/android/net/wifi/usd/IUsdManager.aidl
index f591639b0e..030b240002 100644
--- a/framework/java/android/net/wifi/usd/IUsdManager.aidl
+++ b/framework/java/android/net/wifi/usd/IUsdManager.aidl
@@ -30,8 +30,6 @@ import android.net.wifi.usd.SubscribeConfig;
* {@hide}
*/
interface IUsdManager {
- boolean isSubscriberSupported();
- boolean isPublisherSupported();
boolean isSubscriberAvailable();
boolean isPublisherAvailable();
void registerAvailabilityCallback(IAvailabilityCallback callback);
diff --git a/framework/java/android/net/wifi/usd/UsdManager.java b/framework/java/android/net/wifi/usd/UsdManager.java
index fa762f2d2f..98601ee5c8 100644
--- a/framework/java/android/net/wifi/usd/UsdManager.java
+++ b/framework/java/android/net/wifi/usd/UsdManager.java
@@ -122,44 +122,6 @@ public class UsdManager {
}
/**
- * Return whether subscriber is supported or not.
- */
- @RequiresPermission(MANAGE_WIFI_NETWORK_SELECTION)
- public boolean isSubscriberSupported() {
- if (!Environment.isSdkAtLeastB()) {
- throw new UnsupportedOperationException();
- }
- try {
- return mService.isSubscriberSupported();
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
- * Return whether publish is supported or not.
- * <p>
- * The publisher support is controlled by an overlay config_wifiUsdPublisherSupported.
- * By default, the feature will be disabled because the publisher operation impacts other
- * concurrency operation such as Station. The USD publisher switches channels and dwells a
- * longer time (500 milliseconds to 1 second) on non-home channel which disrupts other
- * concurrency operation.
- *
- * @return true if publisher feature is supported, otherwise false.
- */
- @RequiresPermission(MANAGE_WIFI_NETWORK_SELECTION)
- public boolean isPublisherSupported() {
- if (!Environment.isSdkAtLeastB()) {
- throw new UnsupportedOperationException();
- }
- try {
- return mService.isPublisherSupported();
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
* Checks if the subscriber feature is currently available or not. Due to concurrent operations
* such as Station, SoftAP, Wi-Fi Aware, Wi-Fi Direct ..etc. the subscriber functionality
* may not be available.
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 7b3c7c75e6..385beb6f28 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -9163,4 +9163,36 @@ public class WifiServiceImpl extends IWifiManager.Stub {
() -> mActiveModeWarden.getPrimaryClientModeManager().blockNetwork(option),
"disallowCurrentSuggestedNetwork");
}
+ /**
+ * See {@link WifiManager#isUsdSubscriberSupported()}
+ */
+ @Override
+ public boolean isUsdSubscriberSupported() {
+ if (!Environment.isSdkAtLeastB()) {
+ throw new UnsupportedOperationException("SDK level too old");
+ }
+ int uid = getMockableCallingUid();
+ if (!mWifiPermissionsUtil.checkManageWifiNetworkSelectionPermission(uid)) {
+ throw new SecurityException("App not allowed to use USD (uid = " + uid + ")");
+ }
+ // USDSubscriber is not supported.
+ return false;
+ }
+
+ /**
+ * See {@link WifiManager#isUsdPublisherSupported()}
+ */
+ @Override
+ public boolean isUsdPublisherSupported() {
+ if (!Environment.isSdkAtLeastB()) {
+ throw new UnsupportedOperationException("SDK level too old");
+ }
+ int uid = getMockableCallingUid();
+ if (!mWifiPermissionsUtil.checkManageWifiNetworkSelectionPermission(uid)) {
+ throw new SecurityException("App not allowed to use USD (uid = " + uid + ")");
+ }
+ // USDPublisher is not supported.
+ return false;
+ }
+
}
diff --git a/service/java/com/android/server/wifi/usd/UsdServiceImpl.java b/service/java/com/android/server/wifi/usd/UsdServiceImpl.java
index 5b4ad7b95d..f1528c9032 100644
--- a/service/java/com/android/server/wifi/usd/UsdServiceImpl.java
+++ b/service/java/com/android/server/wifi/usd/UsdServiceImpl.java
@@ -86,32 +86,6 @@ public class UsdServiceImpl extends IUsdManager.Stub {
}
/**
- * See {@link UsdManager#isSubscriberSupported()}
- */
- @Override
- public boolean isSubscriberSupported() {
- int uid = getMockableCallingUid();
- if (!mWifiPermissionsUtil.checkManageWifiNetworkSelectionPermission(uid)) {
- throw new SecurityException("App not allowed to use USD (uid = " + uid + ")");
- }
- // Subscriber is not supported.
- return false;
- }
-
- /**
- * See {@link UsdManager#isPublisherSupported()}
- */
- @Override
- public boolean isPublisherSupported() {
- int uid = getMockableCallingUid();
- if (!mWifiPermissionsUtil.checkManageWifiNetworkSelectionPermission(uid)) {
- throw new SecurityException("App not allowed to use USD (uid = " + uid + ")");
- }
- // Publisher is not supported.
- return false;
- }
-
- /**
* See {@link UsdManager#isSubscriberAvailable()}
*/
@Override