Auto Apply Predefined Preferences
Menny Even Danan edited this page Oct 12, 2021
·
1 revision
In uses cases where the keyboard is mass-installed on many devices, there is also a need to preconfigure it to a specific state. This can be done by providing a preferences backup file at a specific path.
- Install the keyboard on a device.
- Set it up as you wish.
- Back up all the preferences using the backup functionality in the Settings app. Note: at this time, only
App Settings
is supported. - Ensure you have
adb
connection to the device. - Pull the backup file from the device to your current working folder as
STARTUP_PREFS_APPLY.xml
:
adb pull /sdcard/Android/data/com.menny.android.anysoftkeyboard/files/AnySoftKeyboardPrefs.xml STARTUP_PREFS_APPLY.xml
This file will be used in the next step.
- Connect a target device to your computer.
- Install AnySoftKeyboard using your preferred method.
- Push the backup file to the target device:
adb push STARTUP_PREFS_APPLY.xml /sdcard/Android/data/com.menny.android.anysoftkeyboard/files/STARTUP_PREFS_APPLY.xml
- Ensure AnySoftKeyboard is not running:
adb shell am kill --user all com.menny.android.anysoftkeyboard
- Give it write permission
adb shell pm grant com.menny.android.anysoftkeyboard android.permission.WRITE_EXTERNAL_STORAGE
At this state, AnySoftKeyboard is ready to apply the backup file on startup. Once the file is applied, it will be renamed to STARTUP_PREFS_APPLIED_[apply-time].xml
.
You may want to follow the process using logcat
:
adb logcat | grep ASK_Cfg_auto_apply_pref
Expect something similar to:
10-12 12:51:43.401 9597 9597 I ASK_Cfg_auto_apply_pref: Applying prefs file '/storage/emulated/0/Android/data/com.menny.android.anysoftkeyboard/files/STARTUP_PREFS_APPLY.xml'...
10-12 12:51:43.401 9597 9597 D ASKApp : Starting prefsAutoRestoreFunction for '/storage/emulated/0/Android/data/com.menny.android.anysoftkeyboard/files/STARTUP_PREFS_APPLY.xml'
10-12 12:51:43.457 9597 9597 D ASK_Cfg : Checking if configuration upgrade is needed.
10-12 12:51:43.457 9597 9597 I ASKApp : Restored prefs for 'App Settings'
10-12 12:51:43.457 9597 9597 I ASK_Cfg_auto_apply_pref: Prefs from file '/storage/emulated/0/Android/data/com.menny.android.anysoftkeyboard/files/STARTUP_PREFS_APPLY.xml' were applied!
10-12 12:51:43.506 9597 9597 I ASK_Cfg_auto_apply_pref: Renaming applied prefs file from '/storage/emulated/0/Android/data/com.menny.android.anysoftkeyboard/files/STARTUP_PREFS_APPLY.xml' to '/storage/emulated/0/Android/data/com.menny.android.anysoftkeyboard/files/STARTUP_PREFS_APPLIED_2021-10-12__12_51_43_EDT.xml'...