Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist GooglePayLauncherViewModel state #5226

Merged
merged 4 commits into from Jun 30, 2022
Merged

Persist GooglePayLauncherViewModel state #5226

merged 4 commits into from Jun 30, 2022

Conversation

brnunes-stripe
Copy link
Contributor

@brnunes-stripe brnunes-stripe commented Jun 28, 2022

Summary

Persist GooglePayLauncherViewModel state across process death.
GooglePayLauncherViewModel.hasLaunched was kept in memory, so if the ViewModel was destroyed and recreated, it would launch Google Pay again. This is already fixed in GooglePayPaymentMethodLauncherViewModel.
Also fix the example GooglePayLauncherIntegrationActivity which would request a new Payment Intent when the activity is recreated.

Motivation

Fix #5193

Testing

  • Added tests
  • Modified tests
  • Manually verified

Hard to test killing and restoring process, probably a good candidate for the instrumentation tests.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 28, 2022

Diffuse output:

OLD: paymentsheet-example-release-master.apk (signature: none)
NEW: paymentsheet-example-release-pr.apk (signature: none)

          │           compressed           │          uncompressed          
          ├───────────┬───────────┬────────┼───────────┬───────────┬────────
 APK      │ old       │ new       │ diff   │ old       │ new       │ diff   
──────────┼───────────┼───────────┼────────┼───────────┼───────────┼────────
      dex │  14.9 MiB │  14.9 MiB │ +179 B │  50.4 MiB │  50.4 MiB │ +804 B 
     arsc │   1.7 MiB │   1.7 MiB │    0 B │   1.7 MiB │   1.7 MiB │    0 B 
 manifest │   3.6 KiB │   3.6 KiB │    0 B │  16.7 KiB │  16.7 KiB │    0 B 
      res │ 819.9 KiB │ 819.9 KiB │    0 B │   1.3 MiB │   1.3 MiB │    0 B 
   native │   2.5 MiB │   2.5 MiB │    0 B │   5.9 MiB │   5.9 MiB │    0 B 
    asset │     3 MiB │     3 MiB │ +262 B │     3 MiB │     3 MiB │ +262 B 
    other │  80.3 KiB │  80.3 KiB │    0 B │ 155.1 KiB │ 155.1 KiB │    0 B 
──────────┼───────────┼───────────┼────────┼───────────┼───────────┼────────
    total │  22.9 MiB │  22.9 MiB │ +441 B │  62.4 MiB │  62.4 MiB │ +1 KiB 

         │          raw           │            unique            
         ├────────┬────────┬──────┼────────┬────────┬────────────
 DEX     │ old    │ new    │ diff │ old    │ new    │ diff       
─────────┼────────┼────────┼──────┼────────┼────────┼────────────
   files │      4 │      4 │    0 │        │        │            
 strings │ 236113 │ 236115 │   +2 │ 207912 │ 207914 │ +2 (+7 -5) 
   types │  41652 │  41653 │   +1 │  38591 │  38592 │ +1 (+1 -0) 
 classes │  35916 │  35917 │   +1 │  35916 │  35917 │ +1 (+1 -0) 
 methods │ 211550 │ 211553 │   +3 │ 204500 │ 204503 │ +3 (+8 -5) 
  fields │ 155736 │ 155738 │   +2 │ 154993 │ 154995 │ +2 (+3 -1) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  292 │  292 │  0   
 entries │ 5795 │ 5795 │  0
APK
    compressed    │   uncompressed   │                               
─────────┬────────┼─────────┬────────┤                               
 size    │ diff   │ size    │ diff   │ path                          
─────────┼────────┼─────────┼────────┼───────────────────────────────
 8.2 KiB │ +262 B │ 8.1 KiB │ +262 B │ ∆ assets/dexopt/baseline.prof 
 2.7 MiB │ +179 B │ 8.5 MiB │ +804 B │ ∆ classes3.dex                
─────────┼────────┼─────────┼────────┼───────────────────────────────
 2.7 MiB │ +441 B │ 8.5 MiB │ +1 KiB │ (total)
