Loading services/core/java/com/android/server/storage/CacheQuotaStrategy.java +2 −3 Original line number Diff line number Diff line Loading @@ -369,12 +369,11 @@ public class CacheQuotaStrategy implements RemoteCallback.OnResultListener { tagName = parser.getName(); if (TAG_QUOTA.equals(tagName)) { CacheQuotaHint request = getRequestFromXml(parser); if (request == null) { continue; } if (request != null) { quotas.add(request); } } } eventType = parser.next(); } while (eventType != XmlPullParser.END_DOCUMENT); return new Pair<>(previousBytes, quotas); Loading services/tests/servicestests/src/com/android/server/storage/CacheQuotaStrategyTest.java +18 −2 Original line number Diff line number Diff line Loading @@ -23,13 +23,13 @@ import android.test.AndroidTestCase; import android.util.Pair; import android.util.Xml; import com.android.internal.util.FastXmlSerializer; import com.android.modules.utils.TypedXmlSerializer; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.xmlpull.v1.XmlPullParserException; import java.io.ByteArrayInputStream; import java.io.StringWriter; Loading Loading @@ -123,6 +123,22 @@ public class CacheQuotaStrategyTest extends AndroidTestCase { buildCacheQuotaHint("uuid2", 10, 250)); } @Test public void testReadInvalidInput() throws Exception { String input = "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n" + "<cache-info previousBytes=\"1000\">\n" + "<quota/>\n" + "</cache-info>\n"; try { CacheQuotaStrategy.readFromXml(new ByteArrayInputStream( input.getBytes("UTF-8"))); fail("Expected XML parsing exception"); } catch (XmlPullParserException e) { // Expected XmlPullParserException exception } } private CacheQuotaHint buildCacheQuotaHint(String volumeUuid, int uid, long quota) { return new CacheQuotaHint.Builder() .setVolumeUuid(volumeUuid).setUid(uid).setQuota(quota).build(); Loading Loading
services/core/java/com/android/server/storage/CacheQuotaStrategy.java +2 −3 Original line number Diff line number Diff line Loading @@ -369,12 +369,11 @@ public class CacheQuotaStrategy implements RemoteCallback.OnResultListener { tagName = parser.getName(); if (TAG_QUOTA.equals(tagName)) { CacheQuotaHint request = getRequestFromXml(parser); if (request == null) { continue; } if (request != null) { quotas.add(request); } } } eventType = parser.next(); } while (eventType != XmlPullParser.END_DOCUMENT); return new Pair<>(previousBytes, quotas); Loading
services/tests/servicestests/src/com/android/server/storage/CacheQuotaStrategyTest.java +18 −2 Original line number Diff line number Diff line Loading @@ -23,13 +23,13 @@ import android.test.AndroidTestCase; import android.util.Pair; import android.util.Xml; import com.android.internal.util.FastXmlSerializer; import com.android.modules.utils.TypedXmlSerializer; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.xmlpull.v1.XmlPullParserException; import java.io.ByteArrayInputStream; import java.io.StringWriter; Loading Loading @@ -123,6 +123,22 @@ public class CacheQuotaStrategyTest extends AndroidTestCase { buildCacheQuotaHint("uuid2", 10, 250)); } @Test public void testReadInvalidInput() throws Exception { String input = "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n" + "<cache-info previousBytes=\"1000\">\n" + "<quota/>\n" + "</cache-info>\n"; try { CacheQuotaStrategy.readFromXml(new ByteArrayInputStream( input.getBytes("UTF-8"))); fail("Expected XML parsing exception"); } catch (XmlPullParserException e) { // Expected XmlPullParserException exception } } private CacheQuotaHint buildCacheQuotaHint(String volumeUuid, int uid, long quota) { return new CacheQuotaHint.Builder() .setVolumeUuid(volumeUuid).setUid(uid).setQuota(quota).build(); Loading