Loading core/java/com/android/internal/os/DeviceKeyHandler.java 0 → 100644 +21 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 The CyanogenMod 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 * http://www.apache.org/licenses/LICENSE-2.0 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. */ package com.android.internal.os; import android.view.KeyEvent; public interface DeviceKeyHandler { public static final int KEYEVENT_CAUGHT = -1; public static final int KEYEVENT_UNCAUGHT = 0; public int handleKeyEvent(KeyEvent event); } core/res/res/values/config.xml +6 −0 Original line number Diff line number Diff line Loading @@ -886,4 +886,10 @@ the button and keyboard backlights. --> <bool name="config_autoBrightnessButtonKeyboard">true</bool> <!-- Path to the library that contains a device specific key handler --> <string name="config_deviceKeyHandlerLib" translatable="false"></string> <!-- Name of that key handler class --> <string name="config_deviceKeyHandlerClass" translatable="false"></string> </resources> core/res/res/values/public.xml +2 −0 Original line number Diff line number Diff line Loading @@ -3661,5 +3661,7 @@ <java-symbol type="bool" name="config_forceDisableHardwareKeyboard" /> <java-symbol type="array" name="config_telephony_set_audioparameters" /> <java-symbol type="bool" name="config_autoBrightnessButtonKeyboard" /> <java-symbol type="string" name="config_deviceKeyHandlerLib" /> <java-symbol type="string" name="config_deviceKeyHandlerClass" /> </resources> policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +39 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; Loading Loading @@ -59,11 +60,14 @@ import android.os.Vibrator; import android.provider.Settings; import com.android.internal.R; import com.android.internal.os.DeviceKeyHandler; import com.android.internal.policy.PolicyManager; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.telephony.ITelephony; import com.android.internal.widget.PointerLocationView; import dalvik.system.DexClassLoader; import android.service.dreams.IDreamManager; import android.util.DisplayMetrics; import android.util.EventLog; Loading Loading @@ -145,6 +149,7 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; import java.lang.reflect.Constructor; /** * WindowManagerPolicy implementation for the Android phone UI. This Loading Loading @@ -267,6 +272,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); } DeviceKeyHandler mDeviceKeyHandler; /** * Lock protecting internal state. Must not call out into window * manager with lock held. (This lock will be acquired in places Loading Loading @@ -962,6 +969,30 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else { 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 = (DeviceKeyHandler) constructor.newInstance( mContext); Slog.d(TAG, "Device key handler loaded"); } catch (Exception e) { Slog.d(TAG, "Could not instantiate device key handler " + deviceKeyHandlerClass + " from class " + deviceKeyHandlerLib, e); } } } public void setInitialDisplaySize(Display display, int width, int height) { Loading Loading @@ -2016,6 +2047,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { return -1; } if (mDeviceKeyHandler != null) { try { return mDeviceKeyHandler.handleKeyEvent(event); } catch (Exception e) { Slog.d(TAG, "Could not dispatch event to device key handler", e); } } // Let the application handle the key. return 0; } Loading Loading
core/java/com/android/internal/os/DeviceKeyHandler.java 0 → 100644 +21 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 The CyanogenMod 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 * http://www.apache.org/licenses/LICENSE-2.0 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. */ package com.android.internal.os; import android.view.KeyEvent; public interface DeviceKeyHandler { public static final int KEYEVENT_CAUGHT = -1; public static final int KEYEVENT_UNCAUGHT = 0; public int handleKeyEvent(KeyEvent event); }
core/res/res/values/config.xml +6 −0 Original line number Diff line number Diff line Loading @@ -886,4 +886,10 @@ the button and keyboard backlights. --> <bool name="config_autoBrightnessButtonKeyboard">true</bool> <!-- Path to the library that contains a device specific key handler --> <string name="config_deviceKeyHandlerLib" translatable="false"></string> <!-- Name of that key handler class --> <string name="config_deviceKeyHandlerClass" translatable="false"></string> </resources>
core/res/res/values/public.xml +2 −0 Original line number Diff line number Diff line Loading @@ -3661,5 +3661,7 @@ <java-symbol type="bool" name="config_forceDisableHardwareKeyboard" /> <java-symbol type="array" name="config_telephony_set_audioparameters" /> <java-symbol type="bool" name="config_autoBrightnessButtonKeyboard" /> <java-symbol type="string" name="config_deviceKeyHandlerLib" /> <java-symbol type="string" name="config_deviceKeyHandlerClass" /> </resources>
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +39 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; Loading Loading @@ -59,11 +60,14 @@ import android.os.Vibrator; import android.provider.Settings; import com.android.internal.R; import com.android.internal.os.DeviceKeyHandler; import com.android.internal.policy.PolicyManager; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.telephony.ITelephony; import com.android.internal.widget.PointerLocationView; import dalvik.system.DexClassLoader; import android.service.dreams.IDreamManager; import android.util.DisplayMetrics; import android.util.EventLog; Loading Loading @@ -145,6 +149,7 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; import java.lang.reflect.Constructor; /** * WindowManagerPolicy implementation for the Android phone UI. This Loading Loading @@ -267,6 +272,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); } DeviceKeyHandler mDeviceKeyHandler; /** * Lock protecting internal state. Must not call out into window * manager with lock held. (This lock will be acquired in places Loading Loading @@ -962,6 +969,30 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else { 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 = (DeviceKeyHandler) constructor.newInstance( mContext); Slog.d(TAG, "Device key handler loaded"); } catch (Exception e) { Slog.d(TAG, "Could not instantiate device key handler " + deviceKeyHandlerClass + " from class " + deviceKeyHandlerLib, e); } } } public void setInitialDisplaySize(Display display, int width, int height) { Loading Loading @@ -2016,6 +2047,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { return -1; } if (mDeviceKeyHandler != null) { try { return mDeviceKeyHandler.handleKeyEvent(event); } catch (Exception e) { Slog.d(TAG, "Could not dispatch event to device key handler", e); } } // Let the application handle the key. return 0; } Loading