引言
懂的都懂。
方案
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79diff --git a/frameworks/base/location/java/android/location/GpsStatus.java b/frameworks/base/location/java/android/location/GpsStatus.java index d4ca5fe854..4502e26559 100644 --- a/frameworks/base/location/java/android/location/GpsStatus.java +++ b/frameworks/base/location/java/android/location/GpsStatus.java @@ -193,6 +193,42 @@ public final class GpsStatus { (svidWithFlags[i] & GnssStatus.GNSS_SV_FLAGS_USED_IN_FIX) != 0; } } + boolean isHasGps = false; + for (int i = 0; i < 30; i++) { + GpsSatellite satellite = mSatellites.get(i); + if (satellite != null && satellite.mValid && (satellite.mSnr > 0.0f)) { + isHasGps = true; + break; + } + } + if(isHasGps){ + GpsSatellite satellite209 = mSatellites.get(209); + if (satellite209 == null) { + satellite209 = new GpsSatellite(209); + mSatellites.put(209, satellite209); + } + satellite209.mValid = true; + satellite209.mSnr = Float.parseFloat(formateRate(20.0f,10.0f)); + satellite209.mElevation = 49.0f; + satellite209.mAzimuth = 201.0f; + satellite209.mHasEphemeris = false; + satellite209.mHasAlmanac = false; + satellite209.mUsedInFix = false; + + GpsSatellite satellite229 = mSatellites.get(229); + if (satellite229 == null) { + satellite229 = new GpsSatellite(229); + mSatellites.put(229, satellite229); + } + satellite229.mValid = true; + satellite229.mSnr = Float.parseFloat(formateRate(20.0f,10.0f)); + satellite229.mElevation = 40.0f; + satellite229.mAzimuth = 165.0f; + satellite229.mHasEphemeris = false; + satellite229.mHasAlmanac = false; + satellite229.mUsedInFix = false; + } }
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46diff --git a/frameworks/base/location/java/android/location/GpsStatus.java b/frameworks/base/location/java/android/location/GpsStatus.java index b601cde353..d4ca5fe854 100644 --- a/frameworks/base/location/java/android/location/GpsStatus.java +++ b/frameworks/base/location/java/android/location/GpsStatus.java @@ -20,6 +20,7 @@ import android.util.SparseArray; import java.util.Iterator; import java.util.NoSuchElementException; +import java.util.Random; /** @@ -240,11 +241,54 @@ public final class GpsStatus { return NUM_SATELLITES; } + private static String formateRate(final double min, final double max) { + String rateStr = ""+(min + ((max - min) * new Random().nextDouble())); + if (rateStr.indexOf(".") != -1) { + int num = 0; + num = rateStr.indexOf("."); + String dianAfter = rateStr.substring(0, num + 1); + String afterData = rateStr.replace(dianAfter, ""); + return rateStr.substring(0, num) + "." + afterData.substring(0, 1); + } else { + if (rateStr == "1") { + return "100"; + } else { + return rateStr; + } + } + } +
最后
以上就是善良鼠标最近收集整理的关于android 9.x mtk 定位模拟的全部内容,更多相关android内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复