Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: tools/telemetry/telemetry/core/platform/profiler/oomkiller_profiler.py

Issue 338353004: [Android] Switch KillAll, StartActivity, and BroadcastIntent to DeviceUtils. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: appeasing windows Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/telemetry/telemetry/core/platform/profiler/android_profiling_helper.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os 5 import os
6 6
7 from telemetry.core.backends.chrome import android_browser_finder 7 from telemetry.core.backends.chrome import android_browser_finder
8 from telemetry.core.platform import profiler 8 from telemetry.core.platform import profiler
9 from telemetry.util import support_binaries 9 from telemetry.util import support_binaries
10 10
11 from pylib.device import intent
11 12
12 class UnableToFindApplicationException(Exception): 13 class UnableToFindApplicationException(Exception):
13 """Exception when unable to find a launched application""" 14 """Exception when unable to find a launched application"""
14 15
15 def __init__(self, application): 16 def __init__(self, application):
16 super(UnableToFindApplicationException, self).__init__() 17 super(UnableToFindApplicationException, self).__init__()
17 self.application = application 18 self.application = application
18 19
19 def __str__(self): 20 def __str__(self):
20 return repr(self.application) 21 return repr(self.application)
(...skipping 11 matching lines...) Expand all
32 mem_consumer_path = support_binaries.FindPath( 33 mem_consumer_path = support_binaries.FindPath(
33 os.path.join('apks', 'MemConsumer.apk'), 'android') 34 os.path.join('apks', 'MemConsumer.apk'), 'android')
34 assert mem_consumer_path, ('Could not find memconsumer app. Please build ' 35 assert mem_consumer_path, ('Could not find memconsumer app. Please build '
35 'memconsumer target.') 36 'memconsumer target.')
36 self._browser_backend.adb.Install(mem_consumer_path) 37 self._browser_backend.adb.Install(mem_consumer_path)
37 self._browser_backend.adb.GoHome() 38 self._browser_backend.adb.GoHome()
38 self._platform_backend.LaunchApplication( 39 self._platform_backend.LaunchApplication(
39 'org.chromium.memconsumer/.MemConsumer', 40 'org.chromium.memconsumer/.MemConsumer',
40 '--ei memory 20') 41 '--ei memory 20')
41 # Bring the browser to the foreground after launching the mem consumer 42 # Bring the browser to the foreground after launching the mem consumer
42 self._browser_backend.adb.StartActivity(browser_backend.package, 43 self._browser_backend.adb.device().StartActivity(
43 browser_backend.activity, 44 intent.Intent(package=browser_backend.package,
44 True) 45 activity=browser_backend.activity),
46 blocking=True)
45 47
46 @classmethod 48 @classmethod
47 def name(cls): 49 def name(cls):
48 return 'oomkiller' 50 return 'oomkiller'
49 51
50 @classmethod 52 @classmethod
51 def is_supported(cls, browser_type): 53 def is_supported(cls, browser_type):
52 if browser_type == 'any': 54 if browser_type == 'any':
53 return android_browser_finder.CanFindAvailableBrowsers() 55 return android_browser_finder.CanFindAvailableBrowsers()
54 return browser_type.startswith('android') 56 return browser_type.startswith('android')
55 57
56 @classmethod 58 @classmethod
57 def WillCloseBrowser(cls, browser_backend, platform_backend): 59 def WillCloseBrowser(cls, browser_backend, platform_backend):
58 browser_backend.adb.CloseApplication('org.chromium.memconsumer') 60 browser_backend.adb.CloseApplication('org.chromium.memconsumer')
59 61
60 def CollectProfile(self): 62 def CollectProfile(self):
61 missing_applications = self._MissingApplications() 63 missing_applications = self._MissingApplications()
62 if not len(missing_applications): 64 if not len(missing_applications):
63 return [] 65 return []
64 raise UnableToFindApplicationException(', '.join(missing_applications)) 66 raise UnableToFindApplicationException(', '.join(missing_applications))
65 67
66 def _MissingApplications(self): 68 def _MissingApplications(self):
67 # TODO(qsr): Add com.android.launcher to the list, when the reason why the 69 # TODO(qsr): Add com.android.launcher to the list, when the reason why the
68 # launcher is often killed is understood. 70 # launcher is often killed is understood.
69 must_have_apps = [ 71 must_have_apps = [
70 'org.chromium.memconsumer', 72 'org.chromium.memconsumer',
71 ] 73 ]
72 return [app for app in must_have_apps if 74 return [app for app in must_have_apps if
73 not self._platform_backend.IsApplicationRunning(app)] 75 not self._platform_backend.IsApplicationRunning(app)]
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/core/platform/profiler/android_profiling_helper.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698