A question focused on Android 4.0.x is desirable.
I want to immediately or after a few seconds detect any change made Lock SIM cardto Settings > Security > Set up SIM card lock.
I tried 3 methods:
1) read-only access to general settings com.android.settings.
Context settings = getApplicationContext().createPackageContext("com.android.settings", Context.CONTEXT_IGNORE_SECURITY);
SharedPreferences prefSettings = settings.getSharedPreferences("com.android.settings_preferences", MODE_WORLD_READABLE);
Map<String, ?> allSettings = prefSettings.getAll();
for(String s : allSettings.keySet()){
}
There is a warning in logcat: "Try to read the settings file /data/data/com.android.settings/shared_prefs/com.android.settings_preferences.xml without permission." Card returned getAll()is empty.
2) ITelephony.isSimPinEnabled() false, PIN- SIM- . , , . , .
3) ContentObserver Settings.Secure . , settings.db sqlite , . :
try {
int lockPattern = android.provider.Settings.Secure.getInt(getContentResolver(), android.provider.Settings.Secure.LOCK_PATTERN_ENABLED);
} catch (SettingNotFoundException e) {
e.printStackTrace();
}
, , , SIM PIN enabled com.android.settings preferences.xml, :
$adb shell cat /data/data/com.android.settings/shared_prefs/com.android.settings_preferences.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<boolean name="sim_toggle" value="true" />
<string name="sim_pin"></string>
</map>
, , - sim_toggle.
- ? ?