GeezerVison is showing github.com — android: add platform.android_ver() · Issue #71042 · python/cpython
android: add platform.android_ver() #71042Description
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = None
created_at = <Date 2016-04-26.13:18:31.861>
labels = ['3.7', 'type-feature', 'library', 'build']
title = 'android: add platform.android_ver()'
updated_at = <Date 2019-12-10.08:09:38.614>
user = 'https://github.com/xdegaye'
bugs.python.org fields:
activity = <Date 2019-12-10.08:09:38.614>
actor = 'xdegaye'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)', 'Cross-Build']
creation = <Date 2016-04-26.13:18:31.861>
creator = 'xdegaye'
dependencies = []
files = ['42606', '42721', '42723', '42813']
hgrepos = []
issue_num = 26855
keywords = ['patch']
message_count = 23.0
messages = ['264277', '264317', '264369', '264373', '264374', '264376', '264377', '264852', '264854', '264856', '265145', '265294', '265307', '267409', '267413', '267415', '280147', '280166', '307662', '307667', '307672', '307685', '308040']
nosy_count = 6.0
nosy_names = ['lemburg', 'vstinner', 'pmpp', 'Roman.Evstifeev', 'Alex.Willmer', 'yan12125']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'patch review'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue26855'
versions = ['Python 3.7']
Linked PRs
Activityxdegaye commented on Apr 26, 2016 MannequinAuthor More actions The attached patch misses a test case.
Also how can we be sure that the '/system/build.prop' file may be guaranteed to exist on all android devices ?
It is difficult to get a reliable information on the android infrastructure when the information does not relate to the java libraries. yan12125 commented on Apr 26, 2016 xdegaye commented on Apr 27, 2016 MannequinAuthor More actions The android/api-level.h header exists at all the android API levels and define __ANDROID_API__ as, for example at level 21:
#define __ANDROID_API__ 21
So it is possible to get the sdk version from here, and maybe forget about the release version. yan12125 commented on Apr 27, 2016 Isn't this macro used in compile time? I thought android_ver() aims to check runtime versions. malemburg commented on Apr 27, 2016 If the file is guaranteed to exist on most modern Android platforms, this sounds like a good approach.
Perhaps you could add support to fallback to running getprop instead, if the file doesn't exist or cannot be parsed ?! malemburg commented on Apr 27, 2016 Some screenshots showing different file contents:
I think exposing codename and incremental may also make sense to get a complete picture.
ro.product also has a lot of useful entries which could be used for some of the other platform APIs such as uname().
yan12125 commented on Apr 27, 2016 xdegaye changed the title [-]add platform.android_ver() for android[/-] [+]android: add platform.android_ver()[/+] on May 3, 2016yan12125 commented on May 4, 2016 malemburg commented on May 4, 2016 On 04.05.2016 21:47, Chi Hsuan Yen wrote:
- Should Android 4.1 supported? If not pass_fds and logics for deriving it can be removed.
According to http://www.droid-life.com/tag/distribution/ the Jelly
Bean versions (4.1, 4.2 and 4.3) still have a sizable market
share, so if it's not too much trouble, I think supporting 4.1 would
be a plus.
- I can't find ro.build.version.full on any device/emulator I have access to. Maybe it should be removed due to low popularity?
Agreed. yan12125 commented on May 4, 2016 Version 2 attached. Removed ro.build.version.full. yan12125 commented on May 8, 2016 xdegaye commented on May 11, 2016 MannequinAuthor More actions IMHO returning an integer for the sdk field would be better. The patch could use shutil.which() to avoid subprocess calls when getprop is not available. It would be better to use a 'try/except ValueError' clause instead of isdigit(). The OSError and UnicodeDecodeError exceptions should not be masked, as well as ValueError if sdk cannot be parsed as an int. vstinner commented on Dec 5, 2017 xdegaye commented on Dec 5, 2017 MannequinAuthor More actions I cannot find a reference to the "build.prop" file in the Android documentation but google answers at the question ' what is "build.prop"':
The “build.prop” file is a system file that exists on every Android device. The file contains build information and other system properties which are used throughout the operating system.
and stackoverflow is thriving with questions on how to edit this file.
The file contains part of the information returned by the getprop command and all the information we are needing here.
Here is its content and access rights on an android-24-x86_64 emulator:
generic_x86_64:/data/local/tmp/python $ ls -al /system/build.prop
-rw-r--r-- 1 root root 2083 2017-07-12 22:01 /system/build.prop
generic_x86_64:/data/local/tmp/python $ cat /system/build.prop
# begin build properties
# autogenerated by buildinfo.sh
ro.build.id=NYC
ro.build.display.id=sdk_phone_x86_64-userdebug 7.0 NYC 4174735 test-keys
ro.build.version.incremental=4174735
ro.build.version.sdk=24
ro.build.version.preview_sdk=0
ro.build.version.codename=REL
ro.build.version.all_codenames=REL
ro.build.version.release=7.0
ro.build.version.security_patch=2017-06-05
ro.build.version.base_os=
ro.build.date=Wed Jul 12 19:46:52 UTC 2017
ro.build.date.utc=1499888812
ro.build.type=userdebug
ro.build.user=android-build
ro.build.host=wphl5.hot.corp.google.com
ro.build.tags=test-keys
ro.build.flavor=sdk_phone_x86_64-userdebug
ro.product.model=Android SDK built for x86_64
ro.product.brand=Android
ro.product.name=sdk_phone_x86_64
ro.product.device=generic_x86_64
ro.product.board=
# ro.product.cpu.abi and ro.product.cpu.abi2 are obsolete,
# use ro.product.cpu.abilist instead.
ro.product.cpu.abi=x86_64
ro.product.cpu.abilist=x86_64,x86
ro.product.cpu.abilist32=x86
ro.product.cpu.abilist64=x86_64
ro.product.manufacturer=unknown
ro.product.locale=en-US
ro.wifi.channels=
ro.board.platform=
# ro.build.product is obsolete; use ro.product.device
ro.build.product=generic_x86_64
ro.product.cpu.abilist=x86_64,x86
ro.product.cpu.abilist32=x86
ro.product.cpu.abilist64=x86_64
ro.product.manufacturer=unknown
ro.product.locale=en-US
ro.wifi.channels=
ro.board.platform=
# ro.build.product is obsolete; use ro.product.device
ro.build.product=generic_x86_64
# Do not try to parse description, fingerprint, or thumbprint
ro.build.description=sdk_phone_x86_64-userdebug 7.0 NYC 4174735 test-keys
ro.build.fingerprint=Android/sdk_phone_x86_64/generic_x86_64:7.0/NYC/4174735:userdebug/test-keys
ro.build.characteristics=emulator
# end build properties
#
# from build/target/board/generic_x86_64/system.prop
#
#
# system.prop for generic sdk
#
rild.libpath=/system/lib/libreference-ril.so
rild.libargs=-d /dev/ttyS0
#
# ADDITIONAL_BUILD_PROPERTIES
#
ro.config.notification_sound=OnTheHunt.ogg
ro.config.alarm_alert=Alarm_Classic.ogg
persist.sys.dalvik.vm.lib.2=libart.so
dalvik.vm.isa.x86_64.variant=x86_64
dalvik.vm.isa.x86_64.features=default
dalvik.vm.isa.x86.variant=x86
dalvik.vm.isa.x86.features=default
dalvik.vm.lockprof.threshold=500
xmpp.auto-presence=true
ro.config.nocheckin=yes
net.bt.name=Android
dalvik.vm.stack-trace-file=/data/anr/traces.txt vstinner commented on Dec 5, 2017 "-rw-r--r-- 1 root root 2083 2017-07-12 22:01 /system/build.prop" so
anyone can *read* the file. Maybe we can write a cheap parser for it,
instead of spawning a subprocess or relying on a private function
which may be removed in the near future? xdegaye commented on Dec 5, 2017 MannequinAuthor More actions vstinner commented on Dec 11, 2017
Yes, and fall back to spawning getprop if that fails.
I suggest to start simple. Parsing a text file is simple, spawning a subprocess can have annoying side effects :-( mhsmith commented on Feb 8, 2024 We're currently discussing PEP 738, which contains a different specification for android_ver. Please post any comments here:
MetadataMetadataStatusShow more project fields
DevelopmentNo branches or pull requestsIssue actions
|