[Android Apps and Games] Cyb3rGlitch:
Lux Low-Level Plug-ins

Soon Lux will support plug-ins to bypass Android API limitations. These plug-ins serve to replace the overlay system Lux uses to make adjustments for Night/Astronomer modes and brightness in general. The plug-in library is free to use for non-commercial development, and can be found here:

Lux Plug-in Library | Nexus 4 Sample Plug-in Code​

How to make a plug-in

There are two approaches to making a plug-in for Lux. The passive and the active method. The former is as easy as providing a set of superuser commands for Lux to interpret and apply. These command correlate to functions such as setting pixel RGB or brightness levels. This is the type of plug-in the Nexus 4 sample linked above takes.

The active method requires you produce your own code to perform RGB/brightness adjustments. This might include importing a device specific library to do the heavy lifting, and then returning empty superuser commands back to Lux.

Getting Started

Simply import the Lux Plug-in Library source into your IDE as an Android Library Project, and then create a new Android app which extends PassiveDisplay.java.

PassiveDisplay provides hooks into Lux's plug-in framework, which you can use to provide superuser commands for Lux to execute. These commands correlate to functions such as setting RGB values. Take a look at the sample Nexus 4 project to see how it's all done.

Finally, in your new project's AndroidManifest.xml file, add the following:

<activity
android:name="com.vitocassisi.lux.plugin.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<receiver
android:name="com.vitocassisi.lux.plugin.LuxBroadcastReceiver"
android:exported="true" >
<intent-filter>
<action android:name="com.vitocassisi.lux.plugin.search" />
</intent-filter>
</receiver>

<service
android:name=".[B]MY_PLUGIN[/B]"
android:exported="true" >
<intent-filter>
<action android:name="[B]YOUR_PACKAGE_NAME_HERE[/B]" />
</intent-filter>
</service>

Be sure to replace YOUR_PACKAGE_NAME_HERE with the name of your plug-in's package, and MY_PLUGIN with your extended PassiveDisplay class.

And that's it! Now you're ready to test!

Enabling Plug-In support within Lux

To enable plug-in support, you must check 'Enable plug-in support' in the Advanced section of Lux settings. Enabling this option forfeits all responsibility of mine for any issues caused while using Lux. Plug-in's can cause very real damage to your device if they're written incorrectly - don't use plug-ins from sources you don't trust!

Testing your plug-in

Testing is critical for creating a good plug-in. You are dealing directly with system files, and can easily cause damage if you do not know what you're doing.

DO NOT RELEASE A PLUG-IN WITHOUT TESTING IT ON THE TARGET DEVICE FIRST!

Ensure that the following work with your plug-in installed:

Astronomer Mode

Night Mode

General brightness adjustment

Lux readings functional

BE METICULOUS WITH YOUR IMPLEMENTATION OF isSupportedDevice()!

Modifying system files on the wrong model/kernel may cause irreversible issues!

Licence

Copyright © 2013 Vito Cassisi

You may not use this library except in compliance with the following:
- It cannot be used for commercial purposes under any circumstances, unless explicit permission is granted in writing from the author.
- Modifications to this library may not be distributed.

Unless required by applicable law or agreed to in writing, software
distributed under this licence is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.