[Galaxy S I9000 Android Development] RyanZA:
LagFix APK Framework

Here is a quickly put together APK framework for running these lagfixes from inside an APK. It has a pretty decent UI (although needs some prettying up), and has a nice method for specifying options.

Here is how you use the framework to run a 'busybox df -h' under superuser, along with some demo features. It can be found in com.rc.QuickFixLagFix.LagFixes.TestLagFix.java

package com.rc.QuickFixLagFix.LagFixes;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.rc.QuickFixLagFix.LagFixOptions.LagFixCheckOption;
import com.rc.QuickFixLagFix.LagFixOptions.LagFixChoiceOption;
import com.rc.QuickFixLagFix.LagFixOptions.LagFixOption;
import com.rc.QuickFixLagFix.lib.LagFix;
import com.rc.QuickFixLagFix.lib.ShellCommand;
import com.rc.QuickFixLagFix.lib.ShellCommand.CommandResult;

public class TestLagFix extends LagFix {

String Status = "Currently doing nothing.";

@Override
public String GetDisplayName() {
return "Test Lag Fix";
}

@Override
public String GetShortDescription() {
return "This lag fix tests if lag fixes can be tested";
}

@Override
public String GetLongDescription() {
return "If lag fixes could be tested, this lag fix could test testable fixes which are for fixing lags. If this test lag fix does not work, then real lag fixes, imaginary lag fixes, and lag fixes consisting of the number 3 could not be tested.";
}

@Override
public List<LagFixOption> GetOptions() {
List<LagFixOption> lagFixOptionList = new ArrayList<LagFixOption>();

lagFixOptionList.add(new LagFixCheckOption("test1", "Test 1", "First Test Option", true));
lagFixOptionList.add(new LagFixChoiceOption("test3", "Test 3", "Third Test Option",
new String[]{"Bla1", "Bla2", "Bla52"}));
lagFixOptionList.add(new LagFixCheckOption("test2", "Test 2", "Second Test Option", false));

return lagFixOptionList;
}

@Override
public String Run(Map<String, String> options) throws Exception, Error {
UpdateStatus("Initializing the test lag fix by doing nothing!");
Thread.sleep(2000);
if (options.get("test1").equals(LagFixCheckOption.NOT_CHECKED)) {
return "Option 'Test 1' not checked! Failed!";
}
UpdateStatus("Running the test lag fix!");

ShellCommand cmd = new ShellCommand();
CommandResult r = cmd.su.runWaitFor("id");

if (!r.success()) {
return r.stderr;
} else {
UpdateStatus("Got SuperUser");
}

r = cmd.su.runWaitFor("busybox df -h");
UpdateStatus(r.stdout);

return SUCCESS;
}

@Override
public String IsEnabled() throws Exception, Error {
Thread.sleep(2000);
if (Math.random() < 0.005) {
return "Due to lack of luck, this lagfix is disabled.";
}
return ENABLED;
}

}

Fairly straight forward, and has full support for checking if the device can actually run the fix, as well as running in it's own background thread, and a nice scrolling logview of the output, etc.

TODO:

Add in a nice easy way to do boot loop support.

Anyway, here it is for anybody who wants to play around with it. Out of the box, it will only be able to run df -h, a command to see free space. Semi-useful for that alone. ;)

EDIT:

To make your own fix, copy TestLagFix.java and give it a new name.

Inside com.rc.QuickFixLagFix.lib.LagFixWorker, near the top there is a line: WorkerInstance.RegisterLagFix(new TestLagFix());

Add a line after that one: WorkerInstance.RegisterLagFix(new MyNewLagFix());

Then just edit your new .java file, and start up and app and it should be good to go. :)