Page MenuHomePhabricator

Implement native Android module that can remove all active notifications for a given thread
ClosedPublic

Authored by marcin on Jan 11 2023, 4:06 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 11, 3:07 AM
Unknown Object (File)
Tue, Nov 5, 10:01 PM
Unknown Object (File)
Sat, Oct 26, 8:45 PM
Unknown Object (File)
Oct 15 2024, 11:21 PM
Unknown Object (File)
Oct 12 2024, 3:39 AM
Unknown Object (File)
Oct 1 2024, 1:07 AM
Unknown Object (File)
Sep 29 2024, 8:53 PM
Unknown Object (File)
Sep 29 2024, 8:53 PM
Subscribers

Details

Summary

This differential implements native Android module to remove notifications for a given thread. In future differentials we will use to to remove threadID <-> notificationID mapping from redux.

Test Plan

Build the app. Import this module in JavaScript and call this method. Passing any string should work (not crashing).

Diff Detail

Repository
rCOMM Comm
Branch
marcin/eng-2501
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

Fix a bug - bundle contains String so, getString must be called.

tomek requested changes to this revision.Jan 18 2023, 6:59 AM
tomek added inline comments.
native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
28

Can we use this in any version of OS? In CommNotificationsHandler we are checking if android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M.

31–32

This is a strange name. A CharArray is basically a String, but I don't think it makes sense to include a type in a variable name.

native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationsPackage.java
22–26

It's a good practice to avoid mutating things where possible. In this case, the code can be replaced by e.g. List.of or Collections.singletonList. Obviously, if the returned array may be mutated, we can't use these.

This revision now requires changes to proceed.Jan 18 2023, 6:59 AM
native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
28

This was added in API level 23. I will add the if sttement.

31–32

This is my oversight. Initially I used getCharArray method instead of getString.

native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationsPackage.java
22–26
native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationsPackage.java
22–26

At this moment I will introduce urgent changes from this differential (other comments), but I oblige myself to try compiling app with List.of instead of mutable ArrayList. If it works I will introduce the change.

Rename threadIDCharArray to valid name.
Check for android version before using API

tomek added inline comments.
native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
28

Ok, this behavior is consistent with current implementation. I don't think we should search for a solution that allows rescinding in Android 5.0 @ashoat

This revision is now accepted and ready to land.Jan 24 2023, 5:46 AM
native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
38 ↗(On Diff #21239)

Is there any risk of a null pointer exception? Eg. is extras always set?

As for Android 5.0, yeah I agree we shouldn't worry about rescinds for such an old version

native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
38 ↗(On Diff #21239)

Looking at the docs: https://developer.android.com/reference/android/app/Notification#extras, we don't have Nonnull annotation here, therefore the check is necessary. Thanks for catching.