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

[Identity] Creates a Identity specific FileProvider #5762

Merged
merged 2 commits into from
Nov 1, 2022

Conversation

ccen-stripe
Copy link
Contributor

@ccen-stripe ccen-stripe commented Oct 31, 2022

Summary

Using the default androidx.core.content.FileProvider would cause an collision while trying to merge with client app's AndroidManifest if the client app also has a FileProvider. Creating a custom subclass would solve this issue.

See details in https://commonsware.com/blog/2017/06/27/fileprovider-libraries.html

Motivation

Fix FileProvider collision crash

Testing

  • Added tests
  • Modified tests
  • Manually verified

Screenshots

Before After
before screenshot after screenshot

Changelog

@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 2022

Diffuse output:

OLD: identity-example-release-base.apk (signature: none)
NEW: identity-example-release-pr.apk (signature: none)

          │          compressed           │         uncompressed          
          ├───────────┬───────────┬───────┼───────────┬───────────┬───────
 APK      │ old       │ new       │ diff  │ old       │ new       │ diff  
──────────┼───────────┼───────────┼───────┼───────────┼───────────┼───────
      dex │   1.7 MiB │   1.7 MiB │ +15 B │   3.7 MiB │   3.7 MiB │ +24 B 
     arsc │   1.1 MiB │   1.1 MiB │ +16 B │   1.1 MiB │   1.1 MiB │ +16 B 
 manifest │     2 KiB │     2 KiB │  -4 B │   7.1 KiB │   7.1 KiB │ +28 B 
      res │ 381.6 KiB │ 381.6 KiB │   0 B │ 577.7 KiB │ 577.7 KiB │   0 B 
   native │   6.1 MiB │   6.1 MiB │   0 B │  15.6 MiB │  15.6 MiB │   0 B 
    asset │   6.9 KiB │   6.9 KiB │ +20 B │   6.6 KiB │   6.7 KiB │ +20 B 
    other │  28.7 KiB │  28.7 KiB │   0 B │  29.9 KiB │  29.9 KiB │   0 B 
──────────┼───────────┼───────────┼───────┼───────────┼───────────┼───────
    total │   9.3 MiB │   9.3 MiB │ +47 B │    21 MiB │    21 MiB │ +88 B 

 DEX     │ old   │ new   │ diff         
─────────┼───────┼───────┼──────────────
   files │     1 │     1 │  0           
 strings │ 18906 │ 18907 │ +1 (+6 -5)   
   types │  6664 │  6665 │ +1 (+5 -4)   
 classes │  5732 │  5733 │ +1 (+5 -4)   
 methods │ 29469 │ 29470 │ +1 (+23 -22) 
  fields │ 14678 │ 14678 │  0 (+6 -6)   

 ARSC    │ old  │ new  │ diff      
─────────┼──────┼──────┼───────────
 configs │  259 │  259 │ 0         
 entries │ 4735 │ 4735 │ 0 (+1 -1)
APK
    compressed    │   uncompressed   │                               
─────────┬────────┼─────────┬────────┤                               
 size    │ diff   │ size    │ diff   │ path                          
─────────┼────────┼─────────┼────────┼───────────────────────────────
   250 B │ +250 B │   288 B │ +288 B │ + res/zd.xml                  
         │ -250 B │         │ -288 B │ - res/K2.xml                  
 6.2 KiB │  +20 B │ 6.1 KiB │  +20 B │ ∆ assets/dexopt/baseline.prof 
 1.1 MiB │  +16 B │ 1.1 MiB │  +16 B │ ∆ resources.arsc              
 1.7 MiB │  +15 B │ 3.7 MiB │  +24 B │ ∆ classes.dex                 
   2 KiB │   -4 B │ 7.1 KiB │  +28 B │ ∆ AndroidManifest.xml         
─────────┼────────┼─────────┼────────┼───────────────────────────────
 2.8 MiB │  +47 B │ 4.8 MiB │  +88 B │ (total)
MANIFEST
@@ -75,3 +75,3 @@
         android:grantUriPermissions=true
-        android:name=androidx.core.content.FileProvider
+        android:name=com.stripe.android.identity.IdentityFileProvider
         >
@@ -79,3 +79,3 @@
           android:name=android.support.FILE_PROVIDER_PATHS
-          android:resource=@xml/file_paths
+          android:resource=@xml/stripe_identity_file_paths
           />
DEX
STRINGS:

   old   │ new   │ diff       
  ───────┼───────┼────────────
   18906 │ 18907 │ +1 (+6 -5) 
  + Lcom/stripe/android/identity/IdentityFileProvider;
  + Lr2/b_a;
  + Lr2/b_b;
  + Lr2/b_c;
  + Lr2/d;
  + ~~R8{backend:dex,compilation-mode:release,has-checksums:false,min-api:21,pg-map-id:413d596,r8-mode:compatibility,version:3.3.83}
  
  - Landroidx/core/content/FileProvider_a;
  - Landroidx/core/content/FileProvider_b;
  - Landroidx/core/content/FileProvider_c;
  - Landroidx/core/content/FileProvider;
  - ~~R8{backend:dex,compilation-mode:release,has-checksums:false,min-api:21,pg-map-id:250923a,r8-mode:compatibility,version:3.3.83}
  

