[TIMOB-25878] Android: Modify "Ti.Platform.architecture" to provide consistent results like iOS
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-10-25T21:29:46.000+0000 |
Affected Version/s | Release 7.1.1 |
Fix Version/s | n/a |
Components | Android |
Labels | analytics, android, architecture |
Reporter | Joshua Quick |
Assignee | Gary Mathews |
Created | 2018-03-17T04:13:24.000+0000 |
Updated | 2018-10-25T21:29:52.000+0000 |
Description
*Summary:*
Currently, the
Ti.Platform.architecture
property on Android is difficult to use compared to iOS and Windows. It commonly fails to identify the device's architecture by returning "Unknown" or returns a difficult to parse string containing version and revision numbers appended to it.
Below is a list of all architecture strings that has been reported to our analytics system:
'Unknown'
'ARMv7 Processor rev 0 (v7l)'
'ARMv7 Processor rev 4 (v7l)'
'AArch64 Processor rev 4 (aarch64)'
'ARMv7 Processor rev 3 (v7l)'
'AArch64 Processor rev 1 (aarch64)'
'ARMv7 Processor rev 5 (v7l)'
'AArch64 Processor rev 2 (aarch64)'
'AArch64 Processor rev 3 (aarch64)'
'AArch64 Processor rev 0 (aarch64)'
'ARMv7 Processor rev 1 (v7l)'
'ARMv7 Processor rev 2 (v7l)'
'ARMv8 Processor rev 2 (v8l)'
'ARMv7 Processor rev 8 (v7l)'
'ARMv7 Processor rev 10 (v7l)'
'ARMv7 Processor rev 9 (v7l)'
'ARMv7 processor rev 4 (v7l)'
'64-bit ARMv8 Processor rev 0 (v7l)'
'AArch64 Processor rev 13 (aarch64)'
'ARMv7 processor rev 1 (v7l)'
'sc7731 rev 5 (v7l)'
'64-bit ARMv8 Processor rev 1 (v7l)'
'NVIDIA Denver 1.0 rev 0 (aarch64)'
'MT6732 rev 2 (v7l)'
'AArch64 Processor rev 12 (aarch64)'
'ARMv6-compatible processor rev 5 (v6l)'
'6591 rev 4 (v7l)processor'
'ARMv7'
'mtk6580L rev 5 (v7l)'
'ARMv8 Processor rev 4 (aarch64)'
'Qualcomm Snapdragon 800'
'UNIVERSAL5410'
'ARMv7 Processor rev 12 (v7l)'
'MT6592 2.0GHZ (Octa-Core) rev 5 (v7l)'
'ARMv7 Processor rev 3 srev 0x23 (v7l)'
'MTK6580 rev 5 (v7l)'
'ARMv7 Processor rev 2 srev 0x23 (v7l)'
'ARMv7 Processor rev 6 (v7l)'
'S805'
'ARMv8 processor rev 1 (aarch64)'
'UNKNOWN rev 0 (UNKNOWN)'
'ARMv7 Processor'
'Quad-Core ARMv7 Processor'
'ARMv8 Processor rev 5 (v7l)'
'S905'
'ARMv7 Processor rev 5 rev 5 (v7l)'
'ARMv7 processor (v7l)'
'Quadcore Cortex-A71.2GHz rev 5 (v7l)'
'arm'
'MT6592 2.0GHZ rev 5 (v7l)'
I've tested the following devices and they return the following:
||Device Name||Returned Architecture String||
|Emulator|Unknown|
|Pixel XL|Unknown|
|Galaxy Tab 3|Unknown|
|Galaxy Nexus|ARMv7 Processor rev 10 (v7l)|
|Galaxy Note 2|ARMv7 Processor rev 0 (v7l)|
|Nexus 4|ARMv7 Processor rev 2 (v7l)|
|Nexus 5|ARMv7 Processor rev 0 (v7l)|
|Nexus 10|ARMv7 Processor rev 4 (v7l)|
|Pixel 2|AArch64 Processor rev 1 (aarch64)|
|Amazon Fire HD 8 (7th gen)|AArch64 Processor rev 3 (aarch64)|
Note that "Unknown" is the most commonly reported architecture name in our analytics system. Odds are most of these are coming from Google's Android emulator.
*Cause:*
The Ti.Platform.architecture
property uses our APS library to fetch the architecture name, which attempts to fetch this string from a system file named "cpuinfo". This is an undocumented feature that we should avoid. Especially since it's proven to be unreliable and causes "Unknown" to be returned.
[APSAnalyticsHelper.java#L339](https://github.com/appcelerator/aps_sdk/blob/195633dd10a37d96ecf52be35c0c712dff5ef331/android/analytics/APSAnalytics/src/main/java/com/appcelerator/aps/APSAnalyticsHelper.java#L339)
*Recommended Solution:*
The APS library's getArchitecture()
method should be changed to fetch architecture via Google's android.os.Build
class using its Build.SUPPORTED_ABIS
and Build.CPU_ABI
constants.
https://developer.android.com/reference/android/os/Build.html
I've tested the above constants on real Android devices and in the emulator. The above always return strings matching the APK's lib folder architecture subfolder names, where the *.so
C/C++ libraries are kept. With the only exception being with the "x86_64" being returned by the emulator. For example:
* armeabi-v7a
* arm64-v8a
* x86
* x86_64
*Ideal Solution:*
Android should ideally return the same architecture string types that iOS does. This would make it easier to work with from a portability standpoint. It would also make it easier from an analytics standpoint to identify popular architectures between platforms.
iOS fetches CPU architecture from the APS library here...
[APSUtility.m#L24](https://github.com/appcelerator/aps_sdk/blob/195633dd10a37d96ecf52be35c0c712dff5ef331/ios/support/analytics/APSAnalytics/APSUtility.m#L24)
iOS currently returns the following hardcoded strings:
* x86_64
* arm
* armv6
* armv7
* armv7s
* arm64
* i386
*Work-Around:*
You can use hyperloop to fetch the architecture using the above mentioned Java "Build" class constants.
// WARNING: You must add "hyperloop" module to the project for the below to work.
var buildClass = require("android.os.Build");
if (Ti.Platform.Android.API_LEVEL >= 21) {
Ti.API.info("@@@ Build.SUPPORTED_ABIS[0]: " + buildClass.SUPPORTED_ABIS[0]);
} else {
Ti.API.info("@@@ Build.CPU_ABI: " + buildClass.CPU_ABI);
}
aps_sdk: https://github.com/appcelerator/aps_sdk/pull/314
[~gmathews], this was merged. Can we close it?