0

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

2
  • Is it now possible to do android using python? Is this an official thing. Commented Mar 18, 2017 at 11:54
  • Sure it is @ChrisHarris! In fact it's been around for awhile. A project started on googlecode and that now is being maintained on github. You get an RPC server that translate python calls to android native java instructions if I'm not wrong in the concept. Commented Mar 18, 2017 at 12:08

2 Answers 2

1

maybe store the min and max as two variables, then do if os(version)> (min value): then check if os(version) < (max value)

Sign up to request clarification or add additional context in comments.

1 Comment

I'll give it a try then. I tried something similar but I there was a bad evaluation of values. Thanks
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.