summaryrefslogtreecommitdiff
path: root/wifi/java
diff options
context:
space:
mode:
author Isaac Katzenelson <isaackatz@google.com> 2023-03-07 17:31:24 +0000
committer Isaac Katzenelson <isaack@android.com> 2023-03-08 19:31:18 +0000
commit6d035f93e2f2778158f91093930cd1e2f5b91aaf (patch)
tree0312892fe77291315490559c278a01d4794d5b10 /wifi/java
parent3fd4802dad7416a6f31bef9e5922b5753385ce13 (diff)
Added methods to check shared connectivity features availablility.
Added methods and flags to check what level of funcionality the service supports. Added flags to enable instant tether and nearby Wi-Fi. The flags will be enabled in an overlay file based on the level of UI support by the OEM. The service checks the flags and provides an API to allow the API's client to decide what level of functionality to provide. Also fixed the naming of flags. Bug: 271934662 Test: atest SharedConnectivityServiceTest Change-Id: Ifba6b73904862dfdc58741856e8b940ae6d6634b
Diffstat (limited to 'wifi/java')
-rw-r--r--wifi/java/src/android/net/wifi/sharedconnectivity/app/SharedConnectivityManager.java4
-rw-r--r--wifi/java/src/android/net/wifi/sharedconnectivity/service/SharedConnectivityService.java28
2 files changed, 30 insertions, 2 deletions
diff --git a/wifi/java/src/android/net/wifi/sharedconnectivity/app/SharedConnectivityManager.java b/wifi/java/src/android/net/wifi/sharedconnectivity/app/SharedConnectivityManager.java
index 604641520252..15fd817ba73b 100644
--- a/wifi/java/src/android/net/wifi/sharedconnectivity/app/SharedConnectivityManager.java
+++ b/wifi/java/src/android/net/wifi/sharedconnectivity/app/SharedConnectivityManager.java
@@ -161,9 +161,9 @@ public class SharedConnectivityManager {
Resources resources = context.getResources();
try {
String servicePackageName = resources.getString(
- R.string.shared_connectivity_service_package);
+ R.string.config_sharedConnectivityServicePackage);
String serviceIntentAction = resources.getString(
- R.string.shared_connectivity_service_intent_action);
+ R.string.config_sharedConnectivityServiceIntentAction);
return new SharedConnectivityManager(context, servicePackageName, serviceIntentAction);
} catch (Resources.NotFoundException e) {
Log.e(TAG, "To support shared connectivity service on this device, the service's"
diff --git a/wifi/java/src/android/net/wifi/sharedconnectivity/service/SharedConnectivityService.java b/wifi/java/src/android/net/wifi/sharedconnectivity/service/SharedConnectivityService.java
index c53da9c15d4d..57108e4aa227 100644
--- a/wifi/java/src/android/net/wifi/sharedconnectivity/service/SharedConnectivityService.java
+++ b/wifi/java/src/android/net/wifi/sharedconnectivity/service/SharedConnectivityService.java
@@ -25,6 +25,7 @@ import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.app.Service;
+import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.wifi.sharedconnectivity.app.HotspotNetwork;
@@ -40,8 +41,11 @@ import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.util.Log;
+import com.android.internal.R;
+
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
/**
@@ -382,6 +386,30 @@ public abstract class SharedConnectivityService extends Service {
}
/**
+ * System and settings UI support on the device for instant tether.
+ * @return True if the UI can display Instant Tether network data. False otherwise.
+ */
+ public static boolean areHotspotNetworksEnabledForService(@NonNull Context context) {
+ String servicePackage = context.getResources()
+ .getString(R.string.config_sharedConnectivityServicePackage);
+ return Objects.equals(context.getPackageName(), servicePackage)
+ && context.getResources()
+ .getBoolean(R.bool.config_hotspotNetworksEnabledForService);
+ }
+
+ /**
+ * System and settings UI support on the device for known networks.
+ * @return True if the UI can display known networks data. False otherwise.
+ */
+ public static boolean areKnownNetworksEnabledForService(@NonNull Context context) {
+ String servicePackage = context.getResources()
+ .getString(R.string.config_sharedConnectivityServicePackage);
+ return Objects.equals(context.getPackageName(), servicePackage)
+ && context.getResources()
+ .getBoolean(R.bool.config_knownNetworksEnabledForService);
+ }
+
+ /**
* Implementing application should implement this method.
*
* Implementation should initiate a connection to the Hotspot Network indicated.