-
Notifications
You must be signed in to change notification settings - Fork 548
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
Fix(pinpoint) 2762: Resolve Android 12 notification trampolining restrictions and ADM Push Notifications #2925
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
15290d5
Resolve Android 12 notification trampolining restrictions
tylerjroach 302147f
Merge branch 'main' into tjroach/notification-trampoline-fix
tylerjroach d0a74d6
Update pinpoint notification test
tylerjroach 6db9409
Merge branch 'main' into tjroach/notification-trampoline-fix
div5yesh 83e87b8
set correct target class for ADM
tylerjroach e6bf12c
Merge remote-tracking branch 'origin/tjroach/notification-trampoline-…
tylerjroach 1fa9588
remove line from test
tylerjroach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...zonaws/mobileconnectors/pinpoint/targeting/notification/PinpointNotificationActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazonaws.mobileconnectors.pinpoint.targeting.notification; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.content.pm.PackageManager; | ||
import android.os.Bundle; | ||
|
||
/** | ||
* The Amazon Pinpoint push notification tracking/routing activity. | ||
* This class is an Activity instead of BroadcastReceiver due to Android 12 restrictions around | ||
* notification trampolining. | ||
*/ | ||
public class PinpointNotificationActivity extends Activity { | ||
private static String TAG = PinpointNotificationActivity.class.getSimpleName(); | ||
|
||
private static volatile NotificationClient notificationClient = null; | ||
|
||
public static void setNotificationClient(NotificationClient notificationClient) { | ||
PinpointNotificationActivity.notificationClient = notificationClient; | ||
} | ||
|
||
public static void setNotificationClient(NotificationClientBase notificationClientBase) { | ||
PinpointNotificationActivity.notificationClient = new NotificationClient(notificationClientBase); | ||
} | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
Intent intent = getIntent(); | ||
Bundle extras = intent.getExtras(); | ||
if (notificationClient != null) { | ||
EventSourceType eventSourceType = EventSourceType.getEventSourceType(extras); | ||
notificationClient.handleNotificationOpen(eventSourceType.getAttributeParser().parseAttributes(extras), extras); | ||
} else { | ||
final PackageManager pm = getPackageManager(); | ||
final Intent launchIntent = pm.getLaunchIntentForPackage(intent.getPackage()); | ||
launchIntent.putExtras(extras); | ||
startActivity(launchIntent); | ||
} | ||
|
||
finish(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<!--This theme ensures the Headless PinpointNotificationActivity is completely hidden--> | ||
<style name="PinpointNotificationActivityTheme" parent="android:Theme"> | ||
<item name="android:windowIsTranslucent">true</item> | ||
<item name="android:windowBackground">@android:color/transparent</item> | ||
<item name="android:windowContentOverlay">@null</item> | ||
<item name="android:windowNoTitle">true</item> | ||
<item name="android:windowIsFloating">true</item> | ||
<item name="android:backgroundDimEnabled">false</item> | ||
</style> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nice!