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 44
44
45
45
<provider
46
46
android : name =" androidx.core.content.FileProvider"
47
- android : authorities =" ${applicationId}.provider "
47
+ android : authorities =" ${applicationId}.appdistro.fileprovider "
48
48
android : exported =" false"
49
49
android : grantUriPermissions =" true" >
50
50
<meta-data
51
51
android : name =" android.support.FILE_PROVIDER_PATHS"
52
- android : resource =" @xml/provider_paths " />
52
+ android : resource =" @xml/appdistro_provider_paths " />
53
53
</provider >
54
54
</application >
55
55
</manifest >
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 () + ".provider" ,
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 @@ -178,7 +178,13 @@ private void downloadToDisk(
178
178
long bytesDownloaded = 0 ;
179
179
try (BufferedOutputStream outputStream =
180
180
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 ))) {
182
188
183
189
byte [] data = new byte [8 * 1024 ];
184
190
int readSize = input .read (data );
File renamed without changes.
You can’t perform that action at this time.
0 commit comments