【发布时间】:2022-01-28 15:52:29
【问题描述】:
Google 拒绝了我的应用,当我将应用作为生产版本提交时,我遇到了这个安全错误:
隐式内部意图
您的应用包含隐式内部意图漏洞。请 有关详细信息,请参阅此 Google 帮助中心文章。
com.mypackage.name.sync.SyncService.onHandleIntent
我采纳了此处列出的所有建议: Remediation for Implicit PendingIntent Vulnerability
但错误仍然存在。
我的服务:
public class SyncService extends IntentService {
protected void onHandleIntent(Intent intent) {
...
Intent i = new Intent("com.mypackage.name.REFRESH");
app.sendBroadcast(i);
...
}
}
清单:
<service
android:name=".sync.SyncService"
android:exported="false" >
</service>
服务在许多地方以 3 种方法启动,如下所示: (根据谷歌的建议,我确实添加了 PendingIntent.FLAG_IMMUTABLE)
方法一:
Intent intent = new Intent(this, SyncService.class);
PendingIntent pIntent = PendingIntent.getService(this, 0, intent,
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmMgr = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
alarmMgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtMillis,
SYNC_FREQUENCY, pIntent);
方法二:
Intent intent = new Intent("com.mypackage.name.REFRESH");
intent = new Intent(getApplicationContext(), SyncService.class);
intent.putExtra("notification_unassigned_sync", true);
startService(intent);
方法三:
Intent intent = new Intent(getApplicationContext(), SyncService.class);
startService(intent);
我的代码有什么问题吗?有什么建议吗?
【问题讨论】:
标签: java android android-intent google-play-console android-pendingintent