// Ripped from https://github.com/Ch0pin/medusa/ and modified to fit Androguard packets

colorLog('[+] LOADING INTENTS/PENDING_INTENTS.JS',{c: Color.Red});

var pendingIntent = Java.use('android.app.PendingIntent');

pendingIntent.getActivity.overloads[0].implementation = function(context, requestCode, intent, flags){
    agPacket({intent: dumpIntent(intent), requestCode: requestCode, flags: flags}).send();
    return this.getActivity(context, requestCode, intent, flags);    
}

pendingIntent.getActivity.overloads[1].implementation = function(context, requestCode, intent, flags, bundle){
    agPacket({intent: dumpIntent(intent), requestCode: requestCode, flags: flags, bundle: bundle}).send();
    return this.getActivity(context, requestCode, intent, flags, bundle); 
}

pendingIntent.getBroadcast.implementation = function(context, requestCode, intent, flags){
    agPacket({intent: dumpIntent(intent), requestCode: requestCode, flags: flags}).send();
    return this.getBroadcast(context, requestCode, intent, flags); 
}

pendingIntent.getService.implementation = function(context, requestCode, intent, flags){
    agPacket({intent: dumpIntent(intent), requestCode: requestCode, flags: flags}).send();
    return this.getService(context, requestCode, intent, flags); 
}

pendingIntent.getActivities.overloads[0].implementation = function(context, requestCode, intent, flags) {
    for (let value of intent)
        agPacket({intent: dumpIntent(value), requestCode: requestCode, flags: flags}).send();
    return this.getService(context, requestCode, intent, flags); 
}

pendingIntent.getActivities.overloads[1].implementation = function(context, requestCode, intent, flags,bundle){
    for (let value of intent)
        agPacket({intent: dumpIntent(value), requestCode: requestCode, flags: flags}).send();
    return this.getService(context, requestCode, intent, flags,bundle); 
}
