Android設備(支持NFC)搭載GMS Google pay, 卻不能在Tap & pay菜單 被選擇爲默認payment應用。
在集成同樣apk的不同項目裏邊,竟然有時還是不可見的, 有時是可見的。
見下圖, 左邊桌面明明有Google pay,但是選擇支付應用時,右邊卻看不到Google Pay(右圖是可以看到的情況截圖).
通過PM掃包看了下兩個同時出現的情況,兩個是不同APK,包名不一樣。
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。