Remove ACCESS_COARSE_LOCATION permission checking

- The calling package needs ACCESS_FINE_LOCATION permission to get WiFi
result data.

- The ACCESS_COARSE_LOCATION permission is not allowed.

Bug: 185126813
Test: manual test
make RunSettingsRoboTests ROBOTEST_FILTER=WifiDialogActivityTest

Change-Id: I2c9013a74d173066270b422ae2179b0d1018f2d7
This commit is contained in:
Weng Su
2021-11-05 01:36:13 +08:00
parent e87862a245
commit a27167dbd8
2 changed files with 2 additions and 9 deletions

View File

@@ -16,7 +16,6 @@
package com.android.settings.wifi; package com.android.settings.wifi;
import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
import static android.Manifest.permission.ACCESS_FINE_LOCATION; import static android.Manifest.permission.ACCESS_FINE_LOCATION;
import android.content.DialogInterface; import android.content.DialogInterface;
@@ -359,12 +358,6 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog
return false; return false;
} }
if (getPackageManager().checkPermission(ACCESS_COARSE_LOCATION, callingPackage)
== PackageManager.PERMISSION_GRANTED) {
Log.d(TAG, "The calling package has ACCESS_COARSE_LOCATION permission for result.");
return true;
}
if (getPackageManager().checkPermission(ACCESS_FINE_LOCATION, callingPackage) if (getPackageManager().checkPermission(ACCESS_FINE_LOCATION, callingPackage)
== PackageManager.PERMISSION_GRANTED) { == PackageManager.PERMISSION_GRANTED) {
Log.d(TAG, "The calling package has ACCESS_FINE_LOCATION permission for result."); Log.d(TAG, "The calling package has ACCESS_FINE_LOCATION permission for result.");

View File

@@ -310,7 +310,7 @@ public class WifiDialogActivityTest {
} }
@Test @Test
public void hasPermissionForResult_hasCoarseLocationPermission_returnTrue() { public void hasPermissionForResult_hasCoarseLocationPermission_returnFalse() {
WifiDialogActivity activity = spy(Robolectric.setupActivity(WifiDialogActivity.class)); WifiDialogActivity activity = spy(Robolectric.setupActivity(WifiDialogActivity.class));
when(activity.getCallingPackage()).thenReturn(CALLING_PACKAGE); when(activity.getCallingPackage()).thenReturn(CALLING_PACKAGE);
when(activity.getPackageManager()).thenReturn(mPackageManager); when(activity.getPackageManager()).thenReturn(mPackageManager);
@@ -321,7 +321,7 @@ public class WifiDialogActivityTest {
final boolean result = activity.hasPermissionForResult(); final boolean result = activity.hasPermissionForResult();
assertThat(result).isTrue(); assertThat(result).isFalse();
} }
@Test @Test