-
Notifications
You must be signed in to change notification settings - Fork 549
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix(pinpoint) 2762: Resolve Android 12 notification trampolining rest…
…rictions and ADM Push Notifications (#2925) * Resolve Android 12 notification trampolining restrictions * Update pinpoint notification test * set correct target class for ADM * remove line from test Co-authored-by: Divyesh Chitroda <div5yesh@gmail.com>
- Loading branch information
1 parent
f34d1e7
commit a544544
Showing
10 changed files
with
114 additions
and
53 deletions.
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