From 0792af865d7e10f8524b8c66cf5954d5597d1566 Mon Sep 17 00:00:00 2001 From: Shannon Rodricks Date: Sun, 22 Aug 2021 12:00:11 +0530 Subject: [PATCH] Permissions revamp - Removed share flag - Removed granular encryption, is now across types --- .../cipher/MADAssistantCipherImplTest.kt | 8 -- .../AnalyticsPermissionModelTest.kt | 7 -- .../ApiCallsPermissionModelTest.kt | 11 +-- .../MADAssistantPermissionsTest.kt | 28 ------- .../permissions/AnalyticsPermissionModel.kt | 18 +---- .../permissions/ApiCallsPermissionModel.kt | 14 +--- .../permissions/ExceptionsPermissionModel.kt | 22 ++---- .../permissions/GenericLogsPermissionModel.kt | 48 +++++------ .../permissions/MADAssistantPermissions.kt | 79 ++++++++++--------- .../transmission/TransmissionModel.java | 79 ------------------- .../models/transmission/TransmissionModel.kt | 58 ++++++++++++++ 11 files changed, 132 insertions(+), 240 deletions(-) delete mode 100644 madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/models/permissions/MADAssistantPermissionsTest.kt delete mode 100644 madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/transmission/TransmissionModel.java create mode 100644 madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/transmission/TransmissionModel.kt diff --git a/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/cipher/MADAssistantCipherImplTest.kt b/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/cipher/MADAssistantCipherImplTest.kt index 8b7c79a..0c0c781 100644 --- a/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/cipher/MADAssistantCipherImplTest.kt +++ b/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/cipher/MADAssistantCipherImplTest.kt @@ -27,12 +27,4 @@ class MADAssistantCipherImplTest { assertEquals(plainText, deciphered) } - @Test - fun testPermissionModel() { - val input = MADAssistantPermissions( - deviceId = "fsdfsdfsd", - - ) - } - } \ No newline at end of file diff --git a/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/models/permissions/AnalyticsPermissionModelTest.kt b/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/models/permissions/AnalyticsPermissionModelTest.kt index fc42884..7df5b56 100644 --- a/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/models/permissions/AnalyticsPermissionModelTest.kt +++ b/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/models/permissions/AnalyticsPermissionModelTest.kt @@ -7,16 +7,12 @@ class AnalyticsPermissionModelTest { private fun testJson( enabled: Boolean = false, - read: Boolean = false, - share: Boolean = false, filterDestination: String? = null, filterEventName: String? = null, filterParamData: String? = null ) { val input = AnalyticsPermissionModel( enabled = enabled, - read = read, - share = share, filterDestination = filterDestination, filterEventName = filterEventName, filterParamData = filterParamData @@ -30,8 +26,6 @@ class AnalyticsPermissionModelTest { fun serializeSimpleObject() { testJson( enabled = true, - read = true, - share = true, filterDestination = "Test*", filterEventName = null ) @@ -41,7 +35,6 @@ class AnalyticsPermissionModelTest { fun serializeRegexFilter() { testJson( enabled = true, - read = true, filterDestination = "(Destination1|Destination2).*", filterParamData = "\"screen_view\"" ) diff --git a/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/models/permissions/ApiCallsPermissionModelTest.kt b/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/models/permissions/ApiCallsPermissionModelTest.kt index 8e5036d..924437d 100644 --- a/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/models/permissions/ApiCallsPermissionModelTest.kt +++ b/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/models/permissions/ApiCallsPermissionModelTest.kt @@ -7,15 +7,11 @@ class ApiCallsPermissionModelTest { private fun testJson( enabled: Boolean = false, - read: Boolean = false, - share: Boolean = false, filterMethod: String? = null, filterUrl: String? = null ): ApiCallsPermissionModel { val input = ApiCallsPermissionModel( enabled = enabled, - read = read, - share = share, filterMethod = filterMethod, filterUrl = filterUrl ) @@ -30,8 +26,6 @@ class ApiCallsPermissionModelTest { fun serializeSimpleObject() { testJson( enabled = true, - read = true, - share = true, filterMethod = ".*(GET|POST).*", filterUrl = null ) @@ -41,12 +35,9 @@ class ApiCallsPermissionModelTest { fun withRegexUrlFilter() { testJson( enabled = true, - read = true, filterMethod = null, filterUrl = "/records/.*" - ).apply { - assertEquals(false, this.share) - } + ) } } \ No newline at end of file diff --git a/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/models/permissions/MADAssistantPermissionsTest.kt b/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/models/permissions/MADAssistantPermissionsTest.kt deleted file mode 100644 index 4914a73..0000000 --- a/madassistant-common/src/androidTest/java/com/evdayapps/madassistant/common/models/permissions/MADAssistantPermissionsTest.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.evdayapps.madassistant.common.models.permissions - -import org.junit.Assert.assertEquals - -class MADAssistantPermissionsTest { - - private fun runSerializationAssertation( - timestampStart: Long? = null, - timestampEnd: Long? = null, - deviceId: String? = null, - networkCalls: ApiCallsPermissionModel = ApiCallsPermissionModel(), - analytics: AnalyticsPermissionModel = AnalyticsPermissionModel(), - exceptions: ExceptionsPermissionModel = ExceptionsPermissionModel(), - genericLogs: GenericLogsPermissionModel = GenericLogsPermissionModel(), - randomString: String? = System.currentTimeMillis().toString() - ): MADAssistantPermissions { - val input = MADAssistantPermissions( - - ) - - val output = MADAssistantPermissions(input.toJsonObject()) - - assertEquals(input, output) - - return output - } - -} \ No newline at end of file diff --git a/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/AnalyticsPermissionModel.kt b/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/AnalyticsPermissionModel.kt index 6b46934..861a977 100644 --- a/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/AnalyticsPermissionModel.kt +++ b/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/AnalyticsPermissionModel.kt @@ -4,19 +4,14 @@ import com.evdayapps.madassistant.common.kotlinx.getStringOrNull import org.json.JSONObject data class AnalyticsPermissionModel( - var enabled: Boolean = false, - var read: Boolean = false, - var share: Boolean = false, - var filterDestination: String? = null, - var filterEventName: String? = null, - var filterParamData: String? = null, + val enabled: Boolean = false, + val filterDestination: String? = null, + val filterEventName: String? = null, + val filterParamData: String? = null, ) { companion object { private const val KEY_enabled = "enabled" - private const val KEY_read = "read" - private const val KEY_share = "share" - private const val KEY_filterDestination = "filterDestination" private const val KEY_filterEventName = "filterEventName" private const val KEY_filterParamData = "filterParamData" @@ -25,8 +20,6 @@ data class AnalyticsPermissionModel( @Throws(Exception::class) constructor(json: JSONObject) : this( enabled = json.optBoolean(KEY_enabled, false), - read = json.optBoolean(KEY_read, false), - share = json.optBoolean(KEY_share, false), filterDestination = json.getStringOrNull(KEY_filterDestination), filterEventName = json.getStringOrNull(KEY_filterEventName), filterParamData = json.getStringOrNull(KEY_filterParamData), @@ -35,9 +28,6 @@ data class AnalyticsPermissionModel( fun toJsonObject(): JSONObject { return JSONObject().apply { put(KEY_enabled, enabled) - put(KEY_read, read) - put(KEY_share, share) - putOpt(KEY_filterDestination, filterDestination) putOpt(KEY_filterEventName, filterEventName) putOpt(KEY_filterParamData, filterParamData) diff --git a/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/ApiCallsPermissionModel.kt b/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/ApiCallsPermissionModel.kt index 0915127..5d7ce40 100644 --- a/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/ApiCallsPermissionModel.kt +++ b/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/ApiCallsPermissionModel.kt @@ -5,17 +5,13 @@ import org.json.JSONException import org.json.JSONObject data class ApiCallsPermissionModel( - var enabled: Boolean = false, - var read: Boolean = false, - var share: Boolean = false, - var filterMethod: String? = null, - var filterUrl: String? = null + val enabled: Boolean = false, + val filterMethod: String? = null, + val filterUrl: String? = null ) { companion object { private const val KEY_enabled = "enabled" - private const val KEY_read = "read" - private const val KEY_share = "share" private const val KEY_filterMethod = "filterMethod" private const val KEY_filterUrl = "filterUrl" } @@ -23,8 +19,6 @@ data class ApiCallsPermissionModel( @Throws(JSONException::class) constructor(json: JSONObject) : this( enabled = json.optBoolean(KEY_enabled, false), - read = json.optBoolean(KEY_read, false), - share = json.optBoolean(KEY_share, false), filterMethod = json.getStringOrNull(KEY_filterMethod), filterUrl = json.getStringOrNull(KEY_filterUrl) ) @@ -32,8 +26,6 @@ data class ApiCallsPermissionModel( fun toJsonObject(): JSONObject { return JSONObject().apply { put(KEY_enabled, enabled) - put(KEY_read, read) - put(KEY_share, share) putOpt(KEY_filterMethod, filterMethod) putOpt(KEY_filterUrl, filterUrl) } diff --git a/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/ExceptionsPermissionModel.kt b/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/ExceptionsPermissionModel.kt index 0ac1898..70afa2f 100644 --- a/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/ExceptionsPermissionModel.kt +++ b/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/ExceptionsPermissionModel.kt @@ -4,20 +4,14 @@ import com.evdayapps.madassistant.common.kotlinx.getStringOrNull import org.json.JSONObject data class ExceptionsPermissionModel( - var enabled: Boolean = false, - var read: Boolean = false, - var share: Boolean = false, - // Filters - var filterType: String? = null, - var filterMessage: String? = null, - // Crashes - var crashesEnabled: Boolean = false, + val enabled: Boolean = false, + val filterType: String? = null, + val filterMessage: String? = null, + val logCrashes: Boolean = false, ) { companion object { private const val KEY_enabled = "enabled" - private const val KEY_read = "read" - private const val KEY_share = "share" private const val KEY_filterType = "filterType" private const val KEY_filterMessage = "filterMessage" private const val KEY_logCrashes = "logCrashes" @@ -26,9 +20,7 @@ data class ExceptionsPermissionModel( @Throws(Exception::class) constructor(json: JSONObject) : this( enabled = json.optBoolean(KEY_enabled, false), - read = json.optBoolean(KEY_read, false), - share = json.optBoolean(KEY_share, false), - crashesEnabled = json.optBoolean(KEY_logCrashes, false), + logCrashes = json.optBoolean(KEY_logCrashes, false), filterType = json.getStringOrNull(KEY_filterType), filterMessage = json.getStringOrNull(KEY_filterMessage) ) @@ -36,9 +28,7 @@ data class ExceptionsPermissionModel( fun toJsonObject(): JSONObject { return JSONObject().apply { put(KEY_enabled, enabled) - put(KEY_read, read) - put(KEY_share, share) - + put(KEY_logCrashes, logCrashes) putOpt(KEY_filterType, filterType) putOpt(KEY_filterMessage, filterMessage) } diff --git a/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/GenericLogsPermissionModel.kt b/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/GenericLogsPermissionModel.kt index c7bfa5a..3aaf3f7 100644 --- a/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/GenericLogsPermissionModel.kt +++ b/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/GenericLogsPermissionModel.kt @@ -4,22 +4,18 @@ import com.evdayapps.madassistant.common.kotlinx.getStringOrNull import org.json.JSONObject data class GenericLogsPermissionModel( - var enabled: Boolean = false, - var read: Boolean = false, - var share: Boolean = false, - var filterTag: String? = null, - var filterMessage: String? = null, - var logDebug: Boolean = true, - var logInfo: Boolean = true, - var logWarning: Boolean = true, - var logError: Boolean = true, - var logVerbose: Boolean = true + val enabled: Boolean = false, + val filterTag: String? = null, + val filterMessage: String? = null, + val logDebug: Boolean = false, + val logInfo: Boolean = false, + val logWarning: Boolean = false, + val logError: Boolean = false, + val logVerbose: Boolean = false ) { companion object { private const val KEY_enabled = "enabled" - private const val KEY_read = "read" - private const val KEY_share = "share" private const val KEY_filterTag = "filterTag" private const val KEY_filterMessage = "filterMessage" private const val KEY_logVerbose = "logVerbose" @@ -30,28 +26,20 @@ data class GenericLogsPermissionModel( } @Throws(Exception::class) - constructor(json: JSONObject) : this() { - json.run { - enabled = json.optBoolean(KEY_enabled, false) - read = json.optBoolean(KEY_read, false) - share = json.optBoolean(KEY_share, false) - - filterTag = json.getStringOrNull(KEY_filterTag) - filterMessage = json.getStringOrNull(KEY_filterMessage) - - logVerbose = json.optBoolean(KEY_logVerbose, false) - logInfo = json.optBoolean(KEY_logInfo, false) - logWarning = json.optBoolean(KEY_logWarning, false) - logError = json.optBoolean(KEY_logError, false) - logDebug = json.optBoolean(KEY_logDebug, false) - } - } + constructor(json: JSONObject) : this( + enabled = json.optBoolean(KEY_enabled, false), + filterTag = json.getStringOrNull(KEY_filterTag), + filterMessage = json.getStringOrNull(KEY_filterMessage), + logVerbose = json.optBoolean(KEY_logVerbose, false), + logInfo = json.optBoolean(KEY_logInfo, false), + logWarning = json.optBoolean(KEY_logWarning, false), + logError = json.optBoolean(KEY_logError, false), + logDebug = json.optBoolean(KEY_logDebug, false) + ) fun toJsonObject(): JSONObject { return JSONObject().apply { put(KEY_enabled, enabled) - put(KEY_read, read) - put(KEY_share, share) put(KEY_logVerbose, logVerbose) put(KEY_logInfo, logInfo) diff --git a/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/MADAssistantPermissions.kt b/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/MADAssistantPermissions.kt index 6cae7fc..4e959d3 100644 --- a/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/MADAssistantPermissions.kt +++ b/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/permissions/MADAssistantPermissions.kt @@ -3,21 +3,35 @@ package com.evdayapps.madassistant.common.models.permissions import com.evdayapps.madassistant.common.kotlinx.getOr import org.json.JSONObject +/** + * Main permission class + * @property deviceId The installation identifier of the client (optional if no device id check in sdk) + * @property timestampStart Optional. Time from which data can be logged. + * @property timestampEnd Optional. Time till which data can be logged. Should be after [timestampStart] if its been specified. + * @property encrypted Should the logs (and app configurations) be encrypted? + * @property networkCalls Permissions for network/api call logs + * @property analytics Permissions for analytics logs + * @property exceptions Permissions for exceptions logs + * @property genericLogs Permissions for generic logs + * @property randomString A random string (current timestamp) added to + */ data class MADAssistantPermissions( - var timestampStart: Long? = null, - var timestampEnd: Long? = null, - var deviceId: String? = null, - var networkCalls: ApiCallsPermissionModel = ApiCallsPermissionModel(), - var analytics: AnalyticsPermissionModel = AnalyticsPermissionModel(), - var exceptions: ExceptionsPermissionModel = ExceptionsPermissionModel(), - var genericLogs: GenericLogsPermissionModel = GenericLogsPermissionModel(), - var randomString: String? = System.currentTimeMillis().toString() + val deviceId: String?, + val timestampStart: Long?, + val timestampEnd: Long?, + val encrypted: Boolean, + val networkCalls: ApiCallsPermissionModel, + val analytics: AnalyticsPermissionModel, + val exceptions: ExceptionsPermissionModel, + val genericLogs: GenericLogsPermissionModel, + val randomString: String? = System.currentTimeMillis().toString() ) { companion object { private const val KEY_randomString = "randomString" private const val KEY_timestampStart = "timestampStart" private const val KEY_timestampEnd = "timestampEnd" + private const val KEY_encrypted = "encrypted" private const val KEY_deviceId = "deviceId" private const val KEY_networkCalls = "networkCalls" private const val KEY_genericLogs = "genericLogs" @@ -25,65 +39,56 @@ data class MADAssistantPermissions( private const val KEY_exceptions = "exceptions" } - constructor(json: JSONObject) : this() { - randomString = json.optString(KEY_randomString, "") - - timestampStart = json.getOr(KEY_timestampStart, null) - timestampEnd = json.getOr(KEY_timestampEnd, null) - - deviceId = json.optString(KEY_deviceId, "") - - networkCalls = json.getJSONObject(KEY_networkCalls).run { + constructor(json: JSONObject) : this( + randomString = json.optString(KEY_randomString, ""), + timestampStart = json.getOr(KEY_timestampStart, null), + timestampEnd = json.getOr(KEY_timestampEnd, null), + deviceId = json.optString(KEY_deviceId, ""), + encrypted = json.getOr(KEY_encrypted, false), + networkCalls = json.optJSONObject(KEY_networkCalls)?.run { try { ApiCallsPermissionModel(this) } catch (ex: Exception) { ApiCallsPermissionModel() } - } - - analytics = json.getJSONObject(KEY_analytics).run { + } ?: ApiCallsPermissionModel(), + analytics = json.optJSONObject(KEY_analytics)?.run { try { AnalyticsPermissionModel(this) } catch (ex: Exception) { AnalyticsPermissionModel() } - } - - exceptions = json.getJSONObject(KEY_exceptions).run { + } ?: AnalyticsPermissionModel(), + exceptions = json.optJSONObject(KEY_exceptions)?.run { try { ExceptionsPermissionModel(this) } catch (ex: Exception) { ExceptionsPermissionModel() } - } - - genericLogs = json.getJSONObject(KEY_genericLogs).run { + } ?: ExceptionsPermissionModel(), + genericLogs = json.optJSONObject(KEY_genericLogs)?.run { try { GenericLogsPermissionModel(this) } catch (ex: Exception) { GenericLogsPermissionModel() } - } - } + } ?: GenericLogsPermissionModel() + ) fun toJsonObject(): JSONObject { - networkCalls.apply { enabled = share || read } - genericLogs.apply { enabled = share || read } - analytics.apply { enabled = share || read } - exceptions.apply { enabled = share || read } - return JSONObject().apply { put(KEY_deviceId, deviceId) put(KEY_randomString, randomString) + put(KEY_encrypted, encrypted) putOpt(KEY_timestampStart, timestampStart) putOpt(KEY_timestampEnd, timestampEnd) - putOpt(KEY_networkCalls, networkCalls.toJsonObject()) - putOpt(KEY_genericLogs, genericLogs.toJsonObject()) - putOpt(KEY_exceptions, exceptions.toJsonObject()) - putOpt(KEY_analytics, analytics.toJsonObject()) + put(KEY_networkCalls, networkCalls.toJsonObject()) + put(KEY_genericLogs, genericLogs.toJsonObject()) + put(KEY_exceptions, exceptions.toJsonObject()) + put(KEY_analytics, analytics.toJsonObject()) } } } \ No newline at end of file diff --git a/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/transmission/TransmissionModel.java b/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/transmission/TransmissionModel.java deleted file mode 100644 index b4135c1..0000000 --- a/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/transmission/TransmissionModel.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.evdayapps.madassistant.common.models.transmission; - -import android.os.Parcel; -import android.os.Parcelable; - -/** - * Model for data that is transmitted from the client to the repository - */ -public class TransmissionModel implements Parcelable { - - public static final Creator CREATOR = new Creator() { - @Override - public TransmissionModel createFromParcel(Parcel source) { - return new TransmissionModel(source); - } - - @Override - public TransmissionModel[] newArray(int size) { - return new TransmissionModel[size]; - } - }; - - public long sessionId; - public String transmissionId; - public long timestamp; - public int numTotalSegments; - public int currentSegmentIndex; - public int type; - public boolean encrypted; - public byte[] payload; - - public TransmissionModel( - long sessionId, - String transmissionId, - long timestamp, - boolean encrypted, - int numTotalSegments, - int currentSegmentIndex, - int type, - byte[] payload - ) { - this.sessionId = sessionId; - this.transmissionId = transmissionId; - this.timestamp = timestamp; - this.encrypted = encrypted; - this.numTotalSegments = numTotalSegments; - this.currentSegmentIndex = currentSegmentIndex; - this.type = type; - this.payload = payload; - } - - protected TransmissionModel(Parcel in) { - this.sessionId = in.readLong(); - this.transmissionId = in.readString(); - this.timestamp = in.readLong(); - this.encrypted = in.readByte() != 0; - this.numTotalSegments = in.readInt(); - this.currentSegmentIndex = in.readInt(); - this.type = in.readInt(); - this.payload = in.createByteArray(); - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeLong(this.sessionId); - dest.writeString(this.transmissionId); - dest.writeLong(this.timestamp); - dest.writeByte(this.encrypted ? (byte) 1 : (byte) 0); - dest.writeInt(this.numTotalSegments); - dest.writeInt(this.currentSegmentIndex); - dest.writeInt(this.type); - dest.writeByteArray(this.payload); - } -} diff --git a/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/transmission/TransmissionModel.kt b/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/transmission/TransmissionModel.kt new file mode 100644 index 0000000..3946b8f --- /dev/null +++ b/madassistant-common/src/main/java/com/evdayapps/madassistant/common/models/transmission/TransmissionModel.kt @@ -0,0 +1,58 @@ +package com.evdayapps.madassistant.common.models.transmission + +import android.os.Parcel +import android.os.Parcelable +import android.os.Parcelable.Creator + +/** + * Model for data that is transmitted from the client to the repository + */ +class TransmissionModel( + val sessionId: Long, + val transmissionId: String?, + var timestamp: Long, + val numTotalSegments: Int, + val currentSegmentIndex: Int, + val type: Int, + val encrypted: Boolean, + val payload: ByteArray +) : Parcelable { + + constructor(parcel: Parcel) : this( + sessionId = parcel.readLong(), + transmissionId = parcel.readString(), + timestamp = parcel.readLong(), + numTotalSegments = parcel.readInt(), + currentSegmentIndex = parcel.readInt(), + type = parcel.readInt(), + encrypted = parcel.readByte() != 0.toByte(), + payload = parcel.createByteArray() ?: ByteArray(0) + ) + + override fun writeToParcel(parcel: Parcel, flags: Int) { + parcel.writeLong(sessionId) + parcel.writeString(transmissionId) + parcel.writeLong(timestamp) + parcel.writeInt(numTotalSegments) + parcel.writeInt(currentSegmentIndex) + parcel.writeInt(type) + parcel.writeByte(if (encrypted) 1 else 0) + parcel.writeByteArray(payload) + } + + override fun describeContents(): Int { + return 0 + } + + companion object CREATOR : Creator { + override fun createFromParcel(parcel: Parcel): TransmissionModel { + return TransmissionModel(parcel) + } + + override fun newArray(size: Int): Array { + return arrayOfNulls(size) + } + } + + +} \ No newline at end of file