Add boot count service (#3374)

Co-authored-by: Marvin W <git@larma.de>
This commit is contained in:
DaVinci9196 2026-04-03 17:05:11 +08:00 committed by GitHub
parent 67cb36c589
commit 624a880f26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,7 @@
package com.google.android.gms.clearcut.internal;
import com.google.android.gms.common.api.Status;
interface IBootCountCallbacks {
void onBootCount(in Status status, int bootCount) = 0;
}

View file

@ -0,0 +1,7 @@
package com.google.android.gms.clearcut.internal;
import com.google.android.gms.clearcut.internal.IBootCountCallbacks;
interface IBootCountService {
void getBootCount(IBootCountCallbacks callbacks) = 0;
}

View file

@ -1250,6 +1250,12 @@
</intent-filter>
</receiver>
<service android:name="org.microg.gms.clearcut.BootCountService" >
<intent-filter>
<action android:name="com.google.android.gms.clearcut.bootcount.service.START" />
</intent-filter>
</service>
<service android:name="org.microg.gms.DummyService">
<intent-filter>
<action android:name="com.google.android.contextmanager.service.ContextManagerService.START" />

View file

@ -0,0 +1,39 @@
/*
* SPDX-FileCopyrightText: 2024 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/
package org.microg.gms.clearcut
import android.content.Context
import android.os.Parcel
import android.provider.Settings
import android.util.Log
import com.google.android.gms.clearcut.internal.IBootCountCallbacks
import com.google.android.gms.clearcut.internal.IBootCountService
import com.google.android.gms.common.api.CommonStatusCodes
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 org.microg.gms.BaseService
import org.microg.gms.common.GmsService
import org.microg.gms.utils.warnOnTransactionIssues
private const val TAG = "BootCountService"
class BootCountService : BaseService(TAG, GmsService.BOOT_COUNT) {
override fun handleServiceRequest(callback: IGmsCallbacks, request: GetServiceRequest, service: GmsService) {
Log.d(TAG, "handleServiceRequest")
callback.onPostInitComplete(CommonStatusCodes.SUCCESS, BootCountServiceImpl(this), null)
}
}
class BootCountServiceImpl(private val context: Context) : IBootCountService.Stub() {
override fun getBootCount(callbacks: IBootCountCallbacks?) {
Log.d(TAG, "getBootCount called")
val bootCount = Settings.Global.getInt(context.contentResolver, Settings.Global.BOOT_COUNT, 1)
callbacks?.onBootCount(Status.SUCCESS, bootCount)
}
override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean =
warnOnTransactionIssues(code, reply, flags, TAG) { super.onTransact(code, data, reply, flags) }
}