disabling the android lock screen & welcome message

I build android systems from source often enough these days.; usually to test some new feature or the other. One of the first things one can do with a new android system is tap the ‘OK’ button on the “Welcome to android” tutorial that comes up. After doing this for the umpteenth time, I had enough! And that silly lock screen too! There had to be a way to statically disable these annoyances in source code, and I was going to find it!

Fortunately, it wasn’t as difficult as I thought it would be.

Disabling the Lock Screen

This turned out to be a rather simple affair. The lock-screen is a part of the android “frameworks/base” project and is implemented in what is called “keyguard”. Just search for a file called “KeyguardViewMediator.java”. You are looking for a function called “doKeyguardLocked()”. Here is a snippet of the relevant section,

/**
 * Enable the keyguard if the settings are appropriate.
 */
private void doKeyguardLocked(Bundle options) {
    ...
    if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen");
        showLocked(options);
}

See that last function call to showLocked() ? Just comment it out like so,

/**
 * Enable the keyguard if the settings are appropriate.
 */
private void doKeyguardLocked(Bundle options) {
    ...
    if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen");
        // showLocked(options);
}

and after a recompile, the lockscreen will be no-more! 🙂

Banishing the welcome message

This is a bit trickier. My understanding of software tells me that since the welcome message pops up only during the first boot of a new android system, there must be some variable/flag that gets set to tell the system NOT to show the message again. Which means that if I could statically set this flag, I will have achieved my goal. Sadly, that isn’t quite the case. With my limited understanding of the android innards, I haven’t been able to figure out how android manages its settings. Fortunately, I found something else instead.

Turns out that the welcome message is an annoyance for those unit-testing android too. To accommodate those scenarios, there is a special mode called ‘test harness’. Basically, its a mode of android where the tutorial-like messages are disabled, making it easier to put the system in an automated build system. I decided to make use of this feature by permanately ‘enabling’ the test harness mode.

Again, we turn to the “frameworks/base” project. You are looking for a file called “ActivityManager.java”. Do the following ‘fix’,

/**
 * Returns "true" if device is running in a test harness.
 */
public static boolean isRunningInTestHarness() {     
    // return SystemProperties.getBoolean("ro.test_harness", false);
    return true;
}

Rather cheesy, isn’t it? But it works – the “Welcome to android” message is no more!

Advertisements