aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-07-03 12:15:37 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-07-03 12:15:37 +0000
commit1b3568f9c2ec0e7bd9441e8e6093e9b4ad225b76 (patch)
treea46be3f940dd6aa64b9a4928dedbc437ad3023b3 /java
parente85c57fbee3afa859037cd099feefc95ed60597b (diff)
parent8064a47f09e2959e26a0ede59ecc08e5754b6e51 (diff)
downloadlatinime-1b3568f9c2ec0e7bd9441e8e6093e9b4ad225b76.tar.gz
latinime-1b3568f9c2ec0e7bd9441e8e6093e9b4ad225b76.tar.xz
latinime-1b3568f9c2ec0e7bd9441e8e6093e9b4ad225b76.zip
Merge "LatinIME: Fix Implicit PendingIntent Vulnerability" into main
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/inputmethod/dictionarypack/DictionaryService.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java b/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java
index fe988ac70..5ab55bc44 100644
--- a/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java
+++ b/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java
@@ -229,8 +229,14 @@ public final class DictionaryService extends Service {
final long now = System.currentTimeMillis();
final long alarmTime = now + new Random().nextInt(MAX_ALARM_DELAY_MILLIS);
final Intent updateIntent = new Intent(DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION);
+ // Set the package name to ensure the PendingIntent is only delivered to trusted components
+ updateIntent.setPackage(context.getPackageName());
+ int pendingIntentFlags = PendingIntent.FLAG_CANCEL_CURRENT;
+ if (android.os.Build.VERSION.SDK_INT >= 23) {
+ pendingIntentFlags |= PendingIntent.FLAG_IMMUTABLE;
+ }
final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0,
- updateIntent, PendingIntent.FLAG_CANCEL_CURRENT);
+ updateIntent, pendingIntentFlags);
// We set the alarm in the type that doesn't forcefully wake the device
// from sleep, but fires the next time the device actually wakes for any