Update Log events

This commit is contained in:
Marvin W 2016-09-16 23:05:05 +02:00
parent 7f5440d36e
commit 351a4b8615
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
2 changed files with 120 additions and 13 deletions

View File

@ -16,10 +16,89 @@
package com.google.android.gms.clearcut;
import android.util.Base64;
import com.google.android.gms.playlog.internal.PlayLoggerContext;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.util.Arrays;
public class LogEventParcelable extends AutoSafeParcelable {
// TODO
@SafeParceled(1)
private int versionCode = 1;
@SafeParceled(2)
public final PlayLoggerContext context;
@SafeParceled(3)
public final byte[] bytes;
@SafeParceled(4)
public final int[] testCodes;
@SafeParceled(5)
public final String[] mendelPackages;
@SafeParceled(6)
public final int[] experimentIds;
@SafeParceled(7)
public final byte[][] experimentTokens;
@SafeParceled(8)
public final boolean addPhenotypeExperimentTokens;
private LogEventParcelable() {
context = null;
bytes = null;
testCodes = experimentIds = null;
mendelPackages = null;
experimentTokens = null;
addPhenotypeExperimentTokens = false;
}
public LogEventParcelable(PlayLoggerContext context, byte[] bytes, int[] testCodes, String[] mendelPackages, int[] experimentIds, byte[][] experimentTokens, boolean addPhenotypeExperimentTokens) {
this.context = context;
this.bytes = bytes;
this.testCodes = testCodes;
this.mendelPackages = mendelPackages;
this.experimentIds = experimentIds;
this.experimentTokens = experimentTokens;
this.addPhenotypeExperimentTokens = addPhenotypeExperimentTokens;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("LogEventParcelable[")
.append(versionCode).append(", ").append(context)
.append(", LogEventBytes: ").append(getBytesAsString());
if (testCodes != null) sb.append(", TestCodes: ").append(Arrays.toString(testCodes));
if (mendelPackages != null)
sb.append(", MendelPackages: ").append(Arrays.toString(mendelPackages));
if (experimentIds != null)
sb.append(", ExperimentIds: ").append(Arrays.toString(experimentIds));
if (experimentTokens != null)
sb.append(", ExperimentTokens: ").append(Arrays.toString(experimentTokens));
return sb.append(", AddPhenotypeExperimentTokens: ").append(addPhenotypeExperimentTokens)
.append(']').toString();
}
private String getBytesAsString() {
if (bytes == null) return "null";
try {
CharsetDecoder d = Charset.forName("US-ASCII").newDecoder();
CharBuffer r = d.decode(ByteBuffer.wrap(bytes));
return r.toString();
} catch (Exception e) {
return Base64.encodeToString(bytes, Base64.NO_WRAP);
}
}
public static final Creator<LogEventParcelable> CREATOR = new AutoCreator<LogEventParcelable>(LogEventParcelable.class);
}

View File

@ -27,6 +27,9 @@ public class PlayLoggerContext extends AutoSafeParcelable {
@SafeParceled(2)
public final String packageName;
@SafeParceled(3)
public final int packageVersionCode;
@SafeParceled(4)
public final int logSource;
@ -42,31 +45,56 @@ public class PlayLoggerContext extends AutoSafeParcelable {
@SafeParceled(8)
public final String logSourceName;
@SafeParceled(9)
public final boolean isAnonymous;
@SafeParceled(10)
public final int qosTier;
private PlayLoggerContext() {
packageName = uploadAccount = logSourceName = null;
logSource = loggingId = -1;
logAndroidId = false;
qosTier = packageVersionCode = logSource = loggingId = -1;
isAnonymous = logAndroidId = false;
}
public PlayLoggerContext(String packageName, int logSource, String uploadAccount, int loggingId, String logSourceName) {
public PlayLoggerContext(String packageName, int packageVersionCode, int logSource, String uploadAccount, int loggingId, boolean logAndroidId) {
this.packageName = packageName;
this.packageVersionCode = packageVersionCode;
this.logSource = logSource;
this.logSourceName = null;
this.uploadAccount = uploadAccount;
this.loggingId = loggingId;
this.logAndroidId = logAndroidId;
this.isAnonymous = false;
this.qosTier = 0;
}
public PlayLoggerContext(String packageName, int packageVersionCode, int logSource, String logSourceName, String uploadAccount, int loggingId, boolean isAnonymous, int qosTier) {
this.packageName = packageName;
this.packageVersionCode = packageVersionCode;
this.logSource = logSource;
this.logSourceName = logSourceName;
this.logAndroidId = true;
this.uploadAccount = uploadAccount;
this.loggingId = loggingId;
this.logAndroidId = !isAnonymous;
this.isAnonymous = isAnonymous;
this.qosTier = qosTier;
}
@Override
public String toString() {
return "PlayLoggerContext{" +
"packageName='" + packageName + '\'' +
", logSource=" + logSource +
", uploadAccount='" + uploadAccount + '\'' +
", loggingId=" + loggingId +
", logAndroidId=" + logAndroidId +
", logSourceName='" + logSourceName + '\'' +
'}';
final StringBuilder sb = new StringBuilder("PlayLoggerContext[").append(versionCode);
sb.append(", package=").append(packageName);
sb.append(", packageVersionCode=").append(packageVersionCode);
sb.append(", logSource=").append(logSource);
sb.append(", uploadAccount=").append(uploadAccount);
sb.append(", loggingId=").append(loggingId);
sb.append(", logAndroidId=").append(logAndroidId);
sb.append(", logSourceName=").append(logSourceName);
sb.append(", isAnonymous=").append(isAnonymous);
sb.append(", qosTier=").append(qosTier);
sb.append(']');
return sb.toString();
}
public static Creator<PlayLoggerContext> CREATOR = new AutoCreator<PlayLoggerContext>(PlayLoggerContext.class);