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

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

var intent = Java.use('android.content.Intent');

if (intent.$init) {
    intent.setClassName.overload('java.lang.String', 'java.lang.String').implementation = function( packageName,  className){
        agPacket({intent: dumpIntent(this), packageName: packageName, className: className}).send();
        return this.setClassName(packageName,className);
    }

    intent.putExtra.overload('java.lang.String', '[I').implementation = function(name,  intB){
        agPacket({intent: dumpIntent(this), name: name, intB: intB}).send();
        return this.putExtra(name, intB);
    }

    intent.putExtra.overload('java.lang.String', '[D').implementation = function(name,  doubleD){
        agPacket({intent: dumpIntent(this), name: name, doubleD: doubleD}).send();
        return this.putExtra(name,doubleD);
    }

    intent.putExtra.overload('java.lang.String', '[F').implementation = function(name,  floatF){
        agPacket({intent: dumpIntent(this), name: name, floatF: floatF}).send();
        return this.putExtra(name,floatF);
    }

    intent.putExtra.overload('java.lang.String', '[B').implementation = function(name,  byteB){
        agPacket({intent: dumpIntent(this), name: name, byteB: byteB}).send();
        return this.putExtra(name,byteB);
    }

    intent.putExtra.overload('java.lang.String', '[C').implementation = function(name,  charC){
        agPacket({intent: dumpIntent(this), name: name, charC: charC}).send();
        return this.putExtra(name,charC);
    }

    intent.putExtra.overload('java.lang.String', '[Z').implementation = function(name,  z){
        agPacket({intent: dumpIntent(this), name: name, z: z}).send();
        return this.putExtra(name,z);
    }

    intent.putExtra.overload('java.lang.String', 'boolean').implementation = function(name,  boolvalue){
        agPacket({intent: dumpIntent(this), name: name, boolvalue: boolvalue}).send();
        return this.putExtra(name, boolvalue);
    }


    intent.putExtra.overload('java.lang.String', '[S').implementation = function(name,  stringS){
        agPacket({intent: dumpIntent(this), name: name, stringS: stringS}).send();
        return this.putExtra(name,stringS);
    }

    intent.putExtra.overload('java.lang.String', '[Landroid.os.Parcelable;').implementation = function(name,  parcel){
        agPacket({intent: dumpIntent(this), name: name, parcel: parcel}).send();
        return this.putExtra(name,parcel);
    }

    intent.putExtra.overload('java.lang.String', 'byte').implementation = function(name,  bt){
        agPacket({intent: dumpIntent(this), name: name, bt: bt}).send();
        return this.putExtra(name,bt);
    }

    intent.putExtra.overload('java.lang.String', '[Ljava.lang.CharSequence;').implementation = function(name,  chars){
        agPacket({intent: dumpIntent(this), name: name, chars: chars}).send();
        return this.putExtra(name,chars);
    }

    intent.putExtra.overload('java.lang.String', '[Ljava.lang.String;').implementation = function(name,  data){
        agPacket({intent: dumpIntent(this), name: name, data: data}).send();
        return this.putExtra(name,data);
    }

    intent.putExtra.overload('java.lang.String', 'android.os.Bundle').implementation = function(name,  bundle){
        agPacket({intent: dumpIntent(this), name: name, bundle: bundle}).send();
        return this.putExtra(name,bundle);
    }

    intent.putExtra.overload('java.lang.String', 'int').implementation = function(name,  intA){
        agPacket({intent: dumpIntent(this), name: name, intA: intA}).send();
        return this.putExtra(name,intA);
    }

    intent.putExtra.overload('java.lang.String', 'long').implementation = function(name,  longA){
        agPacket({intent: dumpIntent(this), name: name, longA: longA}).send();
        return this.putExtra(name,longA);
    }

    intent.putExtra.overload('java.lang.String', 'float').implementation = function(name,  floatA){
        agPacket({intent: dumpIntent(this), name: name, floatA: floatA}).send();
        return this.putExtra(name,floatA);
    }

    intent.putExtra.overload('java.lang.String', 'short').implementation = function(name,  shortA){
        agPacket({intent: dumpIntent(this), name: name, shortA: shortA}).send();
        return this.putExtra(name,shortA);
    }

    intent.putExtra.overload('java.lang.String', 'char').implementation = function(name,  charA){
        agPacket({intent: dumpIntent(this), name: name, charA: charA}).send();
        return this.putExtra(name,charA);

    }
    intent.putExtra.overload('java.lang.String', 'double').implementation = function(name,  doubleA){
        agPacket({intent: dumpIntent(this), name: name, doubleA: doubleA}).send();
        return this.putExtra(name,doubleA);
    }

    intent.putExtra.overload('java.lang.String', 'java.lang.String').implementation = function(name,  stringA){
        agPacket({intent: dumpIntent(this), name: name, stringA: stringA}).send();
        return this.putExtra(name,stringA);
    }

    intent.putExtra.overload('java.lang.String', 'java.lang.CharSequence').implementation = function(name,  CharSequence)
    {
        charsJoin = CharSequence.join("");
        agPacket({intent: dumpIntent(this), name: name, charsJoin: charsJoin}).send();
        return this.putExtra(name, CharSequence);
    }

    intent.putExtra.overload('java.lang.String', 'java.io.Serializable').implementation = function(name,  serializable){
        agPacket({intent: dumpIntent(this), name: name, serializable: serializable}).send();
        return this.putExtra(name,serializable);
    }

    intent.putExtra.overload('java.lang.String', 'android.os.Parcelable').implementation = function(name,  parcelable) {
        agPacket({intent: dumpIntent(this), name: name, parcelable: parcelable}).send();
        return this.putExtra(name,parcelable);
    }

    intent.putExtra.overload('java.lang.String', 'android.os.IBinder').implementation = function(name,  binder){
        agPacket({intent: dumpIntent(this), name: name, binder: binder}).send();
        return this.putExtra(name,binder);
    }
}