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 @property 19 def android_action_runner(self): 20 return self._android_action_runner 21 22 @property 23 def system_ui(self): 24 """Returns an AppUi object to interact with Android's system UI. 25 26 See devil.android.app_ui for the documentation of the API provided. 27 """ 28 return self._platform_backend.GetSystemUi() 29 30 def IsSvelte(self): 31 return self._platform_backend.IsSvelte() 32 33 def LaunchAndroidApplication(self, 34 start_intent, 35 is_app_ready_predicate=None, 36 app_has_webviews=True): 37 """Launches an Android application given the intent. 38 39 Args: 40 start_intent: The intent to use to start the app. 41 is_app_ready_predicate: A predicate function to determine 42 whether the app is ready. This is a function that takes an 43 AndroidApp instance and return a boolean. When it is not passed in, 44 the app is ready when the intent to launch it is completed. 45 app_has_webviews: A boolean indicating whether the app is expected to 46 contain any WebViews. If True, the app will be launched with 47 appropriate webview flags, and the GetWebViews method of the returned 48 object may be used to access them. 49 50 Returns: 51 A reference to the android_app launched. 52 """ 53 self._platform_backend.DismissCrashDialogIfNeeded() 54 app_backend = android_app_backend.AndroidAppBackend( 55 self._platform_backend, start_intent, is_app_ready_predicate, 56 app_has_webviews) 57 return android_app.AndroidApp(app_backend, self._platform_backend) 58