forked from PolymerLabs/arcs
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 4b05a28 Merge: f4c1d26 99000c2 Author: Alex Rosengarten <alxrsngrtn@google.com> Date: Tue Mar 3 11:18:14 2020 -0800 Merge branch 'r2p' of github.com:alxrsngrtn/arcs into r2p commit f4c1d26 Merge: 140111f 5c6310d Author: Alex Rosengarten <alxrsngrtn@google.com> Date: Tue Mar 3 11:14:35 2020 -0800 Merge branch 'master' of github.com:PolymerLabs/arcs into r2p Fixed lint errors commit 99000c2 Merge: 140111f 5c6310d Author: Alex Rosengarten <alxrsngrtn@google.com> Date: Tue Mar 3 11:14:35 2020 -0800 Merge branch 'master' of github.com:PolymerLabs/arcs into r2p Fixed lint errors commit 140111f Author: Alex Rosengarten <alxrsngrtn@google.com> Date: Tue Mar 3 11:08:12 2020 -0800 Removed flatMap, added TODOs and link to GH issue commit 5c6310d Author: jblebrun <jibbl@google.com> Date: Tue Mar 3 11:02:34 2020 -0800 Simplify service test pattern (PolymerLabs#4817) * Make a simple test lifecycle registry, instead of creating empty testactivity * Remove use of `runBlockingTest`: according to Kotlin/kotlinx.coroutines#1222, if the test results in coroutines being finished on other threads, it's possible to receive "This job has not yet completed" exceptions, even though the jobs were properly terminated. Since we don't need the delay-skipping properties of `runBlockingTest`, I think it's OK to use `runBlocking`. commit 472bc84 Author: Alex Rosengarten <alxrsngrtn@google.com> Date: Tue Mar 3 10:27:56 2020 -0800 Improved build rules commit ca1ebf8 Author: Alex Rosengarten <alxrsngrtn@google.com> Date: Tue Mar 3 10:17:13 2020 -0800 Impl suggestsions for r2p commit b5578ea Author: Jason Feinstein <jwf@google.com> Date: Tue Mar 3 09:54:17 2020 -0800 Add tests for dereferencing references to the HandleManagerTest(s) (PolymerLabs#4816) * Add dereferencing tests to the android handle manager test. * Add dereferencing tests to core HandleManager. commit a695797 Author: Jason Feinstein <jwf@google.com> Date: Mon Mar 2 18:14:07 2020 -0800 Create RawEntityDereferencerTest, storage Reference-> CrdtEntity.Reference (PolymerLabs#4812) * Create RawEntityDereferencerTest, make storage Reference implement CrdtEntity.Reference. Also: Create ParcelableReference. * Add dep. Also, apparently read/writeBoolean is Q-only. * Just write null if there is no version map. * Just write null if there is no version map. commit ba7a107 Author: Gogul Balakrishnan <bgogul@google.com> Date: Mon Mar 2 17:51:35 2020 -0800 Add a decoder for PrimitiveTypeProto and an option to disable android constraints in BUILD. (PolymerLabs#4793) commit f6df54a Author: Alex Rosengarten <alxrsngrtn@google.com> Date: Mon Mar 2 15:44:32 2020 -0800 tools/sigh lint commit bede8d9 Author: Alex Rosengarten <alxrsngrtn@google.com> Date: Mon Mar 2 14:52:02 2020 -0800 Fixed build rule, simplified runtime commit 62dcc57 Author: Alex Rosengarten <alxrsngrtn@google.com> Date: Mon Mar 2 14:38:14 2020 -0800 Fixed test, added TODO
- Loading branch information
Showing
33 changed files
with
978 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2020 Google LLC. | ||
* | ||
* This code may only be used under the BSD style license found at | ||
* http://polymer.github.io/LICENSE.txt | ||
* | ||
* Code distributed by Google as part of this project is also subject to an additional IP rights | ||
* grant found at | ||
* http://polymer.github.io/PATENTS.txt | ||
*/ | ||
|
||
package arcs.android.crdt | ||
|
||
import android.os.Parcel | ||
import android.os.Parcelable | ||
import arcs.android.util.writeProto | ||
import arcs.core.storage.Reference | ||
import arcs.core.storage.StorageKeyParser | ||
|
||
/** Parcelable version of [Reference]. */ | ||
data class ParcelableReference(override val actual: Reference) : ParcelableReferencable { | ||
override fun writeToParcel(parcel: Parcel, flags: Int) { | ||
super.writeToParcel(parcel, flags) | ||
parcel.writeString(actual.id) | ||
parcel.writeString(actual.storageKey.toString()) | ||
actual.version?.let { | ||
parcel.writeProto(it.toProto()) | ||
} ?: { | ||
parcel.writeTypedObject(null, flags) | ||
}() | ||
} | ||
|
||
override fun describeContents(): Int = 0 | ||
|
||
/* Don't use this directly, instead use ParcelableReferencable. */ | ||
internal companion object CREATOR : Parcelable.Creator<ParcelableReference> { | ||
override fun createFromParcel(parcel: Parcel): ParcelableReference { | ||
val id = requireNotNull(parcel.readString()) { | ||
"Required id not found in parcel for ParcelableReference" | ||
} | ||
val storageKeyString = requireNotNull(parcel.readString()) { | ||
"Required storageKey not found in parcel for ParcelableReference" | ||
} | ||
val versionMap = parcel.readVersionMap()?.takeIf { it.isNotEmpty() } | ||
|
||
return ParcelableReference( | ||
Reference(id, StorageKeyParser.parse(storageKeyString), versionMap) | ||
) | ||
} | ||
|
||
override fun newArray(size: Int): Array<ParcelableReference?> = arrayOfNulls(size) | ||
} | ||
} | ||
|
||
/** Writes the [Reference] to the receiving [Parcel]. */ | ||
fun Parcel.writeReference(reference: Reference, flags: Int) = | ||
writeTypedObject(ParcelableReference(reference), flags) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2020 Google LLC. | ||
* | ||
* This code may only be used under the BSD style license found at | ||
* http://polymer.github.io/LICENSE.txt | ||
* | ||
* Code distributed by Google as part of this project is also subject to an additional IP rights | ||
* grant found at | ||
* http://polymer.github.io/PATENTS.txt | ||
*/ | ||
|
||
package arcs.core.data.proto | ||
|
||
import arcs.core.data.PrimitiveType | ||
|
||
/** | ||
* Converts a [PrimitiveTypeProto] protobuf instance into a native kotlin [PrimitiveType] instance. | ||
*/ | ||
fun PrimitiveTypeProto.decode(): PrimitiveType = | ||
when (this) { | ||
PrimitiveTypeProto.TEXT -> PrimitiveType.Text | ||
PrimitiveTypeProto.NUMBER -> PrimitiveType.Number | ||
PrimitiveTypeProto.BOOLEAN -> PrimitiveType.Boolean | ||
PrimitiveTypeProto.UNRECOGNIZED -> | ||
throw IllegalArgumentException("Unknown PrimitiveTypeProto value.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.