Merge "Fix NPE in SyncManager#isSyncSetting." into sc-dev

This commit is contained in:
TreeHugger Robot
2021-03-23 17:51:05 +00:00
committed by Android (Google) Code Review
2 changed files with 21 additions and 0 deletions

View File

@@ -3978,6 +3978,9 @@ public class SyncManager {
* @return true if the provided key is used by the SyncManager in scheduling the sync.
*/
private static boolean isSyncSetting(String key) {
if (key == null) {
return false;
}
if (key.equals(ContentResolver.SYNC_EXTRAS_EXPEDITED)) {
return true;
}

View File

@@ -16,6 +16,7 @@
package com.android.server.content;
import android.content.ContentResolver;
import android.os.Bundle;
import android.test.suitebuilder.annotation.SmallTest;
@@ -57,6 +58,23 @@ public class SyncManagerTest extends TestCase {
SyncManager.syncExtrasEquals(b1, b2, false /* don't care about system extras */));
}
public void testSyncExtrasEqualsFails_WithNull() throws Exception {
Bundle b1 = new Bundle();
b1.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
b1.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
Bundle b2 = new Bundle();
b2.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
b2.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
b2.putString(null, "Hello NPE!");
b2.putString("a", "b");
b2.putString("c", "d");
b2.putString("e", "f");
assertFalse("Extras not properly compared between bundles.",
SyncManager.syncExtrasEquals(b1, b2, false /* don't care about system extras */));
}
public void testSyncExtrasEqualsFails_differentValues() throws Exception {
Bundle b1 = new Bundle();
Bundle b2 = new Bundle();