Skip to content

Commit

Permalink
Completing PoTokenService Functions
Browse files Browse the repository at this point in the history
  • Loading branch information
DaVinci9196 committed Dec 19, 2023
1 parent be20546 commit dc6daaa
Show file tree
Hide file tree
Showing 10 changed files with 451 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.potokens;

parcelable PoToken;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.google.android.gms.potokens.internal;

import com.google.android.gms.common.api.internal.IStatusCallback;
import com.google.android.gms.potokens.internal.ITokenCallbacks;

interface IPoTokensService{

void responseStatus(IStatusCallback call,in int code)=1;

void responseStatusToken(ITokenCallbacks call, in int code, in byte[] data)=2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.google.android.gms.potokens.internal;

import com.google.android.gms.common.api.Status;
import com.google.android.gms.potokens.PoToken;

interface ITokenCallbacks{
void responseToken(in Status status,in PoToken token)=1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.google.android.gms.potokens;

import org.microg.safeparcel.AutoSafeParcelable;

public class PoToken extends AutoSafeParcelable {

@Field(1)
public byte[] data;

public PoToken(byte[] data) {
this.data = data;
}

public static Creator<PoToken> CREATOR = new AutoCreator<>(PoToken.class);
}
58 changes: 58 additions & 0 deletions play-services-core-proto/src/main/proto/potoken.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
option java_package = "com.google.android.gms.potokens";

option java_multiple_files = true;

message CipherKey {
optional int32 key = 1;
optional bytes value = 3;
}

message KeyData {
optional string typeUrl = 1;
optional CipherKey value = 2;
optional int32 keyMaterialType = 3;
}

message Key {
optional KeyData data = 1;
optional int32 status = 2;
optional int32 keyId = 3;
optional int32 outputPrefixType = 4;
}

message KeySet {
optional int32 primaryKeyId = 1;
repeated Key keyList = 2;
}

message PoTokenInfo {
optional int32 time = 1;
optional bytes inputData = 2;
optional string pkgName = 3;
optional bytes pkgSignSha256 = 4;
optional bytes piTokenData = 5;
optional int32 key = 6;
}

message GetPoIntegrityTokenRequest {
optional int32 mode = 1;
optional bytes dgResult = 2;
optional bytes dgRandKey = 3;
}

message GetPoIntegrityTokenResponse {
optional bytes desc = 1;
optional int32 code = 2;
optional bytes backup = 3;
optional bytes piTokenData = 4;
optional bytes poTokenData = 5;
}

message PoTokenResult {
optional bytes encryptData = 1;
optional bytes piTokenData = 2;
}

message PoTokenResultWrap {
optional PoTokenResult data = 1;
}
11 changes: 11 additions & 0 deletions play-services-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,17 @@
</intent-filter>
</activity>

<!-- poToken -->

<service
android:name="com.google.android.gms.potokens.internal.PoTokensApiService"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.gms.potokens.service.START" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</service>

<!-- Other -->

<service
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.google.android.gms.potokens.internal

import android.os.RemoteException
import android.util.Log
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 org.microg.gms.BaseService
import org.microg.gms.common.GmsService

const val TAG = "PoTokensApi"

class PoTokensApiService : BaseService(TAG, GmsService.POTOKENS) {
@Throws(RemoteException::class)
override fun handleServiceRequest(callback: IGmsCallbacks, request: GetServiceRequest, service: GmsService) {
val connectionInfo = ConnectionInfo()
connectionInfo.features = arrayOf(Feature("PO_TOKENS", 1))
Log.d(TAG,"PoTokensApiService handleServiceRequest")
callback.onPostInitCompleteWithConnectionInfo(
CommonStatusCodes.SUCCESS, PoTokensApiServiceImpl(
applicationContext, request.packageName
), connectionInfo
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.google.android.gms.potokens.internal

import android.content.Context
import android.os.RemoteException
import android.util.Log
import com.google.android.gms.common.api.Status
import com.google.android.gms.common.api.internal.IStatusCallback
import com.google.android.gms.potokens.PoToken
import com.google.android.gms.potokens.utils.PoTokenHelper

class PoTokensApiServiceImpl(private val context: Context, private val packageName: String) :
IPoTokensService.Stub() {

@Throws(RemoteException::class)
override fun responseStatus(call: IStatusCallback, code: Int) {
Log.d(TAG, "responseStatus this is success")
call.onResult(Status.SUCCESS)
}

@Throws(RemoteException::class)
override fun responseStatusToken(call: ITokenCallbacks, i: Int, bArr: ByteArray) {
Log.d(TAG, "responseStatusToken this is packageName,$packageName")

val poTokenHelper = PoTokenHelper()
val bytes = poTokenHelper.callPoToken(context, packageName, bArr)
Log.d(TAG, "responseStatusToken this is result," + bytes.size)

call.responseToken(Status.SUCCESS, PoToken(bytes))
Log.d(TAG, "responseStatusToken this is result end")
}

}
Loading

0 comments on commit dc6daaa

Please sign in to comment.