Package com.unitech.api.keymap
Class KeymappingCtrl
java.lang.Object
com.unitech.api.keymap.KeymappingCtrl
This controller is used to manage the Programmable Key API.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final intstatic final intstatic final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic Intentstatic Integer -
Method Summary
Modifier and TypeMethodDescriptionBundleaddKeyMappings(String keyName, String keyCode, boolean wakeup, String broadcastDownAction, Bundle[] broadcastDownParams, String broadcastUpAction, Bundle[] broadcastUpParams, Bundle[] startActivityParams) Add a key mapping into the Programmable Key listBundleenableKeyMapping(boolean enabled) Enable or disable the Programmable Key serviceBundleexportKeyMappings(String folderPath) Export the settings of the key mappings to the folderBundlegetDefaultKeyCode(String keyName) Get selected keyName default KeyCodeBundlegetDefaultKeyMapping(String keyName) Get the factory default setting of a key (This is essentially the same as the factory default keys_config.txt for a particular key.)static KeymappingCtrlgetInstance(Context context) Get an instance of the KeymappingCtrlBundlegetKeyMapping(String keyName) Get selected keyName mapping valueBundleCheck if the Programmable Key service is enabledBundleGet a list of remappable keys in the deviceBundleimportKeyMappings(String folderPath) Import the settings of the key mappings to the folderBundleresetKeyMapping(String keyName) Reset selected keyName to default settingsBundleReset all of the key mappings from the Programmable Key service
-
Field Details
-
KEY_PROGRAMMABLE_KEYS_SET
- See Also:
-
KEY_PROGRAMMABLE_KEY
- See Also:
-
KEY_PROGRAMMABLE_KEY_NAME
- See Also:
-
KEY_PROGRAMMABLE_KEY_CODE
- See Also:
-
KEY_PROGRAMMABLE_WAKEUP
- See Also:
-
KEY_PROGRAMMABLE_BROADCAST_DOWN
- See Also:
-
KEY_PROGRAMMABLE_BROADCAST_UP
- See Also:
-
KEY_PROGRAMMABLE_DOWN_PARAMS
- See Also:
-
KEY_PROGRAMMABLE_UP_PARAMS
- See Also:
-
KEY_PROGRAMMABLE_PARAMS_KEY
- See Also:
-
KEY_PROGRAMMABLE_PARAMS_VALUE
- See Also:
-
KEY_PROGRAMMABLE_DOWN_KEY
- See Also:
-
KEY_PROGRAMMABLE_UP_KEY
- See Also:
-
KEY_PROGRAMMABLE_DOWN_VALUE
- See Also:
-
KEY_PROGRAMMABLE_UP_VALUE
- See Also:
-
KEY_PROGRAMMABLE_START_ACTIVITY_PARAMS
- See Also:
-
KEY_PROGRAMMABLE_START_ACTIVITY_PARAM
- See Also:
-
KEY_PROGRAMMABLE_START_ACTIVITY_KEY
- See Also:
-
KEY_PROGRAMMABLE_START_ACTIVITY_VALUE
- See Also:
-
KEY_IMPORT_PROGRAMMABLE_KEYS
- See Also:
-
KEY_IMPORT_PROGRAMMABLE_KEYS_ENABLE
- See Also:
-
KEY_IMPORT_PROGRAMMABLE_KEYS_FILE_PATH
- See Also:
-
KEY_EXPORT_PROGRAMMABLE_KEYS
- See Also:
-
KEY_EXPORT_PROGRAMMABLE_KEYS_ENABLE
- See Also:
-
KEY_EXPORT_PROGRAMMABLE_KEYS_FILE_PATH
- See Also:
-
KEY_RESET_PROGRAMMABLE_KEYS
- See Also:
-
TAG_ENABLED
- See Also:
-
TAG_KEY
- See Also:
-
TAG_KEY_NAME
- See Also:
-
TAG_KEY_CODE
- See Also:
-
TAG_WAKEUP
- See Also:
-
TAG_BROADCAST_KEY_DOWN
- See Also:
-
TAG_ACTION
- See Also:
-
TAG_ACTION_PARAMS
- See Also:
-
TAG_PARAM
- See Also:
-
TAG_VALUE
- See Also:
-
TAG_BROADCAST_KEY_UP
- See Also:
-
TAG_START_ACTIVITY_PARAMS
- See Also:
-
BUNDLE_ERROR_CODE
- See Also:
-
BUNDLE_ERROR_MSG
- See Also:
-
REQUEST_CODE_IMPORT
public static final int REQUEST_CODE_IMPORT- See Also:
-
REQUEST_CODE_EXPORT
public static final int REQUEST_CODE_EXPORT- See Also:
-
RESULT_CODE_ERROR
public static final int RESULT_CODE_ERROR- See Also:
-
RESULT_CODE_SUCCESS
public static final int RESULT_CODE_SUCCESS- See Also:
-
INTENT_RESULT_MESSAGE
- See Also:
-
ACTION_KEY_EXPORT
- See Also:
-
ACTION_KEY_IMPORT
- See Also:
-
tmpIntent
public static volatile Intent tmpIntent -
tmpResultCode
-
-
Method Details
-
getInstance
Get an instance of the KeymappingCtrl- Parameters:
context- The context which will use this controller instance- Returns:
- A KeymappingCtrl instance
-
getKeyMappingEnabled
public Bundle getKeyMappingEnabled()Check if the Programmable Key service is enabled- Returns:
- A bundle contains the error code and message
int errorCode = bundle.getInt("errorCode"), (error:1, success=0)
String errorMsg = bundle.getString("errorMsg");
int enabled = bundle.getInt("status");
-
enableKeyMapping
public Bundle enableKeyMapping(boolean enabled) Enable or disable the Programmable Key service- Parameters:
enabled- true: Enable, false: Disable- Returns:
- A bundle contains the error code and message
int errorCode = bundle.getInt("errorCode"), (error:1, success=0)
String errorMsg = bundle.getString("errorMsg");
-
addKeyMappings
public Bundle addKeyMappings(String keyName, String keyCode, boolean wakeup, String broadcastDownAction, Bundle[] broadcastDownParams, String broadcastUpAction, Bundle[] broadcastUpParams, Bundle[] startActivityParams) Add a key mapping into the Programmable Key list- Parameters:
keyName- The key name what you want to remap. e.g. "VOLUME_UP"keyCode- The key code that you want to remap to. e.g. "25" (VOLUME_DOWN) or "com.unitech.keyremap" (target activity)wakeup- Set that pressing the key will wake the screen up or not.broadcastDownAction- Set the broadcast action if you want system to send a broadcast while pressing the key down.broadcastDownParams- Set the broadcast extras if you want system to send a broadcast while pressing the key down.
A bundle contains 2 string extras: "Key" and "Value" (use "," to separate key and value, use ";" to separate pairs)broadcastUpAction- Set the broadcast action if you want system to send a broadcast while releasing the key.broadcastUpParams- Set the broadcast extras if you want system to send a broadcast while releasing the key.
A bundle contains 2 string extras: "Key" and "Value" (use "," to separate key and value, use ";" to separate pairs)startActivityParams- Set the extras of the activity intent if the key code is set to start an activity
A bundle contains 2 string extras: "Key" and "Value" (use "," to separate key and value, use ";" to separate pairs)- Returns:
- A bundle contains the error code and message
int errorCode = bundle.getInt("errorCode"), (error:1, success=0)
String errorMsg = bundle.getString("errorMsg");
-
resetKeyMappings
public Bundle resetKeyMappings()Reset all of the key mappings from the Programmable Key service- Returns:
- A bundle contains the error code and message
int errorCode = bundle.getInt("errorCode"), (error:1, success=0)
String errorMsg = bundle.getString("errorMsg");
-
importKeyMappings
Import the settings of the key mappings to the folder- Parameters:
folderPath- The folder path of settings. e.g. "/sdcard/progkey/"- Returns:
- A bundle contains the error code and message
int errorCode = bundle.getInt("errorCode"), (error:1, success=0)
String errorMsg = bundle.getString("errorMsg");
-
exportKeyMappings
Export the settings of the key mappings to the folder- Parameters:
folderPath- The folder path of settings. e.g. "/sdcard/progkey/"- Returns:
- A bundle contains the error code and message
int errorCode = bundle.getInt("errorCode"), (error:1, success=0)
String errorMsg = bundle.getString("errorMsg");
-
getKeyMapping
Get selected keyName mapping value- Returns:
- A bundle contains the error code and message
int errorCode = bundle.getInt("errorCode"), (error:1, success=0)
String errorMsg=bundle.getString("errorMsg");
Other key set include keyCode, keyName, wakeup, broadcastDown(Up)Action.
broadcastDown(Up)Params, startActivityParams
-
getDefaultKeyCode
Get selected keyName default KeyCode- Returns:
- A bundle contains the error code and message
int errorCode = bundle.getInt("errorCode"), (error:1, success=0)
String errorMsg=bundle.getString("errorMsg");
String DefaultKeyCode = bundle.getString("DefaultKeyCode");
-
resetKeyMapping
Reset selected keyName to default settings- Returns:
- Bundle should include the following values:
"errorCode" - int:
0: Succeed
1: Failed
"errorMsg" - String:
"Error reason"
-
getRemappableKeyList
public Bundle getRemappableKeyList()Get a list of remappable keys in the device- Returns:
- Bundle should include the following values:
"errorCode" - int:
0: Succeed
1: Failed
"errorMsg" - String:
"Error reason" If errorCode is 0, the key list is returned as a number of key/value pairs in the bundle that indicates all the remappable keys available in this device Example: "VOLUME_UP", "24" "VOLUME_DOWN", "25" "RemappableKeyName_1" - String:
"RemappableKeyCode_1" "RemappableKeyName_2" - String:
"RemappableKeyCode_2" "RemappableKeyName_..." - String:
"RemappableKeyCode_..." "RemappableKeyName_N" - String:
"RemappableKeyCode_N"
-
getDefaultKeyMapping
Get the factory default setting of a key (This is essentially the same as the factory default keys_config.txt for a particular key.)- Returns:
- Bundle should include the following values:
"errorCode" - int:
0: Succeed
1: Failed
"errorMsg" - String:
"Error reason" If errorCode is 0, the factory default settings of the given keyname are also listed in the bundle "keyName" - String: The target key name that the user wants to get its mapping. e.g. "VOLUME_UP"
"keyCode" - String: The key behavior that the user wants the target key to be. May be keycode or package name and activity name
e.g. "25" (Remap volume up key to volume down)
"com.example.app/com.example.app.MainActivity" (Start an activity)
"wakeup" - boolean: Whether the key wake up the device or not. e.g. true / false
"broadcastDownAction" - String: The action of the key down broadcast. It will be null if the key down broadcast is disabled.
e.g. "VOLUME_UP.KEYDOWN"
"broadcastDownParams" - Bundle: The extras of the key down broadcast. It will be null if the key down broadcast is disabled.
"broadcastUpAction" - String: The action of the key up broadcast. It will be null if the key up broadcast is disabled.
e.g. "VOLUME_UP.KEYUP"
"broadcastUpParams" - Bundle: The extras of the key up broadcast. It will be null if the key down broadcast is disabled.
"startActivityParams" - Bundle: The extras of the intent for starting an activity.
-