Android 禁止屏幕休眠和锁屏的方法(2)

我们知道Android系统的锁屏时间存放在Setting数据库中,字段为Settings.System.SCREEN_OFF_TIMEOUT。我们可以查看SettingsProvider源码,查看如下文件的源码如下:

~/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java   查看loadSystemSettings()函数的代码如下

private void loadSystemSettings(SQLiteDatabase db) {           SQLiteStatement stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"                   + " VALUES(?,?);");           Resources r = mContext.getResources();           loadBooleanSetting(stmt, Settings.System.DIM_SCREEN,                   R.bool.def_dim_screen);           loadSetting(stmt, Settings.System.STAY_ON_WHILE_PLUGGED_IN,                   "1".equals(SystemProperties.get("ro.kernel.qemu")) ? 1 : 0);           loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,                   R.integer.def_screen_off_timeout);           // Set default cdma emergency tone            loadSetting(stmt, Settings.System.EMERGENCY_TONE, 0);           // Set default cdma call auto retry            loadSetting(stmt, Settings.System.CALL_AUTO_RETRY, 0);           // Set default cdma DTMF type            loadSetting(stmt, Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, 0);           // Set default hearing aid            loadSetting(stmt, Settings.System.HEARING_AID, 0);           // Set default tty mode            loadSetting(stmt, Settings.System.TTY_MODE, 0);           loadBooleanSetting(stmt, Settings.System.AIRPLANE_MODE_ON,                   R.bool.def_airplane_mode_on);           loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_RADIOS,                   R.string.def_airplane_mode_radios);           loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS,                   R.string.airplane_mode_toggleable_radios);           loadBooleanSetting(stmt, Settings.System.AUTO_TIME,                   R.bool.def_auto_time); // Sync time to NITZ            loadIntegerSetting(stmt, Settings.System.SCREEN_BRIGHTNESS,                   R.integer.def_screen_brightness);           loadBooleanSetting(stmt, Settings.System.SCREEN_BRIGHTNESS_MODE,                   R.bool.def_screen_brightness_automatic_mode);           loadDefaultAnimationSettings(stmt);           loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION,                   R.bool.def_accelerometer_rotation);           loadDefaultHapticSettings(stmt);           stmt.close();       }  

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwygjd.html