| Conditions | 6 |
| Total Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | import logging |
||
| 11 | @classmethod |
||
| 12 | def is_android(cls): |
||
| 13 | if cls._is_android is not None: |
||
| 14 | return cls._is_android |
||
| 15 | |||
| 16 | try: |
||
| 17 | # Check android platform criteria |
||
| 18 | if not os.path.exists('/system/build.prop'): |
||
| 19 | # Couldn't find "build.prop" file |
||
| 20 | cls._is_android = False |
||
| 21 | elif os.path.exists('/system/lib/libandroid_runtime.so'): |
||
| 22 | # Found "libandroid_runtime.so" file |
||
| 23 | log.info('Detected android system (found the "libandroid_runtime.so" file)') |
||
| 24 | cls._is_android = True |
||
| 25 | elif '-google' in platform.python_compiler(): |
||
| 26 | # Found "-google" in the python compiler attribute |
||
| 27 | log.info('Detected android system (found "-google" in the python compiler attribute)') |
||
| 28 | cls._is_android = True |
||
| 29 | else: |
||
| 30 | log.warn('Found the "build.prop" file, but could\'t confirm if the system is running android') |
||
| 31 | cls._is_android = False |
||
| 32 | |||
| 33 | except Exception, ex: |
||
| 34 | log.warn('Unable to check if the system is running android: %s', ex, exc_info=True) |
||
| 35 | |||
| 36 | return cls._is_android |
||
| 37 |