diff --git a/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/DogfoodsToken.aidl b/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/DogfoodsToken.aidl new file mode 100644 index 00000000..4150d172 --- /dev/null +++ b/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/DogfoodsToken.aidl @@ -0,0 +1,3 @@ +package com.mgoogle.android.gms.phenotype; + +parcelable DogfoodsToken; diff --git a/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/ExperimentTokens.aidl b/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/ExperimentTokens.aidl new file mode 100644 index 00000000..e44110d2 --- /dev/null +++ b/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/ExperimentTokens.aidl @@ -0,0 +1,3 @@ +package com.mgoogle.android.gms.phenotype; + +parcelable ExperimentTokens; diff --git a/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/Flag.aidl b/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/Flag.aidl new file mode 100644 index 00000000..61a342a4 --- /dev/null +++ b/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/Flag.aidl @@ -0,0 +1,3 @@ +package com.mgoogle.android.gms.phenotype; + +parcelable Flag; diff --git a/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/FlagOverrides.aidl b/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/FlagOverrides.aidl new file mode 100644 index 00000000..8c9dc318 --- /dev/null +++ b/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/FlagOverrides.aidl @@ -0,0 +1,3 @@ +package com.mgoogle.android.gms.phenotype; + +parcelable FlagOverrides; diff --git a/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/RegistrationInfo.aidl b/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/RegistrationInfo.aidl new file mode 100644 index 00000000..349f2c6a --- /dev/null +++ b/play-services-api/src/main/aidl/com/mgoogle/android/gms/phenotype/RegistrationInfo.aidl @@ -0,0 +1,3 @@ +package com.mgoogle.android.gms.phenotype; + +parcelable RegistrationInfo; diff --git a/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/Configuration.java b/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/Configuration.java index b51ab177..d179375a 100644 --- a/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/Configuration.java +++ b/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/Configuration.java @@ -9,10 +9,10 @@ import org.microg.safeparcel.AutoSafeParcelable; public class Configuration extends AutoSafeParcelable { @Field(2) - public int field2; + public int flagType; @Field(3) - public Flag[] field3; + public Flag[] flags; @Field(4) - public String[] field4; + public String[] names; public static final Creator CREATOR = new AutoCreator<>(Configuration.class); } diff --git a/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/DogfoodsToken.java b/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/DogfoodsToken.java new file mode 100644 index 00000000..dc7687c1 --- /dev/null +++ b/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/DogfoodsToken.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.mgoogle.android.gms.phenotype; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class DogfoodsToken extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(DogfoodsToken.class); +} diff --git a/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/ExperimentTokens.java b/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/ExperimentTokens.java new file mode 100644 index 00000000..2726dbeb --- /dev/null +++ b/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/ExperimentTokens.java @@ -0,0 +1,30 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.mgoogle.android.gms.phenotype; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class ExperimentTokens extends AutoSafeParcelable { + @Field(2) + public String field2; + @Field(3) + public byte[] direct; + @Field(4) + public byte[][] gaia; + @Field(5) + public byte[][] pseudo; + @Field(6) + public byte[][] always; + @Field(7) + public byte[][] other; + @Field(8) + public int[] weak; + @Field(9) + public byte[][] directs; + @Field(10) + public int[] genericDimensions; + public static final Creator CREATOR = new AutoCreator<>(ExperimentTokens.class); +} diff --git a/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/Flag.java b/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/Flag.java index aa6bba20..8318fa59 100644 --- a/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/Flag.java +++ b/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/Flag.java @@ -8,5 +8,95 @@ package com.mgoogle.android.gms.phenotype; import org.microg.safeparcel.AutoSafeParcelable; public class Flag extends AutoSafeParcelable { + @Field(2) + public String name; + @Field(3) + private long longValue; + @Field(4) + private boolean boolValue; + @Field(5) + private double doubleValue; + @Field(6) + private String stringValue; + @Field(7) + private byte[] bytesValue; + @Field(8) + public int dataType; + @Field(9) + public int flagType; + + private Flag() { + } + + public Flag(String name, long longValue, int flagType) { + this.name = name; + this.longValue = longValue; + this.dataType = DATA_TYPE_LONG; + this.flagType = flagType; + } + + public Flag(String name, boolean boolValue, int flagType) { + this.name = name; + this.boolValue = boolValue; + this.dataType = DATA_TYPE_BOOL; + this.flagType = flagType; + } + + public Flag(String name, double doubleValue, int flagType) { + this.name = name; + this.doubleValue = doubleValue; + this.dataType = DATA_TYPE_DOUBLE; + this.flagType = flagType; + } + + public Flag(String name, String stringValue, int flagType) { + this.name = name; + this.stringValue = stringValue; + this.dataType = DATA_TYPE_STRING; + this.flagType = flagType; + } + + public Flag(String name, byte[] bytesValue, int flagType) { + this.name = name; + this.bytesValue = bytesValue; + this.dataType = DATA_TYPE_BYTES; + this.flagType = flagType; + } + + public long getLong() { + if (dataType == DATA_TYPE_LONG) + return longValue; + throw new IllegalArgumentException("Not a long type"); + } + + public boolean getBool() { + if (dataType == DATA_TYPE_BOOL) + return boolValue; + throw new IllegalArgumentException("Not a boolean type"); + } + + public double getDouble() { + if (dataType == DATA_TYPE_DOUBLE) + return doubleValue; + throw new IllegalArgumentException("Not a double type"); + } + + public String getString() { + if (dataType == DATA_TYPE_STRING) + return stringValue; + throw new IllegalArgumentException("Not a String type"); + } + + public byte[] getBytes() { + if (dataType == DATA_TYPE_BYTES) + return bytesValue; + throw new IllegalArgumentException("Not a bytes type"); + } + + public static final int DATA_TYPE_LONG = 1; + public static final int DATA_TYPE_BOOL = 2; + public static final int DATA_TYPE_DOUBLE = 3; + public static final int DATA_TYPE_STRING = 4; + public static final int DATA_TYPE_BYTES = 5; public static final Creator CREATOR = new AutoCreator<>(Flag.class); } diff --git a/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/FlagOverrides.java b/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/FlagOverrides.java new file mode 100644 index 00000000..e13c6ef8 --- /dev/null +++ b/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/FlagOverrides.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.mgoogle.android.gms.phenotype; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class FlagOverrides extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(FlagOverrides.class); +} diff --git a/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/RegistrationInfo.java b/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/RegistrationInfo.java new file mode 100644 index 00000000..4e004422 --- /dev/null +++ b/play-services-api/src/main/java/com/mgoogle/android/gms/phenotype/RegistrationInfo.java @@ -0,0 +1,27 @@ +/* + * SPDX-FileCopyrightText: 2021 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.mgoogle.android.gms.phenotype; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class RegistrationInfo extends AutoSafeParcelable { + @Field(1) + public String field1; + @Field(2) + public int field2; + @Field(3) + public String[] field3; + @Field(4) + public byte[] field4; + @Field(5) + public boolean field5; + @Field(6) + public int[] field6; + @Field(7) + public String field7; + + public static final Creator CREATOR = new AutoCreator<>(RegistrationInfo.class); +} diff --git a/play-services-core/src/main/kotlin/org/microg/gms/phenotype/PhenotypeService.kt b/play-services-core/src/main/kotlin/org/microg/gms/phenotype/PhenotypeService.kt index 63e9e163..b8a4b9e7 100644 --- a/play-services-core/src/main/kotlin/org/microg/gms/phenotype/PhenotypeService.kt +++ b/play-services-core/src/main/kotlin/org/microg/gms/phenotype/PhenotypeService.kt @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-FileCopyrightText: 2020 microG Project Team * SPDX-License-Identifier: Apache-2.0 */ @@ -10,14 +10,14 @@ import android.util.Log import com.google.android.gms.common.api.Status import com.google.android.gms.common.internal.GetServiceRequest import com.google.android.gms.common.internal.IGmsCallbacks -import com.mgoogle.android.gms.phenotype.Configurations +import com.mgoogle.android.gms.phenotype.* import com.mgoogle.android.gms.phenotype.internal.IPhenotypeCallbacks import com.mgoogle.android.gms.phenotype.internal.IPhenotypeService import org.microg.gms.BaseService import org.microg.gms.common.GmsService import org.microg.gms.utils.warnOnTransactionIssues -private const val TAG = "GmsPhenotypeSvc" +private const val TAG = "PhenotypeService" class PhenotypeService : BaseService(TAG, GmsService.PHENOTYPE) { override fun handleServiceRequest(callback: IGmsCallbacks, request: GetServiceRequest?, service: GmsService?) { @@ -28,20 +28,117 @@ class PhenotypeService : BaseService(TAG, GmsService.PHENOTYPE) { class PhenotypeServiceImpl : IPhenotypeService.Stub() { override fun register(callbacks: IPhenotypeCallbacks, p1: String?, p2: Int, p3: Array?, p4: ByteArray?) { Log.d(TAG, "register($p1, $p2, $p3, $p4)") - callbacks.onRegister(Status.SUCCESS) + callbacks.onRegistered(Status.SUCCESS) } - override fun register2(callbacks: IPhenotypeCallbacks, p1: String?, p2: Int, p3: Array?, p4: IntArray?, p5: ByteArray?) { - Log.d(TAG, "register2($p1, $p2, $p3, $p4, $p5)") - callbacks.onRegister(Status.SUCCESS) + override fun weakRegister(callbacks: IPhenotypeCallbacks, p1: String?, p2: Int, p3: Array?, p4: IntArray?, p5: ByteArray?) { + Log.d(TAG, "weakRegister($p1, $p2, $p3, $p4, $p5)") + callbacks.onWeakRegistered(Status.SUCCESS) } - override fun getConfigurationSnapshot(callbacks: IPhenotypeCallbacks, p1: String?, p2: String?, p3: String?) { - Log.d(TAG, "getConfigurationSnapshot($p1, $p2, $p3)") - callbacks.onConfigurations(Status.SUCCESS, Configurations().apply { + override fun unregister(callbacks: IPhenotypeCallbacks, p1: String?) { + Log.d(TAG, "unregister($p1)") + callbacks.onUnregistered(Status.SUCCESS) + } + + override fun getConfigurationSnapshot(callbacks: IPhenotypeCallbacks, p1: String?, p2: String?) { + Log.d(TAG, "getConfigurationSnapshot($p1, $p2)") + callbacks.onConfiguration(Status.SUCCESS, Configurations().apply { field4 = emptyArray() }) } - override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags) { super.onTransact(code, data, reply, flags) } + override fun commitToConfiguration(callbacks: IPhenotypeCallbacks, p1: String?) { + Log.d(TAG, "commitToConfiguration($p1)") + callbacks.onCommitedToConfiguration(Status.SUCCESS) + } + + override fun getExperimentTokens(callbacks: IPhenotypeCallbacks, p1: String?, logSourceName: String?) { + Log.d(TAG, "getExperimentTokens($p1, $logSourceName)") + callbacks.onExperimentTokens(Status.SUCCESS, ExperimentTokens()) + } + + override fun getDogfoodsToken(callbacks: IPhenotypeCallbacks) { + Log.d(TAG, "getDogfoodsToken()") + callbacks.onDogfoodsToken(Status.SUCCESS, DogfoodsToken()) + } + + override fun setDogfoodsToken(callbacks: IPhenotypeCallbacks, p1: ByteArray?) { + Log.d(TAG, "setDogfoodsToken($p1)") + callbacks.onDogfoodsTokenSet(Status.SUCCESS) + } + + override fun getFlag(callbacks: IPhenotypeCallbacks, packageName: String?, name: String?, type: Int) { + Log.d(TAG, "setDogfoodsToken($packageName, $name, $type)") + callbacks.onFlag(Status.SUCCESS, null) + } + + override fun getCommitedConfiguration(callbacks: IPhenotypeCallbacks, p1: String?) { + Log.d(TAG, "getCommitedConfiguration($p1)") + callbacks.onCommittedConfiguration(Status.SUCCESS, Configurations().apply { + field4 = emptyArray() + }) + } + + override fun getConfigurationSnapshot2(callbacks: IPhenotypeCallbacks, p1: String?, p2: String?, p3: String?) { + Log.d(TAG, "getConfigurationSnapshot2($p1, $p2, $p3)") + callbacks.onConfiguration(Status.SUCCESS, Configurations().apply { + field4 = emptyArray() + }) + } + + override fun syncAfterOperation(callbacks: IPhenotypeCallbacks, p1: String?, p2: Long) { + Log.d(TAG, "syncAfterOperation($p1, $p2)") + callbacks.onSyncFinished(Status.SUCCESS, p2) + } + + override fun registerSync(callbacks: IPhenotypeCallbacks, p1: String?, p2: Int, p3: Array?, p4: ByteArray?, p5: String?, p6: String?) { + Log.d(TAG, "registerSync($p1, $p2, $p3, $p4, $p5, $p6)") + callbacks.onConfiguration(Status.SUCCESS, Configurations().apply { + field4 = emptyArray() + }) + } + + override fun setFlagOverrides(callbacks: IPhenotypeCallbacks, packageName: String?, user: String?, flagName: String?, flagType: Int, flagDataType: Int, flagValue: String?) { + Log.d(TAG, "setFlagOverrides($packageName, $user, $flagName, $flagDataType, $flagType, $flagDataType, $flagValue)") + callbacks.onFlagOverridesSet(Status.SUCCESS) + } + + override fun deleteFlagOverrides(callbacks: IPhenotypeCallbacks, packageName: String?, user: String?, flagName: String?) { + Log.d(TAG, "deleteFlagOverrides($packageName, $user, $flagName)") + callbacks.onFlagOverrides(Status.SUCCESS, FlagOverrides()) + } + + override fun listFlagOverrides(callbacks: IPhenotypeCallbacks, packageName: String?, user: String?, flagName: String?) { + Log.d(TAG, "listFlagOverrides($packageName, $user, $flagName)") + callbacks.onFlagOverrides(Status.SUCCESS, FlagOverrides()) + } + + override fun clearFlagOverrides(callbacks: IPhenotypeCallbacks, packageName: String?, user: String?) { + Log.d(TAG, "clearFlagOverrides($packageName, $user)") + callbacks.onFlagOverridesSet(Status.SUCCESS) + } + + override fun bulkRegister(callbacks: IPhenotypeCallbacks, infos: Array?) { + Log.d(TAG, "bulkRegister($infos)") + callbacks.onRegistered(Status.SUCCESS) + } + + override fun setAppSpecificProperties(callbacks: IPhenotypeCallbacks, p1: String?, p2: ByteArray?) { + Log.d(TAG, "setAppSpecificProperties($p1, $p2)") + callbacks.onAppSpecificPropertiesSet(Status.SUCCESS) + } + + override fun getServingVersion(callbacks: IPhenotypeCallbacks) { + Log.d(TAG, "getServingVersion()") + callbacks.onServingVersion(Status.SUCCESS, 1) + } + + override fun getExperimentTokens2(callbacks: IPhenotypeCallbacks, p1: String?, p2: String?, p3: String?, p4: String?) { + Log.d(TAG, "getExperimentTokens2($p1, $p2, $p3, $p4)") + callbacks.onExperimentTokens(Status.SUCCESS, ExperimentTokens()) + } + + override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = + warnOnTransactionIssues(code, reply, flags) { super.onTransact(code, data, reply, flags) } }