- add sources.
[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.core import util
15 from telemetry.page import cloud_storage
16
17
18 _DEVICE_PROFILER_DIR = '/data/local/tmp/profilers/'
19
20
21 def GetDevicePath(profiler_binary):
22   return os.path.join(_DEVICE_PROFILER_DIR, os.path.basename(profiler_binary))
23
24
25 def GetHostPath(profiler_binary):
26   return os.path.join(util.GetTelemetryDir(),
27                       'bin', 'prebuilt', 'android', profiler_binary)
28
29
30 def GetIfChanged(profiler_binary):
31   cloud_storage.GetIfChanged(cloud_storage.PUBLIC_BUCKET,
32                              GetHostPath(profiler_binary))
33
34
35 def InstallOnDevice(adb, profiler_binary):
36   GetIfChanged(profiler_binary)
37   adb.Adb().PushIfNeeded(GetHostPath(profiler_binary),
38                          GetDevicePath(profiler_binary))
39   adb.Adb().RunShellCommand('chmod 777 ' + GetDevicePath(profiler_binary))