summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Su <dysu@google.com>2020-03-30 17:46:40 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-30 17:46:40 +0000
commit6bad6344acf1fd89917f71e30c46a8fdc4ada53c (patch)
tree0c20772e612561efa50f172674616543e8f20f27
parentefd9c0c53135988db2e0a25f9525b4f1f46eacb2 (diff)
parent334cf751f60cc67b565d33fb617f40b4aee12af8 (diff)
Merge changes from topics "wifi-sign-apk-aosp", "wifi-sign-apk-in-apex" into rvc-dev
* changes: Resolve OsuLogin dynamically Resolve ServiceWifiResources package name dynamically ServiceWifiResources: Generate AOSP keys and sign APK Rename wifi-service-resources to ServiceWifiResources
-rw-r--r--service/Android.bp16
-rw-r--r--service/AndroidManifest_Resources.xml7
-rw-r--r--service/apex/Android.bp2
-rw-r--r--service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java7
-rw-r--r--service/java/com/android/server/wifi/ConnectionFailureNotificationBuilder.java7
-rw-r--r--service/java/com/android/server/wifi/EapFailureNotifier.java12
-rw-r--r--service/java/com/android/server/wifi/SimRequiredNotifier.java7
-rw-r--r--service/java/com/android/server/wifi/SoftApManager.java5
-rw-r--r--service/java/com/android/server/wifi/SoftApNotifier.java7
-rw-r--r--service/java/com/android/server/wifi/WakeupNotificationFactory.java7
-rw-r--r--service/java/com/android/server/wifi/WifiContext.java51
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java4
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java8
-rw-r--r--service/java/com/android/server/wifi/WifiService.java13
-rw-r--r--service/java/com/android/server/wifi/WrongPasswordNotifier.java6
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointProvisioner.java47
-rw-r--r--service/java/com/android/server/wifi/util/Environment.java16
-rw-r--r--service/res/values/config.xml3
-rw-r--r--service/res/values/overlayable.xml1
-rw-r--r--service/resources-certs/com.android.wifi.resources.pk8bin0 -> 2376 bytes
-rw-r--r--service/resources-certs/com.android.wifi.resources.x509.pem35
-rw-r--r--service/resources-certs/key.pem52
-rw-r--r--tests/wifitests/Android.bp2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java10
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java3
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SoftApNotifierTest.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiInjectorTest.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java3
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProvisionerTest.java14
30 files changed, 266 insertions, 97 deletions
diff --git a/service/Android.bp b/service/Android.bp
index 928f9c554..0fdc7fe95 100644
--- a/service/Android.bp
+++ b/service/Android.bp
@@ -58,7 +58,7 @@ java_library {
"jsr305",
"framework-annotations-lib",
// load the resources from the resources APK.
- "wifi-service-resources",
+ "ServiceWifiResources",
// need pre-jarjar symbols so that wifi-service can reference the original class names at
// compile time
"framework-wifi-pre-jarjar",
@@ -143,11 +143,9 @@ genrule {
}
// APK to hold all the wifi overlayable resources.
-// TODO: This should be signed by a wifi specific certificate.
// ============================================================
android_app {
- // TODO: Rename to service-wifi-resources? What about b/151678653?
- name: "wifi-service-resources",
+ name: "ServiceWifiResources",
defaults: ["wifi-service-common"],
resource_dirs: [
"res",
@@ -156,6 +154,16 @@ android_app {
sdk_version: "system_current",
export_package_resources: true,
manifest: "AndroidManifest_Resources.xml",
+ apex_available: [
+ "com.android.wifi",
+ "test_com.android.wifi",
+ ],
+ certificate: ":com.android.wifi.resources.certificate",
+}
+
+android_app_certificate {
+ name: "com.android.wifi.resources.certificate",
+ certificate: "resources-certs/com.android.wifi.resources"
}
// Prebuilt for the wifi.rc file.
diff --git a/service/AndroidManifest_Resources.xml b/service/AndroidManifest_Resources.xml
index 458572153..a6b2a580e 100644
--- a/service/AndroidManifest_Resources.xml
+++ b/service/AndroidManifest_Resources.xml
@@ -26,5 +26,12 @@
android:defaultToDeviceProtectedStorage="true"
android:directBootAware="true"
android:usesCleartextTraffic="true">
+ <!-- This is only used to identify this app by resolving the action.
+ The activity is never actually triggered. -->
+ <activity android:name="android.app.Activity" android:exported="true" android:enabled="true">
+ <intent-filter>
+ <action android:name="com.android.server.wifi.intent.action.SERVICE_WIFI_RESOURCES_APK" />
+ </intent-filter>
+ </activity>
</application>
</manifest>
diff --git a/service/apex/Android.bp b/service/apex/Android.bp
index 65cd6d573..e23d9cc8f 100644
--- a/service/apex/Android.bp
+++ b/service/apex/Android.bp
@@ -30,8 +30,8 @@ apex_defaults {
key: "com.android.wifi.key",
certificate: ":com.android.wifi.certificate",
apps: [
- "wifi-service-resources",
"OsuLogin",
+ "ServiceWifiResources",
],
}
diff --git a/service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java b/service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java
index f4bd95f30..4f7b4e820 100644
--- a/service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java
+++ b/service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java
@@ -18,7 +18,6 @@ package com.android.server.wifi;
import android.app.Notification;
import android.app.PendingIntent;
-import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Icon;
import android.net.wifi.ScanResult;
@@ -51,12 +50,12 @@ public class ConnectToNetworkNotificationBuilder {
public static final String AVAILABLE_NETWORK_NOTIFIER_TAG =
"com.android.server.wifi.ConnectToNetworkNotification.AVAILABLE_NETWORK_NOTIFIER_TAG";
- private Context mContext;
+ private WifiContext mContext;
private WifiInjector mWifiInjector;
private FrameworkFacade mFrameworkFacade;
public ConnectToNetworkNotificationBuilder(
- Context context,
+ WifiContext context,
WifiInjector wifiInjector,
FrameworkFacade framework) {
mContext = context;
@@ -158,7 +157,7 @@ public class ConnectToNetworkNotificationBuilder {
CharSequence title, CharSequence content, String extraData) {
return mFrameworkFacade.makeNotificationBuilder(mContext,
WifiService.NOTIFICATION_NETWORK_AVAILABLE)
- .setSmallIcon(Icon.createWithResource(WifiContext.WIFI_OVERLAY_APK_PKG_NAME,
+ .setSmallIcon(Icon.createWithResource(mContext.getWifiOverlayApkPkgName(),
com.android.wifi.resources.R.drawable.stat_notify_wifi_in_range))
.setTicker(title)
.setContentTitle(title)
diff --git a/service/java/com/android/server/wifi/ConnectionFailureNotificationBuilder.java b/service/java/com/android/server/wifi/ConnectionFailureNotificationBuilder.java
index a16dac214..6f0a487cf 100644
--- a/service/java/com/android/server/wifi/ConnectionFailureNotificationBuilder.java
+++ b/service/java/com/android/server/wifi/ConnectionFailureNotificationBuilder.java
@@ -21,7 +21,6 @@ import android.app.AlertDialog;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
-import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Icon;
@@ -44,14 +43,14 @@ public class ConnectionFailureNotificationBuilder {
public static final String RANDOMIZATION_SETTINGS_NETWORK_SSID =
"com.android.server.wifi.RANDOMIZATION_SETTINGS_NETWORK_SSID";
- private Context mContext;
+ private WifiContext mContext;
private String mPackageName;
private FrameworkFacade mFrameworkFacade;
private WifiConnectivityManager mWifiConnectivityManager;
private NotificationManager mNotificationManager;
private Handler mHandler;
- public ConnectionFailureNotificationBuilder(Context context, String packageName,
+ public ConnectionFailureNotificationBuilder(WifiContext context, String packageName,
FrameworkFacade framework) {
mContext = context;
mPackageName = packageName;
@@ -81,7 +80,7 @@ public class ConnectionFailureNotificationBuilder {
return mFrameworkFacade.makeNotificationBuilder(
mContext, WifiService.NOTIFICATION_NETWORK_ALERTS)
- .setSmallIcon(Icon.createWithResource(WifiContext.WIFI_OVERLAY_APK_PKG_NAME,
+ .setSmallIcon(Icon.createWithResource(mContext.getWifiOverlayApkPkgName(),
com.android.wifi.resources.R.drawable.stat_notify_wifi_in_range))
.setTicker(title)
.setContentTitle(title)
diff --git a/service/java/com/android/server/wifi/EapFailureNotifier.java b/service/java/com/android/server/wifi/EapFailureNotifier.java
index 1613bbf0e..3cc80b982 100644
--- a/service/java/com/android/server/wifi/EapFailureNotifier.java
+++ b/service/java/com/android/server/wifi/EapFailureNotifier.java
@@ -42,7 +42,7 @@ public class EapFailureNotifier {
private static final String ERROR_MESSAGE_OVERLAY_PREFIX = "wifi_eap_error_message_code_";
private static final long CANCEL_TIMEOUT_MILLISECONDS = 5 * 60 * 1000;
- private final Context mContext;
+ private final WifiContext mContext;
private final NotificationManager mNotificationManager;
private final FrameworkFacade mFrameworkFacade;
private final TelephonyUtil mTelephonyUtil;
@@ -51,7 +51,7 @@ public class EapFailureNotifier {
public static final int NOTIFICATION_ID = SystemMessage.NOTE_WIFI_EAP_FAILURE;
private String mCurrentShownSsid;
- public EapFailureNotifier(Context context, FrameworkFacade frameworkFacade,
+ public EapFailureNotifier(WifiContext context, FrameworkFacade frameworkFacade,
TelephonyUtil telephonyUtil) {
mContext = context;
mFrameworkFacade = frameworkFacade;
@@ -77,7 +77,7 @@ public class EapFailureNotifier {
mTelephonyUtil.getBestMatchSubscriptionId(config));
if (res == null) return;
int resourceId = res.getIdentifier(ERROR_MESSAGE_OVERLAY_PREFIX + errorCode,
- "string", WifiContext.WIFI_OVERLAY_APK_PKG_NAME);
+ "string", mContext.getWifiOverlayApkPkgName());
if (resourceId == 0) return;
String errorMessage = res.getString(resourceId, config.SSID);
@@ -96,7 +96,7 @@ public class EapFailureNotifier {
WifiService.NOTIFICATION_NETWORK_ALERTS)
.setAutoCancel(true)
.setTimeoutAfter(CANCEL_TIMEOUT_MILLISECONDS)
- .setSmallIcon(Icon.createWithResource(WifiContext.WIFI_OVERLAY_APK_PKG_NAME,
+ .setSmallIcon(Icon.createWithResource(mContext.getWifiOverlayApkPkgName(),
com.android.wifi.resources.R.drawable.stat_notify_wifi_in_range))
.setContentTitle(mContext.getString(
com.android.wifi.resources.R.string.wifi_available_title_failed_to_connect))
@@ -114,11 +114,11 @@ public class EapFailureNotifier {
* Returns the resources from the given context for the MCC/MNC
* associated with the subscription.
*/
- private Resources getResourcesForSubId(Context context, int subId) {
+ private Resources getResourcesForSubId(WifiContext context, int subId) {
Context resourceContext = null;
try {
resourceContext = context.createPackageContext(
- WifiContext.WIFI_OVERLAY_APK_PKG_NAME, 0);
+ context.getWifiOverlayApkPkgName(), 0);
} catch (PackageManager.NameNotFoundException ex) {
return null;
}
diff --git a/service/java/com/android/server/wifi/SimRequiredNotifier.java b/service/java/com/android/server/wifi/SimRequiredNotifier.java
index 19e369dab..8e3d22d6a 100644
--- a/service/java/com/android/server/wifi/SimRequiredNotifier.java
+++ b/service/java/com/android/server/wifi/SimRequiredNotifier.java
@@ -19,7 +19,6 @@ package com.android.server.wifi;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
-import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Icon;
import android.net.wifi.WifiConfiguration;
@@ -33,11 +32,11 @@ import com.android.wifi.resources.R;
*/
public class SimRequiredNotifier {
- private final Context mContext;
+ private final WifiContext mContext;
private final FrameworkFacade mFrameworkFacade;
private final NotificationManager mNotificationManager;
- public SimRequiredNotifier(Context context, FrameworkFacade framework) {
+ public SimRequiredNotifier(WifiContext context, FrameworkFacade framework) {
mContext = context;
mFrameworkFacade = framework;
mNotificationManager =
@@ -84,7 +83,7 @@ public class SimRequiredNotifier {
.setTicker(title)
.setContentText(message)
.setStyle(new Notification.BigTextStyle().bigText(message))
- .setSmallIcon(Icon.createWithResource(WifiContext.WIFI_OVERLAY_APK_PKG_NAME,
+ .setSmallIcon(Icon.createWithResource(mContext.getWifiOverlayApkPkgName(),
R.drawable.stat_notify_wifi_in_range))
.setContentIntent(launchWirelessSettings())
.build();
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java
index 42a228e82..44bbc73c4 100644
--- a/service/java/com/android/server/wifi/SoftApManager.java
+++ b/service/java/com/android/server/wifi/SoftApManager.java
@@ -22,7 +22,6 @@ import static com.android.server.wifi.util.ApConfigUtil.ERROR_UNSUPPORTED_CONFIG
import static com.android.server.wifi.util.ApConfigUtil.SUCCESS;
import android.annotation.NonNull;
-import android.content.Context;
import android.content.Intent;
import android.net.MacAddress;
import android.net.wifi.ScanResult;
@@ -74,7 +73,7 @@ public class SoftApManager implements ActiveModeManager {
public static final String SOFT_AP_SEND_MESSAGE_TIMEOUT_TAG = TAG
+ " Soft AP Send Message Timeout";
- private final Context mContext;
+ private final WifiContext mContext;
private final FrameworkFacade mFrameworkFacade;
private final WifiNative mWifiNative;
@@ -158,7 +157,7 @@ public class SoftApManager implements ActiveModeManager {
}
};
- public SoftApManager(@NonNull Context context,
+ public SoftApManager(@NonNull WifiContext context,
@NonNull Looper looper,
@NonNull FrameworkFacade framework,
@NonNull WifiNative wifiNative,
diff --git a/service/java/com/android/server/wifi/SoftApNotifier.java b/service/java/com/android/server/wifi/SoftApNotifier.java
index 741cab82e..45114a549 100644
--- a/service/java/com/android/server/wifi/SoftApNotifier.java
+++ b/service/java/com/android/server/wifi/SoftApNotifier.java
@@ -19,7 +19,6 @@ package com.android.server.wifi;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
-import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Icon;
@@ -41,11 +40,11 @@ public class SoftApNotifier {
public static final int NOTIFICATION_ID_SOFTAP_AUTO_DISABLED =
SystemMessage.NOTE_SOFTAP_AUTO_DISABLED;
- private final Context mContext;
+ private final WifiContext mContext;
private final FrameworkFacade mFrameworkFacade;
private final NotificationManager mNotificationManager;
- public SoftApNotifier(Context context, FrameworkFacade framework) {
+ public SoftApNotifier(WifiContext context, FrameworkFacade framework) {
mContext = context;
mFrameworkFacade = framework;
mNotificationManager =
@@ -76,7 +75,7 @@ public class SoftApNotifier {
return mFrameworkFacade.makeNotificationBuilder(mContext,
WifiService.NOTIFICATION_NETWORK_STATUS)
- .setSmallIcon(Icon.createWithResource(WifiContext.WIFI_OVERLAY_APK_PKG_NAME,
+ .setSmallIcon(Icon.createWithResource(mContext.getWifiOverlayApkPkgName(),
R.drawable.ic_wifi_settings))
.setContentTitle(title)
.setContentText(contentSummary)
diff --git a/service/java/com/android/server/wifi/WakeupNotificationFactory.java b/service/java/com/android/server/wifi/WakeupNotificationFactory.java
index 11713baa7..9eb69b70c 100644
--- a/service/java/com/android/server/wifi/WakeupNotificationFactory.java
+++ b/service/java/com/android/server/wifi/WakeupNotificationFactory.java
@@ -18,7 +18,6 @@ package com.android.server.wifi;
import android.app.Notification;
import android.app.PendingIntent;
-import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Icon;
@@ -41,11 +40,11 @@ public class WakeupNotificationFactory {
/** Notification channel ID for onboarding messages. */
public static final int ONBOARD_ID = SystemMessage.NOTE_WIFI_WAKE_ONBOARD;
- private final Context mContext;
+ private final WifiContext mContext;
private final WifiInjector mWifiInjector;
private final FrameworkFacade mFrameworkFacade;
- WakeupNotificationFactory(Context context, WifiInjector wifiInjector,
+ WakeupNotificationFactory(WifiContext context, WifiInjector wifiInjector,
FrameworkFacade frameworkFacade) {
mContext = context;
mWifiInjector = wifiInjector;
@@ -68,7 +67,7 @@ public class WakeupNotificationFactory {
return mFrameworkFacade.makeNotificationBuilder(mContext,
WifiService.NOTIFICATION_NETWORK_STATUS)
- .setSmallIcon(Icon.createWithResource(WifiContext.WIFI_OVERLAY_APK_PKG_NAME,
+ .setSmallIcon(Icon.createWithResource(mContext.getWifiOverlayApkPkgName(),
R.drawable.ic_wifi_settings))
.setTicker(title)
.setContentTitle(title)
diff --git a/service/java/com/android/server/wifi/WifiContext.java b/service/java/com/android/server/wifi/WifiContext.java
index 2040d737f..b360a8e3c 100644
--- a/service/java/com/android/server/wifi/WifiContext.java
+++ b/service/java/com/android/server/wifi/WifiContext.java
@@ -19,18 +19,29 @@ package com.android.server.wifi;
import android.annotation.NonNull;
import android.content.Context;
import android.content.ContextWrapper;
+import android.content.Intent;
import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.util.Log;
+import com.android.server.wifi.util.Environment;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
/**
* Wrapper for context to override getResources method. Resources for wifi mainline jar needs to be
* fetched from the resources APK.
*/
public class WifiContext extends ContextWrapper {
private static final String TAG = "WifiContext";
- public static final String WIFI_OVERLAY_APK_PKG_NAME = "com.android.wifi.resources";
+ /** Intent action that is used to identify ServiceWifiResources.apk */
+ private static final String ACTION_RESOURCES_APK =
+ "com.android.server.wifi.intent.action.SERVICE_WIFI_RESOURCES_APK";
+
+ private String mWifiOverlayApkPkgName;
// Cached resources from the resources APK.
private AssetManager mWifiAssetsFromApk;
@@ -41,9 +52,45 @@ public class WifiContext extends ContextWrapper {
super(contextBase);
}
+ /** Get the package name of ServiceWifiResources.apk */
+ public String getWifiOverlayApkPkgName() {
+ if (mWifiOverlayApkPkgName != null) {
+ return mWifiOverlayApkPkgName;
+ }
+
+ List<ResolveInfo> resolveInfos = getPackageManager().queryIntentActivities(
+ new Intent(ACTION_RESOURCES_APK),
+ PackageManager.MATCH_SYSTEM_ONLY);
+
+ // remove apps that don't live in the Wifi apex
+ resolveInfos.removeIf(info ->
+ !Environment.isAppInWifiApex(info.activityInfo.applicationInfo));
+
+ if (resolveInfos.isEmpty()) {
+ // Resource APK not loaded yet, print a stack trace to see where this is called from
+ Log.e(TAG, "Attempted to fetch resources before Wifi Resources APK is loaded!",
+ new IllegalStateException());
+ return null;
+ }
+
+ if (resolveInfos.size() > 1) {
+ // multiple apps found, log a warning, but continue
+ Log.w(TAG, "Found > 1 APK that can resolve Wifi Resources APK intent: "
+ + resolveInfos.stream()
+ .map(info -> info.activityInfo.applicationInfo.packageName)
+ .collect(Collectors.joining(", ")));
+ }
+
+ // Assume the first ResolveInfo is the one we're looking for
+ ResolveInfo info = resolveInfos.get(0);
+ mWifiOverlayApkPkgName = info.activityInfo.applicationInfo.packageName;
+ Log.i(TAG, "Found Wifi Resources APK at: " + mWifiOverlayApkPkgName);
+ return mWifiOverlayApkPkgName;
+ }
+
private Context getResourcesApkContext() {
try {
- return createPackageContext(WIFI_OVERLAY_APK_PKG_NAME, 0);
+ return createPackageContext(getWifiOverlayApkPkgName(), 0);
} catch (PackageManager.NameNotFoundException e) {
Log.wtf(TAG, "Failed to load resources", e);
}
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index a6aa03434..6daca9066 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -83,7 +83,7 @@ public class WifiInjector {
static WifiInjector sWifiInjector = null;
- private final Context mContext;
+ private final WifiContext mContext;
private final BatteryStatsManager mBatteryStats;
private final FrameworkFacade mFrameworkFacade;
private final DeviceConfigFacade mDeviceConfigFacade;
@@ -169,7 +169,7 @@ public class WifiInjector {
private final SettingsMigrationDataHolder mSettingsMigrationDataHolder;
private final LruConnectionTracker mLruConnectionTracker;
- public WifiInjector(Context context) {
+ public WifiInjector(WifiContext context) {
if (context == null) {
throw new IllegalStateException(
"WifiInjector should not be initialized with a null Context.");
diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
index a252d8bf0..19c9da156 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
@@ -126,7 +126,7 @@ public class WifiNetworkSuggestionsManager {
*/
private static final int NUMBER_OF_HIDDEN_NETWORK_FOR_ONE_SCAN = 100;
- private final Context mContext;
+ private final WifiContext mContext;
private final Resources mResources;
private final Handler mHandler;
private final AppOpsManager mAppOps;
@@ -568,7 +568,7 @@ public class WifiNetworkSuggestionsManager {
}
};
- public WifiNetworkSuggestionsManager(Context context, Handler handler,
+ public WifiNetworkSuggestionsManager(WifiContext context, Handler handler,
WifiInjector wifiInjector, WifiPermissionsUtil wifiPermissionsUtil,
WifiConfigManager wifiConfigManager, WifiConfigStore wifiConfigStore,
WifiMetrics wifiMetrics, TelephonyUtil telephonyUtil,
@@ -1317,7 +1317,7 @@ public class WifiNetworkSuggestionsManager {
CharSequence appName = getAppName(packageName, uid);
Notification notification = mFrameworkFacade.makeNotificationBuilder(
mContext, WifiService.NOTIFICATION_NETWORK_STATUS)
- .setSmallIcon(Icon.createWithResource(WifiContext.WIFI_OVERLAY_APK_PKG_NAME,
+ .setSmallIcon(Icon.createWithResource(mContext.getWifiOverlayApkPkgName(),
com.android.wifi.resources.R.drawable.stat_notify_wifi_in_range))
.setTicker(mResources.getString(R.string.wifi_suggestion_title))
.setContentTitle(mResources.getString(R.string.wifi_suggestion_title))
@@ -1359,7 +1359,7 @@ public class WifiNetworkSuggestionsManager {
Notification notification = mFrameworkFacade.makeNotificationBuilder(
mContext, WifiService.NOTIFICATION_NETWORK_STATUS)
- .setSmallIcon(Icon.createWithResource(WifiContext.WIFI_OVERLAY_APK_PKG_NAME,
+ .setSmallIcon(Icon.createWithResource(mContext.getWifiOverlayApkPkgName(),
com.android.wifi.resources.R.drawable.stat_notify_wifi_in_range))
.setTicker(mResources.getString(
R.string.wifi_suggestion_imsi_privacy_title, carrierName))
diff --git a/service/java/com/android/server/wifi/WifiService.java b/service/java/com/android/server/wifi/WifiService.java
index 552afd49f..0197246c8 100644
--- a/service/java/com/android/server/wifi/WifiService.java
+++ b/service/java/com/android/server/wifi/WifiService.java
@@ -39,12 +39,15 @@ public final class WifiService extends SystemService {
public static final String NOTIFICATION_NETWORK_ALERTS = "NETWORK_ALERTS";
public static final String NOTIFICATION_NETWORK_AVAILABLE = "NETWORK_AVAILABLE";
- final WifiServiceImpl mImpl;
+ private final WifiServiceImpl mImpl;
+ private final WifiContext mWifiContext;
public WifiService(Context contextBase) {
- super(new WifiContext(contextBase));
- mImpl = new WifiServiceImpl(getContext(), new WifiInjector(getContext()),
- new WifiAsyncChannel(TAG));
+ super(contextBase);
+ mWifiContext = new WifiContext(contextBase);
+ WifiInjector injector = new WifiInjector(mWifiContext);
+ WifiAsyncChannel channel = new WifiAsyncChannel(TAG);
+ mImpl = new WifiServiceImpl(mWifiContext, injector, channel);
}
@Override
@@ -56,7 +59,7 @@ public final class WifiService extends SystemService {
@Override
public void onBootPhase(int phase) {
if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
- createNotificationChannels(getContext());
+ createNotificationChannels(mWifiContext);
mImpl.checkAndStartWifi();
} else if (phase == SystemService.PHASE_BOOT_COMPLETED) {
mImpl.handleBootCompleted();
diff --git a/service/java/com/android/server/wifi/WrongPasswordNotifier.java b/service/java/com/android/server/wifi/WrongPasswordNotifier.java
index d086ad5b7..9975f973a 100644
--- a/service/java/com/android/server/wifi/WrongPasswordNotifier.java
+++ b/service/java/com/android/server/wifi/WrongPasswordNotifier.java
@@ -42,11 +42,11 @@ public class WrongPasswordNotifier {
// Flag indicating if a wrong password error is detected for the current connection.
private boolean mWrongPasswordDetected;
- private final Context mContext;
+ private final WifiContext mContext;
private final NotificationManager mNotificationManager;
private final FrameworkFacade mFrameworkFacade;
- public WrongPasswordNotifier(Context context, FrameworkFacade frameworkFacade) {
+ public WrongPasswordNotifier(WifiContext context, FrameworkFacade frameworkFacade) {
mContext = context;
mFrameworkFacade = frameworkFacade;
mNotificationManager =
@@ -86,7 +86,7 @@ public class WrongPasswordNotifier {
.setAutoCancel(true)
.setTimeoutAfter(CANCEL_TIMEOUT_MILLISECONDS)
// TODO(zqiu): consider creating a new icon.
- .setSmallIcon(Icon.createWithResource(WifiContext.WIFI_OVERLAY_APK_PKG_NAME,
+ .setSmallIcon(Icon.createWithResource(mContext.getWifiOverlayApkPkgName(),
com.android.wifi.resources.R.drawable.stat_notify_wifi_in_range))
.setContentTitle(mContext.getString(
com.android.wifi.resources.R.string.wifi_available_title_failed_to_connect))
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointProvisioner.java b/service/java/com/android/server/wifi/hotspot2/PasspointProvisioner.java
index 1884536b5..ad8480ae4 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointProvisioner.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointProvisioner.java
@@ -20,6 +20,8 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.net.Network;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
@@ -53,7 +55,7 @@ import com.android.server.wifi.hotspot2.soap.UpdateResponseMessage;
import com.android.server.wifi.hotspot2.soap.command.BrowserUri;
import com.android.server.wifi.hotspot2.soap.command.PpsMoData;
import com.android.server.wifi.hotspot2.soap.command.SppCommand;
-import com.android.wifi.resources.R;
+import com.android.server.wifi.util.Environment;
import java.net.MalformedURLException;
import java.net.URL;
@@ -781,24 +783,43 @@ public class PasspointProvisioner {
}
Intent intent = new Intent(WifiManager.ACTION_PASSPOINT_LAUNCH_OSU_VIEW);
- intent.setPackage(mContext.getResources()
- .getString(R.string.config_wifiOsuLoginPackage));
intent.putExtra(WifiManager.EXTRA_OSU_NETWORK, mNetwork);
intent.putExtra(WifiManager.EXTRA_URL, mWebUrl);
+ intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setFlags(
- Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
-
- // Verify that the intent will resolve to an activity
- if (intent.resolveActivity(mContext.getPackageManager()) != null) {
- mContext.startActivityAsUser(intent, UserHandle.CURRENT);
- invokeProvisioningCallback(PROVISIONING_STATUS,
- ProvisioningCallback.OSU_STATUS_WAITING_FOR_REDIRECT_RESPONSE);
- changeState(STATE_WAITING_FOR_REDIRECT_RESPONSE);
- } else {
+ List<ResolveInfo> resolveInfos = mContext.getPackageManager()
+ .queryIntentActivities(
+ intent,
+ PackageManager.MATCH_DEFAULT_ONLY | PackageManager.MATCH_SYSTEM_ONLY);
+ if (resolveInfos == null || resolveInfos.isEmpty()) {
Log.e(TAG, "can't resolve the activity for the intent");
resetStateMachineForFailure(ProvisioningCallback.OSU_FAILURE_NO_OSU_ACTIVITY_FOUND);
+ return;
+ }
+
+ if (resolveInfos.size() > 1) {
+ if (mVerboseLoggingEnabled) {
+ Log.i(TAG, "Multiple OsuLogin apps found: "
+ + resolveInfos.stream()
+ .map(info -> info.activityInfo.applicationInfo.packageName)
+ .collect(Collectors.joining(", ")));
+ }
+
+ // if multiple apps are found, filter out the default implementation supplied
+ // in the Wifi apex and let other implementations override.
+ resolveInfos.removeIf(info ->
+ Environment.isAppInWifiApex(info.activityInfo.applicationInfo));
}
+ // forcefully resolve to the first one
+ String packageName = resolveInfos.get(0).activityInfo.applicationInfo.packageName;
+ intent.setPackage(packageName);
+ if (mVerboseLoggingEnabled) {
+ Log.i(TAG, "Opening OsuLogin app: " + packageName);
+ }
+ mContext.startActivityAsUser(intent, UserHandle.CURRENT);
+ invokeProvisioningCallback(PROVISIONING_STATUS,
+ ProvisioningCallback.OSU_STATUS_WAITING_FOR_REDIRECT_RESPONSE);
+ changeState(STATE_WAITING_FOR_REDIRECT_RESPONSE);
}
/**
diff --git a/service/java/com/android/server/wifi/util/Environment.java b/service/java/com/android/server/wifi/util/Environment.java
index b4df26d8e..a423d55e6 100644
--- a/service/java/com/android/server/wifi/util/Environment.java
+++ b/service/java/com/android/server/wifi/util/Environment.java
@@ -17,6 +17,7 @@
package com.android.server.wifi.util;
import android.content.ApexEnvironment;
+import android.content.pm.ApplicationInfo;
import android.os.UserHandle;
import java.io.File;
@@ -33,6 +34,13 @@ public class Environment {
private static final String WIFI_APEX_NAME = "com.android.wifi";
/**
+ * The path where the Wifi apex is mounted.
+ * Current value = "/apex/com.android.wifi"
+ */
+ private static final String WIFI_APEX_PATH =
+ new File("/apex", WIFI_APEX_NAME).getAbsolutePath();
+
+ /**
* Wifi shared folder.
*/
public static File getWifiSharedDirectory() {
@@ -46,4 +54,12 @@ public class Environment {
return ApexEnvironment.getApexEnvironment(WIFI_APEX_NAME)
.getCredentialProtectedDataDirForUser(UserHandle.of(userId));
}
+
+ /**
+ * Returns true if the app is in the Wifi apex, false otherwise.
+ * Checks if the app's path starts with "/apex/com.android.wifi".
+ */
+ public static boolean isAppInWifiApex(ApplicationInfo appInfo) {
+ return appInfo.sourceDir.startsWith(WIFI_APEX_PATH);
+ }
}
diff --git a/service/res/values/config.xml b/service/res/values/config.xml
index e51e6401d..b5037b74a 100644
--- a/service/res/values/config.xml
+++ b/service/res/values/config.xml
@@ -399,7 +399,4 @@
<!-- Enable WPA2 to WPA3 auto-upgrade offload to capable Driver/Firmware -->
<bool translatable="false" name="config_wifiSaeUpgradeOffloadEnabled">false</bool>
-
- <!-- Package name for the OSU Login APK -->
- <string translatable="false" name="config_wifiOsuLoginPackage">com.android.hotspot2.osulogin</string>
</resources>
diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml
index 92e8f1987..7244911af 100644
--- a/service/res/values/overlayable.xml
+++ b/service/res/values/overlayable.xml
@@ -126,7 +126,6 @@
<item type="integer" name="config_wifiPollRssiIntervalMilliseconds" />
<item type="bool" name="config_wifiSaeUpgradeEnabled" />
<item type="bool" name="config_wifiSaeUpgradeOffloadEnabled" />
- <item type="string" name="config_wifiOsuLoginPackage" />
<!-- Params from config.xml that can be overlayed -->
<!-- Params from strings.xml that can be overlayed -->
diff --git a/service/resources-certs/com.android.wifi.resources.pk8 b/service/resources-certs/com.android.wifi.resources.pk8
new file mode 100644
index 000000000..50cca9098
--- /dev/null
+++ b/service/resources-certs/com.android.wifi.resources.pk8
Binary files differ
diff --git a/service/resources-certs/com.android.wifi.resources.x509.pem b/service/resources-certs/com.android.wifi.resources.x509.pem
new file mode 100644
index 000000000..c321be108
--- /dev/null
+++ b/service/resources-certs/com.android.wifi.resources.x509.pem
@@ -0,0 +1,35 @@
+-----BEGIN CERTIFICATE-----
+MIIGJzCCBA+gAwI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0aDypNMH+SCgsA==
+-----END CERTIFICATE-----
diff --git a/service/resources-certs/key.pem b/service/resources-certs/key.pem
new file mode 100644
index 000000000..31acc3c89
--- /dev/null
+++ b/service/resources-certs/key.pem
@@ -0,0 +1,52 @@
+-----BEGIN PRIVATE KEY-----
+MIIJRAIBADANBgkqhkiG9w0BAQEFAASCCS4wggkqAgEAAoICAQDqjgjWbsEuZyBI
+OcFD6KeNPlkgGREOUi/7kjVNXZxjEsZA+UKmUN3lipS0rz9RV7W0D06I159n2vMN
+j9/XVAHt9zV4KUh2VZNfAzIHnqTQgG8pyX3IqmAjI509xtbHCGT/BwsQF7LqMp6i
+0prOyMqJm4DOInj1SiisEaXtxdwZloI4M0WrVugtgiSx3OCoAg+d2+MPVx60PJdy
+9XN24CMI2g0ndFcSiGuNSrRx1qdy7r8V+eMM+rWwTVuWTDQxH7xewhpkwpHWzAGJ
+FnCcWcQOexNracV3ftk5xA6Ohy+2KtvIxq/IzelOt80bChyzIvg7cnotMNZwcbU3
++SrFiOweQsWr5flfrQrJzX6uRrvr4yZ5S9JKRXAYsRv0z7+x/jYMjuQ+46AMhknL
+XzJEz1nUkQ/xTU7N9MopfocVCLuJhWLVzvnOsiJtdTgZhs9SKKnrYGwYUIlMMvqf
+KKoHtjbRQ2iCd3ZHeXJjVBfxFyPPWlIbtKP1aNnKFKUf3GGU4HsX5NkSnB90ZLhu
+vR16H6wvUhmNESOxoJmhtHtYpwY1azsnT9V1yZhdw1fMsvDZpCZJW5Y7Bg+dl7gQ
+ulUNHiIe3Cylo4DAiRRTZDYFNLMmd/m5mtvBVr8yc3d4oubHlqnjxoHK33YI8W5T
+c0BClsNDHvVp/0tDijs/+TgDPWe0QwIDAQABAoICAQCXq2SXlGKiqNi9G2uXh/fg
+Y3KqSMs4oXiZij+hWWjov5knJocsmJoD9gqWk8Ozy62ZU1SLNDLFq1UDbgdma9Ib
+mIEgxEExE8EJ7T0KpFEa6hH3yWzmtxUXY84nxk3Xwdvc9Sb4Lvroafc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LWyR0coPDgYz/EdUENDSXkzW
+CCxbF7lH7jc60vOVqMH0HyFT+k5SOQDVWckzQzGLoMhKobv9FHijCnc/jdsAYkOx
++MMdUcFf1X4WjHb9U5be/YrhiOO4Ar41hEm2ezsrcreszr69Zv4Tw3BLpr/nkS37
+adx3U1hB9OzUKVm21xtowKxcrEsOpvR1
+-----END PRIVATE KEY-----
diff --git a/tests/wifitests/Android.bp b/tests/wifitests/Android.bp
index 4d808b70c..7fd2a5f75 100644
--- a/tests/wifitests/Android.bp
+++ b/tests/wifitests/Android.bp
@@ -86,7 +86,7 @@ android_test {
"jsr305",
"services",
// load the resources from the resources APK.
- "wifi-service-resources",
+ "ServiceWifiResources",
"unsupportedappusage",
],
diff --git a/tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java b/tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java
index ea030a4e6..08076dd72 100644
--- a/tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java
@@ -16,13 +16,14 @@
package com.android.server.wifi;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
+
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
-import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.wifi.WifiConfiguration;
@@ -32,10 +33,6 @@ import android.telephony.SubscriptionManager;
import androidx.test.filters.SmallTest;
-import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
-
-import static org.mockito.Mockito.lenient;
-
import com.android.server.wifi.util.TelephonyUtil;
import org.junit.After;
@@ -52,7 +49,7 @@ import org.mockito.MockitoSession;
*/
@SmallTest
public class EapFailureNotifierTest extends WifiBaseTest {
- @Mock Context mContext;
+ @Mock WifiContext mContext;
@Mock Resources mResources;
@Mock NotificationManager mNotificationManager;
@Mock FrameworkFacade mFrameworkFacade;
@@ -93,6 +90,7 @@ public class EapFailureNotifierTest extends WifiBaseTest {
when(mResources.getString(eq(0), anyString())).thenReturn(null);
when(mResources.getString(eq(1), anyString())).thenReturn("Error Message");
when(mContext.createPackageContext(anyString(), eq(0))).thenReturn(mContext);
+ when(mContext.getWifiOverlayApkPkgName()).thenReturn("test.com.android.wifi.resources");
mEapFailureNotifier =
new EapFailureNotifier(mContext, mFrameworkFacade, mTelephonyUtil);
}
diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
index 0e63b51ee..a7e21c996 100644
--- a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
@@ -117,7 +117,7 @@ public class SoftApManagerTest extends WifiBaseTest {
private SoftApInfo mTestSoftApInfo;
private SoftApCapability mTestSoftApCapability;
- @Mock Context mContext;
+ @Mock WifiContext mContext;
@Mock Resources mResources;
@Mock WifiNative mWifiNative;
@Mock WifiManager.SoftApCallback mCallback;
@@ -153,6 +153,7 @@ public class SoftApManagerTest extends WifiBaseTest {
when(mContext.getResources()).thenReturn(mResources);
when(mContext.getSystemService(NotificationManager.class))
.thenReturn(mNotificationManager);
+ when(mContext.getWifiOverlayApkPkgName()).thenReturn("test.com.android.wifi.resources");
when(mResources.getInteger(R.integer.config_wifiFrameworkSoftApShutDownTimeoutMilliseconds))
.thenReturn((int) TEST_DEFAULT_SHUTDOWN_TIMEOUT_MILLS);
diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApNotifierTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApNotifierTest.java
index 9ff893438..3d4d23998 100644
--- a/tests/wifitests/src/com/android/server/wifi/SoftApNotifierTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SoftApNotifierTest.java
@@ -45,7 +45,7 @@ import org.mockito.MockitoAnnotations;
public class SoftApNotifierTest extends WifiBaseTest {
private static final String TEST_SSID = "Test SSID";
- @Mock Context mContext;
+ @Mock WifiContext mContext;
@Mock Resources mResources;
@Mock NotificationManager mNotificationManager;
@Mock FrameworkFacade mFrameworkFacade;
@@ -61,8 +61,8 @@ public class SoftApNotifierTest extends WifiBaseTest {
when(mContext.getSystemService(NotificationManager.class))
.thenReturn(mNotificationManager);
when(mContext.getResources()).thenReturn(mResources);
- mSoftApNotifier =
- new SoftApNotifier(mContext, mFrameworkFacade);
+ when(mContext.getWifiOverlayApkPkgName()).thenReturn("test.com.android.wifi.resources");
+ mSoftApNotifier = new SoftApNotifier(mContext, mFrameworkFacade);
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiInjectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiInjectorTest.java
index 2c73d09ae..6af10d0c4 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiInjectorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiInjectorTest.java
@@ -16,10 +16,6 @@
package com.android.server.wifi;
-import static org.mockito.Mockito.*;
-
-import android.content.Context;
-
import androidx.test.filters.SmallTest;
import org.junit.Before;
@@ -31,7 +27,7 @@ import org.mockito.MockitoAnnotations;
@SmallTest
public class WifiInjectorTest extends WifiBaseTest {
- @Mock private Context mContext;
+ @Mock private WifiContext mContext;
private WifiInjector mInjector;
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
index ea2953a20..bb090cae5 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
@@ -124,7 +124,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
private static final int TEST_NETWORK_ID = 110;
private static final int TEST_CARRIER_ID = 1911;
- private @Mock Context mContext;
+ private @Mock WifiContext mContext;
private @Mock Resources mResources;
private @Mock AppOpsManager mAppOpsManager;
private @Mock NotificationManager mNotificationManger;
@@ -210,6 +210,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
when(mContext.getSystemService(ActivityManager.class)).thenReturn(mActivityManager);
when(mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
.thenReturn(mock(LayoutInflater.class));
+ when(mContext.getWifiOverlayApkPkgName()).thenReturn("test.com.android.wifi.resources");
when(mActivityManager.isLowRamDevice()).thenReturn(false);
when(mActivityManager.getPackageImportance(any())).thenReturn(
IMPORTANCE_FOREGROUND_SERVICE);
diff --git a/tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java b/tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java
index 3b4bdfd31..4afcfbadf 100644
--- a/tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java
@@ -42,7 +42,7 @@ import org.mockito.MockitoAnnotations;
public class WrongPasswordNotifierTest extends WifiBaseTest {
private static final String TEST_SSID = "Test SSID";
- @Mock Context mContext;
+ @Mock WifiContext mContext;
@Mock Resources mResources;
@Mock NotificationManager mNotificationManager;
@Mock FrameworkFacade mFrameworkFacade;
@@ -58,8 +58,8 @@ public class WrongPasswordNotifierTest extends WifiBaseTest {
when(mContext.getSystemService(Context.NOTIFICATION_SERVICE))
.thenReturn(mNotificationManager);
when(mContext.getResources()).thenReturn(mResources);
- mWrongPassNotifier =
- new WrongPasswordNotifier(mContext, mFrameworkFacade);
+ when(mContext.getWifiOverlayApkPkgName()).thenReturn("test.com.android.wifi.resources");
+ mWrongPassNotifier = new WrongPasswordNotifier(mContext, mFrameworkFacade);
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProvisionerTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProvisionerTest.java
index f234a1ef5..6423f950f 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProvisionerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProvisionerTest.java
@@ -62,7 +62,6 @@ import android.telephony.TelephonyManager;
import androidx.test.filters.SmallTest;
import com.android.dx.mockito.inline.extended.ExtendedMockito;
-import com.android.server.wifi.MockResources;
import com.android.server.wifi.WifiBaseTest;
import com.android.server.wifi.WifiMetrics;
import com.android.server.wifi.WifiNative;
@@ -80,7 +79,6 @@ import com.android.server.wifi.hotspot2.soap.UpdateResponseMessage;
import com.android.server.wifi.hotspot2.soap.command.BrowserUri;
import com.android.server.wifi.hotspot2.soap.command.PpsMoData;
import com.android.server.wifi.hotspot2.soap.command.SppCommand;
-import com.android.wifi.resources.R;
import org.junit.After;
import org.junit.Before;
@@ -258,16 +256,13 @@ public class PasspointProvisionerTest extends WifiBaseTest {
when(mOsuServerConnection.exchangeSoapMessage(
any(SoapSerializationEnvelope.class))).thenReturn(true);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
- MockResources mockResources = new MockResources();
- mockResources.setString(R.string.config_wifiOsuLoginPackage, OSU_APP_PACKAGE);
- when(mContext.getResources()).thenReturn(mockResources);
ResolveInfo resolveInfo = new ResolveInfo();
resolveInfo.activityInfo = new ActivityInfo();
resolveInfo.activityInfo.applicationInfo = new ApplicationInfo();
resolveInfo.activityInfo.name = OSU_APP_NAME;
resolveInfo.activityInfo.applicationInfo.packageName = OSU_APP_PACKAGE;
- when(mPackageManager.resolveActivity(any(Intent.class),
- eq(PackageManager.MATCH_DEFAULT_ONLY))).thenReturn(resolveInfo);
+ when(mPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
+ .thenReturn(Arrays.asList(resolveInfo));
Map<String, byte[]> trustCertInfo = new HashMap<>();
trustCertInfo.put("https://testurl.com", "testData".getBytes());
@@ -632,7 +627,7 @@ public class PasspointProvisionerTest extends WifiBaseTest {
verifyNoMoreInteractions(mCallback);
}
- /**
+ /**
* Verifies that the right provisioning callbacks are invoked as the provisioner connects
* to OSU AP and OSU server and that invalid server URL generates the right error callback.
*/
@@ -782,8 +777,7 @@ public class PasspointProvisionerTest extends WifiBaseTest {
@Test
public void verifyNoOsuActivityFoundFailure() throws RemoteException {
// There is no activity found for the intent
- when(mPackageManager.resolveActivity(any(Intent.class),
- eq(PackageManager.MATCH_DEFAULT_ONLY))).thenReturn(null);
+ when(mPackageManager.queryIntentActivities(any(Intent.class), anyInt())).thenReturn(null);
stopAfterStep(STEP_SERVER_CONNECT);
// Server validation passed