File tree Expand file tree Collapse file tree 2 files changed +22
-8
lines changed
firebase-app-distribution/src/main/java/com/google/firebase/appdistribution Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -45,14 +45,22 @@ protected void onCreate(@NonNull Bundle savedInstanceState) {
45
45
String path = originalIntent .getStringExtra ("INSTALL_PATH" );
46
46
Intent intent = new Intent (Intent .ACTION_VIEW );
47
47
intent .putExtra (Intent .EXTRA_RETURN_RESULT , true );
48
- Uri apkUri =
49
- FileProvider .getUriForFile (
50
- getApplicationContext (),
51
- getApplicationContext ().getPackageName () + ".appdistro.fileprovider" ,
52
- new File (path ));
48
+ File apkFile = new File (path );
53
49
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
+
56
64
mStartForResult .launch (intent );
57
65
}
58
66
Original file line number Diff line number Diff line change @@ -181,7 +181,13 @@ private void downloadToDisk(
181
181
long bytesDownloaded = 0 ;
182
182
try (BufferedOutputStream outputStream =
183
183
new BufferedOutputStream (
184
- firebaseApp .getApplicationContext ().openFileOutput (fileName , Context .MODE_PRIVATE ))) {
184
+ firebaseApp
185
+ .getApplicationContext ()
186
+ .openFileOutput (
187
+ fileName ,
188
+ android .os .Build .VERSION .SDK_INT >= android .os .Build .VERSION_CODES .N
189
+ ? Context .MODE_PRIVATE
190
+ : Context .MODE_WORLD_READABLE ))) {
185
191
186
192
byte [] data = new byte [8 * 1024 ];
187
193
int readSize = input .read (data );
You can’t perform that action at this time.
0 commit comments