-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/platform interaction stability improvements #106
Fix/platform interaction stability improvements #106
Conversation
@Test | ||
fun safeErrorRetrievable() { | ||
val errorId = "Hello" | ||
val v = safe { throw Exception(errorId) } |
Check warning
Code scanning / detekt
Thrown exception is too generic. Prefer throwing project specific exceptions to handle error cases. Warning test
@Test | ||
fun safeLazyEvaluatedOnceOnError() { | ||
var count = 0 | ||
val lazy = safeLazy { ++count; throw Exception() } |
Check warning
Code scanning / detekt
Thrown exception is too generic. Prefer throwing project specific exceptions to handle error cases. Warning test
TestCase.assertTrue(errCause is Exception && errCause.message == errorId) | ||
countDownLatch.countDown() | ||
} | ||
) { throw Exception(errorId) } |
Check warning
Code scanning / detekt
Thrown exception is too generic. Prefer throwing project specific exceptions to handle error cases. Warning test
...int/src/main/java/com/fingerprintjs/android/fingerprint/device_id_providers/GsfIdProvider.kt
Fixed
Show fixed
Hide fixed
TestCase.assertTrue( | ||
err is ExecutionTimeoutException | ||
&& err.executionThreadStackTrace != null | ||
&& err.executionThreadStackTrace.any { it.className == "java.lang.Thread" && it.methodName == "sleep" } |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style. Warning test
fun safeFromMultipleThreadsIsNotBlocked() { | ||
val countDownLatch = CountDownLatch(2) | ||
val elapsedTime = elapsedTimeMs { | ||
safeAsync(timeoutMs = TimeConstants.t2) { safe { Thread.sleep(TimeConstants.t1); countDownLatch.countDown() } } |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style. Warning test
val countDownLatch = CountDownLatch(2) | ||
val elapsedTime = elapsedTimeMs { | ||
safeAsync(timeoutMs = TimeConstants.t2) { safe { Thread.sleep(TimeConstants.t1); countDownLatch.countDown() } } | ||
safeAsync(timeoutMs = TimeConstants.t2) { safe { Thread.sleep(TimeConstants.t1); countDownLatch.countDown() } } |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style. Warning test
TestCase.assertTrue( | ||
errImmutable is ExecutionTimeoutException | ||
&& errImmutable.executionThreadStackTrace != null | ||
&& errImmutable.executionThreadStackTrace.any { it.className == "java.lang.Thread" && it.methodName == "sleep" } |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style. Warning test
|
||
|
||
/** | ||
* A factory for [Fingerprinter] class. | ||
*/ | ||
public object FingerprinterFactory { | ||
|
||
private var configuration: Configuration = Configuration(version = Fingerprinter.Version.fingerprintingGroupedSignalsLastVersion.intValue) | ||
private var configuration = Configuration(version = Fingerprinter.Version.fingerprintingGroupedSignalsLastVersion.intValue) |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style. Warning
targetSdk = 33 | ||
|
||
minSdk = 21 |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
// As for now, I don't see any non-deprecated ways of accomplishing this task. | ||
// Discussions: | ||
// https://stackoverflow.com/questions/76084080/apply-targetsdk-in-android-instrumentation-test | ||
// https://issuetracker.google.com/issues/230625468 (looks like lint.targetSdk and testOptions.targetSdk will become available soon) |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style. Warning
} | ||
} | ||
|
||
compileSdk = 34 |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
@@ -8,7 +8,7 @@ | |||
} | |||
|
|||
android { | |||
compileSdk = 33 | |||
compileSdk = 34 |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
fingerprint/src/main/java/com/fingerprintjs/android/fingerprint/tools/logs/Messages.kt
Outdated
Show resolved
Hide resolved
...nt/src/main/java/com/fingerprintjs/android/fingerprint/info_providers/SensorsInfoProvider.kt
Outdated
Show resolved
Hide resolved
1. moving all platform calls into try-catch block, even in factory code 2. implementing a timeout for platform code execution to avoid infinite hangs 3. adding high-level try-catch blocks for Fingerprinter methods. in case of any unexpected error, the result from DummyResults will be returned
5551948
to
1d3d7d7
Compare
|
||
internal fun Logger.ePleaseReport(throwable: Throwable?) { | ||
e( | ||
msg = "Unexpected error occurred. Feel free to create an issue on Github repository of the fingerprintjs-android library.", |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style. Warning
import java.util.Locale | ||
import java.util.TimeZone | ||
|
||
|
||
@Deprecated(message = DeprecationMessages.UNREACHABLE_SYMBOL_UNINTENDED_PUBLIC_API) | ||
public interface DevicePersonalizationInfoProvider { | ||
public fun ringtoneSource(): String | ||
public fun availableLocales(): Array<String> | ||
public fun availableLocales(): Array<String> // // theoretically, may contain "null" strings for backwards compatibility reasons |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style. Warning
// defaults from Executors.newCachedThreadPool() | ||
ThreadPoolExecutor( | ||
0, Integer.MAX_VALUE, | ||
60L, TimeUnit.SECONDS, |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
Behavioural changes:
MediaCodecInfo
fromCodecInfoProvider
is now guaranteed to havecapabilities
of typeList<String>
instead ofList<String?>
DevicePersonalizationInfoProvider.availableLocales()
is now guaranteed to returnArray<String>
instead ofArray<String?>
It is achieved by converting nullable strings to
"null"
string. This way fingerprints are guaranteed to not be affected.