Fix security issue for using mock location without permission.

Remove mock location apps if developer option is disabled.

Change-Id: Iad32ea336376eeb923f6d4424fd85c2da2bb5128
Bugs: 145136060
Test: manual
This commit is contained in:
Stanley Wang
2020-02-10 17:50:32 +08:00
parent cf4e12bbd9
commit cdf4028142
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) {