C#經由過程反射創立自界說泛型。本站提示廣大學習愛好者:(C#經由過程反射創立自界說泛型)文章只能為提供參考,不一定能成為您想要的結果。以下是C#經由過程反射創立自界說泛型正文
在停止Android體系開辟的時刻,有些特定的情形須要設置體系永不鎖屏,永不休眠。本篇文章給年夜家引見Android 永不鎖屏,開機不鎖屏,刪除設置中休眠時光選項,須要的同伙一路進修吧。
Android 6.0.1
Create:2016-02-29
1.Settings 刪失落屏幕待機選項
packages/apps/Settings/res/xml/display_settings.xml <!-- Hide screen sleep <ListPreference android:key="screen_timeout" android:title="@string/screen_timeout" android:summary="@string/screen_timeout_summary" android:persistent="false" android:entries="@array/screen_timeout_entries" android:entryValues="@array/screen_timeout_values" /> -->
正文失落這個ListPreference
packages/apps/Settings/src/com/android/settings/DisplaySettings.java
添加if前提,假如沒有找到這個preference就不履行相干操作;詳細可以參考被隱蔽的 night_mode
mScreenTimeoutPreference = (ListPreference) findPreference(KEY_SCREEN_TIMEOUT); if (mScreenTimeoutPreference !=null ) { final long currentTimeout = Settings.System.getLong(resolver, SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE); mScreenTimeoutPreference.setValue(String.valueOf(currentTimeout)); mScreenTimeoutPreference.setOnPreferenceChangeListener(this); disableUnusableTimeouts(mScreenTimeoutPreference); updateTimeoutPreferenceDescription(currentTimeout); }
2.制止鎖屏
frameworks/base/packages/SettingsProvider/res/values/defaults.xml <bool name="def_lockscreen_disabled">false</bool> 改成 true;即默許制止鎖屏 frameworks/base/core/res/res/values/config.xml <integer name="config_multiuserMaximumUsers">1</integer> 不許可多用戶;即最年夜用戶數為1
分離編譯frameworks/base/packages/SettingsProvider 與 frameworks/base
編譯後push 到 system/priv-app/SettingsProvider/SettingsProvider.apk system/framework/framework.jar
刪去機械中對應的oat目次。重啟或恢復出廠設置。第一次開機時,會先湧現status bar,launcher要等一會才出來。
以後重啟便可以直接進入launcher。機械會默許不鎖屏。但照樣會進入sleep狀況。
源碼流程:
frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java if (upgradeVersion == 54)// 版本為54才會設置timeout ...... private void upgradeScreenTimeoutFromNever(SQLiteDatabase db) { // See if the timeout is -1 (for "Never"). Cursor c = db.query(TABLE_SYSTEM, new String[] { "_id", "value" }, "name=? AND value=?", new String[] { Settings.System.SCREEN_OFF_TIMEOUT, "-1" }, null, null, null); SQLiteStatement stmt = null; if (c.getCount() > 0) { c.close(); try { stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)" + " VALUES(?,?);"); // Set the timeout to 30 minutes in milliseconds loadSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, Integer.toString(30 * 60 * 1000)); } finally { if (stmt != null) stmt.close(); } } else { c.close(); } } ...... if (SystemProperties.getBoolean("ro.lockscreen.disable.default", false) == true) { loadSetting(stmt, Settings.System.LOCKSCREEN_DISABLED, "1"); } else { loadBooleanSetting(stmt, Settings.System.LOCKSCREEN_DISABLED, R.bool.def_lockscreen_disabled); }
timeout若是-1,則永不鎖屏
讀取"ro.lockscreen.disable.default",假如默許為true,則設置制止鎖屏;不然從xml中讀設置裝備擺設
frameworks/base/packages/SettingsProvider/res/values/defaults.xml <integer name="def_screen_off_timeout">60000</integer> <bool name="def_lockscreen_disabled">false</bool>`
制止鎖屏默許為false
以上內容是小編給年夜家引見的設置Android體系永不鎖屏永不休眠的辦法,願望對年夜家有所贊助。