Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: telemetry/telemetry/internal/platform/android_platform_backend.py

Issue 2995713002: Add GetSharedPrefs to Android platform (Closed)
Patch Set: Address nit Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « telemetry/telemetry/core/android_platform.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import os 6 import os
7 import posixpath 7 import posixpath
8 import re 8 import re
9 import subprocess 9 import subprocess
10 import tempfile 10 import tempfile
(...skipping 21 matching lines...) Expand all
32 psutil = external_modules.ImportOptionalModule('psutil') 32 psutil = external_modules.ImportOptionalModule('psutil')
33 import adb_install_cert 33 import adb_install_cert
34 34
35 from devil.android import app_ui 35 from devil.android import app_ui
36 from devil.android import battery_utils 36 from devil.android import battery_utils
37 from devil.android import device_errors 37 from devil.android import device_errors
38 from devil.android import device_utils 38 from devil.android import device_utils
39 from devil.android.perf import cache_control 39 from devil.android.perf import cache_control
40 from devil.android.perf import perf_control 40 from devil.android.perf import perf_control
41 from devil.android.perf import thermal_throttle 41 from devil.android.perf import thermal_throttle
42 from devil.android.sdk import shared_prefs
42 from devil.android.sdk import version_codes 43 from devil.android.sdk import version_codes
43 from devil.android.tools import video_recorder 44 from devil.android.tools import video_recorder
44 45
45 try: 46 try:
46 # devil.android.forwarder uses fcntl, which doesn't exist on Windows. 47 # devil.android.forwarder uses fcntl, which doesn't exist on Windows.
47 from devil.android import forwarder 48 from devil.android import forwarder
48 except ImportError: 49 except ImportError:
49 forwarder = None 50 forwarder = None
50 51
51 try: 52 try:
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return self._device 131 return self._device
131 132
132 def Initialize(self): 133 def Initialize(self):
133 self.EnsureBackgroundApkInstalled() 134 self.EnsureBackgroundApkInstalled()
134 135
135 def GetSystemUi(self): 136 def GetSystemUi(self):
136 if self._system_ui is None: 137 if self._system_ui is None:
137 self._system_ui = app_ui.AppUi(self.device, 'com.android.systemui') 138 self._system_ui = app_ui.AppUi(self.device, 'com.android.systemui')
138 return self._system_ui 139 return self._system_ui
139 140
141 def GetSharedPrefs(self, package, filename):
142 """Creates a Devil SharedPrefs instance.
143
144 See devil.android.sdk.shared_prefs for the documentation of the returned
145 object.
146
147 Args:
148 package: A string containing the package of the app that the SharedPrefs
149 instance will be for.
150 filename: A string containing the specific settings file of the app that
151 the SharedPrefs instance will be for.
152
153 Returns:
154 A reference to a SharedPrefs object for the given package and filename
155 on whatever device the platform backend has a reference to.
156 """
157 return shared_prefs.SharedPrefs(self._device, package, filename)
158
140 def IsSvelte(self): 159 def IsSvelte(self):
141 description = self._device.GetProp('ro.build.description', cache=True) 160 description = self._device.GetProp('ro.build.description', cache=True)
142 if description is not None: 161 if description is not None:
143 return 'svelte' in description 162 return 'svelte' in description
144 return False 163 return False
145 164
146 def IsAosp(self): 165 def IsAosp(self):
147 description = self._device.GetProp('ro.build.description', cache=True) 166 description = self._device.GetProp('ro.build.description', cache=True)
148 if description is not None: 167 if description is not None:
149 return 'aosp' in description 168 return 'aosp' in description
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 for process in psutil.process_iter(): 841 for process in psutil.process_iter():
823 try: 842 try:
824 if psutil.version_info >= (2, 0): 843 if psutil.version_info >= (2, 0):
825 if 'adb' in process.name(): 844 if 'adb' in process.name():
826 process.cpu_affinity([0]) 845 process.cpu_affinity([0])
827 else: 846 else:
828 if 'adb' in process.name: 847 if 'adb' in process.name:
829 process.set_cpu_affinity([0]) 848 process.set_cpu_affinity([0])
830 except (psutil.NoSuchProcess, psutil.AccessDenied): 849 except (psutil.NoSuchProcess, psutil.AccessDenied):
831 logging.warn('Failed to set adb process CPU affinity') 850 logging.warn('Failed to set adb process CPU affinity')
OLDNEW
« no previous file with comments | « telemetry/telemetry/core/android_platform.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698