Chromium Code Reviews| Index: build/android/pylib/local/device/local_device_instrumentation_test_run.py |
| diff --git a/build/android/pylib/local/device/local_device_instrumentation_test_run.py b/build/android/pylib/local/device/local_device_instrumentation_test_run.py |
| index 7bfe3f5974efed2439e332afc0cd94f7ccd968ab..f1b2246045a65af4e9011cf5493e471e709594de 100644 |
| --- a/build/android/pylib/local/device/local_device_instrumentation_test_run.py |
| +++ b/build/android/pylib/local/device/local_device_instrumentation_test_run.py |
| @@ -11,6 +11,7 @@ import time |
| from devil.android import device_errors |
| from devil.android import flag_changer |
| +from devil.android.sdk import intent |
| from devil.android.sdk import shared_prefs |
| from devil.utils import reraiser_thread |
| from pylib import valgrind_tools |
| @@ -132,6 +133,26 @@ class LocalDeviceInstrumentationTestRun( |
| def edit_shared_prefs(): |
| for pref in self._test_instance.edit_shared_prefs: |
| + # Workaround for Android's SharedPreferencesImpl failing to open |
|
bsheedy
2017/03/10 00:01:45
This is a very hacky workaround, but I've been una
jbudorick
2017/03/10 02:19:21
Dollars to donuts that this is an SELinux issue. C
|
| + # shared preference files if they are created by something other |
| + # than the process that uses them (see b/36093591), even with proper |
| + # permissions, owner, and group. |
| + # This gets around that by adding the option to start and kill |
| + # an activity before modifying the preferences file, thus allowing |
| + # the app to create a default file that can then be edited. |
| + if 'start_and_kill_activity' in pref: |
| + act_options = pref['start_and_kill_activity'] |
| + dev.StartActivity(intent.Intent( |
| + action=act_options.get('action', None), |
| + activity=act_options.get('activity', None), |
| + category=act_options.get('category', None), |
| + component=act_options.get('component', None), |
| + data=act_options.get('data', None), |
| + extras=act_options.get('extras', None), |
| + flags=act_options.get('flags', None), |
| + package=pref['package'])) |
| + dev.ForceStop(pref['package']) |
| + |
| prefs = shared_prefs.SharedPrefs(dev, pref['package'], |
| pref['filename']) |
| prefs.Load() |