Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3e4c1f9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents f688a8b9 32fea82f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;
        }
+18 −0
Original line number Diff line number Diff line
@@ -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();