DEX
STRINGS:

   old    │ new    │ diff       
  ────────┼────────┼────────────
   207912 │ 207914 │ +2 (+7 -5) 
  + J
  ���
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  ���
  ���
  
  ���
  
  ���
  
  ���
  �����2�0�B=������0�������0�������0���������0	�����
  ��0��
  �������0
  ¢����J5����H�����*�0�2�����0�2��������H�0�2�����0�H�¢����R�����0�X��¢��
  R�����0�X��¢��
  R�����0	X��¢��
  R��
  ��0�X��¢��
  ¨��
  +  �
  ���
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  ���
  ���
  ���
  
  ���
  ���
  ���
  ���
  ���
  
  ���
  
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  
  ���
  
  ���
  ���
  ���
  
  ���
  ��	�� B2�0�:�BCBE������0�������0�������0�������0	���
  ��0������0
  ������0�������0�¢����J!���0#2��_��0%2��&��0'H�@ø�¢���(J��)������0+0*H�@ø�¢���,J��-��0.2�����0�H�@ø�¢���/J��0��012��2��032��4��05H�¢���6J#�7��0�2��8��092��:��0;H�@ø�¢���<�=J��>��0�H�@ø�¢���,J��?��0#2��8��092��:��0;J��@��0#2��A��0�R���������0�0�X��¢��
  R�����0�X��¢��
  R����0
  X��¢��
  R�����0�X��¢��
  R������
   �*���0�0�0�X��¢��
  ������R_����0�2�����0�8F@FX��¢��������� �!R��
  ��0�X��¢��
  R�����0�X��¢��
  R�����0�X��¢��
  R�����0�X��¢��
  R�����0	X��¢��
  ���
  ���¨�D
  + (Landroid/app/Application;Lcom/stripe/android/googlepaylauncher/GooglePayLauncherContract_Args;Landroidx/savedstate/SavedStateRegistryOwner;ZLkotlin/coroutines/CoroutineContext;Landroid/os/Bundle;)V
  + (Lcom/google/android/gms/wallet/PaymentsClient;Lcom/stripe/android/core/networking/ApiRequest_Options;Lcom/stripe/android/googlepaylauncher/GooglePayLauncherContract_Args;Lcom/stripe/android/networking/StripeRepository;Lcom/stripe/android/PaymentController;Lcom/stripe/android/GooglePayJsonFactory;Lcom/stripe/android/googlepaylauncher/GooglePayRepository;Landroidx/lifecycle/SavedStateHandle;)V
  + Lcom/stripe/android/googlepaylauncher/GooglePayLauncherViewModel_Companion;
  + SMAP
  GooglePayLauncherViewModel.kt
  Kotlin
  *S Kotlin
  *F
  + 1 GooglePayLauncherViewModel.kt
  com/stripe/android/googlepaylauncher/GooglePayLauncherViewModel
  + 2 Transformations.kt
  androidx/lifecycle/TransformationsKt
  + 3 fake.kt
  kotlin/jvm/internal/FakeKt
  *L
  1#1,297:1
  87#2:298
  1#3:299
  *S KotlinDebug
  *F
  + 1 GooglePayLauncherViewModel.kt
  com/stripe/android/googlepaylauncher/GooglePayLauncherViewModel
  *L
  62#1:298
  *E
  
  + getHAS_LAUNCHED_KEY_annotations
  
  - 2
  ���
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  ���
  ���
  
  ���
  �����2�0�B)������0�������0���������0���������0	¢���
  J%����H���*�0
  2��������H0�H�¢����R�����0�X��¢��
  R�����0�X��¢��
  R�����0�X��¢��
  R�����0	X��¢��
  ¨��
  - ��
  ���
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  ���
  ���
  ���
  
  ���
  ���
  ���
  ���
  ���
  
  ���
  
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  
  ���
  
  ���
  ���
  ���
  
  ���
  �����2�0�:�?B=������0�������0�������0�������0	���
  ��0������0
  ������0�¢����J!����0 2��!��02��#��0_H�@ø�¢���%J��&������0(0'H�@ø�¢���)J��*��0+2�����0�H�@ø�¢���,J��-��0.2��/��002��1��02H�¢���3J#�4��0�2��5��062��7��08H�@ø�¢���9�:J��;��0�H�@ø�¢���)J��<��0 2��5��062��7��08J��=��0 2��>��0�R���������0�0�X��¢��
  R�����0�X��¢��
  R����0
  X��¢��
  R�����0�X��¢��
  R������
   �*���0�0�0�X��¢��
  ������R�����0�X��¢��
  �����������R��
  ��0�X��¢��
  R�����0�X��¢��
  R�����0�X��¢��
  R�����0	X��¢��
  ���
  ���¨�@
  - (Landroid/app/Application;Lcom/stripe/android/googlepaylauncher/GooglePayLauncherContract_Args;ZLkotlin/coroutines/CoroutineContext;)V
  - (Lcom/google/android/gms/wallet/PaymentsClient;Lcom/stripe/android/core/networking/ApiRequest_Options;Lcom/stripe/android/googlepaylauncher/GooglePayLauncherContract_Args;Lcom/stripe/android/networking/StripeRepository;Lcom/stripe/android/PaymentController;Lcom/stripe/android/GooglePayJsonFactory;Lcom/stripe/android/googlepaylauncher/GooglePayRepository;)V
  - SMAP
  GooglePayLauncherViewModel.kt
  Kotlin
  *S Kotlin
  *F
  + 1 GooglePayLauncherViewModel.kt
  com/stripe/android/googlepaylauncher/GooglePayLauncherViewModel
  + 2 Transformations.kt
  androidx/lifecycle/TransformationsKt
  + 3 fake.kt
  kotlin/jvm/internal/FakeKt
  *L
  1#1,273:1
  87#2:274
  1#3:275
  *S KotlinDebug
  *F
  + 1 GooglePayLauncherViewModel.kt
  com/stripe/android/googlepaylauncher/GooglePayLauncherViewModel
  *L
  50#1:274
  *E
  
  

TYPES:

   old   │ new   │ diff       
 
...✂

@brnunes-stripe brnunes-stripe merged commit 544fda1 into master Jun 30, 2022
@brnunes-stripe brnunes-stripe deleted the gpayfix branch June 30, 2022 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to close google pay sheet programmatically
4 participants