TYPES:

   old  │ new  │ diff       
  ──────┼──────┼────────────
   6664 │ 6665 │ +1 (+5 -4) 
  + Lcom/stripe/android/identity/IdentityFileProvider;
  + Lr2/b_a;
  + Lr2/b_b;
  + Lr2/b_c;
  + Lr2/d;
  
  - Landroidx/core/content/FileProvider_a;
  - Landroidx/core/content/FileProvider_b;
  - Landroidx/core/content/FileProvider_c;
  - Landroidx/core/content/FileProvider;
  

METHODS:

   old   │ new   │ diff         
  ───────┼───────┼──────────────
   29469 │ 29470 │ +1 (+23 -22) 
  + com.stripe.android.identity.IdentityFileProvider <init>()
  + r2.b_a a(Context) → File[]
  + r2.b_b a(Uri) → File
  + r2.b_b b(File) → Uri
  + r2.b_c <init>(String)
  + r2.b_c a(Uri) → File
  + r2.b_c b(File) → Uri
  + r2.b <clinit>()
  + r2.b <init>()
  + r2.b a(Context, String) → b_b
  + r2.b attachInfo(Context, ProviderInfo)
  + r2.b b(Context, String) → b_c
  + r2.b delete(Uri, String, String[]) → int
  + r2.b getType(Uri) → String
  + r2.b insert(Uri, ContentValues) → Uri
  + r2.b onCreate() → boolean
  + r2.b openFile(Uri, String) → ParcelFileDescriptor
  + r2.b query(Uri, String[], String, String[], String) → Cursor
  + r2.b update(Uri, ContentValues, String, String[]) → int
  + r2.c F(d0)
  + r2.c x(d0)
  + r2.d C(i)
  + r2.d J(i)
  
  - androidx.core.content.FileProvider_a a(Context) → File[]
  - androidx.core.content.FileProvider_b a(Uri) → File
  - androidx.core.content.FileProvider_b b(File) → Uri
  - androidx.core.content.FileProvider_c <init>(String)
  - androidx.core.content.FileProvider_c a(Uri) → File
  - androidx.core.content.FileProvider_c b(File) → Uri
  - androidx.core.content.FileProvider <clinit>()
  - androidx.core.content.FileProvider <init>()
  - androidx.core.content.FileProvider a(Context, String) → FileProvider_b
  - androidx.core.content.FileProvider attachInfo(Context, ProviderInfo)
  - androidx.core.content.FileProvider b(Context, String) → FileProvider_c
  - androidx.core.content.FileProvider delete(Uri, String, String[]) → int
  - androidx.core.content.FileProvider getType(Uri) → String
  - androidx.core.content.FileProvider insert(Uri, ContentValues) → Uri
  - androidx.core.content.FileProvider onCreate() → boolean
  - androidx.core.content.FileProvider openFile(Uri, String) → ParcelFileDescriptor
  - androidx.core.content.FileProvider query(Uri, String[], String, String[], String) → Cursor
  - androidx.core.content.FileProvider update(Uri, ContentValues, String, String[]) → int
  - r2.b F(d0)
  - r2.b x(d0)
  - r2.c C(i)
  - r2.c J(i)
  

FIELDS:

   old   │ new   │ diff      
  ───────┼───────┼───────────
   14678 │ 14678 │ 0 (+6 -6) 
  + r2.b_c a: String
  + r2.b_c b: HashMap
  + r2.b j: b_b
  + r2.b k: String[]
  + r2.b l: File
  + r2.b m: HashMap
  
  - androidx.core.content.FileProvider_c a: String
  - androidx.core.content.FileProvider_c b: HashMap
  - androidx.core.content.FileProvider j: FileProvider_b
  - androidx.core.content.FileProvider k: String[]
  - androidx.core.content.FileProvider l: File
  - androidx.core.content.FileProvider m: HashMap
ARSC
ENTRIES:

   old  │ new  │ diff      
  ──────┼──────┼───────────
   4735 │ 4735 │ 0 (+1 -1) 
  + xml/stripe_identity_file_paths
  
  - xml/file_paths

@ccen-stripe ccen-stripe force-pushed the ccen/updateFileProvider branch from 8222630 to 0eac922 Compare November 1, 2022 18:05
@ccen-stripe ccen-stripe merged commit 456fd1d into master Nov 1, 2022
@ccen-stripe ccen-stripe deleted the ccen/updateFileProvider branch November 1, 2022 19:44
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.

2 participants