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

Proposed fix for issue 5593 #5597

Merged
merged 4 commits into from
Dec 13, 2023
Merged

Proposed fix for issue 5593 #5597

merged 4 commits into from
Dec 13, 2023

Conversation

argzdev
Copy link
Contributor

@argzdev argzdev commented Dec 11, 2023

Possible fix for #5593

Android 14 requires RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED flag when using registerReceiver command:

Currently, com.google.firebase:firebase-ml-modeldownloader:24.2.1 uses the registerReceiver without this flag:

context.registerReceiver(
broadcastReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

Proposed fix:

context.registerReceiver(
          broadcastReceiver,
          new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE),
          context.RECEIVER_NOT_EXPORTED);

An alternative solution is using ContextCompat but requires version 1.9.0 of androidx.core:core. I noticed in the Android documentation is using ContextCompat for calling registerReceiver, or for the flag RECEIVER_EXPORTED & RECEIVER_NOT_EXPORTED:

ContextCompat.registerReceiver(
          context,
          broadcastReceiver,
          new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE),
          ContextCompat.RECEIVER_NOT_EXPORTED);

However, ContextCompat.RECEIVER_NOT_EXPORTED and the RECEIVER_NOT_EXPORTED from context have the same value, so I don't think this is necessary to use ContextCompat.

FYI, added @SuppressLint("WrongConstant") annotation due to the method throwing an error: https://stackoverflow.com/a/74433641

@argzdev
Copy link
Contributor Author

argzdev commented Dec 12, 2023

Will try to do further testings with Android 14.0.

Android 10.0 seems to work alright:

2023-12-13 03:02:26.732  8553-8585  ModelFileDownloadSer    com.example.issue5593                D  Need to download a new model.
2023-12-13 03:02:26.752  8553-8585  ModelFileDownloadSer    com.example.issue5593                D  Schedule a new downloading task: 7
2023-12-13 03:02:28.099  8553-8609  ProfileInstaller        com.example.issue5593                D  Installing profile for com.example.issue5593
2023-12-13 03:02:28.585  8553-8600  ModelFileDownloadSer    com.example.issue5593                D  Model downloaded successfully
2023-12-13 03:02:28.589  8553-8600  ModelFileDownloadSer    com.example.issue5593                D  Moving downloaded model from external storage to destination folder.

Android 14.0 doesn't receive the signal after it finishes downloading:

2023-12-13 02:59:28.518  6170-6209  ModelFileDownloadSer    com.example.issue5593                D  Need to download a new model.
2023-12-13 02:59:28.593  6170-6209  ModelFileDownloadSer    com.example.issue5593                D  Schedule a new downloading task: 21
2023-12-13 02:59:28.612  6170-6237  Compatibil...geReporter com.example.issue5593                D  Compat change id reported: 194532703; UID 10209; state: ENABLED
2023-12-13 02:59:28.613  6170-6237  Compatibil...geReporter com.example.issue5593                D  Compat change id reported: 253665015; UID 10209; state: ENABLED
2023-12-13 02:59:29.462  6170-6244  ProfileInstaller        com.example.issue5593                D  Installing profile for com.example.issue5593
... no update for Model downloaded successfully

@VinayGuthal VinayGuthal merged commit ff6cc57 into firebase:master Dec 13, 2023
19 checks passed
@firebase firebase locked and limited conversation to collaborators Jan 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy