Loading core/java/android/content/RestrictionsManager.java +14 −4 Original line number Diff line number Diff line Loading @@ -719,10 +719,20 @@ public class RestrictionsManager { bundle.putBundle(entry.getKey(), childBundle); break; case RestrictionEntry.TYPE_BUNDLE_ARRAY: restrictions = entry.getRestrictions(); Bundle[] bundleArray = new Bundle[restrictions.length]; for (int i = 0; i < restrictions.length; i++) { bundleArray[i] = addRestrictionToBundle(new Bundle(), restrictions[i]); RestrictionEntry[] bundleRestrictionArray = entry.getRestrictions(); Bundle[] bundleArray = new Bundle[bundleRestrictionArray.length]; for (int i = 0; i < bundleRestrictionArray.length; i++) { RestrictionEntry[] bundleRestrictions = bundleRestrictionArray[i].getRestrictions(); if (bundleRestrictions == null) { // Non-bundle entry found in bundle array. Log.w(TAG, "addRestrictionToBundle: " + "Non-bundle entry found in bundle array"); bundleArray[i] = new Bundle(); } else { bundleArray[i] = convertRestrictionsToBundle(Arrays.asList( bundleRestrictions)); } } bundle.putParcelableArray(entry.getKey(), bundleArray); break; Loading core/tests/coretests/src/android/content/RestrictionsManagerTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -74,4 +74,18 @@ public class RestrictionsManagerTest extends AndroidTestCase { assertEquals(2, childBundleArray.length); } public void testConvertRestrictionsToBundle_bundleArray() { String packageName = getContext().getPackageName(); List<RestrictionEntry> manifestRestrictions = mRm.getManifestRestrictions(packageName); Bundle bundle = RestrictionsManager.convertRestrictionsToBundle(manifestRestrictions); assertEquals(6, bundle.size()); Parcelable[] array = bundle.getParcelableArray("bundle_array_key"); assertNotNull(array); assertEquals(2, array.length); Bundle firstBundle = (Bundle) array[0]; assertEquals(0, firstBundle.size()); Bundle secondBundle = (Bundle) array[1]; assertEquals(1, secondBundle.size()); assertTrue(secondBundle.containsKey("bundle_array_bundle_int_key")); } } Loading
core/java/android/content/RestrictionsManager.java +14 −4 Original line number Diff line number Diff line Loading @@ -719,10 +719,20 @@ public class RestrictionsManager { bundle.putBundle(entry.getKey(), childBundle); break; case RestrictionEntry.TYPE_BUNDLE_ARRAY: restrictions = entry.getRestrictions(); Bundle[] bundleArray = new Bundle[restrictions.length]; for (int i = 0; i < restrictions.length; i++) { bundleArray[i] = addRestrictionToBundle(new Bundle(), restrictions[i]); RestrictionEntry[] bundleRestrictionArray = entry.getRestrictions(); Bundle[] bundleArray = new Bundle[bundleRestrictionArray.length]; for (int i = 0; i < bundleRestrictionArray.length; i++) { RestrictionEntry[] bundleRestrictions = bundleRestrictionArray[i].getRestrictions(); if (bundleRestrictions == null) { // Non-bundle entry found in bundle array. Log.w(TAG, "addRestrictionToBundle: " + "Non-bundle entry found in bundle array"); bundleArray[i] = new Bundle(); } else { bundleArray[i] = convertRestrictionsToBundle(Arrays.asList( bundleRestrictions)); } } bundle.putParcelableArray(entry.getKey(), bundleArray); break; Loading
core/tests/coretests/src/android/content/RestrictionsManagerTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -74,4 +74,18 @@ public class RestrictionsManagerTest extends AndroidTestCase { assertEquals(2, childBundleArray.length); } public void testConvertRestrictionsToBundle_bundleArray() { String packageName = getContext().getPackageName(); List<RestrictionEntry> manifestRestrictions = mRm.getManifestRestrictions(packageName); Bundle bundle = RestrictionsManager.convertRestrictionsToBundle(manifestRestrictions); assertEquals(6, bundle.size()); Parcelable[] array = bundle.getParcelableArray("bundle_array_key"); assertNotNull(array); assertEquals(2, array.length); Bundle firstBundle = (Bundle) array[0]; assertEquals(0, firstBundle.size()); Bundle secondBundle = (Bundle) array[1]; assertEquals(1, secondBundle.size()); assertTrue(secondBundle.containsKey("bundle_array_bundle_int_key")); } }