Loading src/com/android/settings/development/MockLocationAppPreferenceController.java +9 −1 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.text.TextUtils; import android.text.TextUtils; import androidx.annotation.VisibleForTesting; import androidx.preference.Preference; import androidx.preference.Preference; import com.android.settings.R; import com.android.settings.R; Loading Loading @@ -86,6 +87,12 @@ public class MockLocationAppPreferenceController extends DeveloperOptionsPrefere return true; return true; } } @Override public void onDeveloperOptionsDisabled() { super.onDeveloperOptionsDisabled(); removeAllMockLocations(); } private void updateMockLocation() { private void updateMockLocation() { final String mockLocationApp = getCurrentMockLocationApp(); final String mockLocationApp = getCurrentMockLocationApp(); Loading Loading @@ -151,7 +158,8 @@ public class MockLocationAppPreferenceController extends DeveloperOptionsPrefere } } } } private String getCurrentMockLocationApp() { @VisibleForTesting String getCurrentMockLocationApp() { final List<AppOpsManager.PackageOps> packageOps = mAppsOpsManager.getPackagesForOps( final List<AppOpsManager.PackageOps> packageOps = mAppsOpsManager.getPackagesForOps( MOCK_LOCATION_APP_OPS); MOCK_LOCATION_APP_OPS); if (packageOps != null) { if (packageOps != null) { Loading tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java +10 −3 Original line number Original line Diff line number Diff line package com.android.settings.development; package com.android.settings.development; import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes.REQUEST_MOCK_LOCATION_APP; .REQUEST_MOCK_LOCATION_APP; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat; Loading @@ -20,7 +19,6 @@ import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.util.Pair; import androidx.preference.Preference; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen; Loading Loading @@ -145,6 +143,15 @@ public class MockLocationAppPreferenceControllerTest { assertThat(mController.handlePreferenceTreeClick(mPreference)).isFalse(); assertThat(mController.handlePreferenceTreeClick(mPreference)).isFalse(); } } @Test public void onDeveloperOptionsDisabled_currentMockLocationApp_shouldBeNull() { mController.onDeveloperOptionsDisabled(); final String appName = mController.getCurrentMockLocationApp(); assertThat(appName).isNull(); } private AppOpsManager.OpEntry createOpEntry(int opMode) { private AppOpsManager.OpEntry createOpEntry(int opMode) { return new OpEntry(0, opMode, Collections.emptyMap()); return new OpEntry(0, opMode, Collections.emptyMap()); } } Loading Loading
src/com/android/settings/development/MockLocationAppPreferenceController.java +9 −1 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.text.TextUtils; import android.text.TextUtils; import androidx.annotation.VisibleForTesting; import androidx.preference.Preference; import androidx.preference.Preference; import com.android.settings.R; import com.android.settings.R; Loading Loading @@ -86,6 +87,12 @@ public class MockLocationAppPreferenceController extends DeveloperOptionsPrefere return true; return true; } } @Override public void onDeveloperOptionsDisabled() { super.onDeveloperOptionsDisabled(); removeAllMockLocations(); } private void updateMockLocation() { private void updateMockLocation() { final String mockLocationApp = getCurrentMockLocationApp(); final String mockLocationApp = getCurrentMockLocationApp(); Loading Loading @@ -151,7 +158,8 @@ public class MockLocationAppPreferenceController extends DeveloperOptionsPrefere } } } } private String getCurrentMockLocationApp() { @VisibleForTesting String getCurrentMockLocationApp() { final List<AppOpsManager.PackageOps> packageOps = mAppsOpsManager.getPackagesForOps( final List<AppOpsManager.PackageOps> packageOps = mAppsOpsManager.getPackagesForOps( MOCK_LOCATION_APP_OPS); MOCK_LOCATION_APP_OPS); if (packageOps != null) { if (packageOps != null) { Loading
tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java +10 −3 Original line number Original line Diff line number Diff line package com.android.settings.development; package com.android.settings.development; import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes.REQUEST_MOCK_LOCATION_APP; .REQUEST_MOCK_LOCATION_APP; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat; Loading @@ -20,7 +19,6 @@ import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.util.Pair; import androidx.preference.Preference; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen; Loading Loading @@ -145,6 +143,15 @@ public class MockLocationAppPreferenceControllerTest { assertThat(mController.handlePreferenceTreeClick(mPreference)).isFalse(); assertThat(mController.handlePreferenceTreeClick(mPreference)).isFalse(); } } @Test public void onDeveloperOptionsDisabled_currentMockLocationApp_shouldBeNull() { mController.onDeveloperOptionsDisabled(); final String appName = mController.getCurrentMockLocationApp(); assertThat(appName).isNull(); } private AppOpsManager.OpEntry createOpEntry(int opMode) { private AppOpsManager.OpEntry createOpEntry(int opMode) { return new OpEntry(0, opMode, Collections.emptyMap()); return new OpEntry(0, opMode, Collections.emptyMap()); } } Loading