OLD | NEW |
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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 | 554 |
555 def InstallTestCa(self, ca_cert_path): | 555 def InstallTestCa(self, ca_cert_path): |
556 """Install a randomly generated root CA on the android device. | 556 """Install a randomly generated root CA on the android device. |
557 | 557 |
558 This allows transparent HTTPS testing with WPR server without need | 558 This allows transparent HTTPS testing with WPR server without need |
559 to tweak application network stack. | 559 to tweak application network stack. |
560 | 560 |
561 Note: If this method fails with any exception, then RemoveTestCa will be | 561 Note: If this method fails with any exception, then RemoveTestCa will be |
562 automatically called by the network_controller_backend. | 562 automatically called by the network_controller_backend. |
563 """ | 563 """ |
| 564 |
564 if self._device_cert_util is not None: | 565 if self._device_cert_util is not None: |
565 logging.warning('Test certificate authority is already installed.') | 566 logging.warning('Test certificate authority is already installed.') |
566 return | 567 return |
567 self._device_cert_util = adb_install_cert.AndroidCertInstaller( | 568 self._device_cert_util = adb_install_cert.AndroidCertInstaller( |
568 self._device.adb.GetDeviceSerial(), None, ca_cert_path, | 569 self._device.adb.GetDeviceSerial(), None, ca_cert_path, |
569 adb_path=self._device.adb.GetAdbPath()) | 570 adb_path=self._device.adb.GetAdbPath()) |
570 self._device_cert_util.install_cert(overwrite_cert=True) | 571 self._device_cert_util.install_cert(overwrite_cert=True) |
571 | 572 |
572 def RemoveTestCa(self): | 573 def RemoveTestCa(self): |
573 """Remove root CA from device installed by InstallTestCa. | 574 """Remove root CA from device installed by InstallTestCa. |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 for process in psutil.process_iter(): | 842 for process in psutil.process_iter(): |
842 try: | 843 try: |
843 if psutil.version_info >= (2, 0): | 844 if psutil.version_info >= (2, 0): |
844 if 'adb' in process.name(): | 845 if 'adb' in process.name(): |
845 process.cpu_affinity([0]) | 846 process.cpu_affinity([0]) |
846 else: | 847 else: |
847 if 'adb' in process.name: | 848 if 'adb' in process.name: |
848 process.set_cpu_affinity([0]) | 849 process.set_cpu_affinity([0]) |
849 except (psutil.NoSuchProcess, psutil.AccessDenied): | 850 except (psutil.NoSuchProcess, psutil.AccessDenied): |
850 logging.warn('Failed to set adb process CPU affinity') | 851 logging.warn('Failed to set adb process CPU affinity') |
OLD | NEW |