Skip to content

Commit f9c7274

Browse files
committed
fix #5: [Android 11] powerRequirement is out of range of [1, 3]
1 parent 4cfeab7 commit f9c7274

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ combination of:
2121
#### Notes
2222

2323
* minimum supported version of Android:
24-
* Android 1.0 (API level 1)
24+
* Android 1.5 (API level 3)
2525

2626
- - - -
2727

android-studio-project/Mock-my-GPS/src/main/java/com/github/warren_bank/mock_location/service/looper/MockLocationProvider.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@ public MockLocationProvider(String name, Context ctx) {
2424
this.providerName = name;
2525
this.ctx = ctx;
2626

27+
int powerUsage = 0;
28+
int accuracy = 5;
29+
30+
if (Build.VERSION.SDK_INT >= 30) {
31+
powerUsage = 1;
32+
accuracy = 2;
33+
}
34+
2735
LocationManager lm = (LocationManager) ctx.getSystemService(
2836
Context.LOCATION_SERVICE);
2937
try
3038
{
3139
lm.addTestProvider(providerName, false, false, false, false, false,
32-
true, true, 0, 5);
40+
true, true, powerUsage, accuracy);
3341
lm.setTestProviderEnabled(providerName, true);
3442
} catch(SecurityException e) {
3543
throw new SecurityException("Not allowed to perform MOCK_LOCATION");

android-studio-project/constants.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project.ext {
2-
releaseVersionCode = Integer.parseInt("002010701", 10) //Integer.MAX_VALUE == 2147483647
3-
releaseVersion = '002.01.07-01API'
4-
minSdkVersion = 1
2+
releaseVersionCode = Integer.parseInt("002010803", 10) //Integer.MAX_VALUE == 2147483647
3+
releaseVersion = '002.01.08-03API'
4+
minSdkVersion = 3
55
targetSdkVersion = 28
66
compileSdkVersion = 28
77
buildToolsVersion = '28.0.3'

0 commit comments

Comments
 (0)