diff options
| author | Matthew Williams <mjwilliams@google.com> | 2013-10-10 15:51:00 -0700 |
|---|---|---|
| committer | Matthew Williams <mjwilliams@google.com> | 2013-10-11 13:18:22 -0700 |
| commit | 632515b9d0960749ddb1636677d7f12f196d73f7 (patch) | |
| tree | 4812bfb7f9de3d5e9851e4fb1fa5f11f4e224bb7 /services/tests | |
| parent | 9dc7e12c67476d05e64822d3f019c4b7f46d253b (diff) | |
| download | frameworks_base-632515b9d0960749ddb1636677d7f12f196d73f7.zip frameworks_base-632515b9d0960749ddb1636677d7f12f196d73f7.tar.gz frameworks_base-632515b9d0960749ddb1636677d7f12f196d73f7.tar.bz2 | |
Fix infinite boot-loop bug in SM.
Bug:11064918
If the ContentResolver sync API is used with the empty ("")
string as a provider, the ContentService will throw an RTE.
This cl addresses all the entry points of the API that could
allow this, as well as adds an ifEmpty check at the point of
failure.
Also removed RTE throws from public functions(no point in
crashing the phone).
Change-Id: I57427d12a6cafb3e6d7a32ca0c10b05315b20580
Diffstat (limited to 'services/tests')
| -rw-r--r-- | services/tests/servicestests/src/com/android/server/content/SyncStorageEngineTest.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/services/tests/servicestests/src/com/android/server/content/SyncStorageEngineTest.java b/services/tests/servicestests/src/com/android/server/content/SyncStorageEngineTest.java index e44652f..f870e4c 100644 --- a/services/tests/servicestests/src/com/android/server/content/SyncStorageEngineTest.java +++ b/services/tests/servicestests/src/com/android/server/content/SyncStorageEngineTest.java @@ -670,6 +670,61 @@ public class SyncStorageEngineTest extends AndroidTestCase { assertEquals(0, engine.getIsSyncable(account, 0, "other3")); assertEquals(1, engine.getIsSyncable(account, 0, "other4")); } + + /** + * Verify that the API cannot cause a run-time reboot by passing in the empty string as an + * authority. The problem here is that + * {@link SyncStorageEngine#getOrCreateAuthorityLocked(account, provider)} would register + * an empty authority which causes a RTE in {@link SyncManager#scheduleReadyPeriodicSyncs()}. + * This is not strictly a SSE test, but it does depend on the SSE data structures. + */ + @SmallTest + public void testExpectedIllegalArguments() throws Exception { + try { + ContentResolver.setSyncAutomatically(account1, "", true); + fail("empty provider string should throw IllegalArgumentException"); + } catch (IllegalArgumentException expected) {} + + try { + ContentResolver.addPeriodicSync(account1, "", Bundle.EMPTY, 84000L); + fail("empty provider string should throw IllegalArgumentException"); + } catch (IllegalArgumentException expected) {} + + try { + ContentResolver.removePeriodicSync(account1, "", Bundle.EMPTY); + fail("empty provider string should throw IllegalArgumentException"); + } catch (IllegalArgumentException expected) {} + + try { + ContentResolver.cancelSync(account1, ""); + fail("empty provider string should throw IllegalArgumentException"); + } catch (IllegalArgumentException expected) {} + + try { + ContentResolver.setIsSyncable(account1, "", 0); + fail("empty provider string should throw IllegalArgumentException"); + } catch (IllegalArgumentException expected) {} + + try { + ContentResolver.cancelSync(account1, ""); + fail("empty provider string should throw IllegalArgumentException"); + } catch (IllegalArgumentException expected) {} + + try { + ContentResolver.requestSync(account1, "", Bundle.EMPTY); + fail("empty provider string should throw IllegalArgumentException"); + } catch (IllegalArgumentException expected) {} + + try { + ContentResolver.getSyncStatus(account1, ""); + fail("empty provider string should throw IllegalArgumentException"); + } catch (IllegalArgumentException expected) {} + + // Make sure we aren't blocking null account/provider for those functions that use it + // to specify ALL accounts/providers. + ContentResolver.requestSync(null, null, Bundle.EMPTY); + ContentResolver.cancelSync(null, null); + } } class TestContext extends ContextWrapper { |
