私のC2DM(古い)メッセージング用のブロードキャストレシーバーがあります
<receiver android:name=".C2DMRegistrationReceiver">
<!-- Receive the actual message -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.test" />
</intent-filter>
<!-- Receive the registration id -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.test" />
</intent-filter>
<intent-filter>
<action android:name="REGISTRY_RETRY" />
<category android:name="com.test" />
</intent-filter>
</receiver>
セキュリティ上の理由から、この受信者の許可を次のように宣言する必要があります
<receiver android:name=".C2DMRegistrationReceiver" permission="com.google.android.c2dm.permission.SEND">
ここでの私の問題は、com.google.android.c2dm.permission.SEND パーミッションを強制しているため、3. インテント フィルターが通話を受信しないことです。
私の質問: 1 つのブロードキャスト レシーバーに対して 2 つのアクセス許可を定義する方法はありますか、それとも onReceive コード内で発信者にアクセス許可を適用できますか?
私は試した
private boolean checkC2DMPermission(Context context) {
String permission = "com.google.android.c2dm.permission.SEND";
context.enforceCallingPermission(permission, "Keine C2DM Permission");
return true;
}
context.checkCallingPermission(permission)
また、C2DM Register Intent の -1 をテスト しました。Enforce で SecurityException が発生しました。