Smile2Life
Smile2Life

Reputation: 1921

Your app contains an Implicit Internal Intent vulnerability

Google rejecting my app and i'm having trouble with this security error that appear when i submit app as production release:

Implicit Internal Intent

Your app contains an Implicit Internal Intent vulnerability. Please see this Google Help Center article for details.

com.mypackage.name.sync.SyncService.onHandleIntent

I applied all recommendations listed here: Remediation for Implicit PendingIntent Vulnerability

But the error still persists.

My service:

public class SyncService extends IntentService {
    protected void onHandleIntent(Intent intent) {
... 
 Intent i = new Intent("com.mypackage.name.REFRESH");
 app.sendBroadcast(i);
...
   }
 }

Manifest:

<service
    android:name=".sync.SyncService"
    android:exported="false" >
</service>

The service started in many places in 3 methods like this: (As recommended by google i did add PendingIntent.FLAG_IMMUTABLE)

Method 1:

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);

Method 2:

Intent intent = new Intent("com.mypackage.name.REFRESH");
intent = new Intent(getApplicationContext(), SyncService.class);
intent.putExtra("notification_unassigned_sync", true);
startService(intent);

Method 3:

Intent intent = new Intent(getApplicationContext(), SyncService.class);
startService(intent);

Is there anything wrong in my code ? Any recommendations ?

Upvotes: 2

Views: 2130

Answers (2)

Sambhav Khandelwal
Sambhav Khandelwal

Reputation: 3765

How to implement broadcast receiver?

  1. Create a java class named MyBroadcastReceiver.java.

  2. Paste this code in the class

    public class MyBroadcastReceiverextends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            Toast.makeText(context,"I have received.",Toast.LENGHT_SHORT).show();
        }
    }
    
  3. Once you have implemented this code, you need to add this to you manifest inside the application tag.

    <receiver android:name="com.chatverse.free.TimeBroadcastReceiver"
         android:exported="true">
         <intent-filter>
             <action android:name="com.mypackage.name.REFRESH"/> 
         </intent-filter>
    </receiver>
    
  4. Add this code to your activity which opens the first.

    IntentFilter mFilter = new IntentFilter("com.mypackage.name.REFRESH");
    registerReceiver(new MyBroadcastReceiver(), mFilter);
    

Upvotes: 0

Crispert
Crispert

Reputation: 1167

Setting the package name for the intents should fix the issue

intent.setPackage("com.mypackage.name"); // replace with your package name 
                                         // from AndroidManifest.xml

Upvotes: 1

Related Questions