Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions transport/transport-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- [feature] Support multiple encrypted experiment IDs.

# 4.0.0

- [changed] Updated protobuf dependency to `3.25.5` to fix
Expand Down
2 changes: 1 addition & 1 deletion transport/transport-api/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.

version=4.0.1
version=4.1.0
latestReleasedVersion=4.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.auto.value.AutoValue;
import java.util.List;

@AutoValue
public abstract class EventContext {
Expand All @@ -31,6 +32,10 @@ public abstract class EventContext {
@SuppressWarnings("mutable")
public abstract byte[] getExperimentIdsEncrypted();

@Nullable
@SuppressWarnings("mutable")
public abstract List<byte[]> getExperimentIdsEncryptedList();

public static Builder builder() {
return new AutoValue_EventContext.Builder();
}
Expand All @@ -46,6 +51,9 @@ public abstract static class Builder {
@NonNull
public abstract Builder setExperimentIdsEncrypted(byte[] value);

@NonNull
public abstract Builder setExperimentIdsEncryptedList(List<byte[]> value);

@NonNull
public abstract EventContext build();
}
Expand Down
2 changes: 2 additions & 0 deletions transport/transport-backend-cct/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- [feature] Support multiple encrypted experiment IDs.

# 4.0.0

- [changed] Updated protobuf dependency to `3.25.5` to fix
Expand Down
2 changes: 1 addition & 1 deletion transport/transport-backend-cct/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.

version=4.0.1
version=4.1.0
latestReleasedVersion=4.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.net.NetworkInfo;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.util.Base64;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.google.android.datatransport.Encoding;
Expand Down Expand Up @@ -206,6 +207,15 @@ private static int getNetSubtypeValue(NetworkInfo networkInfo) {
return NetworkConnectionInfo.MobileSubtype.forNumber(subtype) != null ? subtype : 0;
}

private List<String> encodeListByteData(List<byte[]> input) {
List<String> output = new ArrayList<>(input.size());
for (byte[] chunk : input) {
String encoded = Base64.encodeToString(chunk, Base64.NO_WRAP);
output.add(encoded);
}
return output;
}

private BatchedLogRequest getRequestBody(BackendRequest backendRequest) {
HashMap<String, List<EventInternal>> eventInternalMap = new HashMap<>();
for (EventInternal eventInternal : backendRequest.getEvents()) {
Expand Down Expand Up @@ -302,13 +312,23 @@ private BatchedLogRequest getRequestBody(BackendRequest backendRequest) {
}

if (eventInternal.getExperimentIdsClear() != null
|| eventInternal.getExperimentIdsEncrypted() != null) {
|| eventInternal.getExperimentIdsEncrypted() != null
|| eventInternal.getExperimentIdsEncryptedList() != null) {
ExperimentIds.Builder builder = ExperimentIds.builder();
if (eventInternal.getExperimentIdsClear() != null) {
builder.setClearBlob(eventInternal.getExperimentIdsClear());
}
List<String> experimentIdsEncrypted = new ArrayList<>();
if (eventInternal.getExperimentIdsEncryptedList() != null) {
experimentIdsEncrypted.addAll(
encodeListByteData(eventInternal.getExperimentIdsEncryptedList()));
}
if (eventInternal.getExperimentIdsEncrypted() != null) {
builder.setEncryptedBlob(eventInternal.getExperimentIdsEncrypted());
experimentIdsEncrypted.add(
Base64.encodeToString(eventInternal.getExperimentIdsEncrypted(), Base64.NO_WRAP));
}
if (!experimentIdsEncrypted.isEmpty()) {
builder.setEncryptedBlob(experimentIdsEncrypted);
}
event.setExperimentIds(builder.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.auto.value.AutoValue;
import java.util.List;

@AutoValue
public abstract class ExperimentIds {
Expand All @@ -26,7 +27,7 @@ public abstract class ExperimentIds {

@SuppressWarnings("mutable")
@Nullable
public abstract byte[] getEncryptedBlob();
public abstract List<String> getEncryptedBlob();
Comment thread
VinayGuthal marked this conversation as resolved.

@NonNull
public static ExperimentIds.Builder builder() {
Expand All @@ -39,7 +40,7 @@ public abstract static class Builder {
public abstract ExperimentIds.Builder setClearBlob(@Nullable byte[] value);

@NonNull
public abstract ExperimentIds.Builder setEncryptedBlob(@Nullable byte[] value);
public abstract ExperimentIds.Builder setEncryptedBlob(@Nullable List<String> value);

@NonNull
public abstract ExperimentIds build();
Expand Down
Loading
Loading