First of all, nice day to everyone!
My code needs to detect which android version is being used on by means of getprop ro.build.version.release. I do so using systems with root and python for android.
For the time being the devices I tested the code things were working nice but partially of course because I haven't taking into consideration the updates in between new os versions. I just added the new version I was testing on to a dictionary.
So let's say I have this dictionary:
VersionName = {'4.0':"Ice Cream Sandwich", '4.0.4':"Ice Cream Sandwich", '4.1':"Jelly Bean", '4.2':"Jelly Bean", '4.3':"Jelly Bean", '4.4':"KitKat", '5.0':"Lollipop", '5.1':'Lollipop', '6.0':"Marshmallow", '7.1.1':"Nougat"}
I would add:
'4.4.2':'KitKat'
To save and detect the new version I was working on but that's not going to work. To overcome this I just simply made a search to select the first and the last release of an android version.
VersionName = {'Ice Cream Sandwich':['4.0', '4.0.4'], 'Jelly Bean':['4.1', '4.3.1'], 'KitKat':['4.4', '4.4.4'], 'Lollipop':['5.0', '5.1.1'], 'Marshmallow':['6.0', '6.0.1'], 'Nougat':['7.0', '7.1.1']}
The problems comes if the update version is in between the two values.
Given {'KitKat':['4.4', '4.4.4']} and device version 4.4.2 how can I detect if it's part of KitKat
maybe store the min and max as two variables, then do if os(version)> (min value):
then check if os(version) < (max value)
This is how I would approach the problem with the help provided! There are better ways I know that much so if anyone has another method please share.
def DroidName(ReleaseVersion):
# ReleaseVersion = '4.4.2'
VersionValue = {'Ice Cream Sandwich':['4.0', '4.0.4'], 'Jelly Bean':['4.1', '4.3.1'], 'KitKat':['4.4', '4.4.4'], 'Lollipop':['5.0', '5.1.1'], 'Marshmallow':['6.0', '6.0.1'], 'Nougat':['7.0', '7.1.1']}
for i in VersionValue.items():
AndroidName = i[0]
MinimalValue = i[1][0]
MaximunValue = i[1][1]
if ReleaseVersion >= MinimalValue and ReleaseVersion <= MaximunValue:
print AndroidName, ReleaseVersion
break
Related
I have noticed that from time to time, android shows the following log message:
I/OpenGLRenderer( 4958): Davey! duration=1923ms; Flags=1, IntendedVsync=12247...
Does anyone know the reason why my OpenGLRenderer is calling Davey!?
This "Davey!" is here because Dave Burke, VP on Android, cares deeply about jank and performance and filed many, many, many bugs for the engineering teams. This is just a fun nod to him when the system automatically detects jank.
I had the same question. It looks like a name, but the code suggests it isn't (?).
From Android source file frameworks/base/libs/hwui/JankTracker.cpp, around line 177
....
// Log daveys since they are weird and we don't know what they are (b/70339576)
if (totalDuration >= 700_ms) {
static int sDaveyCount = 0;
std::stringstream ss;
ss << "Davey! duration=" << ns2ms(totalDuration) << "ms; ";
....
The logging code was added here: Android 0e89ca2088b7e5424b35d9a564b83847dc0df84a.
Maybe ask the engineer that added the code: John Reck .
"Davey" is a transliteration of the Russian "Дава́й"
It means "come on!" and is an expression used to mean anything from "GO!" (in the sense of 'watch out!') to "COME ON!!!" (in the sense of 'hurry up! go!')
The programmer adding this was probably not Russian but making some kind of Slavic language joke.
I want to access a android device from python to download some photos.
libmtp works from the CLI.
Than pymtp. It's been around for a while but it's designed for python 2 and i'm using python 3. Meanwhile fixed several minor issues but i'm stuck at an error from function get_filelisting
specially this section:
ret = []
next = files
while next:
ret.append(next.contents)
if (next(next.contents) is None):
break
next = next(next.contents)
The error is related to the "next".
That section looks strange to me, i've been coding in python for a while but i'm new to ctypes. Tried a lot of variants, they all failed. The "next" could be confusing with python buildin function so i renamed it to nextpointer and came to this code:
ret = []
nextpointer = files
while nextpointer:
ret.append(nextpointer.contents)
nextpointer = nextpointer.contents.next
It seems to work but did it work by accident ? does it have any design flaws ? Could anyone with experience on python ctypes confirm this a solution ? Any suggestion welcome.
From python2.7 documentation
next(iterator[, default])
Retrieve the next item from the iterator by calling its next() method. If default is given, it is returned if the iterator is
exhausted, otherwise StopIteration is raised.
from python3 documentation
next(iterator[, default])
Retrieve the next item from the iterator by calling its __next__() method. If default is given, it is returned if the iterator is
exhausted, otherwise StopIteration is raised.
Notice that next() method was removed from python3 but the function still exists.
This is all I can say about the next function and .next()/__next__() methods.
I downloaded the pymtp module and get_filelisting() is slightly different from what you posted in your ported code, here it is:
ret = []
next = files
while next:
ret.append(next.contents)
if (next.contents.next == None):
break
next = next.contents.next
If none of this helped you (which probably didn't :D), the version of pymtp library that I am using is 0.0.6 download using pip.
I am referring "Android crypto implementation" document. w.r.t Android 4.3 source.
In point 2 it says The framework starts up, and sees that vold.decrypt is set to "1"
But I am not able to locate the code that does things mentioned in point 2. Is anybody able to locate it? Is it somewhere related to class BackupRestoreConfirmation?
Just a simple git grep will get the all the reference to this property:
cmds/bootanimation/BootAnimation.cpp:276: property_get("vold.decrypt", decrypt, "");
services/java/com/android/server/DevicePolicyManagerService.java:1869: String state = SystemProperties.get("vold.decrypt");
services/java/com/android/server/SystemServer.java:239: String cryptState = SystemProperties.get("vold.decrypt");
services/java/com/android/server/usb/UsbDeviceManager.java:173: boolean dataEncrypted = "1".equals(SystemProperties.get("vold.decrypt"));
And I think the one you need is in DevicePolicyManagerService.java or SystemServer.java
I need to use Android 2.2 (API 8) and I have seen that Normalizer.normalize(text, Normalizer.Form.NFD) is only available from Android API 9.
What can I add to my regex to ignore accents ?
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(text);
for (String keyword : keywords.keySet()) {
String caseInsensitiveRegex = "(?i)\\b" + keyword + "\\b";
Pattern pattern = Pattern.compile(caseInsensitiveRegex);
Matcher m = pattern.matcher(stringBuilder);
while (m.find()){
// Do some stuff
}
}
Thanks per advance for your help ;)
is only available from Android API 9
Android is open sourced project. There's nothing preventing you from grabbing that part of API 9 and putting directly in your app so you will no longer be API dependent and I at the moment I am not seeing any obstacles for doing this in your case.
how can i get android device's platformId,deviceUser,deviceName,deviceModel, deviceOperatingSystem,deviceOSVersion from my program.
Edit: i have already used that Build class and got device id, model and user but for my requirement i need device OS, OS version and platform id.so how can i get them??
thanks
venu
Use android.os.Build.
Here's an example:
StringBuffer buf = new StringBuffer();
buf.append("VERSION.RELEASE {"+Build.VERSION.RELEASE+"}");
buf.append("\nVERSION.INCREMENTAL {"+Build.VERSION.INCREMENTAL+"}");
buf.append("\nVERSION.SDK_INT {"+Build.VERSION.SDK_INT+"}");
buf.append("\nFINGERPRINT {"+Build.FINGERPRINT+"}");
buf.append("\nBOARD {"+Build.BOARD+"}");
buf.append("\nBRAND {"+Build.BRAND+"}");
buf.append("\nDEVICE {"+Build.DEVICE+"}");
buf.append("\nMANUFACTURER {"+Build.MANUFACTURER+"}");
buf.append("\nMODEL {"+Build.MODEL+"}");
Complete android.os.Build documentation is at http://developer.android.com/reference/android/os/Build.html
Note that VERSION.SDK is marked as deprecated, so VERSION.SDK_INT was used instead.
Extending to what CommonsWare suggested, I think here's what you need:
Build.VERSION_CODES: Enumeration of the currently known SDK version codes. These are the values that can be found in SDK. Version numbers increment monotonically with each official platform release.
DONUT : Constant Value: 4 (0x00000004)
ECLAIR : Constant Value: 5 (0x00000005)
ECLAIR_0_1 : Constant Value: 6 (0x00000006)
ECLAIR_MR1 : Constant Value: 7 (0x00000007)
FROYO : Constant Value: 8 (0x00000008)
GINGERBREAD : Constant Value: 9 (0x00000009)
Build class: Information about the current build, extracted from system properties.
Build.MODEL
Build.PRODUCT
Build.VERSION:
Various version strings.
Build.VERSION.RELEASE
Build.VERSION.SDK_INT