OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.sync.notifier; | 5 package org.chromium.sync.notifier; |
6 | 6 |
7 import android.accounts.Account; | 7 import android.accounts.Account; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 | 9 |
10 import com.google.ipc.invalidation.external.client.types.ObjectId; | 10 import com.google.ipc.invalidation.external.client.types.ObjectId; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 return registerIntent; | 108 return registerIntent; |
109 } | 109 } |
110 | 110 |
111 /** Returns whether {@code intent} is a stop intent. */ | 111 /** Returns whether {@code intent} is a stop intent. */ |
112 public static boolean isStop(Intent intent) { | 112 public static boolean isStop(Intent intent) { |
113 return intent.getBooleanExtra(EXTRA_STOP, false); | 113 return intent.getBooleanExtra(EXTRA_STOP, false); |
114 } | 114 } |
115 | 115 |
116 /** Returns whether {@code intent} is a registered types change intent. */ | 116 /** Returns whether {@code intent} is a registered types change intent. */ |
117 public static boolean isRegisteredTypesChange(Intent intent) { | 117 public static boolean isRegisteredTypesChange(Intent intent) { |
118 return intent.hasExtra(EXTRA_REGISTERED_TYPES) || | 118 return intent.hasExtra(EXTRA_REGISTERED_TYPES) |
119 intent.hasExtra(EXTRA_REGISTERED_OBJECT_SOURCES); | 119 || intent.hasExtra(EXTRA_REGISTERED_OBJECT_SOURCES); |
120 } | 120 } |
121 | 121 |
122 /** Returns the object ids for which to register contained in the intent. */ | 122 /** Returns the object ids for which to register contained in the intent. */ |
123 public static Set<ObjectId> getRegisteredObjectIds(Intent intent) { | 123 public static Set<ObjectId> getRegisteredObjectIds(Intent intent) { |
124 ArrayList<Integer> objectSources = | 124 ArrayList<Integer> objectSources = |
125 intent.getIntegerArrayListExtra(EXTRA_REGISTERED_OBJECT_SOURCES)
; | 125 intent.getIntegerArrayListExtra(EXTRA_REGISTERED_OBJECT_SOURCES)
; |
126 ArrayList<String> objectNames = | 126 ArrayList<String> objectNames = |
127 intent.getStringArrayListExtra(EXTRA_REGISTERED_OBJECT_NAMES); | 127 intent.getStringArrayListExtra(EXTRA_REGISTERED_OBJECT_NAMES); |
128 if (objectSources == null || objectNames == null || | 128 if (objectSources == null || objectNames == null |
129 objectSources.size() != objectNames.size()) { | 129 || objectSources.size() != objectNames.size()) { |
130 return null; | 130 return null; |
131 } | 131 } |
132 Set<ObjectId> objectIds = new HashSet<ObjectId>(objectSources.size()); | 132 Set<ObjectId> objectIds = new HashSet<ObjectId>(objectSources.size()); |
133 for (int i = 0; i < objectSources.size(); i++) { | 133 for (int i = 0; i < objectSources.size(); i++) { |
134 objectIds.add(ObjectId.newInstance( | 134 objectIds.add(ObjectId.newInstance( |
135 objectSources.get(i), objectNames.get(i).getBytes())); | 135 objectSources.get(i), objectNames.get(i).getBytes())); |
136 } | 136 } |
137 return objectIds; | 137 return objectIds; |
138 } | 138 } |
139 | 139 |
140 private InvalidationIntentProtocol() { | 140 private InvalidationIntentProtocol() { |
141 // Disallow instantiation. | 141 // Disallow instantiation. |
142 } | 142 } |
143 } | 143 } |
OLD | NEW |