diff --git a/termux-shared/src/main/java/com/termux/shared/models/ReportInfo.java b/termux-shared/src/main/java/com/termux/shared/models/ReportInfo.java index 0f70fb56..3e0ad686 100644 --- a/termux-shared/src/main/java/com/termux/shared/models/ReportInfo.java +++ b/termux-shared/src/main/java/com/termux/shared/models/ReportInfo.java @@ -1,5 +1,7 @@ package com.termux.shared.models; +import androidx.annotation.Keep; + import com.termux.shared.markdown.MarkdownUtils; import com.termux.shared.android.AndroidUtils; @@ -10,6 +12,25 @@ import java.io.Serializable; */ public class ReportInfo implements Serializable { + /** + * Explicitly define `serialVersionUID` to prevent exceptions on deserialization. + * + * Like when calling `Bundle.getSerializable()` on Android. + * `android.os.BadParcelableException: Parcelable encountered IOException reading a Serializable object` (name = ) + * `java.io.InvalidClassException: ; local class incompatible` + * + * The `@Keep` annotation is necessary to prevent the field from being removed by proguard when + * app is compiled, even if its kept during library compilation. + * + * **See Also:** + * - https://docs.oracle.com/javase/8/docs/platform/serialization/spec/version.html#a6678 + * - https://docs.oracle.com/javase/8/docs/platform/serialization/spec/class.html#a4100 + */ + @Keep + private static final long serialVersionUID = 1L; + + + /** The user action that was being processed for which the report was generated. */ public final String userAction; /** The internal app component that sent the report. */ diff --git a/termux-shared/src/main/java/com/termux/shared/models/TextIOInfo.java b/termux-shared/src/main/java/com/termux/shared/models/TextIOInfo.java index df9993af..b688c398 100644 --- a/termux-shared/src/main/java/com/termux/shared/models/TextIOInfo.java +++ b/termux-shared/src/main/java/com/termux/shared/models/TextIOInfo.java @@ -3,6 +3,7 @@ package com.termux.shared.models; import android.graphics.Color; import android.graphics.Typeface; +import androidx.annotation.Keep; import androidx.annotation.NonNull; import com.termux.shared.activities.TextIOActivity; @@ -19,6 +20,25 @@ import java.io.Serializable; */ public class TextIOInfo implements Serializable { + /** + * Explicitly define `serialVersionUID` to prevent exceptions on deserialization. + * + * Like when calling `Bundle.getSerializable()` on Android. + * `android.os.BadParcelableException: Parcelable encountered IOException reading a Serializable object` (name = ) + * `java.io.InvalidClassException: ; local class incompatible` + * + * The `@Keep` annotation is necessary to prevent the field from being removed by proguard when + * app is compiled, even if its kept during library compilation. + * + * **See Also:** + * - https://docs.oracle.com/javase/8/docs/platform/serialization/spec/version.html#a6678 + * - https://docs.oracle.com/javase/8/docs/platform/serialization/spec/class.html#a4100 + */ + @Keep + private static final long serialVersionUID = 1L; + + + public static final int GENERAL_DATA_SIZE_LIMIT_IN_BYTES = 1000; public static final int LABEL_SIZE_LIMIT_IN_BYTES = 4000; public static final int TEXT_SIZE_LIMIT_IN_BYTES = 100000 - GENERAL_DATA_SIZE_LIMIT_IN_BYTES - LABEL_SIZE_LIMIT_IN_BYTES; // < 100KB