有些输入法预制到系统中时默认情况下是不能直接使用的,要在设置->语言和键盘中勾选相应输入法,这里提供了一种参考改进,使预制输入法直接可用。
共有两处修改,第一处: 在android2.2中,一些系统定制信息是通过 frameworks/base/package/settingsproviders/res/values/defaults.xml来预设的,在系统首次启动时加载此文件,并应用文件中的设置。文件如下: <?xml version="1.0" encoding="utf-8"?> <!-- /** * Copyright (c) 2009, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ --> <resources> <bool name="def_dim_screen">true</bool> <integer name="def_screen_off_timeout">600000</integer> <bool name="def_airplane_mode_on">false</bool> <!-- Comma-separated list of bluetooth, wifi, and cell. --> <string name="def_airplane_mode_radios" translatable="false">cell,bluetooth,wifi</string> <string name="airplane_mode_toggleable_radios" translatable="false">wifi</string> <bool name="def_auto_time">true</bool> <bool name="def_accelerometer_rotation">true</bool> <!-- Default screen brightness, from 0 to 255. 102 is 40%. --> <integer name="def_screen_brightness">102</integer> <bool name="def_screen_brightness_automatic_mode">false</bool> <fraction name="def_window_animation_scale">0%</fraction> <fraction name="def_window_transition_scale">0%</fraction> <bool name="def_haptic_feedback">true</bool> <bool name="device_provisioned">true</bool> <bool name="def_bluetooth_on">false</bool> <bool name="def_install_non_market_apps">true</bool> <string name="def_enabled_input_methods">com.sohu.inputmethod.sogou/.SogouIME:com.android.inputmethod.pinyin/.PinyinIME</string> <!-- Comma-separated list of location providers. Network location is off by default because it requires user opt-in via Setup Wizard or Settings. --> <string name="def_location_providers_allowed" translatable="false">gps</string> <bool name="assisted_gps_enabled">true</bool> <!-- 0 == mobile, 1 == wifi. --> <integer name="def_network_preference">1</integer> <bool name="def_usb_mass_storage_enabled">true</bool> <bool name="def_wifi_on">false</bool> <bool name="def_networks_available_notification_on">true</bool> <bool name="def_backup_enabled">false</bool> <string name="def_backup_transport" translatable="false">android/com.android.internal.backup.LocalTransport</string><!-- Default value for whether or not to pulse the notification LED when there is a
pending notification --> <bool name="def_notification_pulse">true</bool><bool name="def_mount_play_notification_snd">true</bool>
<bool name="def_mount_ums_autostart">false</bool> <bool name="def_mount_ums_prompt">true</bool> <bool name="def_mount_ums_notify_enabled">true</bool><!-- user interface sound effects -->
<integer name="def_power_sounds_enabled">1</integer> <string name="def_low_battery_sound" translatable="false">/system/media/audio/ui/LowBattery.ogg</string> <integer name="def_dock_sounds_enabled">0</integer> <string name="def_desk_dock_sound" translatable="false">/system/media/audio/ui/Dock.ogg</string> <string name="def_desk_undock_sound" translatable="false">/system/media/audio/ui/Undock.ogg</string> <string name="def_car_dock_sound" translatable="false">/system/media/audio/ui/Dock.ogg</string> <string name="def_car_undock_sound" translatable="false">/system/media/audio/ui/Undock.ogg</string> <integer name="def_lockscreen_sounds_enabled">0</integer> <string name="def_lock_sound" translatable="false">/system/media/audio/ui/Lock.ogg</string> <string name="def_unlock_sound" translatable="false">/system/media/audio/ui/Unlock.ogg</string><!-- Default for Settings.System.VIBRATE_IN_SILENT -->
<bool name="def_vibrate_in_silent">true</bool><string name="def_time_12_24" translatable="false">12</string>
</resources>其中语句<string name="def_enabled_input_methods">com.sohu.inputmethod.sogou/.SogouIME:com.android.inputmethod.pinyin/.PinyinIME</string>
是我们要增加的,表示默认使能google拼音和搜狗拼音,并且这条语句放在最后面的输入法做为系统默认输入法,也就是首选输入法。第二处: 在文件frameworks/base/package/settingsproviders/src/com/android/providers/settings/DatabaseHelper.java的函数
loadSecureSettings()中增加一条语句,制定默认使能的输入法 //added by folksy , for input methods loadStringSetting(stmt, Settings.Secure.ENABLED_INPUT_METHODS, R.string.def_enabled_input_methods); 如: private void loadSecureSettings(SQLiteDatabase db) { SQLiteStatement stmt = null; try { stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" + " VALUES(?,?);");loadBooleanSetting(stmt, Settings.Secure.BLUETOOTH_ON,
R.bool.def_bluetooth_on);// Data roaming default, based on build
loadSetting(stmt, Settings.Secure.DATA_ROAMING, "true".equalsIgnoreCase( SystemProperties.get("ro.com.android.dataroaming", "false")) ? 1 : 0);loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS,
R.bool.def_install_non_market_apps);loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED,
R.string.def_location_providers_allowed);//added by bwu , for input methods
loadStringSetting(stmt, Settings.Secure.ENABLED_INPUT_METHODS, R.string.def_enabled_input_methods);loadBooleanSetting(stmt, Settings.Secure.ASSISTED_GPS_ENABLED,
R.bool.assisted_gps_enabled);loadIntegerSetting(stmt, Settings.Secure.NETWORK_PREFERENCE,
R.integer.def_network_preference);loadBooleanSetting(stmt, Settings.Secure.USB_MASS_STORAGE_ENABLED,
R.bool.def_usb_mass_storage_enabled);loadBooleanSetting(stmt, Settings.Secure.WIFI_ON,
R.bool.def_wifi_on); loadBooleanSetting(stmt, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, R.bool.def_networks_available_notification_on);String wifiWatchList = SystemProperties.get("ro.com.android.wifi-watchlist");
if (!TextUtils.isEmpty(wifiWatchList)) { loadSetting(stmt, Settings.Secure.WIFI_WATCHDOG_WATCH_LIST, wifiWatchList); }// Set the preferred network mode to 0 = Global, CDMA default
int type = SystemProperties.getInt("ro.telephony.default_network", RILConstants.PREFERRED_NETWORK_MODE); loadSetting(stmt, Settings.Secure.PREFERRED_NETWORK_MODE, type);// Enable or disable Cell Broadcast SMS
loadSetting(stmt, Settings.Secure.CDMA_CELL_BROADCAST_SMS, RILConstants.CDMA_CELL_BROADCAST_SMS_DISABLED);// Set the preferred cdma subscription to 0 = Subscription from RUIM, when available
loadSetting(stmt, Settings.Secure.PREFERRED_CDMA_SUBSCRIPTION, RILConstants.PREFERRED_CDMA_SUBSCRIPTION);// Don't do this. The SystemServer will initialize ADB_ENABLED from a
// persistent system property instead. //loadSetting(stmt, Settings.Secure.ADB_ENABLED, 0);// Allow mock locations default, based on build
loadSetting(stmt, Settings.Secure.ALLOW_MOCK_LOCATION, "1".equals(SystemProperties.get("ro.allow.mock.location")) ? 1 : 0);loadSecure35Settings(stmt);
loadBooleanSetting(stmt, Settings.Secure.MOUNT_PLAY_NOTIFICATION_SND,
R.bool.def_mount_play_notification_snd);loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_AUTOSTART,
R.bool.def_mount_ums_autostart);loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_PROMPT,
R.bool.def_mount_ums_prompt);loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_NOTIFY_ENABLED,
R.bool.def_mount_ums_notify_enabled); } finally { if (stmt != null) stmt.close(); } }重新编译即可。
小技巧:修改以上文件,可以重新编译整个system,也可进入frameworks/base/package/settingsproviders/目录下,使用mm命令编译,然后打包system。