diff --git a/core/api/current.txt b/core/api/current.txt index bc74372d4638f..4a6c09af908d2 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -19803,7 +19803,8 @@ package android.location { method public boolean hasSpeed(); method public boolean hasSpeedAccuracy(); method public boolean hasVerticalAccuracy(); - method public boolean isFromMockProvider(); + method @Deprecated public boolean isFromMockProvider(); + method public boolean isMock(); method @Deprecated public void removeAccuracy(); method @Deprecated public void removeAltitude(); method @Deprecated public void removeBearing(); @@ -19819,6 +19820,7 @@ package android.location { method public void setExtras(@Nullable android.os.Bundle); method public void setLatitude(double); method public void setLongitude(double); + method public void setMock(boolean); method public void setProvider(String); method public void setSpeed(float); method public void setSpeedAccuracyMetersPerSecond(float); diff --git a/core/api/system-current.txt b/core/api/system-current.txt index a0e0f7133a257..5158bcfc9ec44 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -4823,7 +4823,7 @@ package android.location { public class Location implements android.os.Parcelable { method public boolean isComplete(); method public void makeComplete(); - method public void setIsFromMockProvider(boolean); + method @Deprecated public void setIsFromMockProvider(boolean); field @Deprecated public static final String EXTRA_NO_GPS_LOCATION = "noGPSLocation"; } diff --git a/location/java/android/location/Location.java b/location/java/android/location/Location.java index 5e2e5595ba9cb..5f8d795cd6547 100644 --- a/location/java/android/location/Location.java +++ b/location/java/android/location/Location.java @@ -1246,20 +1246,42 @@ public class Location implements Parcelable { * Returns true if the Location came from a mock provider. * * @return true if this Location came from a mock provider, false otherwise + * @deprecated Prefer {@link #isMock()} instead. */ + @Deprecated public boolean isFromMockProvider() { - return (mFieldsMask & HAS_MOCK_PROVIDER_MASK) != 0; + return isMock(); } /** * Flag this Location as having come from a mock provider or not. * * @param isFromMockProvider true if this Location came from a mock provider, false otherwise + * @deprecated Prefer {@link #setMock(boolean)} instead. * @hide */ + @Deprecated @SystemApi public void setIsFromMockProvider(boolean isFromMockProvider) { - if (isFromMockProvider) { + setMock(isFromMockProvider); + } + + /** + * Returns true if this location is marked as a mock location. If this location comes from the + * Android framework, this indicates that the location was provided by a test location provider, + * and thus may not be related to the actual location of the device. + * + * @see LocationManager#addTestProvider + */ + public boolean isMock() { + return (mFieldsMask & HAS_MOCK_PROVIDER_MASK) != 0; + } + + /** + * Sets whether this location is marked as a mock location. + */ + public void setMock(boolean mock) { + if (mock) { mFieldsMask |= HAS_MOCK_PROVIDER_MASK; } else { mFieldsMask &= ~HAS_MOCK_PROVIDER_MASK;