• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2014 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from telemetry.core import android_action_runner
6from telemetry.core import platform
7from telemetry.internal.app import android_app
8from telemetry.internal.backends import android_app_backend
9
10
11class AndroidPlatform(platform.Platform):
12
13  def __init__(self, platform_backend):
14    super(AndroidPlatform, self).__init__(platform_backend)
15    self._android_action_runner = android_action_runner.AndroidActionRunner(
16        platform_backend)
17
18  def Initialize(self):
19    self._platform_backend.Initialize()
20
21  @property
22  def android_action_runner(self):
23    return self._android_action_runner
24
25  @property
26  def system_ui(self):
27    """Returns an AppUi object to interact with Android's system UI.
28
29    See devil.android.app_ui for the documentation of the API provided.
30    """
31    return self._platform_backend.GetSystemUi()
32
33  def IsSvelte(self):
34    return self._platform_backend.IsSvelte()
35
36  def LaunchAndroidApplication(self,
37                               start_intent,
38                               is_app_ready_predicate=None,
39                               app_has_webviews=True):
40    """Launches an Android application given the intent.
41
42    Args:
43      start_intent: The intent to use to start the app.
44      is_app_ready_predicate: A predicate function to determine
45          whether the app is ready. This is a function that takes an
46          AndroidApp instance and return a boolean. When it is not passed in,
47          the app is ready when the intent to launch it is completed.
48      app_has_webviews: A boolean indicating whether the app is expected to
49          contain any WebViews. If True, the app will be launched with
50          appropriate webview flags, and the GetWebViews method of the returned
51          object may be used to access them.
52
53    Returns:
54      A reference to the android_app launched.
55    """
56    self._platform_backend.DismissCrashDialogIfNeeded()
57    app_backend = android_app_backend.AndroidAppBackend(
58        self._platform_backend, start_intent, is_app_ready_predicate,
59        app_has_webviews)
60    return android_app.AndroidApp(app_backend, self._platform_backend)
61