File tree Expand file tree Collapse file tree 4 files changed +24
-10
lines changed
firebase-app-distribution/src/main
java/com/google/firebase/appdistribution Expand file tree Collapse file tree 4 files changed +24
-10
lines changed Original file line number Diff line number Diff line change 4444
4545 <provider
4646 android : name =" androidx.core.content.FileProvider"
47- android : authorities =" ${applicationId}.provider "
47+ android : authorities =" ${applicationId}.appdistro.fileprovider "
4848 android : exported =" false"
4949 android : grantUriPermissions =" true" >
5050 <meta-data
5151 android : name =" android.support.FILE_PROVIDER_PATHS"
52- android : resource =" @xml/provider_paths " />
52+ android : resource =" @xml/appdistro_provider_paths " />
5353 </provider >
5454 </application >
5555</manifest >
Original file line number Diff line number Diff line change @@ -45,14 +45,22 @@ protected void onCreate(@NonNull Bundle savedInstanceState) {
4545 String path = originalIntent .getStringExtra ("INSTALL_PATH" );
4646 Intent intent = new Intent (Intent .ACTION_VIEW );
4747 intent .putExtra (Intent .EXTRA_RETURN_RESULT , true );
48- Uri apkUri =
49- FileProvider .getUriForFile (
50- getApplicationContext (),
51- getApplicationContext ().getPackageName () + ".provider" ,
52- new File (path ));
48+ File apkFile = new File (path );
5349 String APK_MIME_TYPE = "application/vnd.android.package-archive" ;
54- intent .setDataAndType (apkUri , APK_MIME_TYPE );
55- intent .addFlags (Intent .FLAG_GRANT_READ_URI_PERMISSION );
50+
51+ if (android .os .Build .VERSION .SDK_INT >= android .os .Build .VERSION_CODES .N ) {
52+ Uri apkUri =
53+ FileProvider .getUriForFile (
54+ getApplicationContext (),
55+ getApplicationContext ().getPackageName () + ".appdistro.fileprovider" ,
56+ apkFile );
57+ intent .setDataAndType (apkUri , APK_MIME_TYPE );
58+ intent .addFlags (Intent .FLAG_GRANT_READ_URI_PERMISSION );
59+ } else {
60+ LogWrapper .getInstance ().d ("Requesting a vanilla URI" );
61+ intent .setDataAndType (Uri .fromFile (apkFile ), APK_MIME_TYPE );
62+ }
63+
5664 mStartForResult .launch (intent );
5765 }
5866
Original file line number Diff line number Diff line change @@ -178,7 +178,13 @@ private void downloadToDisk(
178178 long bytesDownloaded = 0 ;
179179 try (BufferedOutputStream outputStream =
180180 new BufferedOutputStream (
181- firebaseApp .getApplicationContext ().openFileOutput (fileName , Context .MODE_PRIVATE ))) {
181+ firebaseApp
182+ .getApplicationContext ()
183+ .openFileOutput (
184+ fileName ,
185+ android .os .Build .VERSION .SDK_INT >= android .os .Build .VERSION_CODES .N
186+ ? Context .MODE_PRIVATE
187+ : Context .MODE_WORLD_READABLE ))) {
182188
183189 byte [] data = new byte [8 * 1024 ];
184190 int readSize = input .read (data );
File renamed without changes.
You can’t perform that action at this time.
0 commit comments