Add minimal dummy Phenotype service implementation

This commit is contained in:
Marvin W 2020-09-27 11:37:00 +02:00
parent 0ee18ae6f7
commit c4b480c5a9
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
8 changed files with 129 additions and 2 deletions

View File

@ -0,0 +1,3 @@
package com.google.android.gms.phenotype;
parcelable Configurations;

View File

@ -0,0 +1,9 @@
package com.google.android.gms.phenotype.internal;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.phenotype.Configurations;
interface IPhenotypeCallbacks {
void onRegister(in Status status) = 0;
void onConfigurations(in Status status, in Configurations configurations) = 3;
}

View File

@ -0,0 +1,8 @@
package com.google.android.gms.phenotype.internal;
import com.google.android.gms.phenotype.internal.IPhenotypeCallbacks;
interface IPhenotypeService {
void register(IPhenotypeCallbacks callbacks, String p1, int p2, in String[] p3, in byte[] p4) = 0;
void getConfigurationSnapshot(IPhenotypeCallbacks callbacks, String p1, String p2, String p3) = 10;
}

View File

@ -0,0 +1,18 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/
package com.google.android.gms.phenotype;
import org.microg.safeparcel.AutoSafeParcelable;
public class Configuration extends AutoSafeParcelable {
@Field(2)
public int field2;
@Field(3)
public Flag[] field3;
@Field(4)
public String[] field4;
public static final Creator<Configuration> CREATOR = new AutoCreator<>(Configuration.class);
}

View File

@ -0,0 +1,25 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/
package com.google.android.gms.phenotype;
import org.microg.safeparcel.AutoSafeParcelable;
public class Configurations extends AutoSafeParcelable {
@Field(2)
public String field2;
@Field(3)
public String field3;
@Field(4)
public Configuration[] field4;
@Field(5)
public boolean field5;
@Field(6)
public byte[] field6;
@Field(7)
public long field7;
public static final Creator<Configurations> CREATOR = new AutoCreator<>(Configurations.class);
}

View File

@ -0,0 +1,12 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/
package com.google.android.gms.phenotype;
import org.microg.safeparcel.AutoSafeParcelable;
public class Flag extends AutoSafeParcelable {
public static final Creator<Flag> CREATOR = new AutoCreator<>(Flag.class);
}

View File

@ -516,13 +516,21 @@
</intent-filter>
</activity>
<!-- Other -->
<!-- Phenotype -->
<provider
android:name="org.microg.gms.phenotype.ConfigurationProvider"
android:authorities="com.google.android.gms.phenotype"
android:exported="true" />
<service android:name="org.microg.gms.phenotype.PhenotypeService">
<intent-filter>
<action android:name="com.google.android.gms.phenotype.service.START" />
</intent-filter>
</service>
<!-- Other -->
<service
android:name="org.microg.gms.measurement.MeasurementBrokerService"
android:exported="true">
@ -673,7 +681,6 @@
<action android:name="com.google.android.gms.audiomodem.service.AudioModemService.START" />
<action android:name="com.google.android.gms.nearby.sharing.service.NearbySharingService.START" />
<action android:name="com.google.android.gms.herrevad.services.LightweightNetworkQualityAndroidService.START" />
<action android:name="com.google.android.gms.phenotype.service.START" />
<action android:name="com.google.android.gms.auth.api.credentials.service.START" />
<action android:name="com.google.android.gms.gass.START" />
</intent-filter>

View File

@ -0,0 +1,45 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/
package org.microg.gms.phenotype
import android.os.Parcel
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.google.android.gms.phenotype.Configurations
import com.google.android.gms.phenotype.internal.IPhenotypeCallbacks
import com.google.android.gms.phenotype.internal.IPhenotypeService
import org.microg.gms.BaseService
import org.microg.gms.common.GmsService
private const val TAG = "GmsPhenotypeSvc"
class PhenotypeService : BaseService(TAG, GmsService.PHENOTYPE) {
override fun handleServiceRequest(callback: IGmsCallbacks, request: GetServiceRequest?, service: GmsService?) {
callback.onPostInitComplete(0, PhenotypeServiceImpl().asBinder(), null)
}
}
class PhenotypeServiceImpl : IPhenotypeService.Stub() {
override fun register(callbacks: IPhenotypeCallbacks, p1: String?, p2: Int, p3: Array<out String>?, p4: ByteArray?) {
Log.d(TAG, "register($p1, $p2, ${p3?.contentToString()}, $p4)")
callbacks.onRegister(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 {
field4 = emptyArray()
})
}
override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean {
if (super.onTransact(code, data, reply, flags)) return true
Log.d(TAG, "onTransact [unknown]: $code, $data, $flags")
return false
}
}