Loading core/res/res/values/config.xml +6 −0 Original line number Original line Diff line number Diff line Loading @@ -792,4 +792,10 @@ <!-- True if the Sym key should open the InputMethodPicker (default) --> <!-- True if the Sym key should open the InputMethodPicker (default) --> <bool name="config_symKeyShowsImePicker">true</bool> <bool name="config_symKeyShowsImePicker">true</bool> <!-- Path to the library that contains the device key handler --> <string name="config_deviceKeyHandlerLib"></string> <!-- Name of the device key handler --> <string name="config_deviceKeyHandlerClass"></string> </resources> </resources> policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +45 −0 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentResolver; import android.content.Context; import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.ServiceConnection; Loading Loading @@ -65,6 +66,8 @@ import com.android.internal.telephony.ITelephony; import com.android.internal.view.BaseInputHandler; import com.android.internal.view.BaseInputHandler; import com.android.internal.widget.PointerLocationView; import com.android.internal.widget.PointerLocationView; import dalvik.system.DexClassLoader; import android.util.DisplayMetrics; import android.util.DisplayMetrics; import android.util.EventLog; import android.util.EventLog; import android.util.Log; import android.util.Log; Loading Loading @@ -143,6 +146,9 @@ import java.io.FileDescriptor; import java.io.FileReader; import java.io.FileReader; import java.io.IOException; import java.io.IOException; import java.io.PrintWriter; import java.io.PrintWriter; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; import java.util.List; Loading Loading @@ -255,6 +261,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); } } Object mDeviceKeyHandler = null; Method mDeviceKeyHandlerMethod = null; /** /** * Lock protecting internal state. Must not call out into window * Lock protecting internal state. Must not call out into window * manager with lock held. (This lock will be acquired in places * manager with lock held. (This lock will be acquired in places Loading Loading @@ -930,6 +939,32 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else { } else { screenTurnedOff(WindowManagerPolicy.OFF_BECAUSE_OF_USER); screenTurnedOff(WindowManagerPolicy.OFF_BECAUSE_OF_USER); } } String deviceKeyHandlerLib = mContext.getResources().getString( com.android.internal.R.string.config_deviceKeyHandlerLib); String deviceKeyHandlerClass = mContext.getResources().getString( com.android.internal.R.string.config_deviceKeyHandlerClass); if (!deviceKeyHandlerLib.equals("") && !deviceKeyHandlerClass.equals("")) { DexClassLoader loader = new DexClassLoader(deviceKeyHandlerLib, new ContextWrapper(mContext).getCacheDir().getAbsolutePath(), null, ClassLoader.getSystemClassLoader()); try { Class<?> klass = loader.loadClass(deviceKeyHandlerClass); Constructor<?> constructor = klass.getConstructor(Context.class); mDeviceKeyHandler = constructor.newInstance(mContext); mDeviceKeyHandlerMethod = klass.getDeclaredMethod( "handleKeyEvent", KeyEvent.class); Log.d(TAG, "Loaded device key handler"); } catch (Exception e) { Slog.d(TAG, "Could not get device key Handler " + deviceKeyHandlerClass + " from class " + deviceKeyHandlerLib, e); } } } } public void setInitialDisplaySize(int width, int height) { public void setInitialDisplaySize(int width, int height) { Loading Loading @@ -1828,6 +1863,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH); showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH); } } if (mDeviceKeyHandler != null && mDeviceKeyHandlerMethod != null) { try { Integer ret = (Integer) mDeviceKeyHandlerMethod.invoke( mDeviceKeyHandler, event); return ret; } catch (Exception e) { Slog.d(TAG, "Could not invoke device key handler", e); } } // Let the application handle the key. // Let the application handle the key. return 0; return 0; } } Loading Loading
core/res/res/values/config.xml +6 −0 Original line number Original line Diff line number Diff line Loading @@ -792,4 +792,10 @@ <!-- True if the Sym key should open the InputMethodPicker (default) --> <!-- True if the Sym key should open the InputMethodPicker (default) --> <bool name="config_symKeyShowsImePicker">true</bool> <bool name="config_symKeyShowsImePicker">true</bool> <!-- Path to the library that contains the device key handler --> <string name="config_deviceKeyHandlerLib"></string> <!-- Name of the device key handler --> <string name="config_deviceKeyHandlerClass"></string> </resources> </resources>
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +45 −0 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentResolver; import android.content.Context; import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.ServiceConnection; Loading Loading @@ -65,6 +66,8 @@ import com.android.internal.telephony.ITelephony; import com.android.internal.view.BaseInputHandler; import com.android.internal.view.BaseInputHandler; import com.android.internal.widget.PointerLocationView; import com.android.internal.widget.PointerLocationView; import dalvik.system.DexClassLoader; import android.util.DisplayMetrics; import android.util.DisplayMetrics; import android.util.EventLog; import android.util.EventLog; import android.util.Log; import android.util.Log; Loading Loading @@ -143,6 +146,9 @@ import java.io.FileDescriptor; import java.io.FileReader; import java.io.FileReader; import java.io.IOException; import java.io.IOException; import java.io.PrintWriter; import java.io.PrintWriter; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; import java.util.List; Loading Loading @@ -255,6 +261,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); } } Object mDeviceKeyHandler = null; Method mDeviceKeyHandlerMethod = null; /** /** * Lock protecting internal state. Must not call out into window * Lock protecting internal state. Must not call out into window * manager with lock held. (This lock will be acquired in places * manager with lock held. (This lock will be acquired in places Loading Loading @@ -930,6 +939,32 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else { } else { screenTurnedOff(WindowManagerPolicy.OFF_BECAUSE_OF_USER); screenTurnedOff(WindowManagerPolicy.OFF_BECAUSE_OF_USER); } } String deviceKeyHandlerLib = mContext.getResources().getString( com.android.internal.R.string.config_deviceKeyHandlerLib); String deviceKeyHandlerClass = mContext.getResources().getString( com.android.internal.R.string.config_deviceKeyHandlerClass); if (!deviceKeyHandlerLib.equals("") && !deviceKeyHandlerClass.equals("")) { DexClassLoader loader = new DexClassLoader(deviceKeyHandlerLib, new ContextWrapper(mContext).getCacheDir().getAbsolutePath(), null, ClassLoader.getSystemClassLoader()); try { Class<?> klass = loader.loadClass(deviceKeyHandlerClass); Constructor<?> constructor = klass.getConstructor(Context.class); mDeviceKeyHandler = constructor.newInstance(mContext); mDeviceKeyHandlerMethod = klass.getDeclaredMethod( "handleKeyEvent", KeyEvent.class); Log.d(TAG, "Loaded device key handler"); } catch (Exception e) { Slog.d(TAG, "Could not get device key Handler " + deviceKeyHandlerClass + " from class " + deviceKeyHandlerLib, e); } } } } public void setInitialDisplaySize(int width, int height) { public void setInitialDisplaySize(int width, int height) { Loading Loading @@ -1828,6 +1863,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH); showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH); } } if (mDeviceKeyHandler != null && mDeviceKeyHandlerMethod != null) { try { Integer ret = (Integer) mDeviceKeyHandlerMethod.invoke( mDeviceKeyHandler, event); return ret; } catch (Exception e) { Slog.d(TAG, "Could not invoke device key handler", e); } } // Let the application handle the key. // Let the application handle the key. return 0; return 0; } } Loading