зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1774565 - Pass FLAG_IMMUTABLE in pendingIntents. r=calu
This is a requirement when targeting Android 31 and above: https://developer.android.com/about/versions/12/behavior-changes-12. Differential Revision: https://phabricator.services.mozilla.com/D149541
This commit is contained in:
Родитель
b07df4f98c
Коммит
6f1c936fdd
|
@ -52,13 +52,24 @@ public class ExampleCrashHandler extends Service {
|
|||
|
||||
String id = createNotificationChannel();
|
||||
|
||||
int intentFlag = 0;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
intentFlag = PendingIntent.FLAG_IMMUTABLE;
|
||||
}
|
||||
|
||||
PendingIntent reportIntent =
|
||||
PendingIntent.getService(
|
||||
this, 0, new Intent(ACTION_REPORT_CRASH, null, this, ExampleCrashHandler.class), 0);
|
||||
this,
|
||||
0,
|
||||
new Intent(ACTION_REPORT_CRASH, null, this, ExampleCrashHandler.class),
|
||||
intentFlag);
|
||||
|
||||
PendingIntent dismissIntent =
|
||||
PendingIntent.getService(
|
||||
this, 0, new Intent(ACTION_DISMISS, null, this, ExampleCrashHandler.class), 0);
|
||||
this,
|
||||
0,
|
||||
new Intent(ACTION_DISMISS, null, this, ExampleCrashHandler.class),
|
||||
intentFlag);
|
||||
|
||||
Notification notification =
|
||||
new NotificationCompat.Builder(this, id)
|
||||
|
@ -66,8 +77,8 @@ public class ExampleCrashHandler extends Service {
|
|||
.setContentTitle(getResources().getString(R.string.crashed_title))
|
||||
.setContentText(getResources().getString(R.string.crashed_text))
|
||||
.setDefaults(Notification.DEFAULT_ALL)
|
||||
.setContentIntent(reportIntent)
|
||||
.addAction(0, getResources().getString(R.string.crashed_ignore), dismissIntent)
|
||||
.addAction(0, getResources().getString(R.string.crashed_report), reportIntent)
|
||||
.setAutoCancel(true)
|
||||
.setOngoing(false)
|
||||
.build();
|
||||
|
|
|
@ -812,7 +812,8 @@ public class GeckoViewActivity extends AppCompatActivity
|
|||
Intent clickIntent = new Intent(GeckoViewActivity.this, GeckoViewActivity.class);
|
||||
clickIntent.putExtra("onClick", notification);
|
||||
PendingIntent dismissIntent =
|
||||
PendingIntent.getActivity(GeckoViewActivity.this, mLastID, clickIntent, 0);
|
||||
PendingIntent.getActivity(
|
||||
GeckoViewActivity.this, mLastID, clickIntent, PendingIntent.FLAG_IMMUTABLE);
|
||||
|
||||
NotificationCompat.Builder builder =
|
||||
new NotificationCompat.Builder(GeckoViewActivity.this, CHANNEL_ID)
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
<string name="crashed_title">GeckoView Example Crashed</string>
|
||||
<string name="crashed_text">Tap to report to Mozilla.</string>
|
||||
<string name="crashed_ignore">Ignore</string>
|
||||
<string name="crashed_report">Report</string>
|
||||
<string name="device_sharing_microphone">Microphone is on</string>
|
||||
<string name="device_sharing_camera">Camera is on</string>
|
||||
<string name="device_sharing_camera_and_mic">Camera and microphone are on</string>
|
||||
|
|
Загрузка…
Ссылка в новой задаче