summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorPatrik Fimml <patrikf@google.com>2019-10-22 22:25:01 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-10-22 22:25:01 +0000
commit4aa627bb5bd98b380e6a3a2c6f2986066a31aa6c (patch)
tree8f633e3b409f80490c36687d6e0d73585fa0d677 /service
parenta6a9d09a1903f4765601684aef21de6921b9b0cb (diff)
parent542231c5abc5585a864e4ef68bde57bf4f1197bc (diff)
Merge "LOHS: Use system identity for foreground check."
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java14
1 files changed, 5 insertions, 9 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 03f4faf47..3fca21892 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -1329,14 +1329,9 @@ public class WifiServiceImpl extends BaseWifiService {
return LocalOnlyHotspotCallback.ERROR_GENERIC;
}
enforceLocationPermission(packageName, uid);
- long ident = Binder.clearCallingIdentity();
- try {
- // also need to verify that Locations services are enabled.
- if (!mWifiPermissionsUtil.isLocationModeEnabled()) {
- throw new SecurityException("Location mode is not enabled.");
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
+ // also need to verify that Locations services are enabled.
+ if (!Binder.withCleanCallingIdentity(() -> mWifiPermissionsUtil.isLocationModeEnabled())) {
+ throw new SecurityException("Location mode is not enabled.");
}
// verify that tethering is not disabled
@@ -1345,7 +1340,8 @@ public class WifiServiceImpl extends BaseWifiService {
}
// the app should be in the foreground
- if (!mFrameworkFacade.isAppForeground(mContext, uid)) {
+ if (!Binder.withCleanCallingIdentity(
+ () -> mFrameworkFacade.isAppForeground(mContext, uid))) {
return LocalOnlyHotspotCallback.ERROR_INCOMPATIBLE_MODE;
}