Skip to content
praetoriandroidPublic

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

3 watching

Forks

Latest commit

 

History

51 Commits

Folders and files

Repository files navigation

kali

The Customizable Android Transform Gradle Plugin

The initial intent was to wrap WakeLock calls, including those that are in the libraries, to make some behaviour changes. Then we decided to add some more transformations. So, here it is...

What is does?

If you want to replace, for example, all PowerManager.WakeLock.acquire(timeout) calls in your application, including those in any used library, by your own custom static calls like this:

package com.example.kali;

public class FakeLock {
    // ...

    public static void smartAcquire(PowerManager.WakeLock wakeLock, long timeout) {
        if (timeout > MAX_WAKE_LOCK_TIMEOUT) {
            Log.w(TAG, "Long lasting WakeLock: timeout=" + timeout);
            timeout = MAX_WAKE_LOCK_TIMEOUT;
        }
        wakeLock.acquire(timeout);
    }
}

then all you need is to build and deploy this plugin and then add the next lines to your build.gradle file:

buildscript {
    // ...

    dependencies {
        // ...
        classpath 'ru.mail:android-kali:1.0'
    }
}

apply plugin: 'ru.mail.android-kali'

kali {
    replaceCalls {
        ignoreClass 'com.example.kali.FakeLock'
        def wakeLockWrappers = [
                'android.os.PowerManager$WakeLock.acquire(J)V': 'com.example.kali.FakeLock.smartAcquire'
        ]
        replacements wakeLockWrappers
    }
}

acquire(J)V??? V for void return type? But what the J is that!?

Yeah, this is a bit of magic from the heart of Java. See How to describe the types and what is in parentheses and after it. Also note that inner class WakeLock is separated from the parent class by the '$', not by the period.

Ok, what's next?

Well... more transformations, I guess.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages