Enable screen lock and HOME key (eclair and older versions)(转)

from: http://rootfs.wordpress.com/2010/07/23/android-enable-home-screen-lock-and-home-key/

 

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

1. frameworks/base/policies/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/base/policies/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.

posted @ 2012-06-11 22:28  心随灵动  阅读(846)  评论(0编辑  收藏  举报