-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base: Add ClientTelemetry API and dummy (#2376)
Co-authored-by: Marvin W <git@larma.de>
- Loading branch information
1 parent
2a81612
commit ebdacd0
Showing
7 changed files
with
206 additions
and
1 deletion.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...-services-base/src/main/aidl/com/google/android/gms/common/internal/MethodInvocation.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.common.internal; | ||
|
||
parcelable MethodInvocation; |
8 changes: 8 additions & 0 deletions
8
play-services-base/src/main/aidl/com/google/android/gms/common/internal/TelemetryData.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.common.internal; | ||
|
||
parcelable TelemetryData; |
12 changes: 12 additions & 0 deletions
12
...src/main/aidl/com/google/android/gms/common/internal/service/IClientTelemetryService.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.common.internal.service; | ||
|
||
import com.google.android.gms.common.internal.TelemetryData; | ||
|
||
interface IClientTelemetryService { | ||
void log(in TelemetryData data) = 0; | ||
} |
78 changes: 78 additions & 0 deletions
78
...-services-base/src/main/java/com/google/android/gms/common/internal/MethodInvocation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.common.internal; | ||
|
||
import android.os.Parcel; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import androidx.annotation.Nullable; | ||
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter; | ||
|
||
import org.microg.gms.utils.ToStringHelper; | ||
|
||
@SafeParcelable.Class | ||
public class MethodInvocation extends AbstractSafeParcelable { | ||
|
||
@Field(1) | ||
final int methodKey; | ||
@Field(2) | ||
final int resultStatusCode; | ||
@Field(3) | ||
final int connectionResultStatusCode; | ||
@Field(4) | ||
final long startTimeMillis; | ||
@Field(5) | ||
final long endTimeMillis; | ||
@Field(6) | ||
@Nullable | ||
final String callingModuleId; | ||
@Field(7) | ||
@Nullable | ||
final String callingEntryPoint; | ||
@Field(8) | ||
final int serviceId; | ||
@Field(value = 9, defaultValue = "-1") | ||
final int latencyMillis; | ||
|
||
@Constructor | ||
public MethodInvocation(@Param(1) int methodKey, @Param(2) int resultStatusCode, @Param(3) int connectionResultStatusCode, @Param(4) long startTimeMillis, @Param(5) long endTimeMillis, @Param(6) @Nullable String callingModuleId, @Param(7) @Nullable String callingEntryPoint, @Param(8) int serviceId, @Param(9) int latencyMillis) { | ||
this.methodKey = methodKey; | ||
this.resultStatusCode = resultStatusCode; | ||
this.connectionResultStatusCode = connectionResultStatusCode; | ||
this.startTimeMillis = startTimeMillis; | ||
this.endTimeMillis = endTimeMillis; | ||
this.callingModuleId = callingModuleId; | ||
this.callingEntryPoint = callingEntryPoint; | ||
this.serviceId = serviceId; | ||
this.latencyMillis = latencyMillis; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String toString() { | ||
return ToStringHelper.name("MethodInvocation") | ||
.field("methodKey", methodKey) | ||
.field("resultStatusCode", resultStatusCode) | ||
.field("connectionResultStatusCode", connectionResultStatusCode) | ||
.field("startTimeMillis", startTimeMillis) | ||
.field("endTimeMillis", endTimeMillis) | ||
.field("callingModuleId", callingModuleId) | ||
.field("callingEntryPoint", callingEntryPoint) | ||
.field("serviceId", serviceId) | ||
.field("latencyMillis", latencyMillis) | ||
.end(); | ||
} | ||
|
||
public static SafeParcelableCreatorAndWriter<MethodInvocation> CREATOR = findCreator(MethodInvocation.class); | ||
|
||
@Override | ||
public void writeToParcel(@NonNull Parcel dest, int flags) { | ||
CREATOR.writeToParcel(this, dest, flags); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
play-services-base/src/main/java/com/google/android/gms/common/internal/TelemetryData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.common.internal; | ||
|
||
import android.os.Parcel; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import androidx.annotation.Nullable; | ||
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelable; | ||
import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter; | ||
|
||
import org.microg.gms.utils.ToStringHelper; | ||
|
||
import java.util.List; | ||
|
||
@SafeParcelable.Class | ||
public class TelemetryData extends AbstractSafeParcelable { | ||
|
||
@Field(1) | ||
final int telemetryConfigVersion; | ||
@Field(2) | ||
@Nullable | ||
List<MethodInvocation> methodInvocations; | ||
|
||
@Constructor | ||
public TelemetryData(@Param(1) int telemetryConfigVersion, @Param(2) @Nullable List<MethodInvocation> methodInvocations) { | ||
this.telemetryConfigVersion = telemetryConfigVersion; | ||
this.methodInvocations = methodInvocations; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String toString() { | ||
return ToStringHelper.name("TelemetryData") | ||
.field("telemetryConfigVersion", telemetryConfigVersion) | ||
.field("methodInvocations", methodInvocations) | ||
.end(); | ||
} | ||
|
||
@Override | ||
public void writeToParcel(@NonNull Parcel dest, int flags) { | ||
CREATOR.writeToParcel(this, dest, flags); | ||
} | ||
|
||
public static SafeParcelableCreatorAndWriter<TelemetryData> CREATOR = findCreator(TelemetryData.class); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
play-services-core/src/main/kotlin/org/microg/gms/common/ClientTelemetryService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.microg.gms.common | ||
|
||
import android.util.Log | ||
import androidx.lifecycle.Lifecycle | ||
import androidx.lifecycle.LifecycleOwner | ||
import com.google.android.gms.common.Feature | ||
import com.google.android.gms.common.api.CommonStatusCodes | ||
import com.google.android.gms.common.internal.ConnectionInfo | ||
import com.google.android.gms.common.internal.GetServiceRequest | ||
import com.google.android.gms.common.internal.IGmsCallbacks | ||
import com.google.android.gms.common.internal.TelemetryData | ||
import com.google.android.gms.common.internal.service.IClientTelemetryService | ||
import org.microg.gms.BaseService | ||
|
||
private const val TAG = "ClientTelemetryService" | ||
|
||
class ClientTelemetryService : BaseService(TAG, GmsService.TELEMETRY) { | ||
override fun handleServiceRequest(callback: IGmsCallbacks?, request: GetServiceRequest?, service: GmsService?) { | ||
Log.d(TAG, "handleServiceRequest start by $request") | ||
callback?.onPostInitCompleteWithConnectionInfo( | ||
CommonStatusCodes.SUCCESS, | ||
ClientTelemetryServiceImpl(lifecycle), | ||
ConnectionInfo().apply { | ||
features = arrayOf(Feature("CLIENT_TELEMETRY", 1)) | ||
} | ||
) | ||
} | ||
} | ||
|
||
class ClientTelemetryServiceImpl(override val lifecycle: Lifecycle) : | ||
IClientTelemetryService.Stub(), LifecycleOwner { | ||
|
||
override fun log(data: TelemetryData?) { | ||
Log.d(TAG, "log: $data") | ||
} | ||
|
||
} |