Main Class Specification

Substrate extensions are simply classes that will be loaded immediately after the Java VM is initialized, allowing an opportunity to use other Substrate APIs.

Once loaded into a new blessed classloader, they will have a static method named initialize (that takes no arguments and returns void).

These classes are deployed as part of normal Android package files and the name of the class is specified using a named meta-data element in the manifest file as part of your application.

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application>
        <meta-data android:name="com.saurik.substrate.main"
            android:value=".Main"/>
    </application>
</manifest>

Substrate Permission

Android has a fine-grained permissions model that allows us to verify that Substrate extensions are only registered by packages that the user trusts enough to have the far-reaching power to make arbitrary modifications to other packages or the system itself.

Substrate manages this by registering its own permission, cydia.permission.SUBSTRATE, which packages must request in their manifest files with the uses-permission tag.

<permission android:name="cydia.permission.SUBSTRATE"
    android:label="modify code from other packages"
    android:protectionLevel="dangerous"
    android:permissionGroup="android.permission-group.DEVELOPMENT_TOOLS"
/>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="cydia.permission.SUBSTRATE"/>
</manifest>