summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-04-13 18:09:25 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-04-13 18:09:25 +0000
commitb496914f4fe3e4def90464b703593b03dafa1d43 (patch)
tree5095229075759124be2422883106f0063af042c2 /service
parent16da71e75a50589e458a4310d96766fd3a547d2d (diff)
parentfba7f4d4f17e44ac6e62d011588f3e426e6f1364 (diff)
Merge "WrongPasswordNotifier: Set package name on the intent" into rvc-dev
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WrongPasswordNotifier.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WrongPasswordNotifier.java b/service/java/com/android/server/wifi/WrongPasswordNotifier.java
index 9975f973a..c645ccf6f 100644
--- a/service/java/com/android/server/wifi/WrongPasswordNotifier.java
+++ b/service/java/com/android/server/wifi/WrongPasswordNotifier.java
@@ -16,22 +16,30 @@
package com.android.server.wifi;
+import android.app.ActivityManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.graphics.drawable.Icon;
+import android.os.UserHandle;
import android.provider.Settings;
+import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.server.wifi.util.NativeUtil;
+import java.util.List;
+
/**
* Responsible for notifying user for wrong password errors.
*/
public class WrongPasswordNotifier {
+ private static final String TAG = "WrongPasswordNotifier";
// Number of milliseconds to wait before automatically dismiss the notification.
private static final long CANCEL_TIMEOUT_MILLISECONDS = 5 * 60 * 1000;
@@ -73,14 +81,30 @@ public class WrongPasswordNotifier {
}
}
+ private String getSettingsPackageName() {
+ Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
+ List<ResolveInfo> resolveInfos = mContext.getPackageManager().queryIntentActivitiesAsUser(
+ intent, PackageManager.MATCH_SYSTEM_ONLY | PackageManager.MATCH_DEFAULT_ONLY,
+ UserHandle.of(ActivityManager.getCurrentUser()));
+ if (resolveInfos == null || resolveInfos.isEmpty()) {
+ Log.e(TAG, "Failed to resolve wifi settings activity");
+ return null;
+ }
+ // Pick the first one if there are more than 1 since the list is ordered from best to worst.
+ return resolveInfos.get(0).activityInfo.packageName;
+ }
+
/**
* Display wrong password notification for a given Wi-Fi network (specified by its SSID).
*
* @param ssid SSID of the Wi-FI network
*/
private void showNotification(String ssid) {
- Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
- intent.putExtra("wifi_start_connect_ssid", NativeUtil.removeEnclosingQuotes(ssid));
+ String settingsPackage = getSettingsPackageName();
+ if (settingsPackage == null) return;
+ Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS)
+ .setPackage(settingsPackage)
+ .putExtra("wifi_start_connect_ssid", NativeUtil.removeEnclosingQuotes(ssid));
Notification.Builder builder = mFrameworkFacade.makeNotificationBuilder(mContext,
WifiService.NOTIFICATION_NETWORK_ALERTS)
.setAutoCancel(true)