From 27caa745b3410920460e01474efef02f9b44ade4 Mon Sep 17 00:00:00 2001 From: Anil Admal Date: Thu, 30 May 2019 14:44:52 -0700 Subject: [PATCH] Fix permission mismatch logging of NfwNotification when GNSS HAL is disabled Bug: 134073233 Test: Manual Change-Id: I6093994b9a82342ab935d8535b37641e5ce44984 --- .../server/location/GnssVisibilityControl.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/location/GnssVisibilityControl.java b/services/core/java/com/android/server/location/GnssVisibilityControl.java index 8d4ad7f308219..65bd5c6a14da1 100644 --- a/services/core/java/com/android/server/location/GnssVisibilityControl.java +++ b/services/core/java/com/android/server/location/GnssVisibilityControl.java @@ -456,9 +456,8 @@ class GnssVisibilityControl { final String proxyAppPkgName = nfwNotification.mProxyAppPackageName; final ProxyAppState proxyAppState = mProxyAppsState.get(proxyAppPkgName); final boolean isLocationRequestAccepted = nfwNotification.isRequestAccepted(); - final boolean isPermissionMismatched = - (proxyAppState == null) ? isLocationRequestAccepted - : (proxyAppState.mHasLocationPermission != isLocationRequestAccepted); + final boolean isPermissionMismatched = isPermissionMismatched(proxyAppState, + nfwNotification); logEvent(nfwNotification, isPermissionMismatched); if (!nfwNotification.isRequestAttributedToProxyApp()) { @@ -506,14 +505,24 @@ class GnssVisibilityControl { // Log proxy app permission mismatch between framework and GNSS HAL. if (isPermissionMismatched) { - Log.w(TAG, "Permission mismatch. Framework proxy app " + proxyAppPkgName + Log.w(TAG, "Permission mismatch. Proxy app " + proxyAppPkgName + " location permission is set to " + proxyAppState.mHasLocationPermission + + " and GNSS HAL enabled is set to " + mIsGpsEnabled + " but GNSS non-framework location access response type is " + nfwNotification.getResponseTypeAsString() + " for notification: " + nfwNotification); } } + private boolean isPermissionMismatched(ProxyAppState proxyAppState, + NfwNotification nfwNotification) { + // Non-framework non-emergency location requests must be accepted only when IGnss.hal + // is enabled and the proxy app has location permission. + final boolean isLocationRequestAccepted = nfwNotification.isRequestAccepted(); + return (proxyAppState == null || !mIsGpsEnabled) ? isLocationRequestAccepted + : (proxyAppState.mHasLocationPermission != isLocationRequestAccepted); + } + private void showLocationIcon(ProxyAppState proxyAppState, NfwNotification nfwNotification, int uid, String proxyAppPkgName) { // If we receive a new NfwNotification before the location icon is turned off for the