@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ConnectableSensor that = (ConnectableSensor) o;
if (!MessageNano.messageNanoEquals(mSpec, that.mSpec)) return false;
if (mConnectedSensorId != null ? !mConnectedSensorId.equals(that.mConnectedSensorId)
: that.mConnectedSensorId != null) {
return false;
}
return true;
}
java类com.google.protobuf.nano.MessageNano的实例源码
ConnectableSensor.java 文件源码
项目:science-journal
阅读 19
收藏 0
点赞 0
评论 0
UserMetadataManager.java 文件源码
项目:science-journal
阅读 22
收藏 0
点赞 0
评论 0
/**
* Adds a device to the user's list of devices if it is not yet added.
*/
public void addMyDevice(GoosciDeviceSpec.DeviceSpec device) {
GoosciUserMetadata.UserMetadata userMetadata = getUserMetadata();
if (userMetadata == null) {
return;
}
GoosciDeviceSpec.DeviceSpec[] myDevices = userMetadata.myDevices;
for (GoosciDeviceSpec.DeviceSpec myDevice : myDevices) {
if (MessageNano.messageNanoEquals(myDevice, device)) {
return;
}
}
GoosciDeviceSpec.DeviceSpec[] newSpecs = Arrays.copyOf(myDevices, myDevices.length + 1);
newSpecs[newSpecs.length - 1] = device;
userMetadata.myDevices = newSpecs;
// TODO: capture this pattern (read, null check, write) in a helper method?
startWriteTimer();
}
LabelTest.java 文件源码
项目:science-journal
阅读 20
收藏 0
点赞 0
评论 0
@Test
public void testParcelableBehavior() {
GoosciLabel.Label goosciLabel = new GoosciLabel.Label();
goosciLabel.timestampMs = 10;
goosciLabel.type = GoosciLabel.Label.SENSOR_TRIGGER;
SensorTrigger trigger = SensorTrigger.newNoteTypeTrigger("sensorId",
GoosciSensorTriggerInformation.TriggerInformation.TRIGGER_WHEN_DROPS_BELOW, "note",
7.5);
GoosciSensorTriggerLabelValue.SensorTriggerLabelValue labelValue =
new GoosciSensorTriggerLabelValue.SensorTriggerLabelValue();
labelValue.triggerInformation = trigger.getTriggerProto().triggerInformation;
goosciLabel.protoData = MessageNano.toByteArray(labelValue);
Label label = Label.fromLabel(goosciLabel);
label.setTimestamp(20);
Parcel parcel = Parcel.obtain();
label.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
Label result = Label.CREATOR.createFromParcel(parcel);
assertEquals(GoosciLabel.Label.SENSOR_TRIGGER, result.getType());
assertEquals(20, result.getTimeStamp());
assertEquals("note", result.getSensorTriggerLabelValue().triggerInformation.noteText);
}
ExperimentCacheTest.java 文件源码
项目:science-journal
阅读 23
收藏 0
点赞 0
评论 0
public void testExperimentWriteRead() {
Experiment experiment = Experiment.newExperiment(10, "exp_localId", 0);
ExperimentCache cache = new ExperimentCache(getInstrumentation().getContext(),
getFailureFailsListener(), 0);
cache.createNewExperiment(experiment);
cache.writeActiveExperimentFile();
// Was it set correctly in the ExperimentCache?
assertTrue(MessageNano.messageNanoEquals(
cache.getActiveExperimentForTests().getExperimentProto(),
experiment.getExperimentProto()));
// Force a load, make sure that's equal too.
cache.loadActiveExperimentFromFile(experiment.getExperimentOverview());
assertTrue(MessageNano.messageNanoEquals(
cache.getActiveExperimentForTests().getExperimentProto(),
experiment.getExperimentProto()));
// Clean up.
cache.deleteExperiment("exp_localId");
assertNull(cache.getActiveExperimentForTests());
}
DfeRequest.java 文件源码
项目:FMTech
阅读 23
收藏 0
点赞 0
评论 0
private void stripForCache(Response.ResponseWrapper paramResponseWrapper, Cache.Entry paramEntry)
{
if ((paramResponseWrapper.preFetch.length <= 0) && (paramResponseWrapper.commands == null) && (paramResponseWrapper.notification.length <= 0) && (paramResponseWrapper.serverCookies == null)) {
return;
}
Cache localCache = this.mApiContext.mCache;
long l = System.currentTimeMillis();
for (PreFetch localPreFetch : paramResponseWrapper.preFetch)
{
Cache.Entry localEntry = new Cache.Entry();
localEntry.data = localPreFetch.response;
localEntry.etag = localPreFetch.etag;
localEntry.serverDate = paramEntry.serverDate;
localEntry.ttl = (l + localPreFetch.ttl);
localEntry.softTtl = (l + localPreFetch.softTtl);
localCache.put(makeCacheKey(Uri.withAppendedPath(DfeApi.BASE_URI, localPreFetch.url).toString()), localEntry);
}
paramResponseWrapper.preFetch = PreFetch.emptyArray();
paramResponseWrapper.commands = null;
paramResponseWrapper.notification = Notification.emptyArray();
paramResponseWrapper.serverCookies = null;
paramEntry.data = MessageNano.toByteArray(paramResponseWrapper);
}
ContentFiltersActivity2.java 文件源码
项目:FMTech
阅读 34
收藏 0
点赞 0
评论 0
private boolean launchChoiceConfirmationDialog(ContentFilters.FilterRange paramFilterRange, int paramInt1, int paramInt2)
{
if (((paramFilterRange.confirmationDialogTitle.isEmpty()) && (paramFilterRange.confirmationDialogContent.isEmpty())) || (this.mConfirmationDialogsShown.contains(Integer.valueOf(paramInt2)))) {
return false;
}
SimpleAlertDialog.Builder localBuilder = new SimpleAlertDialog.Builder();
if (!TextUtils.isEmpty(paramFilterRange.confirmationDialogTitle)) {
localBuilder.setTitle(paramFilterRange.confirmationDialogTitle);
}
if (!TextUtils.isEmpty(paramFilterRange.confirmationDialogContent)) {
localBuilder.setMessage(paramFilterRange.confirmationDialogContent);
}
localBuilder.setEventLog(322, null, -1, -1, null);
localBuilder.setPositiveId(2131362418).setCanceledOnTouchOutside(true);
Bundle localBundle = new Bundle();
localBundle.putInt("ContentFiltersActivity2.selectedChoiceIndex", paramInt1);
localBundle.putByteArray("ContentFiltersActivity2.filterRange", MessageNano.toByteArray(paramFilterRange));
localBundle.putInt("ContentFiltersActivity2.filterRangeIndex", paramInt2);
localBuilder.setCallback(null, 1, localBundle);
localBuilder.build().show(getSupportFragmentManager(), "ContentFiltersActivity2.confirmationDialog");
return true;
}
FinskyEventLog.java 文件源码
项目:FMTech
阅读 23
收藏 0
点赞 0
评论 0
private static void writeLogToListener(String paramString, byte[] paramArrayOfByte)
{
try
{
if (sLogTestListener != null)
{
ClientAnalytics.LogEvent localLogEvent = new ClientAnalytics.LogEvent();
localLogEvent.eventTimeMs = System.currentTimeMillis();
localLogEvent.tag = paramString;
if (paramArrayOfByte != null) {
localLogEvent.sourceExtension = paramArrayOfByte;
}
MessageNano.toByteArray(localLogEvent);
}
return;
}
finally {}
}
DfeRequest.java 文件源码
项目:FMTech
阅读 26
收藏 0
点赞 0
评论 0
private void stripForCache(PlayResponse.PlayResponseWrapper paramPlayResponseWrapper, Cache.Entry paramEntry)
{
if ((paramPlayResponseWrapper.preFetch.length <= 0) && (paramPlayResponseWrapper.commands == null)) {
return;
}
Cache localCache = this.mApiContext.mCache;
long l = System.currentTimeMillis();
for (PreFetch localPreFetch : paramPlayResponseWrapper.preFetch)
{
Cache.Entry localEntry = new Cache.Entry();
localEntry.data = localPreFetch.response;
localEntry.etag = localPreFetch.etag;
localEntry.serverDate = paramEntry.serverDate;
localEntry.ttl = (l + localPreFetch.ttl);
localEntry.softTtl = (l + localPreFetch.softTtl);
localCache.put(makeCacheKey(Uri.withAppendedPath(PlayDfeApi.BASE_URI, localPreFetch.url).toString()), localEntry);
}
paramPlayResponseWrapper.preFetch = PreFetch.emptyArray();
paramPlayResponseWrapper.commands = null;
paramEntry.data = MessageNano.toByteArray(paramPlayResponseWrapper);
}
SecureRequest.java 文件源码
项目:FMTech
阅读 24
收藏 0
点赞 0
评论 0
protected final Response<Pair<RequestT, ResponseT>> parseNetworkResponse(NetworkResponse paramNetworkResponse)
{
try
{
Class localClass = this.mResponseClass;
MessageNano localMessageNano1 = (MessageNano)this.mResponseClass.newInstance();
byte[] arrayOfByte = paramNetworkResponse.data;
MessageNano localMessageNano2 = (MessageNano)localClass.cast(MessageNano.mergeFrom$1ec43da(localMessageNano1, arrayOfByte, arrayOfByte.length));
ProtoUtils.logResponse(localMessageNano2, getUrl());
Cache.Entry localEntry = HttpHeaderParser.parseCacheHeaders(paramNetworkResponse);
return Response.success(Pair.create(this, localMessageNano2), localEntry);
}
catch (InstantiationException localInstantiationException)
{
throw new RuntimeException("Failed to instantiate proto object.", localInstantiationException);
}
catch (IllegalAccessException localIllegalAccessException)
{
throw new RuntimeException("Failed to access proto constructor.", localIllegalAccessException);
}
catch (IOException localIOException)
{
Log.e("SecureRequest", "Couldn't parse proto response for url=" + getUrl());
}
return Response.error(new ParseError(paramNetworkResponse));
}
ProtoUtils.java 文件源码
项目:FMTech
阅读 27
收藏 0
点赞 0
评论 0
public static <T extends MessageNano> T parseFrom(byte[] paramArrayOfByte, Class<T> paramClass)
{
try
{
MessageNano localMessageNano = MessageNano.mergeFrom$1ec43da((MessageNano)paramClass.newInstance(), paramArrayOfByte, paramArrayOfByte.length);
return localMessageNano;
}
catch (InstantiationException localInstantiationException)
{
throw new RuntimeException("Failed to parse a known parcelable proto " + paramClass.getName());
}
catch (IllegalAccessException localIllegalAccessException)
{
throw new RuntimeException("Failed to parse a known parcelable proto " + paramClass.getName());
}
catch (IOException localIOException)
{
throw new RuntimeException("Failed to parse a known parcelable proto " + paramClass.getName());
}
}
ParcelableProto.java 文件源码
项目:FMTech
阅读 25
收藏 0
点赞 0
评论 0
private static ParcelableProto<MessageNano> createFromParcel(Parcel paramAnonymousParcel)
{
int i = paramAnonymousParcel.readInt();
if (i == -1) {
return new ParcelableProto(null, (byte)0);
}
byte[] arrayOfByte = new byte[i];
paramAnonymousParcel.readByteArray(arrayOfByte);
String str = paramAnonymousParcel.readString();
try
{
MessageNano localMessageNano = (MessageNano)Class.forName(str).getConstructor(null).newInstance(null);
localMessageNano.mergeFrom(CodedInputByteBufferNano.newInstance(arrayOfByte, 0, i));
ParcelableProto localParcelableProto = new ParcelableProto(localMessageNano, (byte)0);
return localParcelableProto;
}
catch (Exception localException)
{
throw new IllegalArgumentException("Exception when unmarshalling: " + str, localException);
}
}
ParcelableProto.java 文件源码
项目:FMTech
阅读 28
收藏 0
点赞 0
评论 0
public static <T extends MessageNano> ArrayList<ParcelableProto<T>> forProtoArray(T[] paramArrayOfT)
{
Object localObject;
if (paramArrayOfT == null) {
localObject = null;
}
for (;;)
{
return localObject;
localObject = new ArrayList(paramArrayOfT.length);
int i = paramArrayOfT.length;
for (int j = 0; j < i; j++) {
((ArrayList)localObject).add(forProto(paramArrayOfT[j]));
}
}
}
ParcelableProto.java 文件源码
项目:FMTech
阅读 29
收藏 0
点赞 0
评论 0
public static <T extends MessageNano> ArrayList<T> getProtoArrayListFromBundle(Bundle paramBundle, String paramString)
{
ArrayList localArrayList = paramBundle.getParcelableArrayList(paramString);
Object localObject;
if (localArrayList == null) {
localObject = null;
}
for (;;)
{
return localObject;
int i = localArrayList.size();
localObject = new ArrayList(i);
for (int j = 0; j < i; j++) {
((ArrayList)localObject).add(((ParcelableProto)localArrayList.get(j)).mPayload);
}
}
}
StorageDelegate.java 文件源码
项目:chromium-for-android-56-debug-video
阅读 21
收藏 0
点赞 0
评论 0
/**
* Update tab entries based on metadata.
* @param metadataBytes Metadata from last time Chrome was alive.
* @param entryMap Map to fill with {@link DocumentTabModel.Entry}s about Tabs.
* @param recentlyClosedTabIdList List to fill with IDs of recently closed tabs.
*/
private void updateTabEntriesFromMetadata(byte[] metadataBytes, SparseArray<Entry> entryMap,
List<Integer> recentlyClosedTabIdList) {
if (metadataBytes != null) {
DocumentList list = null;
try {
list = MessageNano.mergeFrom(new DocumentList(), metadataBytes);
} catch (IOException e) {
Log.e(TAG, "I/O exception", e);
}
if (list == null) return;
for (int i = 0; i < list.entries.length; i++) {
DocumentEntry savedEntry = list.entries[i];
int tabId = savedEntry.tabId;
// If the tab ID isn't in the list, it must have been closed after Chrome died.
if (entryMap.indexOfKey(tabId) < 0) {
recentlyClosedTabIdList.add(tabId);
continue;
}
// Restore information about the Tab.
entryMap.get(tabId).canGoBack = savedEntry.canGoBack;
}
}
}
UserMetadataManager.java 文件源码
项目:science-journal
阅读 21
收藏 0
点赞 0
评论 0
public void removeMyDevice(GoosciDeviceSpec.DeviceSpec device) {
GoosciUserMetadata.UserMetadata userMetadata = getUserMetadata();
if (userMetadata == null) {
return;
}
GoosciDeviceSpec.DeviceSpec[] myDevices = userMetadata.myDevices;
for (int i = 0; i < myDevices.length; i++) {
if (MessageNano.messageNanoEquals(myDevices[i], device)) {
removeMyDeviceAtIndex(userMetadata, i);
return;
}
}
}
Label.java 文件源码
项目:science-journal
阅读 31
收藏 0
点赞 0
评论 0
/**
* Creates a new label with the specified label value.
*/
public static Label newLabelWithValue(long creationTimeMs, int type, MessageNano data,
GoosciCaption.Caption caption) {
Label result = new Label(creationTimeMs, java.util.UUID.randomUUID().toString(), type);
result.setLabelProtoData(data);
result.setCaption(caption);
return result;
}
ExternalSensorSpec.java 文件源码
项目:science-journal
阅读 29
收藏 0
点赞 0
评论 0
public static byte[] getBytes(MessageNano config) {
byte[] output = new byte[config.getSerializedSize()];
CodedOutputByteBufferNano buffer = CodedOutputByteBufferNano.newInstance(output);
try {
config.writeTo(buffer);
} catch (IOException e) {
if (Log.isLoggable(TAG, Log.ERROR)) {
Log.e(TAG, "Could not serialize config", e);
}
}
return output;
}
SensorCardPresenter.java 文件源码
项目:science-journal
阅读 24
收藏 0
点赞 0
评论 0
private GoosciSensorLayout.SensorLayout copyLayout(GoosciSensorLayout.SensorLayout layout) {
try {
return GoosciSensorLayout.SensorLayout.parseFrom(MessageNano.toByteArray(layout));
} catch (InvalidProtocolBufferNanoException e) {
throw new RuntimeException("Should be impossible", e);
}
}
ProtoUtils.java 文件源码
项目:science-journal
阅读 22
收藏 0
点赞 0
评论 0
public static byte[] makeBlob(MessageNano proto) {
int serializedSize = proto.getSerializedSize();
byte[] output = new byte[serializedSize];
CodedOutputByteBufferNano buffer = CodedOutputByteBufferNano.newInstance(output);
try {
proto.writeTo(buffer);
} catch (IOException e) {
Log.e(TAG, "Could not serialize config", e);
}
return output;
}
LauncherBackupHelper.java 文件源码
项目:SimplOS
阅读 27
收藏 0
点赞 0
评论 0
/**
* Deserialize a proto after verifying checksum wrapper.
*/
private <T extends MessageNano> T unpackProto(T proto, byte[] buffer, int dataSize)
throws InvalidProtocolBufferNanoException {
MessageNano.mergeFrom(proto, readCheckedBytes(buffer, dataSize));
if (DEBUG) Log.d(TAG, "unpacked proto " + proto);
return proto;
}
LauncherBackupHelper.java 文件源码
项目:SimplOS
阅读 29
收藏 0
点赞 0
评论 0
private void writeRowToBackup(String backupKey, MessageNano proto,
BackupDataOutput data) throws IOException {
byte[] blob = writeCheckedBytes(proto);
data.writeEntityHeader(backupKey, blob.length);
data.writeEntityData(blob, blob.length);
mBackupDataWasUpdated = true;
if (VERBOSE) Log.v(TAG, "Writing New entry " + backupKey);
}
LauncherBackupHelper.java 文件源码
项目:SimplOS
阅读 30
收藏 0
点赞 0
评论 0
/** Wrap a proto in a CheckedMessage and compute the checksum. */
private byte[] writeCheckedBytes(MessageNano proto) {
CheckedMessage wrapper = new CheckedMessage();
wrapper.payload = MessageNano.toByteArray(proto);
CRC32 checksum = new CRC32();
checksum.update(wrapper.payload);
wrapper.checksum = checksum.getValue();
return MessageNano.toByteArray(wrapper);
}
LauncherBackupHelper.java 文件源码
项目:SimplOS
阅读 28
收藏 0
点赞 0
评论 0
/** Unwrap a proto message from a CheckedMessage, verifying the checksum. */
private static byte[] readCheckedBytes(byte[] buffer, int dataSize)
throws InvalidProtocolBufferNanoException {
CheckedMessage wrapper = new CheckedMessage();
MessageNano.mergeFrom(wrapper, buffer, 0, dataSize);
CRC32 checksum = new CRC32();
checksum.update(wrapper.payload);
if (wrapper.checksum != checksum.getValue()) {
throw new InvalidProtocolBufferNanoException("checksum does not match");
}
return wrapper.payload;
}
StorageDelegate.java 文件源码
项目:AndroidChromium
阅读 25
收藏 0
点赞 0
评论 0
/**
* Update tab entries based on metadata.
* @param metadataBytes Metadata from last time Chrome was alive.
* @param entryMap Map to fill with {@link DocumentTabModel.Entry}s about Tabs.
* @param recentlyClosedTabIdList List to fill with IDs of recently closed tabs.
*/
private void updateTabEntriesFromMetadata(byte[] metadataBytes, SparseArray<Entry> entryMap,
List<Integer> recentlyClosedTabIdList) {
if (metadataBytes != null) {
DocumentList list = null;
try {
list = MessageNano.mergeFrom(new DocumentList(), metadataBytes);
} catch (IOException e) {
Log.e(TAG, "I/O exception", e);
}
if (list == null) return;
for (int i = 0; i < list.entries.length; i++) {
DocumentEntry savedEntry = list.entries[i];
int tabId = savedEntry.tabId;
// If the tab ID isn't in the list, it must have been closed after Chrome died.
if (entryMap.indexOfKey(tabId) < 0) {
recentlyClosedTabIdList.add(tabId);
continue;
}
// Restore information about the Tab.
entryMap.get(tabId).canGoBack = savedEntry.canGoBack;
}
}
}
LauncherBackupHelper.java 文件源码
项目:Trebuchet
阅读 28
收藏 0
点赞 0
评论 0
/**
* Deserialize a proto after verifying checksum wrapper.
*/
private <T extends MessageNano> T unpackProto(T proto, byte[] buffer, int dataSize)
throws InvalidProtocolBufferNanoException {
MessageNano.mergeFrom(proto, readCheckedBytes(buffer, dataSize));
if (DEBUG) Log.d(TAG, "unpacked proto " + proto);
return proto;
}
LauncherBackupHelper.java 文件源码
项目:Trebuchet
阅读 30
收藏 0
点赞 0
评论 0
private void writeRowToBackup(String backupKey, MessageNano proto,
BackupDataOutput data) throws IOException {
byte[] blob = writeCheckedBytes(proto);
data.writeEntityHeader(backupKey, blob.length);
data.writeEntityData(blob, blob.length);
mBackupDataWasUpdated = true;
if (VERBOSE) Log.v(TAG, "Writing New entry " + backupKey);
}
LauncherBackupHelper.java 文件源码
项目:Trebuchet
阅读 41
收藏 0
点赞 0
评论 0
/** Wrap a proto in a CheckedMessage and compute the checksum. */
private byte[] writeCheckedBytes(MessageNano proto) {
CheckedMessage wrapper = new CheckedMessage();
wrapper.payload = MessageNano.toByteArray(proto);
CRC32 checksum = new CRC32();
checksum.update(wrapper.payload);
wrapper.checksum = checksum.getValue();
return MessageNano.toByteArray(wrapper);
}
LauncherBackupHelper.java 文件源码
项目:Trebuchet
阅读 34
收藏 0
点赞 0
评论 0
/** Unwrap a proto message from a CheckedMessage, verifying the checksum. */
private static byte[] readCheckedBytes(byte[] buffer, int dataSize)
throws InvalidProtocolBufferNanoException {
CheckedMessage wrapper = new CheckedMessage();
MessageNano.mergeFrom(wrapper, buffer, 0, dataSize);
CRC32 checksum = new CRC32();
checksum.update(wrapper.payload);
if (wrapper.checksum != checksum.getValue()) {
throw new InvalidProtocolBufferNanoException("checksum does not match");
}
return wrapper.payload;
}
StorageDelegate.java 文件源码
项目:Vafrinn
阅读 23
收藏 0
点赞 0
评论 0
/**
* Update tab entries based on metadata.
* @param metadataBytes Metadata from last time Chrome was alive.
* @param entryMap Map to fill with {@link DocumentTabModel.Entry}s about Tabs.
* @param recentlyClosedTabIdList List to fill with IDs of recently closed tabs.
*/
private void updateTabEntriesFromMetadata(byte[] metadataBytes, SparseArray<Entry> entryMap,
List<Integer> recentlyClosedTabIdList) {
if (metadataBytes != null) {
DocumentList list = null;
try {
list = MessageNano.mergeFrom(new DocumentList(), metadataBytes);
} catch (IOException e) {
Log.e(TAG, "I/O exception", e);
}
if (list == null) return;
for (int i = 0; i < list.entries.length; i++) {
DocumentEntry savedEntry = list.entries[i];
int tabId = savedEntry.tabId;
// If the tab ID isn't in the list, it must have been closed after Chrome died.
if (entryMap.indexOfKey(tabId) < 0) {
recentlyClosedTabIdList.add(tabId);
continue;
}
// Restore information about the Tab.
entryMap.get(tabId).canGoBack = savedEntry.canGoBack;
}
}
}
ProtoUtils.java 文件源码
项目:PainlessMusicPlayer
阅读 22
收藏 0
点赞 0
评论 0
public static void writeToFile(@NonNull final Context context,
@NonNull final String fileName,
@NonNull final MessageNano messageNano) {
final byte[] output;
try {
output = toByteArray(messageNano);
} catch (IOException e) {
Log.w(TAG, e);
return;
}
FileUtils.writeOrDeletePrivateFile(context, fileName, output);
}