From 02938a0a735da7fafaaed84e31e1aa93cdf80a56 Mon Sep 17 00:00:00 2001 From: Ivan Podogov Date: Mon, 5 Dec 2016 16:47:34 +0000 Subject: In permission review mode, always request user's consent to toggle WiFi. Bug: 33155556 Test: Manual: flash the watch, check that the consent UI was displayed in both apps (the one with CompileSDK=21 and TargetSDK=21, and the one with CompileSDK=25 and TargetSDK=25). Change-Id: I41d9adb916c12327643d59fd05a50d097800e2ac --- .../com/android/server/wifi/WifiServiceImpl.java | 23 ++++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index 18681484b..cecb3e2bc 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -600,14 +600,14 @@ public class WifiServiceImpl extends IWifiManager.Stub { if (enable) { if (wiFiEnabledState == WifiManager.WIFI_STATE_DISABLING || wiFiEnabledState == WifiManager.WIFI_STATE_DISABLED) { - if (startConsentUiIfNeeded(packageName, Binder.getCallingUid(), + if (startConsentUi(packageName, Binder.getCallingUid(), WifiManager.ACTION_REQUEST_ENABLE)) { return true; } } } else if (wiFiEnabledState == WifiManager.WIFI_STATE_ENABLING || wiFiEnabledState == WifiManager.WIFI_STATE_ENABLED) { - if (startConsentUiIfNeeded(packageName, Binder.getCallingUid(), + if (startConsentUi(packageName, Binder.getCallingUid(), WifiManager.ACTION_REQUEST_DISABLE)) { return true; } @@ -1344,7 +1344,7 @@ public class WifiServiceImpl extends IWifiManager.Stub { } }; - private boolean startConsentUiIfNeeded(String packageName, + private boolean startConsentUi(String packageName, int callingUid, String intentAction) throws RemoteException { if (UserHandle.getAppId(callingUid) == Process.SYSTEM_UID) { return false; @@ -1360,19 +1360,16 @@ public class WifiServiceImpl extends IWifiManager.Stub { + " not in uid " + callingUid); } - // Legacy apps in permission review mode trigger a user prompt - if (applicationInfo.targetSdkVersion < Build.VERSION_CODES.M) { - Intent intent = new Intent(intentAction); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK - | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); - intent.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName); - mContext.startActivity(intent); - return true; - } + // Permission review mode, trigger a user prompt + Intent intent = new Intent(intentAction); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); + intent.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName); + mContext.startActivity(intent); + return true; } catch (PackageManager.NameNotFoundException e) { throw new RemoteException(e.getMessage()); } - return false; } /** -- cgit v1.2.3