| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.content; |
| 18 |
|
| 19 |
import android.annotation.SystemService; |
| 20 |
import android.app.Activity; |
| 21 |
import android.app.admin.DevicePolicyManager; |
| 22 |
import android.compat.annotation.UnsupportedAppUsage; |
| 23 |
import android.content.pm.ApplicationInfo; |
| 24 |
import android.content.pm.PackageManager; |
| 25 |
import android.content.pm.PackageManager.NameNotFoundException; |
| 26 |
import android.content.res.TypedArray; |
| 27 |
import android.content.res.XmlResourceParser; |
| 28 |
import android.os.Build; |
| 29 |
import android.os.Bundle; |
| 30 |
import android.os.PersistableBundle; |
| 31 |
import android.os.RemoteException; |
| 32 |
import android.service.restrictions.RestrictionsReceiver; |
| 33 |
import android.util.AttributeSet; |
| 34 |
import android.util.Log; |
| 35 |
import android.util.Xml; |
| 36 |
|
| 37 |
import com.android.internal.R; |
| 38 |
import com.android.internal.util.XmlUtils; |
| 39 |
|
| 40 |
import org.xmlpull.v1.XmlPullParser; |
| 41 |
import org.xmlpull.v1.XmlPullParserException; |
| 42 |
|
| 43 |
import java.io.IOException; |
| 44 |
import java.util.ArrayList; |
| 45 |
import java.util.Arrays; |
| 46 |
import java.util.List; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
@SystemService(Context.RESTRICTIONS_SERVICE) |
| 127 |
public class RestrictionsManager { |
| 128 |
|
| 129 |
private static final String TAG = "RestrictionsManager"; |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
public static final String ACTION_PERMISSION_RESPONSE_RECEIVED = |
| 144 |
"android.content.action.PERMISSION_RESPONSE_RECEIVED"; |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
public static final String ACTION_REQUEST_PERMISSION = |
| 158 |
"android.content.action.REQUEST_PERMISSION"; |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
public static final String ACTION_REQUEST_LOCAL_APPROVAL = |
| 173 |
"android.content.action.REQUEST_LOCAL_APPROVAL"; |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
public static final String EXTRA_PACKAGE_NAME = "android.content.extra.PACKAGE_NAME"; |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
public static final String EXTRA_REQUEST_TYPE = "android.content.extra.REQUEST_TYPE"; |
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
public static final String EXTRA_REQUEST_ID = "android.content.extra.REQUEST_ID"; |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
public static final String EXTRA_REQUEST_BUNDLE = "android.content.extra.REQUEST_BUNDLE"; |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
public static final String EXTRA_RESPONSE_BUNDLE = "android.content.extra.RESPONSE_BUNDLE"; |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
public static final String REQUEST_TYPE_APPROVAL = "android.request.type.approval"; |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
public static final String REQUEST_KEY_ID = "android.request.id"; |
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
public static final String REQUEST_KEY_DATA = "android.request.data"; |
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
public static final String REQUEST_KEY_TITLE = "android.request.title"; |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
public static final String REQUEST_KEY_MESSAGE = "android.request.mesg"; |
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
public static final String REQUEST_KEY_ICON = "android.request.icon"; |
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
public static final String REQUEST_KEY_APPROVE_LABEL = "android.request.approve_label"; |
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
public static final String REQUEST_KEY_DENY_LABEL = "android.request.deny_label"; |
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
public static final String REQUEST_KEY_NEW_REQUEST = "android.request.new_request"; |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
public static final String RESPONSE_KEY_RESULT = "android.response.result"; |
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
public static final int RESULT_APPROVED = 1; |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
public static final int RESULT_DENIED = 2; |
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
public static final int RESULT_NO_RESPONSE = 3; |
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
public static final int RESULT_UNKNOWN_REQUEST = 4; |
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
public static final int RESULT_ERROR = 5; |
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
public static final int RESULT_ERROR_BAD_REQUEST = 1; |
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
public static final int RESULT_ERROR_NETWORK = 2; |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
public static final int RESULT_ERROR_INTERNAL = 3; |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
public static final String RESPONSE_KEY_ERROR_CODE = "android.response.errorcode"; |
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
public static final String RESPONSE_KEY_MESSAGE = "android.response.msg"; |
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
public static final String RESPONSE_KEY_RESPONSE_TIMESTAMP = "android.response.timestamp"; |
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
public static final String META_DATA_APP_RESTRICTIONS = "android.content.APP_RESTRICTIONS"; |
| 403 |
|
| 404 |
private static final String TAG_RESTRICTION = "restriction"; |
| 405 |
|
| 406 |
private final Context mContext; |
| 407 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
| 408 |
private final IRestrictionsManager mService; |
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
public RestrictionsManager(Context context, IRestrictionsManager service) { |
| 414 |
mContext = context; |
| 415 |
mService = service; |
| 416 |
} |
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
public Bundle getApplicationRestrictions() { |
| 425 |
try { |
| 426 |
if (mService != null) { |
| 427 |
return mService.getApplicationRestrictions(mContext.getPackageName()); |
| 428 |
} |
| 429 |
} catch (RemoteException re) { |
| 430 |
throw re.rethrowFromSystemServer(); |
| 431 |
} |
| 432 |
return null; |
| 433 |
} |
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
public boolean hasRestrictionsProvider() { |
| 442 |
try { |
| 443 |
if (mService != null) { |
| 444 |
return mService.hasRestrictionsProvider(); |
| 445 |
} |
| 446 |
} catch (RemoteException re) { |
| 447 |
throw re.rethrowFromSystemServer(); |
| 448 |
} |
| 449 |
return false; |
| 450 |
} |
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
public void requestPermission(String requestType, String requestId, PersistableBundle request) { |
| 470 |
if (requestType == null) { |
| 471 |
throw new NullPointerException("requestType cannot be null"); |
| 472 |
} |
| 473 |
if (requestId == null) { |
| 474 |
throw new NullPointerException("requestId cannot be null"); |
| 475 |
} |
| 476 |
if (request == null) { |
| 477 |
throw new NullPointerException("request cannot be null"); |
| 478 |
} |
| 479 |
try { |
| 480 |
if (mService != null) { |
| 481 |
mService.requestPermission(mContext.getPackageName(), requestType, requestId, |
| 482 |
request); |
| 483 |
} |
| 484 |
} catch (RemoteException re) { |
| 485 |
throw re.rethrowFromSystemServer(); |
| 486 |
} |
| 487 |
} |
| 488 |
|
| 489 |
public Intent createLocalApprovalIntent() { |
| 490 |
try { |
| 491 |
if (mService != null) { |
| 492 |
return mService.createLocalApprovalIntent(); |
| 493 |
} |
| 494 |
} catch (RemoteException re) { |
| 495 |
throw re.rethrowFromSystemServer(); |
| 496 |
} |
| 497 |
return null; |
| 498 |
} |
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
public void notifyPermissionResponse(String packageName, PersistableBundle response) { |
| 510 |
if (packageName == null) { |
| 511 |
throw new NullPointerException("packageName cannot be null"); |
| 512 |
} |
| 513 |
if (response == null) { |
| 514 |
throw new NullPointerException("request cannot be null"); |
| 515 |
} |
| 516 |
if (!response.containsKey(REQUEST_KEY_ID)) { |
| 517 |
throw new IllegalArgumentException("REQUEST_KEY_ID must be specified"); |
| 518 |
} |
| 519 |
if (!response.containsKey(RESPONSE_KEY_RESULT)) { |
| 520 |
throw new IllegalArgumentException("RESPONSE_KEY_RESULT must be specified"); |
| 521 |
} |
| 522 |
try { |
| 523 |
if (mService != null) { |
| 524 |
mService.notifyPermissionResponse(packageName, response); |
| 525 |
} |
| 526 |
} catch (RemoteException re) { |
| 527 |
throw re.rethrowFromSystemServer(); |
| 528 |
} |
| 529 |
} |
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
public List<RestrictionEntry> getManifestRestrictions(String packageName) { |
| 540 |
ApplicationInfo appInfo = null; |
| 541 |
try { |
| 542 |
appInfo = mContext.getPackageManager().getApplicationInfo(packageName, |
| 543 |
PackageManager.GET_META_DATA); |
| 544 |
} catch (NameNotFoundException pnfe) { |
| 545 |
throw new IllegalArgumentException("No such package " + packageName); |
| 546 |
} |
| 547 |
if (appInfo == null || !appInfo.metaData.containsKey(META_DATA_APP_RESTRICTIONS)) { |
| 548 |
return null; |
| 549 |
} |
| 550 |
|
| 551 |
XmlResourceParser xml = |
| 552 |
appInfo.loadXmlMetaData(mContext.getPackageManager(), META_DATA_APP_RESTRICTIONS); |
| 553 |
return loadManifestRestrictions(packageName, xml); |
| 554 |
} |
| 555 |
|
| 556 |
private List<RestrictionEntry> loadManifestRestrictions(String packageName, |
| 557 |
XmlResourceParser xml) { |
| 558 |
Context appContext; |
| 559 |
try { |
| 560 |
appContext = mContext.createPackageContext(packageName, 0 ); |
| 561 |
} catch (NameNotFoundException nnfe) { |
| 562 |
return null; |
| 563 |
} |
| 564 |
ArrayList<RestrictionEntry> restrictions = new ArrayList<>(); |
| 565 |
RestrictionEntry restriction; |
| 566 |
|
| 567 |
try { |
| 568 |
int tagType = xml.next(); |
| 569 |
while (tagType != XmlPullParser.END_DOCUMENT) { |
| 570 |
if (tagType == XmlPullParser.START_TAG) { |
| 571 |
restriction = loadRestrictionElement(appContext, xml); |
| 572 |
if (restriction != null) { |
| 573 |
restrictions.add(restriction); |
| 574 |
} |
| 575 |
} |
| 576 |
tagType = xml.next(); |
| 577 |
} |
| 578 |
} catch (XmlPullParserException e) { |
| 579 |
Log.w(TAG, "Reading restriction metadata for " + packageName, e); |
| 580 |
return null; |
| 581 |
} catch (IOException e) { |
| 582 |
Log.w(TAG, "Reading restriction metadata for " + packageName, e); |
| 583 |
return null; |
| 584 |
} |
| 585 |
|
| 586 |
return restrictions; |
| 587 |
} |
| 588 |
|
| 589 |
private RestrictionEntry loadRestrictionElement(Context appContext, XmlResourceParser xml) |
| 590 |
throws IOException, XmlPullParserException { |
| 591 |
if (xml.getName().equals(TAG_RESTRICTION)) { |
| 592 |
AttributeSet attrSet = Xml.asAttributeSet(xml); |
| 593 |
if (attrSet != null) { |
| 594 |
TypedArray a = appContext.obtainStyledAttributes(attrSet, |
| 595 |
com.android.internal.R.styleable.RestrictionEntry); |
| 596 |
return loadRestriction(appContext, a, xml); |
| 597 |
} |
| 598 |
} |
| 599 |
return null; |
| 600 |
} |
| 601 |
|
| 602 |
private RestrictionEntry loadRestriction(Context appContext, TypedArray a, XmlResourceParser xml) |
| 603 |
throws IOException, XmlPullParserException { |
| 604 |
String key = a.getString(R.styleable.RestrictionEntry_key); |
| 605 |
int restrictionType = a.getInt( |
| 606 |
R.styleable.RestrictionEntry_restrictionType, -1); |
| 607 |
String title = a.getString(R.styleable.RestrictionEntry_title); |
| 608 |
String description = a.getString(R.styleable.RestrictionEntry_description); |
| 609 |
int entries = a.getResourceId(R.styleable.RestrictionEntry_entries, 0); |
| 610 |
int entryValues = a.getResourceId(R.styleable.RestrictionEntry_entryValues, 0); |
| 611 |
|
| 612 |
if (restrictionType == -1) { |
| 613 |
Log.w(TAG, "restrictionType cannot be omitted"); |
| 614 |
return null; |
| 615 |
} |
| 616 |
|
| 617 |
if (key == null) { |
| 618 |
Log.w(TAG, "key cannot be omitted"); |
| 619 |
return null; |
| 620 |
} |
| 621 |
|
| 622 |
RestrictionEntry restriction = new RestrictionEntry(restrictionType, key); |
| 623 |
restriction.setTitle(title); |
| 624 |
restriction.setDescription(description); |
| 625 |
if (entries != 0) { |
| 626 |
restriction.setChoiceEntries(appContext, entries); |
| 627 |
} |
| 628 |
if (entryValues != 0) { |
| 629 |
restriction.setChoiceValues(appContext, entryValues); |
| 630 |
} |
| 631 |
|
| 632 |
switch (restrictionType) { |
| 633 |
case RestrictionEntry.TYPE_NULL: |
| 634 |
case RestrictionEntry.TYPE_STRING: |
| 635 |
case RestrictionEntry.TYPE_CHOICE: |
| 636 |
restriction.setSelectedString( |
| 637 |
a.getString(R.styleable.RestrictionEntry_defaultValue)); |
| 638 |
break; |
| 639 |
case RestrictionEntry.TYPE_INTEGER: |
| 640 |
restriction.setIntValue( |
| 641 |
a.getInt(R.styleable.RestrictionEntry_defaultValue, 0)); |
| 642 |
break; |
| 643 |
case RestrictionEntry.TYPE_MULTI_SELECT: |
| 644 |
int resId = a.getResourceId(R.styleable.RestrictionEntry_defaultValue, 0); |
| 645 |
if (resId != 0) { |
| 646 |
restriction.setAllSelectedStrings( |
| 647 |
appContext.getResources().getStringArray(resId)); |
| 648 |
} |
| 649 |
break; |
| 650 |
case RestrictionEntry.TYPE_BOOLEAN: |
| 651 |
restriction.setSelectedState( |
| 652 |
a.getBoolean(R.styleable.RestrictionEntry_defaultValue, false)); |
| 653 |
break; |
| 654 |
case RestrictionEntry.TYPE_BUNDLE: |
| 655 |
case RestrictionEntry.TYPE_BUNDLE_ARRAY: |
| 656 |
final int outerDepth = xml.getDepth(); |
| 657 |
List<RestrictionEntry> restrictionEntries = new ArrayList<>(); |
| 658 |
while (XmlUtils.nextElementWithin(xml, outerDepth)) { |
| 659 |
RestrictionEntry childEntry = loadRestrictionElement(appContext, xml); |
| 660 |
if (childEntry == null) { |
| 661 |
Log.w(TAG, "Child entry cannot be loaded for bundle restriction " + key); |
| 662 |
} else { |
| 663 |
restrictionEntries.add(childEntry); |
| 664 |
if (restrictionType == RestrictionEntry.TYPE_BUNDLE_ARRAY |
| 665 |
&& childEntry.getType() != RestrictionEntry.TYPE_BUNDLE) { |
| 666 |
Log.w(TAG, "bundle_array " + key |
| 667 |
+ " can only contain entries of type bundle"); |
| 668 |
} |
| 669 |
} |
| 670 |
} |
| 671 |
restriction.setRestrictions(restrictionEntries.toArray(new RestrictionEntry[ |
| 672 |
restrictionEntries.size()])); |
| 673 |
break; |
| 674 |
default: |
| 675 |
Log.w(TAG, "Unknown restriction type " + restrictionType); |
| 676 |
} |
| 677 |
return restriction; |
| 678 |
} |
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
public static Bundle convertRestrictionsToBundle(List<RestrictionEntry> entries) { |
| 697 |
final Bundle bundle = new Bundle(); |
| 698 |
for (RestrictionEntry entry : entries) { |
| 699 |
addRestrictionToBundle(bundle, entry); |
| 700 |
} |
| 701 |
return bundle; |
| 702 |
} |
| 703 |
|
| 704 |
private static Bundle addRestrictionToBundle(Bundle bundle, RestrictionEntry entry) { |
| 705 |
switch (entry.getType()) { |
| 706 |
case RestrictionEntry.TYPE_BOOLEAN: |
| 707 |
bundle.putBoolean(entry.getKey(), entry.getSelectedState()); |
| 708 |
break; |
| 709 |
case RestrictionEntry.TYPE_CHOICE: |
| 710 |
case RestrictionEntry.TYPE_CHOICE_LEVEL: |
| 711 |
case RestrictionEntry.TYPE_MULTI_SELECT: |
| 712 |
bundle.putStringArray(entry.getKey(), entry.getAllSelectedStrings()); |
| 713 |
break; |
| 714 |
case RestrictionEntry.TYPE_INTEGER: |
| 715 |
bundle.putInt(entry.getKey(), entry.getIntValue()); |
| 716 |
break; |
| 717 |
case RestrictionEntry.TYPE_STRING: |
| 718 |
case RestrictionEntry.TYPE_NULL: |
| 719 |
bundle.putString(entry.getKey(), entry.getSelectedString()); |
| 720 |
break; |
| 721 |
case RestrictionEntry.TYPE_BUNDLE: |
| 722 |
RestrictionEntry[] restrictions = entry.getRestrictions(); |
| 723 |
Bundle childBundle = convertRestrictionsToBundle(Arrays.asList(restrictions)); |
| 724 |
bundle.putBundle(entry.getKey(), childBundle); |
| 725 |
break; |
| 726 |
case RestrictionEntry.TYPE_BUNDLE_ARRAY: |
| 727 |
RestrictionEntry[] bundleRestrictionArray = entry.getRestrictions(); |
| 728 |
Bundle[] bundleArray = new Bundle[bundleRestrictionArray.length]; |
| 729 |
for (int i = 0; i < bundleRestrictionArray.length; i++) { |
| 730 |
RestrictionEntry[] bundleRestrictions = |
| 731 |
bundleRestrictionArray[i].getRestrictions(); |
| 732 |
if (bundleRestrictions == null) { |
| 733 |
|
| 734 |
Log.w(TAG, "addRestrictionToBundle: " + |
| 735 |
"Non-bundle entry found in bundle array"); |
| 736 |
bundleArray[i] = new Bundle(); |
| 737 |
} else { |
| 738 |
bundleArray[i] = convertRestrictionsToBundle(Arrays.asList( |
| 739 |
bundleRestrictions)); |
| 740 |
} |
| 741 |
} |
| 742 |
bundle.putParcelableArray(entry.getKey(), bundleArray); |
| 743 |
break; |
| 744 |
default: |
| 745 |
throw new IllegalArgumentException( |
| 746 |
"Unsupported restrictionEntry type: " + entry.getType()); |
| 747 |
} |
| 748 |
return bundle; |
| 749 |
} |
| 750 |
|
| 751 |
} |