Skip to content

FAD fixing file provider path bug #2972

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

Merged
merged 2 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions firebase-app-distribution/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:authorities="${applicationId}.appdistro.fileprovider"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review, but I think we should change this to firebaseappdistribution.fileprovider because we don't use appdistro externally, and the firebase prefix helps customers quickly identify this authority as part of the Firebase ecosystem (and aligns with the name of the main folder for this SDK)

android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
android:resource="@xml/appdistro_provider_paths" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing here, I think this should be firebase_app_distribution_provider_path

</provider>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,22 @@ protected void onCreate(@NonNull Bundle savedInstanceState) {
String path = originalIntent.getStringExtra("INSTALL_PATH");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
Uri apkUri =
FileProvider.getUriForFile(
getApplicationContext(),
getApplicationContext().getPackageName() + ".provider",
new File(path));
File apkFile = new File(path);
String APK_MIME_TYPE = "application/vnd.android.package-archive";
intent.setDataAndType(apkUri, APK_MIME_TYPE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
Uri apkUri =
FileProvider.getUriForFile(
getApplicationContext(),
getApplicationContext().getPackageName() + ".appdistro.fileprovider",
apkFile);
intent.setDataAndType(apkUri, APK_MIME_TYPE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} else {
LogWrapper.getInstance().d("Requesting a vanilla URI");
intent.setDataAndType(Uri.fromFile(apkFile), APK_MIME_TYPE);
}

mStartForResult.launch(intent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,13 @@ private void downloadToDisk(
long bytesDownloaded = 0;
try (BufferedOutputStream outputStream =
new BufferedOutputStream(
firebaseApp.getApplicationContext().openFileOutput(fileName, Context.MODE_PRIVATE))) {
firebaseApp
.getApplicationContext()
.openFileOutput(
fileName,
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N
? Context.MODE_PRIVATE
: Context.MODE_WORLD_READABLE))) {

byte[] data = new byte[8 * 1024];
int readSize = input.read(data);
Expand Down