Bug 1185969 - [mozdevice] Allow to use android preview releases. r=bc

--HG--
extra : commitid : Ea3gZOnjoy6
extra : rebase_source : 822864eb9507c5650bc9ef29d308ffff63c44b25
This commit is contained in:
Julien Pagès 2015-10-28 17:22:16 +01:00
parent 7e9dbab9aa
commit 5fe647171b
5 changed files with 69 additions and 6 deletions

View File

@ -17,6 +17,7 @@ _HARNESS_FILES = \
$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py \
$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py \
$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/droid.py \
$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/version_codes.py \
$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/Zeroconf.py \
$(topsrcdir)/testing/mozbase/moznetwork/moznetwork/moznetwork.py \
$(topsrcdir)/build/mobile/b2gautomation.py \

View File

@ -38,6 +38,7 @@ TEST_HARNESS_FILES.testing.mochitest += [
'/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py',
'/testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py',
'/testing/mozbase/mozdevice/mozdevice/droid.py',
'/testing/mozbase/mozdevice/mozdevice/version_codes.py',
'/testing/mozbase/mozdevice/mozdevice/Zeroconf.py',
'/testing/mozbase/moznetwork/moznetwork/moznetwork.py',
'b2g_start_script.js',

View File

@ -6,8 +6,9 @@ import os
import re
import time
import version_codes
from adb import ADBDevice, ADBError
from distutils.version import StrictVersion
class ADBAndroid(ADBDevice):
@ -315,9 +316,9 @@ class ADBAndroid(ADBDevice):
:raises: * ADBTimeoutError
* ADBError
"""
version = self.shell_output("getprop ro.build.version.release",
version = self.shell_output("getprop ro.build.version.sdk",
timeout=timeout, root=root)
if StrictVersion(version) >= StrictVersion('3.0'):
if int(version) >= version_codes.HONEYCOMB:
self.shell_output("am force-stop %s" % app_name,
timeout=timeout, root=root)
else:

View File

@ -8,12 +8,13 @@ import re
import threading
import time
import version_codes
from Zeroconf import Zeroconf, ServiceBrowser
from devicemanager import ZeroconfListener
from devicemanagerADB import DeviceManagerADB
from devicemanagerSUT import DeviceManagerSUT
from devicemanager import DMError
from distutils.version import StrictVersion
class DroidMixin(object):
"""Mixin to extend DeviceManager with Android-specific functionality"""
@ -131,8 +132,8 @@ class DroidMixin(object):
:param appName: Name of application (e.g. `com.android.chrome`)
"""
version = self.shellCheckOutput(["getprop", "ro.build.version.release"])
if StrictVersion(version) >= StrictVersion('3.0'):
version = self.shellCheckOutput(["getprop", "ro.build.version.sdk"])
if int(version) >= version_codes.HONEYCOMB:
self.shellCheckOutput([ "am", "force-stop", appName ], root=self._stopApplicationNeedsRoot)
else:
num_tries = 0

View File

@ -0,0 +1,59 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
"""
VERSION CODES of the android releases.
See http://developer.android.com/reference/android/os/Build.VERSION_CODES.html.
"""
# Magic version number for a current development build, which has
# not yet turned into an official release.
CUR_DEVELOPMENT = 10000
# October 2008: The original, first, version of Android
BASE = 1
# February 2009: First Android update, officially called 1.1
BASE_1_1 = 2
# May 2009: Android 1.5
CUPCAKE = 3
# September 2009: Android 1.6
DONUT = 4
# November 2009: Android 2.0
ECLAIR = 5
# December 2009: Android 2.0.1
ECLAIR_0_1 = 6
# January 2010: Android 2.1
ECLAIR_MR1 = 7
# June 2010: Android 2.2
FROYO = 8
# November 2010: Android 2.3
GINGERBREAD = 9
# February 2011: Android 2.3.3
GINGERBREAD_MR1 = 10
# February 2011: Android 3.0
HONEYCOMB = 11
# May 2011: Android 3.1
HONEYCOMB_MR1 = 12
# June 2011: Android 3.2
HONEYCOMB_MR2 = 13
# October 2011: Android 4.0
ICE_CREAM_SANDWICH = 14
# December 2011: Android 4.0.3
ICE_CREAM_SANDWICH_MR1 = 15
# June 2012: Android 4.1
JELLY_BEAN = 16
# November 2012: Android 4.2
JELLY_BEAN_MR1 = 17
# July 2013: Android 4.3
JELLY_BEAN_MR2 = 18
# October 2013: Android 4.4
KITKAT = 19
# Android 4.4W
KITKAT_WATCH = 20
# Lollilop
LOLLIPOP = 21
LOLLIPOP_MR1 = 22
# M
M = 23