Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / tools / telemetry / telemetry / core / platform / profiler / android_prebuilt_profiler_helper.py
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
3 # found in the LICENSE file.
4
5 """Android-specific, downloads and installs pre-built profilers.
6
7 These pre-built binaries are stored in Cloud Storage, and they were
8 built from AOSP source. Specific profilers using this helper class contain
9 more detailed information.
10 """
11
12 import os
13
14 from telemetry import decorators
15 from telemetry.core import util
16 from telemetry.page import cloud_storage
17
18
19 _DEVICE_PROFILER_DIR = '/data/local/tmp/profilers/'
20
21
22 def GetDevicePath(profiler_binary):
23   return os.path.join(_DEVICE_PROFILER_DIR, os.path.basename(profiler_binary))
24
25
26 def GetHostPath(profiler_binary):
27   return os.path.join(util.GetTelemetryDir(),
28                       'bin', 'prebuilt', 'android', profiler_binary)
29
30
31 def GetIfChanged(profiler_binary):
32   cloud_storage.GetIfChanged(GetHostPath(profiler_binary),
33                              cloud_storage.PUBLIC_BUCKET)
34
35
36 @decorators.Cache
37 def InstallOnDevice(adb, profiler_binary):
38   GetIfChanged(profiler_binary)
39   adb.PushIfNeeded(GetHostPath(profiler_binary), GetDevicePath(profiler_binary))
40   adb.RunShellCommand('chmod 777 ' + GetDevicePath(profiler_binary))