Class KeymappingCtrl

java.lang.Object
com.unitech.api.keymap.KeymappingCtrl

public class KeymappingCtrl extends Object
This controller is used to manage the Programmable Key API.
  • Field Details

  • Method Details

    • getInstance

      public static KeymappingCtrl getInstance(Context context)
      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

      public Bundle importKeyMappings(String folderPath)
      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

      public Bundle exportKeyMappings(String folderPath)
      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

      public Bundle getKeyMapping(String keyName)
      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

      public Bundle getDefaultKeyCode(String keyName)
      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

      public Bundle resetKeyMapping(String keyName)
      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

      public Bundle getDefaultKeyMapping(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.)
      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.