Closed theScrabi closed 4 years ago
The overall structure looks good to me :-D Can't the LineageOS-issue be solved by just adding a
.toLowercase()
to both the value read from the csv and the value read from thecsv
?
I thought the same. Of course there might be cases where that is not enough. If that happens and (even after casting to lower case) the device is not found in the list, an error message containing the device string could be thrown. This error message could tell the user to report that specific device string to us, so that we can fix it for the next version. Or the app could even automatically send an error message to us (after asking the user to do so).
Well making the manufacturer case insensitive would solve one problem.
However there is more than just that. If you look carefully you will see that the first line of the "ASDFASDF" output has a different device name. LineageOS calles my device "lake" however the vendor calls it "lake_n" because there are different models of "lake" available. This is an issue that can not be fixed by making things case insensitive. The pint is that apparently Lineage device signature diverge from vendor signatures.
IMO I think this is an issue that will also arise for the official implementation. So if we just want to be close to official builds we may not need to take care about it now, however we should keep this in mind or forward this problem to the LineageOS developer.
What is the fallback if the device cannot be identified? And are the attenuation values etc. for different models of the "same" device mostly similar in the list? If so, maybe it would make sense to make up a heuristic to find out the base device.
The default is rssi: 0, tx: 0
I also compare case-insensitive in microG. My current implementation is based on the 2020-06-13, so I only have oem and model, not device.
As a strategy when also having device I'd suggest to do the following (match/same is case-insensitive):
Thus if only device or model is not the same, but it's still uniquely possible to identify the device (like in your example), the correct entry is picked. If uniqueness is no longer possible (because the model appears multiple times but and the device mismatches), average of models with same name should be a very good estimate.
@haitrec for every device on the list that has confidence set to 1 (LOW), this is already an estimate which is the average of all devices from the same oem.
@mar-v-in you mena 3 not -3.
Taking the average of all rssi from the list i get 3.54
wouldn't it be better to use a correction of rssi = 4 then?
I can't get Mockito running, can someone help me I may need it.
Error I'm getting:
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class android.content.Context.
Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.
IMPORTANT INFORMATION FOR ANDROID USERS:
The regular Byte Buddy mock makers cannot generate code on an Android VM!
To resolve this, please use the 'mockito-android' dependency for your application:
http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22mockito-android%22%20g%3A%22org.mockito%22
Java : 0.9
JVM vendor name : The Android Project
JVM vendor version : 2.1.0
JVM name : Dalvik
JVM version : 0.9
JVM info : null
OS name : Linux
OS version : 4.4.235-lineage-g01625f8
Underlying exception : java.lang.IllegalStateException: Cannot invoke BaseDexClassLoader#addDexPath(String, boolean)
at org.coralibre.android.sdk.internal.DeviceListTest.setup(DeviceListTest.java:74)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at androidx.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:76)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:392)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2196)
Caused by: java.lang.IllegalStateException: Cannot invoke BaseDexClassLoader#addDexPath(String, boolean)
at net.bytebuddy.android.AndroidClassLoadingStrategy$Injecting$Dispatcher$ForAndroidPVm.loadDex(AndroidClassLoadingStrategy.java:770)
at net.bytebuddy.android.AndroidClassLoadingStrategy$Injecting.doLoad(AndroidClassLoadingStrategy.java:639)
at net.bytebuddy.android.AndroidClassLoadingStrategy.load(AndroidClassLoadingStrategy.java:145)
at net.bytebuddy.android.AndroidClassLoadingStrategy$Injecting.load(AndroidClassLoadingStrategy.java:632)
at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:100)
at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6156)
at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:200)
at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:46)
at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:43)
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:152)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:365)
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:174)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:376)
at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:36)
at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:77)
at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:43)
at org.mockito.android.internal.creation.AndroidByteBuddyMockMaker.createMock(AndroidByteBuddyMockMaker.java:39)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:52)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:61)
at org.mockito.Mockito.mock(Mockito.java:1949)
at org.mockito.Mockito.mock(Mockito.java:1860)
... 28 more
Caused by: java.lang.SecurityException: Can't exempt class, process is not debuggable.
at dalvik.system.DexFile.setTrusted(Native Method)
at dalvik.system.DexFile.setTrusted(DexFile.java:421)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:422)
at dalvik.system.DexPathList.addDexPath(DexPathList.java:218)
at dalvik.system.BaseDexClassLoader.addDexPath(BaseDexClassLoader.java:220)
at java.lang.reflect.Method.invoke(Native Method)
at net.bytebuddy.android.AndroidClassLoadingStrategy$Injecting$Dispatcher$ForAndroidPVm.loadDex(AndroidClassLoadingStrategy.java:761)
... 48 more
I'm using these dependencies:
dependencies {
implementation 'androidx.core:core:1.2.0'
implementation('androidx.security:security-crypto:1.0.0-rc02') {
exclude group: 'com.google.protobuf', module: "protobuf-javalite"
// See:
// https://stackoverflow.com/questions/61518039/androidx-security-with-google-protobuf
}
implementation 'androidx.work:work-runtime:2.3.4'
implementation 'com.squareup.retrofit2:retrofit:2.8.1'
implementation 'com.squareup.retrofit2:converter-gson:2.8.1'
implementation('com.squareup.retrofit2:converter-protobuf:2.8.1') {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
}
implementation 'com.google.protobuf:protobuf-lite:3.0.1'
// I changed the protobuf lite version to resolve a duplicate class conflict when building
// the CoraLibre App. This version is the same as in the original corona warn app. Also
// see the 'protobuf {...}' section above.
implementation 'com.google.crypto.tink:tink-android:1.4.0-rc2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.benchmark:benchmark-junit4:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'org.mockito:mockito-android:3.5.10'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.5.10'
implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
mockito-android:2.17.0 works. It leads to some other errors with the current code, but I think these can be fixed more easily. I found it here: https://stackoverflow.com/questions/41050029/mockito-cannot-mock-this-class/59888581#59888581
Yeesss great thank you. :D the current code is not supposed to wrok... i wrote the tests blindly because mockito did not work.
All rights test now run through please review.
Adds rssi/tx device list
android.os.Build.MANUFACTURER/DEVICE/MODEL
differs from Verndor image.