Skip to content

Commit

Permalink
Pay: Add bunch of API details for third-party service (#2416)
Browse files Browse the repository at this point in the history
Co-authored-by: Marvin W <[email protected]>
  • Loading branch information
DaVinci9196 and mar-v-in authored Aug 10, 2024
1 parent ebdacd0 commit 882c8a5
Show file tree
Hide file tree
Showing 36 changed files with 860 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public enum GmsService {
AD_CONSENT_LOOKUP(195, "com.google.android.gms.ads.service.CONSENT_LOOKUP"),
CREDENTIAL_MANAGER(196, "com.google.android.gms.credential.manager.service.firstparty.START"),
PHONE_INTERNAL(197, "com.google.android.gms.auth.api.phone.service.InternalService.START"),
PAY(198, "com.google.android.gms.pay.service.BIND"),
PAY(198, "com.google.android.gms.pay.service.BIND", "com.google.android.gms.pay.service.THIRD_PARTY"),
ASTERISM(199, "com.google.android.gms.asterism.service.START"),
MODULE_RESTORE(201, "com.google.android.gms.backup.GMS_MODULE_RESTORE"),
FACS_CACHE(202, "com.google.android.gms.facs.cache.service.START"),
Expand Down
7 changes: 6 additions & 1 deletion play-services-pay/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ android {
description = 'microG API for play-services-pay'

dependencies {
// Dependencies from play-services-pay:16.5.0
implementation "androidx.activity:activity:1.2.3"
implementation "androidx.fragment:fragment:1.3.4"
api project(':play-services-base')
api project(':play-services-basement')
api project(':play-services-tasks')

implementation "androidx.annotation:annotation:$annotationVersion"
annotationProcessor project(':safe-parcel-processor')
}
34 changes: 22 additions & 12 deletions play-services-pay/core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ SPDX-FileCopyrightText: 2023 microG Project Team
~ SPDX-License-Identifier: Apache-2.0
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<activity-alias
android:name="com.google.android.gms.pay.main.PayActivity"
android:targetActivity="org.microg.gms.pay.PayActivity"
android:exported="true"
android:process=":ui">
android:name="com.google.android.gms.pay.main.PayActivity"
android:exported="true"
android:process=":ui"
android:targetActivity="org.microg.gms.pay.PayActivity">
<intent-filter>
<action android:name="com.google.android.gms.pay.PAY"/>
<action android:name="com.google.android.gms.pay.PAY_OPTIONAL"/>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="com.google.android.gms.pay.PAY" />
<action android:name="com.google.android.gms.pay.PAY_OPTIONAL" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity-alias>
<activity android:name="org.microg.gms.pay.PayActivity"
android:exported="true"
android:process=":ui"/>
<activity
android:name="org.microg.gms.pay.PayActivity"
android:exported="true"
android:process=":ui" />

<service android:name="org.microg.gms.pay.PayService">
<intent-filter>
<action android:name="com.google.android.gms.pay.service.BIND" />
</intent-filter>
</service>
<service
android:name="org.microg.gms.pay.ThirdPartyPayService"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.gms.pay.service.THIRD_PARTY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import org.microg.gms.BaseService
import org.microg.gms.common.GmsService
import org.microg.gms.utils.warnOnTransactionIssues

private const val TAG = "GmsPay"
private const val TAG = "PayService"

class PayService : BaseService(TAG, GmsService.PAY) {
override fun handleServiceRequest(callback: IGmsCallbacks, request: GetServiceRequest, service: GmsService) {
callback.onPostInitCompleteWithConnectionInfo(CommonStatusCodes.SUCCESS, PayImpl(), ConnectionInfo().apply {
callback.onPostInitCompleteWithConnectionInfo(CommonStatusCodes.SUCCESS, PayServiceImpl(), ConnectionInfo().apply {
features = arrayOf(
Feature("pay", 10),
Feature("pay_attestation_signal", 1),
Expand Down Expand Up @@ -93,7 +93,7 @@ class PayService : BaseService(TAG, GmsService.PAY) {
}
}

class PayImpl : IPayService.Stub() {
class PayServiceImpl : IPayService.Stub() {
override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean =
warnOnTransactionIssues(code, reply, flags, TAG) { super.onTransact(code, data, reply, flags) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* SPDX-FileCopyrightText: 2024 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package org.microg.gms.pay

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.api.Status
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.pay.CheckReadinessForEmoneyRequest
import com.google.android.gms.pay.GetMdocCredentialRequest
import com.google.android.gms.pay.GetPayApiAvailabilityStatusRequest
import com.google.android.gms.pay.GetPendingIntentForWalletOnWearRequest
import com.google.android.gms.pay.NotifyCardTapEventRequest
import com.google.android.gms.pay.NotifyEmoneyCardStatusUpdateRequest
import com.google.android.gms.pay.PayApiAvailabilityStatus
import com.google.android.gms.pay.PushEmoneyCardRequest
import com.google.android.gms.pay.SavePassesRequest
import com.google.android.gms.pay.SyncBundleRequest
import com.google.android.gms.pay.internal.IPayServiceCallbacks
import com.google.android.gms.pay.internal.IThirdPartyPayService
import org.microg.gms.BaseService
import org.microg.gms.common.GmsService


private const val TAG = "ThirdPartyPayService"

class ThirdPartyPayService : BaseService(TAG, GmsService.PAY) {

override fun handleServiceRequest(callback: IGmsCallbacks, request: GetServiceRequest, service: GmsService) {
callback.onPostInitCompleteWithConnectionInfo(CommonStatusCodes.SUCCESS, ThirdPartyPayServiceImpl().asBinder(), ConnectionInfo().apply {
features = arrayOf(
Feature("pay_get_pay_api_availability_status", 3),
Feature("pay_save_passes", 5),
Feature("pay_save_passes_jwt", 3),
Feature("pay_sync_bundle", 2),
Feature("pay_get_pending_intent_for_wallet_on_wear", 2),
Feature("pay_get_mdoc_credential_pending_intent", 1),
Feature("pay_notify_card_tap_event", 1),
Feature("pay_check_readiness_for_emoney", 1),
Feature("pay_push_emoney_card", 1),
Feature("pay_notify_emoney_card_status_update", 1)
)
})
}
}

class ThirdPartyPayServiceImpl : IThirdPartyPayService.Stub() {
override fun getPayApiAvailabilityStatus(request: GetPayApiAvailabilityStatusRequest?, callback: IPayServiceCallbacks) {
Log.d(TAG, "onPayApiAvailabilityStatus: Reporting NOT_ELIGIBLE")
callback.onPayApiAvailabilityStatus(Status.SUCCESS, PayApiAvailabilityStatus.NOT_ELIGIBLE)
}

override fun savePasses(request: SavePassesRequest?, callback: IPayServiceCallbacks) {
Log.d(TAG, "savePasses: return SERVICE_MISSING")
callback.onPendingIntent(Status(CommonStatusCodes.SERVICE_MISSING))
}

override fun syncBundle(request: SyncBundleRequest?, callback: IPayServiceCallbacks?) {
Log.d(TAG, "syncBundle Not yet implemented")
}

override fun getPendingForWalletOnWear(request: GetPendingIntentForWalletOnWearRequest?, callback: IPayServiceCallbacks?) {
Log.d(TAG, "getPendingForWalletOnWear Not yet implemented")
}

override fun getMdocCredential(request: GetMdocCredentialRequest?, callback: IPayServiceCallbacks?) {
Log.d(TAG, "getMdocCredential Not yet implemented")
}

override fun notifyCardTapEvent(request: NotifyCardTapEventRequest?, callback: IPayServiceCallbacks?) {
Log.d(TAG, "notifyCardTapEvent Not yet implemented")
}

override fun checkReadinessForEmoney(request: CheckReadinessForEmoneyRequest?, callback: IPayServiceCallbacks?) {
Log.d(TAG, "checkReadinessForEmoney Not yet implemented")
}

override fun pushEmoneyCard(request: PushEmoneyCardRequest?, callback: IPayServiceCallbacks?) {
Log.d(TAG, "pushEmoneyCard Not yet implemented")
}

override fun notifyEmoneyCardStatusUpdate(request: NotifyEmoneyCardStatusUpdateRequest?, callback: IPayServiceCallbacks?) {
Log.d(TAG, "notifyEmoneyCardStatusUpdate Not yet implemented")
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.pay;

parcelable CheckReadinessForEmoneyRequest;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.pay;

parcelable EmoneyReadiness;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.pay;

parcelable GetMdocCredentialRequest;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.pay;

parcelable GetPayApiAvailabilityStatusRequest;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.pay;

parcelable GetPendingIntentForWalletOnWearRequest;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.pay;

parcelable GetWalletStatusResponse;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.pay;

parcelable NotifyCardTapEventRequest;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.pay;

parcelable NotifyEmoneyCardStatusUpdateRequest;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.pay;

parcelable PayApiError;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.pay;

parcelable PushEmoneyCardRequest;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.pay;

parcelable SavePassesRequest;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.pay;

parcelable SyncBundleRequest;
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.google.android.gms.pay.internal;

import android.app.PendingIntent;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.pay.EmoneyReadiness;
import com.google.android.gms.pay.GetWalletStatusResponse;
import com.google.android.gms.pay.PayApiError;

interface IPayServiceCallbacks {
oneway void onStatus(in Status status) = 1;
// oneway void onGetPayGlobalActionCardsResponse(in Status status, in GetPayGlobalActionCardsResponse response) = 2;
oneway void onPendingIntentForWalletOnWear(in Status status, in PendingIntent pendingIntent) = 3;
// oneway void onProtoSafeParcelable(in Status status, in ProtoSafeParcelable proto) = 4;
// oneway void onDataChangeListenerResponse(in DataChangeListenerResponse response) = 5;
// oneway void onGetSortOrderResponse(in Status status, in GetSortOrderResponse response) = 6;
oneway void onStatusAndBoolean(in Status status, boolean b) = 7;
// oneway void onGetTransactionsResponse(in Status status, in GetTransactionsResponse response) = 8;
oneway void onPayApiError(in PayApiError error) = 9;
// oneway void onGetOutstandingPurchaseOrderIdResponse(in Status status, in GetOutstandingPurchaseOrderIdResponse response) = 10;
// oneway void onGetClosedLoopBundleResponse(in Status status, in GetClosedLoopBundleResponse response) = 11;
// oneway void onGetPayCardArtResponse(in Status status, in GetPayCardArtResponse response) = 12;
// oneway void onSyncTransactionsResponse(in Status status, in SyncTransactionsResponse response) = 13;
oneway void onStatusAndByteArray(in Status status, in byte[] bArr) = 14;
// oneway void onGetPassesResponse(in Status status, in GetPassesResponse response) = 15;
oneway void onStatusAndLong(in Status status, long l) = 16;
oneway void onPendingIntent(in Status status) = 17;
// oneway void onGp3SupportInfo(in Status status, Gp3SupportInfo info) = 18;
oneway void onPayApiAvailabilityStatus(in Status status, int availabilityStatus) = 19;
// oneway void onGetTransitCardsResponse(in Status status, in GetTransitCardsResponse response) = 20;
// oneway void onGetWalletStatus(in Status status, in GetWalletStatusResponse getWalletStatusResponse) = 21;
// oneway void onGetSeFeatureReadinessStatusResponse(in Status status, in GetSeFeatureReadinessStatusResponse response) = 22;
// oneway void onSyncTransactionByIdResponse(in Status status, in SyncTransactionByIdResponse response) = 23;
// oneway void onGetImagesForValuableResponse(in Status status, in GetImagesForValuableResponse response) = 24;
oneway void onEmoneyReadiness(in Status status, in EmoneyReadiness emoneyReadiness) = 25;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.google.android.gms.pay.internal;

import com.google.android.gms.pay.GetPayApiAvailabilityStatusRequest;
import com.google.android.gms.pay.internal.IPayServiceCallbacks;
import com.google.android.gms.pay.SavePassesRequest;
import com.google.android.gms.pay.SyncBundleRequest;
import com.google.android.gms.pay.CheckReadinessForEmoneyRequest;
import com.google.android.gms.pay.GetMdocCredentialRequest;
import com.google.android.gms.pay.GetPendingIntentForWalletOnWearRequest;
import com.google.android.gms.pay.NotifyCardTapEventRequest;
import com.google.android.gms.pay.PushEmoneyCardRequest;
import com.google.android.gms.pay.NotifyEmoneyCardStatusUpdateRequest;

interface IThirdPartyPayService {
void getPayApiAvailabilityStatus(in GetPayApiAvailabilityStatusRequest request, in IPayServiceCallbacks callback) = 1; // Reply via onPayApiAvailabilityStatus
void savePasses(in SavePassesRequest request, in IPayServiceCallbacks callback) = 2; // Reply via onPendingIntent
void syncBundle(in SyncBundleRequest request, in IPayServiceCallbacks callback) = 3;
void getPendingForWalletOnWear(in GetPendingIntentForWalletOnWearRequest request, in IPayServiceCallbacks callback) = 4; // Reply via onPendingIntentForWalletOnWear
void getMdocCredential(in GetMdocCredentialRequest request, in IPayServiceCallbacks callback) = 5;
void notifyCardTapEvent(in NotifyCardTapEventRequest request, in IPayServiceCallbacks callback) = 6; // Reply via onStatus or onPayApiError
void checkReadinessForEmoney(in CheckReadinessForEmoneyRequest request, in IPayServiceCallbacks callback) = 7; // Reply via onEmoneyReadiness
void pushEmoneyCard(in PushEmoneyCardRequest request, in IPayServiceCallbacks callback) = 8; // Reply via onPendingIntent
void notifyEmoneyCardStatusUpdate(in NotifyEmoneyCardStatusUpdateRequest request, in IPayServiceCallbacks callback) = 9; // Reply via onStatus
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.google.android.gms.pay;

import android.os.Parcel;

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.common.Hide;

@Hide
@SafeParcelable.Class
public class CheckReadinessForEmoneyRequest extends AbstractSafeParcelable {
@Field(1)
public String serviceProvider;
@Nullable
@Field(2)
public String accountName;

@Constructor
public CheckReadinessForEmoneyRequest(@Param(1) String serviceProvider, @Nullable @Param(2) String accountName) {
this.serviceProvider = serviceProvider;
this.accountName = accountName;
}

@Override
public void writeToParcel(Parcel out, int flags) {
CREATOR.writeToParcel(this, out, flags);
}

public static final SafeParcelableCreatorAndWriter<CheckReadinessForEmoneyRequest> CREATOR = findCreator(CheckReadinessForEmoneyRequest.class);
}
Loading

0 comments on commit 882c8a5

Please sign in to comment.