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 7These pre-built binaries are stored in Cloud Storage, and they were 8built from AOSP source. Specific profilers using this helper class contain 9more detailed information. 10""" 11 12import os 13 14from telemetry.core import util 15from telemetry.page import cloud_storage 16 17 18_DEVICE_PROFILER_DIR = '/data/local/tmp/profilers/' 19 20 21def GetDevicePath(profiler_binary): 22 return os.path.join(_DEVICE_PROFILER_DIR, os.path.basename(profiler_binary)) 23 24 25def GetHostPath(profiler_binary): 26 return os.path.join(util.GetTelemetryDir(), 27 'bin', 'prebuilt', 'android', profiler_binary) 28 29 30def GetIfChanged(profiler_binary): 31 cloud_storage.GetIfChanged(cloud_storage.PUBLIC_BUCKET, 32 GetHostPath(profiler_binary)) 33 34 35def 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)) 40