kopia lustrzana https://github.com/ryukoposting/Signal-Android
Add full support for unknown fields in storage service.
rodzic
4f3c545eda
commit
62ee60df82
|
@ -54,7 +54,7 @@ repositories {
|
||||||
|
|
||||||
protobuf {
|
protobuf {
|
||||||
protoc {
|
protoc {
|
||||||
artifact = 'com.google.protobuf:protoc:3.10.0'
|
artifact = 'com.google.protobuf:protoc:3.11.4'
|
||||||
}
|
}
|
||||||
generateProtoTasks {
|
generateProtoTasks {
|
||||||
all().each { task ->
|
all().each { task ->
|
||||||
|
|
|
@ -420,8 +420,8 @@ dependencyVerification {
|
||||||
['com.google.j2objc:j2objc-annotations:1.3',
|
['com.google.j2objc:j2objc-annotations:1.3',
|
||||||
'21af30c92267bd6122c0e0b4d20cccb6641a37eaf956c6540ec471d584e64a7b'],
|
'21af30c92267bd6122c0e0b4d20cccb6641a37eaf956c6540ec471d584e64a7b'],
|
||||||
|
|
||||||
['com.google.protobuf:protobuf-javalite:3.10.0',
|
['com.google.protobuf:protobuf-javalite:3.11.4',
|
||||||
'215a94dbe100130295906b531bb72a26965c7ac8fcd9a75bf8054a8ac2abf4b4'],
|
'8cacea2f7a042dabae295c509dcdbfe32a49aa3708eec6ddb8efd8593aa0b4a3'],
|
||||||
|
|
||||||
['com.google.zxing:android-integration:3.1.0',
|
['com.google.zxing:android-integration:3.1.0',
|
||||||
'89e56aadf1164bd71e57949163c53abf90af368b51669c0d4a47a163335f95c4'],
|
'89e56aadf1164bd71e57949163c53abf90af368b51669c0d4a47a163335f95c4'],
|
||||||
|
|
|
@ -27,8 +27,8 @@ dependencyVerification {
|
||||||
['androidx.versionedparcelable:versionedparcelable:1.1.1',
|
['androidx.versionedparcelable:versionedparcelable:1.1.1',
|
||||||
'57e8d93260d18d5b9007c9eed3c64ad159de90c8609ebfc74a347cbd514535a4'],
|
'57e8d93260d18d5b9007c9eed3c64ad159de90c8609ebfc74a347cbd514535a4'],
|
||||||
|
|
||||||
['com.google.protobuf:protobuf-javalite:3.10.0',
|
['com.google.protobuf:protobuf-javalite:3.11.4',
|
||||||
'215a94dbe100130295906b531bb72a26965c7ac8fcd9a75bf8054a8ac2abf4b4'],
|
'8cacea2f7a042dabae295c509dcdbfe32a49aa3708eec6ddb8efd8593aa0b4a3'],
|
||||||
|
|
||||||
['org.jetbrains.kotlin:kotlin-stdlib-common:1.4.32',
|
['org.jetbrains.kotlin:kotlin-stdlib-common:1.4.32',
|
||||||
'e1ff6f55ee9e7591dcc633f7757bac25a7edb1cc7f738b37ec652f10f66a4145'],
|
'e1ff6f55ee9e7591dcc633f7757bac25a7edb1cc7f738b37ec652f10f66a4145'],
|
||||||
|
|
|
@ -51,7 +51,7 @@ dependencyResolutionManagement {
|
||||||
alias('material-material').to('com.google.android.material:material:1.3.0')
|
alias('material-material').to('com.google.android.material:material:1.3.0')
|
||||||
|
|
||||||
// Google
|
// Google
|
||||||
alias('google-protobuf-javalite').to('com.google.protobuf:protobuf-javalite:3.10.0')
|
alias('google-protobuf-javalite').to('com.google.protobuf:protobuf-javalite:3.11.4')
|
||||||
alias('google-libphonenumber').to('com.googlecode.libphonenumber:libphonenumber:8.12.17')
|
alias('google-libphonenumber').to('com.googlecode.libphonenumber:libphonenumber:8.12.17')
|
||||||
alias('google-play-services-maps').to('com.google.android.gms:play-services-maps:16.1.0')
|
alias('google-play-services-maps').to('com.google.android.gms:play-services-maps:16.1.0')
|
||||||
alias('google-play-services-auth').to('com.google.android.gms:play-services-auth:16.0.1')
|
alias('google-play-services-auth').to('com.google.android.gms:play-services-auth:16.0.1')
|
||||||
|
|
|
@ -78,8 +78,8 @@ dependencyVerification {
|
||||||
['androidx.viewpager:viewpager:1.0.0',
|
['androidx.viewpager:viewpager:1.0.0',
|
||||||
'147af4e14a1984010d8f155e5e19d781f03c1d70dfed02a8e0d18428b8fc8682'],
|
'147af4e14a1984010d8f155e5e19d781f03c1d70dfed02a8e0d18428b8fc8682'],
|
||||||
|
|
||||||
['com.google.protobuf:protobuf-javalite:3.10.0',
|
['com.google.protobuf:protobuf-javalite:3.11.4',
|
||||||
'215a94dbe100130295906b531bb72a26965c7ac8fcd9a75bf8054a8ac2abf4b4'],
|
'8cacea2f7a042dabae295c509dcdbfe32a49aa3708eec6ddb8efd8593aa0b4a3'],
|
||||||
|
|
||||||
['org.greenrobot:eventbus:3.0.0',
|
['org.greenrobot:eventbus:3.0.0',
|
||||||
'180d4212467df06f2fbc9c8d8a2984533ac79c87769ad883bc421612f0b4e17c'],
|
'180d4212467df06f2fbc9c8d8a2984533ac79c87769ad883bc421612f0b4e17c'],
|
||||||
|
|
|
@ -141,8 +141,8 @@ dependencyVerification {
|
||||||
['com.google.android.material:material:1.3.0',
|
['com.google.android.material:material:1.3.0',
|
||||||
'cbf1e7d69fc236cdadcbd1ec5f6c0a1a41aca6ad1ef7f8481058956270ab1f0a'],
|
'cbf1e7d69fc236cdadcbd1ec5f6c0a1a41aca6ad1ef7f8481058956270ab1f0a'],
|
||||||
|
|
||||||
['com.google.protobuf:protobuf-javalite:3.10.0',
|
['com.google.protobuf:protobuf-javalite:3.11.4',
|
||||||
'215a94dbe100130295906b531bb72a26965c7ac8fcd9a75bf8054a8ac2abf4b4'],
|
'8cacea2f7a042dabae295c509dcdbfe32a49aa3708eec6ddb8efd8593aa0b4a3'],
|
||||||
|
|
||||||
['com.squareup.okhttp3:okhttp:3.12.10',
|
['com.squareup.okhttp3:okhttp:3.12.10',
|
||||||
'3cb8e21cd3ab10d390448f5a475c960732efab583a09c39f06f866a7ed819ebc'],
|
'3cb8e21cd3ab10d390448f5a475c960732efab583a09c39f06f866a7ed819ebc'],
|
||||||
|
|
|
@ -96,8 +96,8 @@ dependencyVerification {
|
||||||
['com.google.android.gms:play-services-wallet:18.1.3',
|
['com.google.android.gms:play-services-wallet:18.1.3',
|
||||||
'e19d1f4650f51ce2202c092cbe174058860b6558cf26c8be37a732eff3ae1864'],
|
'e19d1f4650f51ce2202c092cbe174058860b6558cf26c8be37a732eff3ae1864'],
|
||||||
|
|
||||||
['com.google.protobuf:protobuf-javalite:3.10.0',
|
['com.google.protobuf:protobuf-javalite:3.11.4',
|
||||||
'215a94dbe100130295906b531bb72a26965c7ac8fcd9a75bf8054a8ac2abf4b4'],
|
'8cacea2f7a042dabae295c509dcdbfe32a49aa3708eec6ddb8efd8593aa0b4a3'],
|
||||||
|
|
||||||
['com.squareup.okhttp3:okhttp:3.12.10',
|
['com.squareup.okhttp3:okhttp:3.12.10',
|
||||||
'3cb8e21cd3ab10d390448f5a475c960732efab583a09c39f06f866a7ed819ebc'],
|
'3cb8e21cd3ab10d390448f5a475c960732efab583a09c39f06f866a7ed819ebc'],
|
||||||
|
|
|
@ -135,8 +135,8 @@ dependencyVerification {
|
||||||
['com.google.android.material:material:1.3.0',
|
['com.google.android.material:material:1.3.0',
|
||||||
'cbf1e7d69fc236cdadcbd1ec5f6c0a1a41aca6ad1ef7f8481058956270ab1f0a'],
|
'cbf1e7d69fc236cdadcbd1ec5f6c0a1a41aca6ad1ef7f8481058956270ab1f0a'],
|
||||||
|
|
||||||
['com.google.protobuf:protobuf-javalite:3.10.0',
|
['com.google.protobuf:protobuf-javalite:3.11.4',
|
||||||
'215a94dbe100130295906b531bb72a26965c7ac8fcd9a75bf8054a8ac2abf4b4'],
|
'8cacea2f7a042dabae295c509dcdbfe32a49aa3708eec6ddb8efd8593aa0b4a3'],
|
||||||
|
|
||||||
['org.jetbrains.kotlin:kotlin-stdlib-common:1.4.32',
|
['org.jetbrains.kotlin:kotlin-stdlib-common:1.4.32',
|
||||||
'e1ff6f55ee9e7591dcc633f7757bac25a7edb1cc7f738b37ec652f10f66a4145'],
|
'e1ff6f55ee9e7591dcc633f7757bac25a7edb1cc7f738b37ec652f10f66a4145'],
|
||||||
|
|
|
@ -78,8 +78,8 @@ dependencyVerification {
|
||||||
['androidx.viewpager:viewpager:1.0.0',
|
['androidx.viewpager:viewpager:1.0.0',
|
||||||
'147af4e14a1984010d8f155e5e19d781f03c1d70dfed02a8e0d18428b8fc8682'],
|
'147af4e14a1984010d8f155e5e19d781f03c1d70dfed02a8e0d18428b8fc8682'],
|
||||||
|
|
||||||
['com.google.protobuf:protobuf-javalite:3.10.0',
|
['com.google.protobuf:protobuf-javalite:3.11.4',
|
||||||
'215a94dbe100130295906b531bb72a26965c7ac8fcd9a75bf8054a8ac2abf4b4'],
|
'8cacea2f7a042dabae295c509dcdbfe32a49aa3708eec6ddb8efd8593aa0b4a3'],
|
||||||
|
|
||||||
['org.jetbrains.kotlin:kotlin-stdlib-common:1.4.32',
|
['org.jetbrains.kotlin:kotlin-stdlib-common:1.4.32',
|
||||||
'e1ff6f55ee9e7591dcc633f7757bac25a7edb1cc7f738b37ec652f10f66a4145'],
|
'e1ff6f55ee9e7591dcc633f7757bac25a7edb1cc7f738b37ec652f10f66a4145'],
|
||||||
|
|
|
@ -52,56 +52,16 @@ public final class ProtoUtil {
|
||||||
/**
|
/**
|
||||||
* This takes two arguments: A proto model, and the bytes of another proto model of the same type.
|
* This takes two arguments: A proto model, and the bytes of another proto model of the same type.
|
||||||
* This will take the proto model and append onto it any unknown fields from the serialized proto
|
* This will take the proto model and append onto it any unknown fields from the serialized proto
|
||||||
* model. Why is this useful? Well, if you do {@code myProto.parseFrom(data).toBuilder().build()},
|
* model.
|
||||||
* you will lose any unknown fields that were in {@code data}. This lets you create a new model
|
|
||||||
* and plop the unknown fields back on from some other instance.
|
|
||||||
*
|
|
||||||
* A notable limitation of the current implementation is, however, that it does not support adding
|
|
||||||
* back unknown fields to *inner* messages. Unknown fields on inner messages will simply not be
|
|
||||||
* acknowledged.
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
public static <Proto extends GeneratedMessageLite> Proto combineWithUnknownFields(Proto proto, byte[] serializedWithUnknownFields)
|
public static <Proto extends GeneratedMessageLite> Proto combineWithUnknownFields(Proto proto, byte[] serializedWithUnknownFields)
|
||||||
throws InvalidProtocolBufferException
|
throws InvalidProtocolBufferException
|
||||||
{
|
{
|
||||||
if (serializedWithUnknownFields == null) {
|
return (Proto) proto.newBuilderForType()
|
||||||
return proto;
|
.mergeFrom(serializedWithUnknownFields)
|
||||||
}
|
.mergeFrom(proto)
|
||||||
|
.build();
|
||||||
Proto protoWithUnknownFields = (Proto) proto.getParserForType().parseFrom(serializedWithUnknownFields);
|
|
||||||
byte[] unknownFields = getUnknownFields(protoWithUnknownFields);
|
|
||||||
|
|
||||||
if (unknownFields == null) {
|
|
||||||
return proto;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] combined = ByteUtil.combine(proto.toByteArray(), unknownFields);
|
|
||||||
|
|
||||||
return (Proto) proto.getParserForType().parseFrom(combined);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
private static byte[] getUnknownFields(GeneratedMessageLite proto) {
|
|
||||||
try {
|
|
||||||
Field field = GeneratedMessageLite.class.getDeclaredField("unknownFields");
|
|
||||||
field.setAccessible(true);
|
|
||||||
UnknownFieldSetLite unknownFields = (UnknownFieldSetLite) field.get(proto);
|
|
||||||
|
|
||||||
if (unknownFields == null || unknownFields.getSerializedSize() == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
|
|
||||||
CodedOutputStream outputStream = CodedOutputStream.newInstance(byteStream);
|
|
||||||
|
|
||||||
unknownFields.writeTo(outputStream);
|
|
||||||
outputStream.flush();
|
|
||||||
|
|
||||||
return byteStream.toByteArray();
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException | IOException e) {
|
|
||||||
Log.w(TAG, "Failed to retrieve unknown fields.", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -236,6 +236,6 @@ public class ProtoUtilTest {
|
||||||
TestInnerMessageWithNewString reparsedTest = TestInnerMessageWithNewString.parseFrom(combined.toByteArray());
|
TestInnerMessageWithNewString reparsedTest = TestInnerMessageWithNewString.parseFrom(combined.toByteArray());
|
||||||
|
|
||||||
Assert.assertEquals("a2", reparsedTest.getInner().getA());
|
Assert.assertEquals("a2", reparsedTest.getInner().getA());
|
||||||
Assert.assertEquals("", reparsedTest.getInner().getB());
|
Assert.assertEquals("b1", reparsedTest.getInner().getB());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ dependencyVerification {
|
||||||
['com.fasterxml.jackson.core:jackson-databind:2.9.9.2',
|
['com.fasterxml.jackson.core:jackson-databind:2.9.9.2',
|
||||||
'fb262d42ea2de98044b62d393950a5aa050435fec38bbcadf2325cf7dc41b848'],
|
'fb262d42ea2de98044b62d393950a5aa050435fec38bbcadf2325cf7dc41b848'],
|
||||||
|
|
||||||
['com.google.protobuf:protobuf-javalite:3.10.0',
|
['com.google.protobuf:protobuf-javalite:3.11.4',
|
||||||
'215a94dbe100130295906b531bb72a26965c7ac8fcd9a75bf8054a8ac2abf4b4'],
|
'8cacea2f7a042dabae295c509dcdbfe32a49aa3708eec6ddb8efd8593aa0b4a3'],
|
||||||
|
|
||||||
['com.googlecode.libphonenumber:libphonenumber:8.12.17',
|
['com.googlecode.libphonenumber:libphonenumber:8.12.17',
|
||||||
'729483057ef874b01537da8395d67e23b419d504f8ff29ddf5f69da21bf816ac'],
|
'729483057ef874b01537da8395d67e23b419d504f8ff29ddf5f69da21bf816ac'],
|
||||||
|
|
|
@ -120,8 +120,8 @@ dependencyVerification {
|
||||||
['com.google.android.material:material:1.3.0',
|
['com.google.android.material:material:1.3.0',
|
||||||
'cbf1e7d69fc236cdadcbd1ec5f6c0a1a41aca6ad1ef7f8481058956270ab1f0a'],
|
'cbf1e7d69fc236cdadcbd1ec5f6c0a1a41aca6ad1ef7f8481058956270ab1f0a'],
|
||||||
|
|
||||||
['com.google.protobuf:protobuf-javalite:3.10.0',
|
['com.google.protobuf:protobuf-javalite:3.11.4',
|
||||||
'215a94dbe100130295906b531bb72a26965c7ac8fcd9a75bf8054a8ac2abf4b4'],
|
'8cacea2f7a042dabae295c509dcdbfe32a49aa3708eec6ddb8efd8593aa0b4a3'],
|
||||||
|
|
||||||
['org.jetbrains.kotlin:kotlin-stdlib-common:1.4.32',
|
['org.jetbrains.kotlin:kotlin-stdlib-common:1.4.32',
|
||||||
'e1ff6f55ee9e7591dcc633f7757bac25a7edb1cc7f738b37ec652f10f66a4145'],
|
'e1ff6f55ee9e7591dcc633f7757bac25a7edb1cc7f738b37ec652f10f66a4145'],
|
||||||
|
|
|
@ -27,8 +27,8 @@ dependencyVerification {
|
||||||
['androidx.versionedparcelable:versionedparcelable:1.1.1',
|
['androidx.versionedparcelable:versionedparcelable:1.1.1',
|
||||||
'57e8d93260d18d5b9007c9eed3c64ad159de90c8609ebfc74a347cbd514535a4'],
|
'57e8d93260d18d5b9007c9eed3c64ad159de90c8609ebfc74a347cbd514535a4'],
|
||||||
|
|
||||||
['com.google.protobuf:protobuf-javalite:3.10.0',
|
['com.google.protobuf:protobuf-javalite:3.11.4',
|
||||||
'215a94dbe100130295906b531bb72a26965c7ac8fcd9a75bf8054a8ac2abf4b4'],
|
'8cacea2f7a042dabae295c509dcdbfe32a49aa3708eec6ddb8efd8593aa0b4a3'],
|
||||||
|
|
||||||
['org.jetbrains.kotlin:kotlin-stdlib-common:1.4.32',
|
['org.jetbrains.kotlin:kotlin-stdlib-common:1.4.32',
|
||||||
'e1ff6f55ee9e7591dcc633f7757bac25a7edb1cc7f738b37ec652f10f66a4145'],
|
'e1ff6f55ee9e7591dcc633f7757bac25a7edb1cc7f738b37ec652f10f66a4145'],
|
||||||
|
|
Ładowanie…
Reference in New Issue