Skip to content

Commit

Permalink
Merge tag 'android-5.1.1_r33' into HEAD
Browse files Browse the repository at this point in the history
Ticket: CYNGNOS-1404
Android 5.1.1 release 33

Change-Id: I00d32ba39b5bc3c5bbbc0054fe4b91c4b9fd97
  • Loading branch information
Jessica Wagantall authored and pimpmaneaton committed Mar 7, 2016
1 parent ab44cbb commit 3f045b5
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 8 deletions.
6 changes: 5 additions & 1 deletion core/java/android/content/PeriodicSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import android.os.Parcel;
import android.accounts.Account;

import java.util.Objects;

/**
* Value type that contains information about a periodic sync.
*/
Expand Down Expand Up @@ -144,7 +146,9 @@ public static boolean syncExtrasEquals(Bundle b1, Bundle b2) {
if (!b2.containsKey(key)) {
return false;
}
if (!b1.get(key).equals(b2.get(key))) {
// Null check. According to ContentResolver#validateSyncExtrasBundle null-valued keys
// are allowed in the bundle.
if (!Objects.equals(b1.get(key), b2.get(key))) {
return false;
}
}
Expand Down
12 changes: 5 additions & 7 deletions services/core/java/com/android/server/content/SyncManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;

Expand Down Expand Up @@ -1956,12 +1957,10 @@ public void onBootCompleted() {
doDatabaseCleanup();
synchronized(this) {
// Dispatch any stashed messages.
if (mBootQueue != null) {
for (Message message : mBootQueue) {
sendMessage(message);
}
mBootQueue = null;
for (Message message : mBootQueue) {
sendMessage(message);
}
mBootQueue = null;
mBootCompleted = true;
}
}
Expand Down Expand Up @@ -3201,15 +3200,14 @@ public static boolean syncExtrasEquals(Bundle b1, Bundle b2, boolean includeSync
if (!smaller.containsKey(key)) {
return false;
}
if (!bigger.get(key).equals(smaller.get(key))) {
if (!Objects.equals(bigger.get(key), smaller.get(key))) {
return false;
}
}
return true;
}

/**
* TODO: Get rid of this when we separate sync settings extras from dev specified extras.
* @return true if the provided key is used by the SyncManager in scheduling the sync.
*/
private static boolean isSyncSetting(String key) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.android.server.content;

import android.os.Bundle;

import junit.framework.TestCase;

public class SyncManagerTest extends TestCase {

final String KEY_1 = "key_1";
final String KEY_2 = "key_2";

public void testSyncExtrasEquals_WithNull() throws Exception {
Bundle b1 = new Bundle();
Bundle b2 = new Bundle();

b1.putString(KEY_1, null);
b2.putString(KEY_1, null);

assertTrue("Null extra not properly compared between bundles.",
SyncManager.syncExtrasEquals(b1, b2, false /* don't care about system extras */));
}

public void testSyncExtrasEqualsBigger_WithNull() throws Exception {
Bundle b1 = new Bundle();
Bundle b2 = new Bundle();

b1.putString(KEY_1, null);
b2.putString(KEY_1, null);

b1.putString(KEY_2, "bla");
b2.putString(KEY_2, "bla");

assertTrue("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();

b1.putString(KEY_1, null);
b2.putString(KEY_1, null);

b1.putString(KEY_2, "bla");
b2.putString(KEY_2, "ble"); // different key

assertFalse("Extras considered equal when they are different.",
SyncManager.syncExtrasEquals(b1, b2, false /* don't care about system extras */));
}

public void testSyncExtrasEqualsFails_differentNulls() throws Exception {
Bundle b1 = new Bundle();
Bundle b2 = new Bundle();

b1.putString(KEY_1, null);
b2.putString(KEY_1, "bla"); // different key

b1.putString(KEY_2, "ble");
b2.putString(KEY_2, "ble");

assertFalse("Extras considered equal when they are different.",
SyncManager.syncExtrasEquals(b1, b2, false /* don't care about system extras */));
}
}

0 comments on commit 3f045b5

Please sign in to comment.