Merge "Fix security issue for using mock location without permission."

This commit is contained in:
Stanley Wang
2020-02-12 02:23:52 +00:00
committed by Android (Google) Code Review
2 changed files with 19 additions and 4 deletions

View File

@@ -27,6 +27,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import com.android.settings.R;
@@ -86,6 +87,12 @@ public class MockLocationAppPreferenceController extends DeveloperOptionsPrefere
return true;
}
@Override
public void onDeveloperOptionsDisabled() {
super.onDeveloperOptionsDisabled();
removeAllMockLocations();
}
private void updateMockLocation() {
final String mockLocationApp = getCurrentMockLocationApp();
@@ -151,7 +158,8 @@ public class MockLocationAppPreferenceController extends DeveloperOptionsPrefere
}
}
private String getCurrentMockLocationApp() {
@VisibleForTesting
String getCurrentMockLocationApp() {
final List<AppOpsManager.PackageOps> packageOps = mAppsOpsManager.getPackagesForOps(
MOCK_LOCATION_APP_OPS);
if (packageOps != null) {