Skip to content

Conversation

@ouchadam
Copy link
Contributor

@ouchadam ouchadam commented Oct 22, 2021

Fixing #4267

We're attaching unhandled URIs to our notification data payload which the home screen then attempts to parse and fails.

These Intent.data URIs are needed because they enforce uniqueness of the intents (extras are not evaluated by Intent.filterEquals), android 29 introduces a dedicated Intent.identifier aimed at handling this case but we'll have to wait awhile until 29 becomes the minimum version.

For the time being this PR extracts the URI schema and filters it within the HomeActivity deeplink handling.

BEFORE GROUP AFTER GROUP
before-group-click after-group-click
BEFORE INVITE AFTER INVITE
before-join-notification after-invite

@github-actions
Copy link

github-actions bot commented Oct 22, 2021

Unit Test Results

  48 files  ±0    48 suites  ±0   48s ⏱️ -6s
  91 tests ±0    91 ✔️ ±0  0 💤 ±0  0 ±0 
244 runs  ±0  244 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 55c00a0. ± Comparison against base commit 09fbd5f.

♻️ This comment has been updated with latest results.

call = call,
mode = null).apply {
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
data = Uri.parse("foobar://$call.callId")
Copy link
Contributor Author

@ouchadam ouchadam Oct 22, 2021

Choose a reason for hiding this comment

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

there was a small string interop error here $call.callId instead of ${call.callId}, I wonder if it could have been causing some issues with the outgoing call notification 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Good catch! IDK about an issue fix here. It's OutgoingRingingCallNotification, @ganfra any idea?

Copy link
Member

Choose a reason for hiding this comment

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

Don't think it's actually used

// pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that
contentIntent.data = Uri.parse("foobar://" + inviteNotifiableEvent.eventId)
setContentIntent(PendingIntent.getActivity(context, 0, contentIntent, 0))
contentIntent.makeUnique(inviteNotifiableEvent.eventId)
Copy link
Member

@bmarty bmarty Oct 22, 2021

Choose a reason for hiding this comment

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

I think the comment above (// pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that) is important.
This comes from Riot-Android
@BillCarsonFr can give his POV maybe?

Copy link
Contributor Author

@ouchadam ouchadam Oct 22, 2021

Choose a reason for hiding this comment

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

👍 would be great for some more context

I've still kept the uniqueness but now its from the intent.extras rather than the intent.data since the deeplink mechanism is reading from intent.data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

     * Determine if two intents are the same for the purposes of intent
     * resolution (filtering). That is, if their action, data, type, identity,
     * class, and categories are the same.  This does <em>not</em> compare
     * any extra data included in the intents.  Note that technically when actually
     * matching against an {@link IntentFilter} the identifier is ignored, while here
     * it is directly compared for equality like the other fields.

which means the extra is not enough to provide uniqueness 😢

android 29 provides a way to set a unique Id directly onto the intent which would work for pending intents but we need to support earlier versions.

I'll revert these changes and instead replace foobar:// with a constant which gets filtered by the intent handling

Copy link
Member

Choose a reason for hiding this comment

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

Thanks

- fixes malformed url errors appearing for uri we only create to force uniqueness in the notifications
@ouchadam ouchadam force-pushed the feature/adm/malformed-group-link branch from 8d0a22f to 06b3cc3 Compare October 22, 2021 17:29
handlePermalink(permalinkData, deepLink, context, navigationInterceptor, buildTask)
return when {
deepLink == null -> false
deepLink.isIgnored() -> true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the fix, we're marking ignored deeplinks as handled to avoid attempting to handle them

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, not your fault, but this is where a doc would help, to understand what returning false or true means...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm happy to fix in this PR or a separate one, will also use the opportunity to add some tests

Copy link
Member

Choose a reason for hiding this comment

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

No hurry, can you just fix the commented out code issue and add a changelog file so I can prepare release 1.3.5. Thanks!

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks you, LGTM

// the action must be unique else the parameters are ignored
quickReplyIntent.action = QUICK_LAUNCH_ACTION
quickReplyIntent.data = Uri.parse("foobar://$roomId")
quickReplyIntent.data = _root_ide_package_.im.vector.app.core.extensions.createIgnoredUri($roomId")
Copy link
Member

Choose a reason for hiding this comment

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

Strange change in this (commented out) code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 totally missed that, I guess android studio didn't like auto extracting within the commented code

Copy link
Member

Choose a reason for hiding this comment

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

Yes, probably

handlePermalink(permalinkData, deepLink, context, navigationInterceptor, buildTask)
return when {
deepLink == null -> false
deepLink.isIgnored() -> true
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, not your fault, but this is where a doc would help, to understand what returning false or true means...

@bmarty bmarty enabled auto-merge October 25, 2021 10:03
@bmarty
Copy link
Member

bmarty commented Oct 25, 2021

This PR will be merged, so I'm not requiring new changes here.

android 29 introduces a dedicated Intent.identifier aimed at handling this case but we'll have to wait awhile until 29 becomes the minimum version

Can't we use this new API with if (SDK_INT >= 29)? Not sure what would be the advantage though, except having a fancier codebase :)

@bmarty bmarty merged commit 8b6e018 into develop Oct 25, 2021
@bmarty bmarty deleted the feature/adm/malformed-group-link branch October 25, 2021 10:20
@ouchadam
Copy link
Contributor Author

Can't we use this new API with if (SDK_INT >= 29)? Not sure what would be the advantage though, except having a fancier codebase :)

😄 I think that would be the only advantage, we would have to support an extra code branch in the notifications and deeplinks 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants