Android设备(支持NFC)搭载GMS Google pay, 却不能在Tap & pay菜单 被选择为默认payment应用。
在集成同样apk的不同项目里边,竟然有时还是不可见的, 有时是可见的。
见下图, 左边桌面明明有Google pay,但是选择支付应用时,右边却看不到Google Pay(右图是可以看到的情况截图).
通过PM扫包看了下两个同时出现的情况,两个是不同APK,包名不一样。
/system/product/priv-app/GmsCore/GmsCore.apk
/system/app/GooglePay/GooglePay.apk
GmsCore apk名称为:Google play services,这个是GMS核心套件基础服务, 其包名为com.google.android.gms。
经检测,两个都是支付应用支持NFC, 有注册AID。
NFC服务扫描检测到的log如下:
04-02 17:27:53.332 3768 3768 D HCENfc_RegisteredServicesCache: invalidateCache()
04-02 17:27:53.332 3768 3768 D HCENfc_RegisteredServicesCache: getInstalledServices()
04-02 17:27:53.351 3768 3768 D HCENfc_RegisteredServicesCache: getInstalledStServices() - found 5 resolvedServices
04-02 17:27:53.352 3768 3768 D HCENfc_RegisteredServicesCache: getInstalledStServices() - componentName: com.google.android.apps.walletnfcrel/com.google.commerce.tapandpay.android.hce.service.ValuableApduService
04-02 17:27:53.352 3768 3768 D HCENfc_RegisteredServicesCache: ServicesCacheFilter feature enabled.
04-02 17:27:53.352 3768 3768 D APINfc_StApduServiceInfo: Constructor - onHost: true, reading from meta-data
04-02 17:27:53.357 3768 3768 D APINfc_StApduServiceInfo: Constructor - mService: null
04-02 17:27:53.357 3768 3768 D APINfc_StApduServiceInfo: Constructor - mDescription: Google Pay
04-02 17:27:53.357 3768 3768 D APINfc_StApduServiceInfo: Constructor - mOffHostName: null
04-02 17:27:53.357 3768 3768 D APINfc_StApduServiceInfo: Constructor - groupCategory: other
04-02 17:27:53.357 3768 3768 D HCENfc_RegisteredServicesCache: getInstalledStServices() - componentName: com.google.android.apps.walletnfcrel/com.google.commerce.tapandpay.android.transit.tap.service.TransitHceService
04-02 17:27:53.359 3768 3768 D HCENfc_RegisteredServicesCache: ServicesCacheFilter feature enabled.
04-02 17:27:53.360 3768 3768 D APINfc_StApduServiceInfo: Constructor - onHost: true, reading from meta-data
04-02 17:27:53.362 3768 3768 D APINfc_StApduServiceInfo: Constructor - mService: null
04-02 17:27:53.362 3768 3768 D APINfc_StApduServiceInfo: Constructor - mDescription: Google Pay
04-02 17:27:53.362 3768 3768 D APINfc_StApduServiceInfo: Constructor - mOffHostName: null
04-02 17:27:53.362 3768 3768 D APINfc_StApduServiceInfo: Constructor - groupCategory: other
04-02 17:27:53.362 3768 3768 D HCENfc_RegisteredServicesCache: getInstalledStServices() - componentName: com.google.android.gms/com.google.android.gms.tapandpay.hce.service.TpHceService
04-02 17:27:53.368 3768 3768 D HCENfc_RegisteredServicesCache: ServicesCacheFilter feature enabled.
04-02 17:27:53.368 3768 3768 D APINfc_StApduServiceInfo: Constructor - onHost: true, reading from meta-data
04-02 17:27:53.400 3768 3768 D APINfc_StApduServiceInfo: Constructor - mService: null
04-02 17:27:53.400 3768 3768 D APINfc_StApduServiceInfo: Constructor - mDescription: Google Pay
04-02 17:27:53.400 3768 3768 D APINfc_StApduServiceInfo: Constructor - mOffHostName: null
04-02 17:27:53.400 3768 3768 D APINfc_StApduServiceInfo: Constructor - groupCategory: payment
04-02 17:27:53.401 3768 3768 D HCENfc_RegisteredServicesCache: getInstalledStServices() - componentName: com.jingdong.app.mall/com.jdpaysdk.payment.quickpass.server.QuickPassNFCServer
04-02 17:27:53.402 3768 3768 D HCENfc_RegisteredServicesCache: ServicesCacheFilter feature enabled.
04-02 17:27:53.402 3768 3768 D APINfc_StApduServiceInfo: Constructor - onHost: true, reading from meta-data
04-02 17:27:53.423 3768 3768 D APINfc_StApduServiceInfo: Constructor - mService: null
04-02 17:27:53.423 3768 3768 D APINfc_StApduServiceInfo: Constructor - mDescription: 京东闪付
04-02 17:27:53.423 3768 3768 D APINfc_StApduServiceInfo: Constructor - mOffHostName: null
04-02 17:27:53.423 3768 3768 D APINfc_StApduServiceInfo: Constructor - groupCategory: payment
04-02 17:27:53.423 3768 3768 D HCENfc_RegisteredServicesCache: getInstalledStServices() - componentName: com.pingan.paces.ccms/com.pingan.paces.hce.hce.service.HCEHostApduService
04-02 17:27:53.451 3768 3768 D HCENfc_RegisteredServicesCache: ServicesCacheFilter feature enabled.
04-02 17:27:53.451 3768 3768 D APINfc_StApduServiceInfo: Constructor - onHost: true, reading from meta-data
04-02 17:27:53.479 3768 3768 D APINfc_StApduServiceInfo: Constructor - mService: null
04-02 17:27:53.479 3768 3768 D APINfc_StApduServiceInfo: Constructor - mDescription: 平安信用卡
04-02 17:27:53.479 3768 3768 D APINfc_StApduServiceInfo: Constructor - mOffHostName: null
04-02 17:27:53.479 3768 3768 D APINfc_StApduServiceInfo: Constructor - groupCategory: payment
04-02 17:27:53.479 3768 3768 D HCENfc_RegisteredServicesCache: findOrCreateUserLocked()
04-02 17:27:53.479 3768 3768 D HCENfc_RegisteredServicesCache: invalidateCache() - mLastAddedPackage: com.pingan.paces.ccms
04-02 17:27:53.479 3768 3768 D HCENfc_RegisteredServicesCache: containsStServiceLocked()
通过此log可见:
GooglePay.apk注册了两个service, 不过其注册的AID是other类别,所以其不在Tap & pay备选之列。
那么另一个是集成在GmsCore.apk里边,为什么会扫描不到。
通过命令dump com.google.android.gms包, 得到结果如下:
dataDir=/data/user/0/com.google.android.gms
disabledComponents:
com.google.android.gms.netrec.scoring.receiver.ScoreNetworksBroadcastReceiver
com.google.android.gms.nearby.sharing.DirectShareService
com.google.android.location.drivingmode.DrivingModeSettingsActivity
com.google.android.gms.backup.component.BackupOptInActivity
com.google.android.gms.tapandpay.hce.service.TpHceService
通过可以扫描到的项目dump,发现:
dataDir=/data/user/0/com.google.android.gms
User 0: ceDataInode=5373 installed=true hidden=false suspended=false stopped=false notLaunched=false enabled=0 instant=false virtual=false
overlay paths:
/product/overlay/NavigationBarMode3Button/NavigationBarMode3ButtonOverlay.apk
disabledComponents:
com.google.android.gms.nearby.sharing.DirectShareService
com.google.android.location.drivingmode.DrivingModeSettingsActivity
enabledComponents:
com.google.android.gms.mdm.services.GcmReceiverService
com.google.android.gms.tapandpay.hce.service.TpHceService
由此可见,该service被disable了。
命令:
命令:
adb shell pm enable com.google.android.gms/.tapandpay.hce.service.TpHceService
输出:
Component {com.google.android.gms/com.google.android.gms.tapandpay.hce.service.TpHceService} new state: enabled
再看菜单和log, 发现其已经出来。
所以,到此结论是,
GmsCore不知到什么原因,导致其在某些项目上service会被默认diable, 然后NFC无法查询到可用Google Pay, 菜单见不到Google pay。