blob: 9fe0922d3c8764390631bf715081d113169c7d6f [file] [log] [blame]
Makoto Onukia4f11972015-10-01 13:19:58 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server.pm;
18
19import com.google.android.collect.Sets;
20
Makoto Onuki1a2cd742015-11-16 13:51:27 -080021import com.android.internal.util.Preconditions;
22
23import android.annotation.NonNull;
24import android.annotation.Nullable;
Fyodor Kupolov9cbfc9e2015-10-07 15:52:33 -070025import android.app.ActivityManager;
Makoto Onuki4f160732015-10-27 17:15:38 -070026import android.content.ContentResolver;
27import android.content.Context;
Makoto Onuki4f160732015-10-27 17:15:38 -070028import android.os.Binder;
Makoto Onukia4f11972015-10-01 13:19:58 -070029import android.os.Bundle;
Fyodor Kupolov9cbfc9e2015-10-07 15:52:33 -070030import android.os.RemoteException;
Makoto Onuki4f160732015-10-27 17:15:38 -070031import android.os.UserHandle;
Makoto Onukia4f11972015-10-01 13:19:58 -070032import android.os.UserManager;
Mahaver Chopra830e32c2016-05-17 18:53:09 +010033import android.service.persistentdata.PersistentDataBlockManager;
Mahaver Chopradea471e2015-12-17 11:02:37 +000034import android.telephony.SubscriptionInfo;
35import android.telephony.SubscriptionManager;
Makoto Onuki1a2cd742015-11-16 13:51:27 -080036import android.util.Log;
Makoto Onuki1f1ceef2016-01-28 11:32:32 -080037import android.util.Slog;
Makoto Onukia4f11972015-10-01 13:19:58 -070038
39import org.xmlpull.v1.XmlPullParser;
40import org.xmlpull.v1.XmlSerializer;
41
42import java.io.IOException;
43import java.io.PrintWriter;
Mahaver Chopradea471e2015-12-17 11:02:37 +000044import java.util.List;
Makoto Onukia4f11972015-10-01 13:19:58 -070045import java.util.Set;
46
Makoto Onukid45a4a22015-11-02 17:17:38 -080047/**
Mahaver Chopradea471e2015-12-17 11:02:37 +000048 * Utility methods for user restrictions.
Makoto Onukid45a4a22015-11-02 17:17:38 -080049 *
50 * <p>See {@link UserManagerService} for the method suffixes.
51 */
Makoto Onukia4f11972015-10-01 13:19:58 -070052public class UserRestrictionsUtils {
Makoto Onuki4f160732015-10-27 17:15:38 -070053 private static final String TAG = "UserRestrictionsUtils";
54
Makoto Onukia4f11972015-10-01 13:19:58 -070055 private UserRestrictionsUtils() {
56 }
57
Makoto Onuki1f1ceef2016-01-28 11:32:32 -080058 private static Set<String> newSetWithUniqueCheck(String[] strings) {
59 final Set<String> ret = Sets.newArraySet(strings);
60
61 // Make sure there's no overlap.
62 Preconditions.checkState(ret.size() == strings.length);
63 return ret;
64 }
65
66 public static final Set<String> USER_RESTRICTIONS = newSetWithUniqueCheck(new String[] {
Makoto Onukia4f11972015-10-01 13:19:58 -070067 UserManager.DISALLOW_CONFIG_WIFI,
68 UserManager.DISALLOW_MODIFY_ACCOUNTS,
69 UserManager.DISALLOW_INSTALL_APPS,
70 UserManager.DISALLOW_UNINSTALL_APPS,
71 UserManager.DISALLOW_SHARE_LOCATION,
72 UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,
73 UserManager.DISALLOW_CONFIG_BLUETOOTH,
74 UserManager.DISALLOW_USB_FILE_TRANSFER,
75 UserManager.DISALLOW_CONFIG_CREDENTIALS,
76 UserManager.DISALLOW_REMOVE_USER,
77 UserManager.DISALLOW_DEBUGGING_FEATURES,
78 UserManager.DISALLOW_CONFIG_VPN,
79 UserManager.DISALLOW_CONFIG_TETHERING,
80 UserManager.DISALLOW_NETWORK_RESET,
81 UserManager.DISALLOW_FACTORY_RESET,
82 UserManager.DISALLOW_ADD_USER,
83 UserManager.ENSURE_VERIFY_APPS,
84 UserManager.DISALLOW_CONFIG_CELL_BROADCASTS,
85 UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS,
86 UserManager.DISALLOW_APPS_CONTROL,
87 UserManager.DISALLOW_MOUNT_PHYSICAL_MEDIA,
88 UserManager.DISALLOW_UNMUTE_MICROPHONE,
89 UserManager.DISALLOW_ADJUST_VOLUME,
90 UserManager.DISALLOW_OUTGOING_CALLS,
91 UserManager.DISALLOW_SMS,
92 UserManager.DISALLOW_FUN,
93 UserManager.DISALLOW_CREATE_WINDOWS,
94 UserManager.DISALLOW_CROSS_PROFILE_COPY_PASTE,
95 UserManager.DISALLOW_OUTGOING_BEAM,
96 UserManager.DISALLOW_WALLPAPER,
97 UserManager.DISALLOW_SAFE_BOOT,
98 UserManager.ALLOW_PARENT_PROFILE_APP_LINKING,
99 UserManager.DISALLOW_RECORD_AUDIO,
Fyodor Kupolov9cbfc9e2015-10-07 15:52:33 -0700100 UserManager.DISALLOW_CAMERA,
Mahaver Chopradea471e2015-12-17 11:02:37 +0000101 UserManager.DISALLOW_RUN_IN_BACKGROUND,
Oleksandr Peletskyi7f1f1df2016-01-18 15:40:21 +0100102 UserManager.DISALLOW_DATA_ROAMING,
Oleksandr Peletskyif2519812016-01-26 20:16:06 +0100103 UserManager.DISALLOW_SET_USER_ICON,
Mahaver Chopra3d9805d2016-07-07 16:25:05 +0100104 UserManager.DISALLOW_SET_WALLPAPER,
Tony Makc1205112016-07-22 16:02:59 +0100105 UserManager.DISALLOW_OEM_UNLOCK,
106 UserManager.DISALLLOW_UNMUTE_DEVICE,
Makoto Onuki1f1ceef2016-01-28 11:32:32 -0800107 });
Makoto Onukia4f11972015-10-01 13:19:58 -0700108
109 /**
110 * Set of user restriction which we don't want to persist.
111 */
Makoto Onuki1a2cd742015-11-16 13:51:27 -0800112 private static final Set<String> NON_PERSIST_USER_RESTRICTIONS = Sets.newArraySet(
113 UserManager.DISALLOW_RECORD_AUDIO
114 );
Makoto Onukia4f11972015-10-01 13:19:58 -0700115
Makoto Onuki1a2cd742015-11-16 13:51:27 -0800116 /**
117 * User restrictions that can not be set by profile owners.
118 */
119 private static final Set<String> DEVICE_OWNER_ONLY_RESTRICTIONS = Sets.newArraySet(
120 UserManager.DISALLOW_USB_FILE_TRANSFER,
121 UserManager.DISALLOW_CONFIG_TETHERING,
122 UserManager.DISALLOW_NETWORK_RESET,
123 UserManager.DISALLOW_FACTORY_RESET,
124 UserManager.DISALLOW_ADD_USER,
125 UserManager.DISALLOW_CONFIG_CELL_BROADCASTS,
126 UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS,
127 UserManager.DISALLOW_MOUNT_PHYSICAL_MEDIA,
128 UserManager.DISALLOW_SMS,
129 UserManager.DISALLOW_FUN,
130 UserManager.DISALLOW_SAFE_BOOT,
Mahaver Chopradea471e2015-12-17 11:02:37 +0000131 UserManager.DISALLOW_CREATE_WINDOWS,
132 UserManager.DISALLOW_DATA_ROAMING
Makoto Onuki1a2cd742015-11-16 13:51:27 -0800133 );
134
135 /**
136 * User restrictions that can't be changed by device owner or profile owner.
137 */
138 private static final Set<String> IMMUTABLE_BY_OWNERS = Sets.newArraySet(
139 UserManager.DISALLOW_RECORD_AUDIO,
Mahaver Chopra3d9805d2016-07-07 16:25:05 +0100140 UserManager.DISALLOW_WALLPAPER,
141 UserManager.DISALLOW_OEM_UNLOCK
Makoto Onuki1a2cd742015-11-16 13:51:27 -0800142 );
143
144 /**
145 * Special user restrictions that can be applied to a user as well as to all users globally,
146 * depending on callers. When device owner sets them, they'll be applied to all users.
147 */
148 private static final Set<String> GLOBAL_RESTRICTIONS = Sets.newArraySet(
149 UserManager.DISALLOW_ADJUST_VOLUME,
Fyodor Kupolov9cbfc9e2015-10-07 15:52:33 -0700150 UserManager.DISALLOW_RUN_IN_BACKGROUND,
Tony Makc1205112016-07-22 16:02:59 +0100151 UserManager.DISALLOW_UNMUTE_MICROPHONE,
152 UserManager.DISALLLOW_UNMUTE_DEVICE
Makoto Onuki1a2cd742015-11-16 13:51:27 -0800153 );
154
Makoto Onuki1f1ceef2016-01-28 11:32:32 -0800155 /**
156 * Throws {@link IllegalArgumentException} if the given restriction name is invalid.
157 */
158 public static boolean isValidRestriction(@NonNull String restriction) {
159 if (!USER_RESTRICTIONS.contains(restriction)) {
Makoto Onukiad5619d2016-02-10 13:41:15 -0800160 Slog.e(TAG, "Unknown restriction: " + restriction);
Makoto Onuki1f1ceef2016-01-28 11:32:32 -0800161 return false;
162 }
163 return true;
164 }
165
Makoto Onuki1a2cd742015-11-16 13:51:27 -0800166 public static void writeRestrictions(@NonNull XmlSerializer serializer,
167 @Nullable Bundle restrictions, @NonNull String tag) throws IOException {
168 if (restrictions == null) {
169 return;
170 }
171
Makoto Onukia4f11972015-10-01 13:19:58 -0700172 serializer.startTag(null, tag);
Makoto Onukiac65e1e2015-11-20 15:33:17 -0800173 for (String key : restrictions.keySet()) {
174 if (NON_PERSIST_USER_RESTRICTIONS.contains(key)) {
175 continue; // Don't persist.
Makoto Onukia4f11972015-10-01 13:19:58 -0700176 }
Makoto Onukiac65e1e2015-11-20 15:33:17 -0800177 if (USER_RESTRICTIONS.contains(key)) {
178 if (restrictions.getBoolean(key)) {
179 serializer.attribute(null, key, "true");
180 }
181 continue;
182 }
183 Log.w(TAG, "Unknown user restriction detected: " + key);
Makoto Onukia4f11972015-10-01 13:19:58 -0700184 }
185 serializer.endTag(null, tag);
186 }
187
Esteban Talaverac48b20f2016-08-11 11:23:40 +0100188 public static void readRestrictions(XmlPullParser parser, Bundle restrictions) {
Makoto Onukia4f11972015-10-01 13:19:58 -0700189 for (String key : USER_RESTRICTIONS) {
190 final String value = parser.getAttributeValue(null, key);
191 if (value != null) {
192 restrictions.putBoolean(key, Boolean.parseBoolean(value));
193 }
194 }
195 }
196
Makoto Onuki1a2cd742015-11-16 13:51:27 -0800197 /**
198 * @return {@code in} itself when it's not null, or an empty bundle (which can writable).
199 */
200 public static Bundle nonNull(@Nullable Bundle in) {
201 return in != null ? in : new Bundle();
202 }
203
204 public static boolean isEmpty(@Nullable Bundle in) {
205 return (in == null) || (in.size() == 0);
206 }
207
208 /**
209 * Creates a copy of the {@code in} Bundle. If {@code in} is null, it'll return an empty
210 * bundle.
211 *
212 * <p>The resulting {@link Bundle} is always writable. (i.e. it won't return
213 * {@link Bundle#EMPTY})
214 */
215 public static @NonNull Bundle clone(@Nullable Bundle in) {
216 return (in != null) ? new Bundle(in) : new Bundle();
217 }
218
219 public static void merge(@NonNull Bundle dest, @Nullable Bundle in) {
220 Preconditions.checkNotNull(dest);
221 Preconditions.checkArgument(dest != in);
Makoto Onuki068c54a2015-10-13 14:34:03 -0700222 if (in == null) {
223 return;
224 }
225 for (String key : in.keySet()) {
226 if (in.getBoolean(key, false)) {
227 dest.putBoolean(key, true);
228 }
229 }
230 }
231
Makoto Onuki4f160732015-10-27 17:15:38 -0700232 /**
Makoto Onuki1a2cd742015-11-16 13:51:27 -0800233 * @return true if a restriction is settable by device owner.
234 */
235 public static boolean canDeviceOwnerChange(String restriction) {
236 return !IMMUTABLE_BY_OWNERS.contains(restriction);
237 }
238
239 /**
Makoto Onuki5485ed42015-12-09 11:38:23 -0800240 * @return true if a restriction is settable by profile owner. Note it takes a user ID because
241 * some restrictions can be changed by PO only when it's running on the system user.
Makoto Onuki1a2cd742015-11-16 13:51:27 -0800242 */
Makoto Onuki5485ed42015-12-09 11:38:23 -0800243 public static boolean canProfileOwnerChange(String restriction, int userId) {
244 return !IMMUTABLE_BY_OWNERS.contains(restriction)
245 && !(userId != UserHandle.USER_SYSTEM
246 && DEVICE_OWNER_ONLY_RESTRICTIONS.contains(restriction));
Makoto Onuki1a2cd742015-11-16 13:51:27 -0800247 }
248
249 /**
250 * Takes restrictions that can be set by device owner, and sort them into what should be applied
251 * globally and what should be applied only on the current user.
252 */
253 public static void sortToGlobalAndLocal(@Nullable Bundle in, @NonNull Bundle global,
254 @NonNull Bundle local) {
255 if (in == null || in.size() == 0) {
256 return;
257 }
258 for (String key : in.keySet()) {
259 if (!in.getBoolean(key)) {
260 continue;
261 }
262 if (DEVICE_OWNER_ONLY_RESTRICTIONS.contains(key) || GLOBAL_RESTRICTIONS.contains(key)) {
263 global.putBoolean(key, true);
264 } else {
265 local.putBoolean(key, true);
266 }
267 }
268 }
269
270 /**
271 * @return true if two Bundles contain the same user restriction.
272 * A null bundle and an empty bundle are considered to be equal.
273 */
274 public static boolean areEqual(@Nullable Bundle a, @Nullable Bundle b) {
275 if (a == b) {
276 return true;
277 }
278 if (isEmpty(a)) {
279 return isEmpty(b);
280 }
281 if (isEmpty(b)) {
282 return false;
283 }
284 for (String key : a.keySet()) {
285 if (a.getBoolean(key) != b.getBoolean(key)) {
286 return false;
287 }
288 }
289 for (String key : b.keySet()) {
290 if (a.getBoolean(key) != b.getBoolean(key)) {
291 return false;
292 }
293 }
294 return true;
295 }
296
297 /**
Makoto Onuki4f160732015-10-27 17:15:38 -0700298 * Takes a new use restriction set and the previous set, and apply the restrictions that have
299 * changed.
Makoto Onukid45a4a22015-11-02 17:17:38 -0800300 *
Fyodor Kupolov9cbfc9e2015-10-07 15:52:33 -0700301 * <p>Note this method is called by {@link UserManagerService} without holding any locks.
Makoto Onuki4f160732015-10-27 17:15:38 -0700302 */
Fyodor Kupolov9cbfc9e2015-10-07 15:52:33 -0700303 public static void applyUserRestrictions(Context context, int userId,
Makoto Onukid45a4a22015-11-02 17:17:38 -0800304 Bundle newRestrictions, Bundle prevRestrictions) {
Makoto Onuki4f160732015-10-27 17:15:38 -0700305 for (String key : USER_RESTRICTIONS) {
306 final boolean newValue = newRestrictions.getBoolean(key);
307 final boolean prevValue = prevRestrictions.getBoolean(key);
308
309 if (newValue != prevValue) {
Fyodor Kupolov9cbfc9e2015-10-07 15:52:33 -0700310 applyUserRestriction(context, userId, key, newValue);
Makoto Onuki4f160732015-10-27 17:15:38 -0700311 }
312 }
313 }
Fyodor Kupolov9cbfc9e2015-10-07 15:52:33 -0700314
Makoto Onukid45a4a22015-11-02 17:17:38 -0800315 /**
316 * Apply each user restriction.
317 *
Makoto Onuki28da2e32015-11-20 11:30:44 -0800318 * <p>See also {@link
319 * com.android.providers.settings.SettingsProvider#isGlobalOrSecureSettingRestrictedForUser},
320 * which should be in sync with this method.
Makoto Onukid45a4a22015-11-02 17:17:38 -0800321 */
Fyodor Kupolov9cbfc9e2015-10-07 15:52:33 -0700322 private static void applyUserRestriction(Context context, int userId, String key,
Makoto Onuki4f160732015-10-27 17:15:38 -0700323 boolean newValue) {
Makoto Onuki1a2cd742015-11-16 13:51:27 -0800324 if (UserManagerService.DBG) {
325 Log.d(TAG, "Applying user restriction: userId=" + userId
326 + " key=" + key + " value=" + newValue);
327 }
Makoto Onuki4f160732015-10-27 17:15:38 -0700328 // When certain restrictions are cleared, we don't update the system settings,
329 // because these settings are changeable on the Settings UI and we don't know the original
330 // value -- for example LOCATION_MODE might have been off already when the restriction was
331 // set, and in that case even if the restriction is lifted, changing it to ON would be
332 // wrong. So just don't do anything in such a case. If the user hopes to enable location
333 // later, they can do it on the Settings UI.
Benjamin Franz0ff13fc2016-07-12 13:42:21 +0100334 // WARNING: Remember that Settings.Global and Settings.Secure are changeable via adb.
335 // To prevent this from happening for a given user restriction, you have to add a check to
336 // SettingsProvider.isGlobalOrSecureSettingRestrictedForUser.
Makoto Onuki4f160732015-10-27 17:15:38 -0700337
338 final ContentResolver cr = context.getContentResolver();
339 final long id = Binder.clearCallingIdentity();
340 try {
341 switch (key) {
Makoto Onuki4f160732015-10-27 17:15:38 -0700342 case UserManager.DISALLOW_CONFIG_WIFI:
343 if (newValue) {
344 android.provider.Settings.Secure.putIntForUser(cr,
Makoto Onuki28da2e32015-11-20 11:30:44 -0800345 android.provider.Settings.Global
Makoto Onuki4f160732015-10-27 17:15:38 -0700346 .WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0, userId);
347 }
348 break;
Mahaver Chopradea471e2015-12-17 11:02:37 +0000349 case UserManager.DISALLOW_DATA_ROAMING:
350 if (newValue) {
351 // DISALLOW_DATA_ROAMING user restriction is set.
352
353 // Multi sim device.
354 SubscriptionManager subscriptionManager = new SubscriptionManager(context);
355 final List<SubscriptionInfo> subscriptionInfoList =
356 subscriptionManager.getActiveSubscriptionInfoList();
357 if (subscriptionInfoList != null) {
358 for (SubscriptionInfo subInfo : subscriptionInfoList) {
359 android.provider.Settings.Global.putStringForUser(cr,
360 android.provider.Settings.Global.DATA_ROAMING
361 + subInfo.getSubscriptionId(), "0", userId);
362 }
363 }
364
365 // Single sim device.
366 android.provider.Settings.Global.putStringForUser(cr,
367 android.provider.Settings.Global.DATA_ROAMING, "0", userId);
368 }
369 break;
Makoto Onuki4f160732015-10-27 17:15:38 -0700370 case UserManager.DISALLOW_SHARE_LOCATION:
371 if (newValue) {
372 android.provider.Settings.Secure.putIntForUser(cr,
373 android.provider.Settings.Secure.LOCATION_MODE,
374 android.provider.Settings.Secure.LOCATION_MODE_OFF,
375 userId);
Makoto Onuki4f160732015-10-27 17:15:38 -0700376 }
Makoto Onuki4f160732015-10-27 17:15:38 -0700377 break;
378 case UserManager.DISALLOW_DEBUGGING_FEATURES:
379 if (newValue) {
380 // Only disable adb if changing for system user, since it is global
381 // TODO: should this be admin user?
382 if (userId == UserHandle.USER_SYSTEM) {
383 android.provider.Settings.Global.putStringForUser(cr,
384 android.provider.Settings.Global.ADB_ENABLED, "0",
385 userId);
386 }
387 }
388 break;
389 case UserManager.ENSURE_VERIFY_APPS:
390 if (newValue) {
391 android.provider.Settings.Global.putStringForUser(
392 context.getContentResolver(),
393 android.provider.Settings.Global.PACKAGE_VERIFIER_ENABLE, "1",
394 userId);
395 android.provider.Settings.Global.putStringForUser(
396 context.getContentResolver(),
397 android.provider.Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, "1",
398 userId);
399 }
400 break;
401 case UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES:
402 if (newValue) {
403 android.provider.Settings.Secure.putIntForUser(cr,
404 android.provider.Settings.Secure.INSTALL_NON_MARKET_APPS, 0,
405 userId);
406 }
407 break;
Fyodor Kupolov9cbfc9e2015-10-07 15:52:33 -0700408 case UserManager.DISALLOW_RUN_IN_BACKGROUND:
409 if (newValue) {
410 int currentUser = ActivityManager.getCurrentUser();
411 if (currentUser != userId && userId != UserHandle.USER_SYSTEM) {
412 try {
Sudheer Shankadc589ac2016-11-10 15:30:17 -0800413 ActivityManager.getService().stopUser(userId, false, null);
Fyodor Kupolov9cbfc9e2015-10-07 15:52:33 -0700414 } catch (RemoteException e) {
415 throw e.rethrowAsRuntimeException();
416 }
417 }
418 }
Lenka Trochtova6474f0e2016-03-24 16:43:10 +0100419 break;
420 case UserManager.DISALLOW_SAFE_BOOT:
421 // Unlike with the other restrictions, we want to propagate the new value to
422 // the system settings even if it is false. The other restrictions modify
423 // settings which could be manually changed by the user from the Settings app
424 // after the policies enforcing these restrictions have been revoked, so we
425 // leave re-setting of those settings to the user.
426 android.provider.Settings.Global.putInt(
427 context.getContentResolver(),
428 android.provider.Settings.Global.SAFE_BOOT_DISALLOWED,
429 newValue ? 1 : 0);
430 break;
Mahaver Chopra830e32c2016-05-17 18:53:09 +0100431 case UserManager.DISALLOW_FACTORY_RESET:
Mahaver Chopra3d9805d2016-07-07 16:25:05 +0100432 case UserManager.DISALLOW_OEM_UNLOCK:
Mahaver Chopra830e32c2016-05-17 18:53:09 +0100433 if (newValue) {
434 PersistentDataBlockManager manager = (PersistentDataBlockManager) context
435 .getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
Esteban Talaverac48b20f2016-08-11 11:23:40 +0100436 if (manager != null
437 && manager.getOemUnlockEnabled()
438 && manager.getFlashLockState()
439 != PersistentDataBlockManager.FLASH_LOCK_UNLOCKED) {
440 // Only disable OEM unlock if the bootloader is locked. If it's already
441 // unlocked, setting the OEM unlock enabled flag to false has no effect
442 // (the bootloader would remain unlocked).
Mahaver Chopra830e32c2016-05-17 18:53:09 +0100443 manager.setOemUnlockEnabled(false);
444 }
445 }
Tony Makc1205112016-07-22 16:02:59 +0100446 break;
Makoto Onuki4f160732015-10-27 17:15:38 -0700447 }
Makoto Onuki4f160732015-10-27 17:15:38 -0700448 } finally {
449 Binder.restoreCallingIdentity(id);
450 }
451 }
452
Makoto Onukia4f11972015-10-01 13:19:58 -0700453 public static void dumpRestrictions(PrintWriter pw, String prefix, Bundle restrictions) {
454 boolean noneSet = true;
455 if (restrictions != null) {
456 for (String key : restrictions.keySet()) {
457 if (restrictions.getBoolean(key, false)) {
458 pw.println(prefix + key);
459 noneSet = false;
460 }
461 }
Makoto Onuki068c54a2015-10-13 14:34:03 -0700462 if (noneSet) {
463 pw.println(prefix + "none");
464 }
465 } else {
466 pw.println(prefix + "null");
Makoto Onukia4f11972015-10-01 13:19:58 -0700467 }
468 }
469}