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

Side by Side Diff: build/android/pylib/content_settings.py

Issue 338353004: [Android] Switch KillAll, StartActivity, and BroadcastIntent to DeviceUtils. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: appeasing windows Created 6 years, 6 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 | « build/android/pylib/android_commands.py ('k') | build/android/pylib/device/adb_wrapper.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 5
6 class ContentSettings(dict): 6 class ContentSettings(dict):
7 7
8 """A dict interface to interact with device content settings. 8 """A dict interface to interact with device content settings.
9 9
10 System properties are key/value pairs as exposed by adb shell content. 10 System properties are key/value pairs as exposed by adb shell content.
(...skipping 23 matching lines...) Expand all
34 if isinstance(value, long): 34 if isinstance(value, long):
35 return 'l' 35 return 'l'
36 if isinstance(value, str): 36 if isinstance(value, str):
37 return 's' 37 return 's'
38 raise ValueError('Unsupported type %s' % type(value)) 38 raise ValueError('Unsupported type %s' % type(value))
39 39
40 def iteritems(self): 40 def iteritems(self):
41 # Example row: 41 # Example row:
42 # 'Row: 0 _id=13, name=logging_id2, value=-1fccbaa546705b05' 42 # 'Row: 0 _id=13, name=logging_id2, value=-1fccbaa546705b05'
43 for row in self._device.RunShellCommand( 43 for row in self._device.RunShellCommand(
44 'content query --uri content://%s' % self._table, root=True): 44 'content query --uri content://%s' % self._table, as_root=True):
45 fields = row.split(', ') 45 fields = row.split(', ')
46 key = None 46 key = None
47 value = None 47 value = None
48 for field in fields: 48 for field in fields:
49 k, _, v = field.partition('=') 49 k, _, v = field.partition('=')
50 if k == 'name': 50 if k == 'name':
51 key = v 51 key = v
52 elif k == 'value': 52 elif k == 'value':
53 value = v 53 value = v
54 assert key, value 54 assert key, value
55 yield key, value 55 yield key, value
56 56
57 def __getitem__(self, key): 57 def __getitem__(self, key):
58 return self._device.RunShellCommand( 58 return self._device.RunShellCommand(
59 'content query --uri content://%s --where "name=\'%s\'" ' 59 'content query --uri content://%s --where "name=\'%s\'" '
60 '--projection value' % (self._table, key), root=True).strip() 60 '--projection value' % (self._table, key), as_root=True).strip()
61 61
62 def __setitem__(self, key, value): 62 def __setitem__(self, key, value):
63 if key in self: 63 if key in self:
64 self._device.RunShellCommand( 64 self._device.RunShellCommand(
65 'content update --uri content://%s ' 65 'content update --uri content://%s '
66 '--bind value:%s:%s --where "name=\'%s\'"' % ( 66 '--bind value:%s:%s --where "name=\'%s\'"' % (
67 self._table, 67 self._table,
68 self._GetTypeBinding(value), value, key), 68 self._GetTypeBinding(value), value, key),
69 root=True) 69 as_root=True)
70 else: 70 else:
71 self._device.RunShellCommand( 71 self._device.RunShellCommand(
72 'content insert --uri content://%s ' 72 'content insert --uri content://%s '
73 '--bind name:%s:%s --bind value:%s:%s' % ( 73 '--bind name:%s:%s --bind value:%s:%s' % (
74 self._table, 74 self._table,
75 self._GetTypeBinding(key), key, 75 self._GetTypeBinding(key), key,
76 self._GetTypeBinding(value), value), 76 self._GetTypeBinding(value), value),
77 root=True) 77 as_root=True)
78 78
79 def __delitem__(self, key): 79 def __delitem__(self, key):
80 self._device.RunShellCommand( 80 self._device.RunShellCommand(
81 'content delete --uri content://%s ' 81 'content delete --uri content://%s '
82 '--bind name:%s:%s' % ( 82 '--bind name:%s:%s' % (
83 self._table, 83 self._table,
84 self._GetTypeBinding(key), key), 84 self._GetTypeBinding(key), key),
85 root=True) 85 as_root=True)
OLDNEW
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | build/android/pylib/device/adb_wrapper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698