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

Commit 32fea82f authored by Varun Shah's avatar Varun Shah
Browse files

Fix NPE in SyncManager#isSyncSetting.

Fixes: 183243522
Test: atest SyncManagerTest
Change-Id: I8df3d2cd590e448c92035a422430b4011e378dba
parent c3f3255c
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();