[Android] Enable screen lock and HOME key (eclair and older versions)

The lock pattern does not take effect after setting. And the HOME key does not work.

1. frameworks/policies/base/phone/com/android/internal/policy/impl/KeyguardViewMediator.java.

In private void doKeyguard() routine:

final boolean provisioned = mUpdateMonitor.isDeviceProvisioned();

if (!lockedOrMissing && !provisioned) {
if (DEBUG) Log.d(TAG, “doKeyguard: not showing because device isn’t provisioned”
+ ” and the sim is not locked or missing”);
return;
}

2.  frameworks/policies/base/phone/com/android/internal/policy/impl/KeyguardUpdateMonitor.java.

public boolean isDeviceProvisioned() {
return mDeviceProvisioned;
}

In public KeyguardUpdateMonitor(Context context) routine:

mDeviceProvisioned = Settings.Secure.getInt(
mContext.getContentResolver(), Settings.Secure.DEVICE_PROVISIONED, 0) != 0;

3. frameworks/base/core/java/android/provider/Settings.java

public static final String DEVICE_PROVISIONED = Secure.DEVICE_PROVISIONED;

The default value for device_provisioned is 0, need set it to 1.

Fix 1: (Modify the database)

$ adb shell

$ cd data/data/com.android.providers.settings/databases

$ sqlite3 settings.db

sqlite> .tables

sqlite>  select * from secure;

sqlite>  INSERT INTO secure (name, value) VALUES (‘device_provisioned’, 1);

sqlite>  .exit

$

Reboot the phone, lock screen shows up. Note that this modification also enables the HOME and some other key functions.

Fix 2: (Need to rebuild the image)

1. Modify packages/apps/Launcher/src/com/android/launcher/Launcher.java as follows:

1): Add “import android.provider.Settings;” to the header.

2): Add below line to somewhere of the OnCreate() routine:

Settings.Secure.putInt(getContentResolver(), Settings.Secure.DEVICE_PROVISIONED, 1);

2. Add write permission in packages/apps/Launcher/Androidmenifest .xml:

<!– <uses-permission android:name=”android.permission.WRITE_SETTINGS” /> Already exist –>
<uses-permission android:name=”android.permission.WRITE_SECURE_SETTINGS” />

Rebuild the image. The lock pattern and HOME key function would work now.

 

Note: Since Android 2.2 (froyo), a default Provision package has been added to the system image. So the issue has gone.

 

3 Responses to “[Android] Enable screen lock and HOME key (eclair and older versions)”

  1. voice Says:

    Hello, thank you for your information, but I do as you told, the home key still does not work and the Launcher does not work any more, any other suggestion? Thank you very much!

    • rootfs Says:

      Hi voice,

      Which way are you trying, and which Android release are you using? The Fix 1 must work on the eclair release. I used it on my emulator every time.

      Best regards,
      Ming

  2. voice Says:

    Hi,
    Thank you very much!
    I try this on Android-2.1_r2 version. It will show the home screen at first time, but reboot this system, the home screen won’t launch, it need to press menu button to launch the home screen.
    Any suggestion?

Leave a comment