File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
java/src/com/android/inputmethod/dictionarypack Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -229,8 +229,14 @@ private static void checkTimeAndMaybeSetupUpdateAlarm(final Context context) {
229229 final long now = System .currentTimeMillis ();
230230 final long alarmTime = now + new Random ().nextInt (MAX_ALARM_DELAY_MILLIS );
231231 final Intent updateIntent = new Intent (DictionaryPackConstants .UPDATE_NOW_INTENT_ACTION );
232+ // Set the package name to ensure the PendingIntent is only delivered to trusted components
233+ updateIntent .setPackage (context .getPackageName ());
234+ int pendingIntentFlags = PendingIntent .FLAG_CANCEL_CURRENT ;
235+ if (android .os .Build .VERSION .SDK_INT >= 23 ) {
236+ pendingIntentFlags |= PendingIntent .FLAG_IMMUTABLE ;
237+ }
232238 final PendingIntent pendingIntent = PendingIntent .getBroadcast (context , 0 ,
233- updateIntent , PendingIntent . FLAG_CANCEL_CURRENT );
239+ updateIntent , pendingIntentFlags );
234240
235241 // We set the alarm in the type that doesn't forcefully wake the device
236242 // from sleep, but fires the next time the device actually wakes for any
You can’t perform that action at this time.
0 commit comments