-
Notifications
You must be signed in to change notification settings - Fork 171
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
Bugfix/issue 1812 Android 13 Support #1826
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1826 +/- ##
=============================================
+ Coverage 54.04% 54.05% +0.01%
- Complexity 5532 5535 +3
=============================================
Files 562 562
Lines 25821 25821
Branches 3398 3398
=============================================
+ Hits 13954 13958 +4
+ Misses 10596 10594 -2
+ Partials 1271 1269 -2
|
if (permissionsNeeded().length > 0) { | ||
requestPermission(permissionsNeeded(), REQUEST_CODE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (permissionsNeeded().length > 0) { | |
requestPermission(permissionsNeeded(), REQUEST_CODE); | |
String[] permissionsNeeded = permissionsNeeded(); | |
if (permissionsNeeded.length > 0) { | |
requestPermission(permissionsNeeded, REQUEST_CODE); |
if (checkBTPermission()) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this is still needed? Seems like we could get rid of it.
if (checkBTPermission()) { | |
return; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed because we need to not call SdlReceiver.queryForConnectedService(this);
below only if we need the BLUETOOTH_CONNECT permission.
We could change it below at line 35 to
if (!checkBTPermission()) {
//If we are connected to a module we want to start our SdlService
SdlReceiver.queryForConnectedService(this);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With having an array with strings that contain our permission needs already it seems like we could check those with something like:
for (String permission : permissionsNeeded) {
if(Manifest.permission.BLUETOOTH_CONNECT.equals(permission)){
return;
}
}
I just don't know the efficiency of checking for the permission again, and it seems redundant. At the very least I would say your suggestions should be used as it's bit more concise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option would be to flip the methods for checking permission into returning if the permission is granted instead of currently returning if it is not granted, because that in itself is a big confusing as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it was confusing especially with the naming of those methods, I flipped them and renamed to hasPNPermission
and hasBTPermission
. I wanted to not flip them and name them needPNPermision
and needBTPermission
since its checking the API level and then the permission, But need
really isn't a proper java naming convention that I could find, so I added some JavDocs to them.
ActivityCompat.requestPermissions(this, permissions, REQUEST_CODE); | ||
} | ||
|
||
private String[] permissionsNeeded() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a big deal, but still a good idea.
private String[] permissionsNeeded() { | |
private @NonNull String[] permissionsNeeded() { |
return; | ||
String[] permissionsNeeded = permissionsNeeded(); | ||
if (permissionsNeeded.length > 0) { | ||
requestPermission(permissionsNeeded(), REQUEST_CODE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requestPermission(permissionsNeeded(), REQUEST_CODE); | |
requestPermission(permissionsNeeded, REQUEST_CODE); |
if (checkBTPermission()) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With having an array with strings that contain our permission needs already it seems like we could check those with something like:
for (String permission : permissionsNeeded) {
if(Manifest.permission.BLUETOOTH_CONNECT.equals(permission)){
return;
}
}
I just don't know the efficiency of checking for the permission again, and it seems redundant. At the very least I would say your suggestions should be used as it's bit more concise.
if (checkBTPermission()) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option would be to flip the methods for checking permission into returning if the permission is granted instead of currently returning if it is not granted, because that in itself is a big confusing as well.
Fixes #1812
This PR is [ready] for review.
Risk
This PR makes [minor] API changes.
Testing Plan
Unit Tests
n/a
Core Tests
POST_NOTIFICATIONS TESTS
1 app API 33 on Android 13 device
Test 1:
Results: Notifications appear and the app works as expected
Test 2:
Results: Notifications do not appear and the app works as expected
Test 3:
Results: Notifications do not appear and the app works as expected
Test 4:
Results: Notifications do not appear and the app works as expected
1 app API 31 on Android 13 device
Test 5:
Results: Notifications appear and the app works as expected
Test 6:
Results: Notifications do not appear and the app works as expected
Test 7:
Results: Notifications do not appear and the app works as expected
App 1 API 33, App 2 API 31 on Android 13 device
Test 8:
Results: Notifications appear and the app works as expected
Test 9:
Results: Notifications appear for App 1 and RouterScervice but not for App 2. Apps work as expected
Test 10
Expected Results: No notifications for App 1 and RouterService, App 2 has 1 notification. Apps work as expected.
Observed behavior: No Notifications at all until you disconnect and reconnect to core then App 2 has 1 notification. Outside of that sdl still works fine.
Core version / branch / commit hash / module tested against: Sync 3.0
HMI name / version / branch / commit hash / module tested against: Sync 3.0
Summary
This Pr makes updates to target API 33 as well as update
hello_sdl_android
to demonstrate how to requestPOST_NOTIFICATIONS
permission added in Android 13.There is one issue with test 10 where no notification appears when one should, but after a disconnect and reconnect it works itself out and the behavior of SDL is not altered outside of displayed notifications.
Notifications are still required, but they do not have to be displayed if they don't have the proper permissions. Another major downside to this is if you accidentally dismiss the
BLUETOOTH_CONNECT
permission and thePOST_NOTIFICATIONS
it does not give the user any sense of what they did wrong, but that should work itself out after the app gets closed and opened again.Changelog
Bug Fixes
POST_NOTIFICATIONS
permissionCLA