-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Implementing automatic "safe display mode" for e-ink devices. #17646
Changes from 1 commit
e6efbdc
d7a3cf9
8967aec
fc29239
87a54de
2f4fbf7
b991ef2
0836814
4ce520c
36f6448
2ea33e0
8ae2dd0
9fb9fd0
b384c00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,9 @@ class EInkDeviceIdentifier { | |
get() = originalModel.lowercase(Locale.ROOT).trim() | ||
|
||
companion object { | ||
val current: DeviceInfo | ||
get() = DeviceInfo(Build.MANUFACTURER, Build.MODEL) | ||
val current: DeviceInfo by lazy { | ||
DeviceInfo(Build.MANUFACTURER, Build.MODEL) | ||
} | ||
} | ||
} | ||
|
||
|
@@ -122,7 +123,7 @@ class EInkDeviceIdentifier { | |
DeviceInfo("barnesandnoble", "bnrv520"), | ||
DeviceInfo("barnesandnoble", "bnrv700"), | ||
DeviceInfo("barnesandnoble", "evk_mx6s1"), | ||
DeviceInfo("barnesandnoble","ereader"), // probably a eink device | ||
DeviceInfo("barnesandnoble", "ereader"), // Probably an eink device | ||
DeviceInfo("freescale", "bnrv510"), | ||
DeviceInfo("freescale", "bnrv520"), | ||
DeviceInfo("freescale", "bnrv700"), | ||
|
@@ -134,20 +135,20 @@ class EInkDeviceIdentifier { | |
DeviceInfo("sony", "dpt-rp1"), | ||
DeviceInfo("onyx", "tagus_pokep"), | ||
DeviceInfo("xiaomi", "xiaomi_reader"), | ||
DeviceInfo("artatech", "pri"), // probably a eink device | ||
DeviceInfo("crema", "crema-0710c"), // probably a eink device | ||
DeviceInfo("crema", "crema-0670c"), // probably a eink device | ||
DeviceInfo("artatech", "pri"), // Probably an eink device | ||
DeviceInfo("crema", "crema-0710c"), // Probably an eink device | ||
DeviceInfo("crema", "crema-0670c"), // Probably an eink device | ||
|
||
// Source: https://github.com/plotn/coolreader/blob/e5baf0607e678468aa045053ba5f092164aa1dd7/android/src/org/coolreader/crengine/DeviceInfo.java | ||
DeviceInfo("barnesandnoble", "NOOK"), | ||
DeviceInfo("barnesandnoble", "bnrv350"), | ||
DeviceInfo("barnesandnoble", "bnrv300"), | ||
DeviceInfo("barnesandnoble", "bnrv500"), | ||
DeviceInfo("sony", "PRS-T"), // probably a eink device | ||
DeviceInfo("sony", "PRS-T"), // Probably an eink device | ||
DeviceInfo("dns", "DNS Airbook EGH"), | ||
|
||
// Source: https://github.com/ankidroid/Anki-Android/issues/17618 | ||
DeviceInfo("Viwoods", "Viwoods AiPaper"), | ||
DeviceInfo("Viwoods", "Viwoods AiPaper") | ||
) | ||
|
||
private val eInkManufacturersList = setOf( | ||
|
@@ -167,7 +168,7 @@ class EInkDeviceIdentifier { | |
"dns", | ||
"crema", | ||
"kindle", | ||
"bigme", | ||
"bigme" | ||
) | ||
|
||
/** | ||
|
@@ -185,15 +186,17 @@ class EInkDeviceIdentifier { | |
for (device in knownEInkDevices) { | ||
// Check if the device is an exact match. | ||
if (currentDevice.manufacturer == device.manufacturer && | ||
currentDevice.model == device.model) { | ||
currentDevice.model == device.model | ||
) { | ||
isExactMatch = true | ||
break | ||
} | ||
// Check if the device is a partial match. Partial matches are detected using substring matching. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? partial matches are defined as a match on either manufacturer [or casing issues] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am reporting potential e-ink if there is a manufacturer match or partial match , the partial match algorithm is that it checks if the current device's manufaturer and model is substring of any of the pair of manufaturer and model in the knowEInkDevices set or vice-versa as in the below source There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. few more sources doing the same |
||
if ((currentDevice.manufacturer.contains(device.manufacturer) || | ||
device.manufacturer.contains(currentDevice.manufacturer)) && | ||
(currentDevice.model.contains(device.model) || | ||
device.model.contains(currentDevice.model))) { | ||
device.model.contains(currentDevice.model)) | ||
) { | ||
isPartialMatch = true | ||
} | ||
} | ||
|
@@ -202,7 +205,7 @@ class EInkDeviceIdentifier { | |
Timber.d("Confirmed E-ink device: $currentDevice") | ||
return true | ||
} | ||
//if the device is a partial match or if the manufacturer is in the list of known E-ink manufacturers then report it | ||
// If the device is a partial match or if the manufacturer is in the list of known E-ink manufacturers then report it | ||
if (isPartialMatch || eInkManufacturersList.contains(currentDevice.manufacturer)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Split out obtaining the output, and performing actions based on the outputs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. both the manufaturer match and partial match results in repoting the device only so why should i seperate them |
||
Timber.w("Potential E-ink device: $currentDevice") | ||
ACRA.errorReporter.handleSilentException(Exception("Potential E-ink device: $currentDevice")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. like this right ?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added better diagnostics in: #17686 We should extract this and also use it here, so we get a useful fingerprint |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These shouldn't recompute the value each time if the function is pure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah you are right , i will fix that