diff options
47 files changed, 509 insertions, 39 deletions
diff --git a/core/java/android/accounts/ChooseAccountTypeActivity.java b/core/java/android/accounts/ChooseAccountTypeActivity.java index acc85496ba2..5b3b553fa78 100644 --- a/core/java/android/accounts/ChooseAccountTypeActivity.java +++ b/core/java/android/accounts/ChooseAccountTypeActivity.java @@ -134,7 +134,6 @@ public class ChooseAccountTypeActivity extends Activity { if (sequence != null) { name = sequence.toString(); } - name = sequence.toString(); } catch (PackageManager.NameNotFoundException e) { // Nothing we can do much here, just log if (Log.isLoggable(TAG, Log.WARN)) { diff --git a/core/java/android/database/sqlite/SQLiteSession.java b/core/java/android/database/sqlite/SQLiteSession.java index d86a91f5665..d80ab1f2e86 100644 --- a/core/java/android/database/sqlite/SQLiteSession.java +++ b/core/java/android/database/sqlite/SQLiteSession.java @@ -926,7 +926,7 @@ public final class SQLiteSession { } private void throwIfNestedTransaction() { - if (mTransactionStack != null && mTransactionStack.mParent != null) { + if (hasNestedTransaction()) { throw new IllegalStateException("Cannot perform this operation because " + "a nested transaction is in progress."); } diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index c340d462a15..36074031947 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -2490,6 +2490,12 @@ public final class Settings { */ public static final String STATUS_BAR_IME_SWITCHER = "status_bar_ime_switcher"; + /** + * Statusbar State + * @hide + */ + public static final String EXPANDED_DESKTOP_STATE = "expanded_desktop_state"; + /** * Whether to use a separate delay for "slide to unlock" and security * lock @@ -2723,6 +2729,12 @@ public final class Settings { public static final String POWER_MENU_SCREENSHOT_ENABLED = "power_menu_screenshot_enabled"; /** + * Whether power menu expanded desktop is enabled + * @hide + */ + public static final String POWER_MENU_EXPANDED_DESKTOP_ENABLED = "power_menu_expanded_desktop_enabled"; + + /** * Whether power menu profiles switcher is enabled * @hide */ diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index d12c47b39ee..83bc40ff248 100644 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2006 The Android Open Source Project + * Copyright (c) 2012, Code Aurora Forum. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +25,7 @@ import android.os.RemoteException; import android.provider.Settings; import android.util.DisplayMetrics; import android.util.SparseArray; +import android.os.SystemProperties; /** * Contains methods to standard constants used in the UI for timeouts, sizes, and distances. @@ -408,8 +410,13 @@ public class ViewConfiguration { * a long press */ public static int getLongPressTimeout() { + // Allow increase of timeout using property for targets which + // may take more time than default timeout to report headset + // events. The value will be Zero incase the property is not + // defined for a particular target. + int delay = SystemProperties.getInt("headset.hook.delay", 0); return AppGlobals.getIntCoreSetting(Settings.Secure.LONG_PRESS_TIMEOUT, - DEFAULT_LONG_PRESS_TIMEOUT); + DEFAULT_LONG_PRESS_TIMEOUT + delay); } /** diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index 7c1967f5026..52d007b3849 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -902,6 +902,14 @@ public interface WindowManagerPolicy { public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen); /** + * Tell the policy that the jack switch has changed state. + * @param whenNanos The time when the change occurred in uptime nanoseconds.. + * @param switchCode Explains the Jack types + * @param jackOpen True if the jacktype is now inserted. + */ + public void notifyJackSwitchChanged(long whenNanos, int switchCode, boolean jackOpen); + + /** * Tell the policy if anyone is requesting that keyguard not come on. * * @param enabled Whether keyguard can be on or not. does not actually diff --git a/core/res/res/drawable-hdpi/ic_lock_expanded_desktop.png b/core/res/res/drawable-hdpi/ic_lock_expanded_desktop.png Binary files differnew file mode 100644 index 00000000000..01f5b89cbc7 --- /dev/null +++ b/core/res/res/drawable-hdpi/ic_lock_expanded_desktop.png diff --git a/core/res/res/drawable-mdpi/ic_lock_expanded_desktop.png b/core/res/res/drawable-mdpi/ic_lock_expanded_desktop.png Binary files differnew file mode 100644 index 00000000000..bffad732e8f --- /dev/null +++ b/core/res/res/drawable-mdpi/ic_lock_expanded_desktop.png diff --git a/core/res/res/drawable-sw600dp-xhdpi/ic_lock_expanded_desktop.png b/core/res/res/drawable-sw600dp-xhdpi/ic_lock_expanded_desktop.png Binary files differnew file mode 100644 index 00000000000..e0c99e5bcbd --- /dev/null +++ b/core/res/res/drawable-sw600dp-xhdpi/ic_lock_expanded_desktop.png diff --git a/core/res/res/drawable-xhdpi/ic_lock_expanded_desktop.png b/core/res/res/drawable-xhdpi/ic_lock_expanded_desktop.png Binary files differnew file mode 100644 index 00000000000..e0c99e5bcbd --- /dev/null +++ b/core/res/res/drawable-xhdpi/ic_lock_expanded_desktop.png diff --git a/core/res/res/values-ru/strings.xml b/core/res/res/values-ru/strings.xml index e3a9000ad8d..908e32eff83 100644 --- a/core/res/res/values-ru/strings.xml +++ b/core/res/res/values-ru/strings.xml @@ -1316,6 +1316,11 @@ <!-- label for item that screenshots in phone options dialog --> <string name="global_action_screenshot">Скриншот</string> + <!-- label for item that toggles expand desktop mode --> + <string name="global_actions_toggle_expanded_desktop_mode">Расширенный рабочий стол</string> + <string name="global_actions_expanded_desktop_mode_on_status">Включен</string> + <string name="global_actions_expanded_desktop_mode_off_status">Выключен</string> + <!-- Button to reboot the phone, within the Reboot Options dialog --> <string name="global_action_reboot">Перезагрузка</string> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 47755a1cae9..c3e1828d028 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -3702,6 +3702,9 @@ <java-symbol type="string" name="global_action_screenshot" /> <java-symbol type="string" name="global_action_choose_profile" /> <java-symbol type="string" name="global_action_reboot" /> + <java-symbol type="string" name="global_actions_toggle_expanded_desktop_mode" /> + <java-symbol type="string" name="global_actions_expanded_desktop_mode_off_status" /> + <java-symbol type="string" name="global_actions_expanded_desktop_mode_on_status" /> <java-symbol type="string" name="global_actions" /> <java-symbol type="string" name="reboot_system" /> <java-symbol type="string" name="reboot_progress" /> @@ -3710,6 +3713,7 @@ <java-symbol type="drawable" name="ic_lock_screenshot" /> <java-symbol type="drawable" name="ic_lock_reboot" /> <java-symbol type="drawable" name="ic_lock_profile" /> + <java-symbol type="drawable" name="ic_lock_expanded_desktop" /> <!-- Profiles --> <java-symbol type="xml" name="profile_default" /> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index bb02081833e..ee622cce837 100755 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -318,6 +318,13 @@ <!-- label for item that screenshots in phone options dialog --> <string name="global_action_screenshot">Screenshot</string> + <!-- label for item that toggles expand desktop mode --> + <string name="global_actions_toggle_expanded_desktop_mode">Expanded desktop</string> + <!-- status message in phone options dialog for when expand desktop mode is on --> + <string name="global_actions_expanded_desktop_mode_on_status">Enabled</string> + <!-- status message in phone options dialog for when expand desktop mode is off --> + <string name="global_actions_expanded_desktop_mode_off_status">Disabled</string> + <!-- Button to reboot the phone, within the Reboot Options dialog --> <string name="reboot_reboot">Reboot</string> <!-- Button to reboot the phone into recovery, within the Reboot Options dialog --> diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index fd82f387039..50ab7ed0259 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -3548,9 +3548,16 @@ public class AudioService extends IAudioService.Stub implements OnFinished { // Volume restore capping final boolean capVolumeRestore = Settings.System.getInt(mContentResolver, Settings.System.SAFE_HEADSET_VOLUME_RESTORE, 1) == 1; - if (capVolumeRestore) { - for (int stream = 0; stream < AudioSystem.getNumStreamTypes(); stream++) { - if (stream == mStreamVolumeAlias[stream]) { + + for (int stream = 0; stream < AudioSystem.getNumStreamTypes(); stream++) { + if (stream == mStreamVolumeAlias[stream]) { + VolumeStreamState streamState = mStreamStates[mStreamVolumeAlias[stream]]; + device = getDeviceForStream(stream); + // apply stored value for device + streamState.applyDeviceVolume(device); + + // now reduce volume if required + if (capVolumeRestore) { final int volume = getStreamVolume(stream); final int restoreCap = rescaleIndex(HEADSET_VOLUME_RESTORE_CAP, AudioSystem.STREAM_MUSIC, stream); @@ -3566,6 +3573,16 @@ public class AudioService extends IAudioService.Stub implements OnFinished { if (noDelayInATwoDP) { setBluetoothA2dpOnInt(true); } + + // Restore volumes + for (int stream = 0; stream < AudioSystem.getNumStreamTypes(); stream++) { + if (stream == mStreamVolumeAlias[stream]) { + VolumeStreamState streamState = mStreamStates[mStreamVolumeAlias[stream]]; + device = getDeviceForStream(stream); + // apply stored value for device + streamState.applyDeviceVolume(device); + } + } } } else if (action.equals(Intent.ACTION_USB_AUDIO_ACCESSORY_PLUG) || action.equals(Intent.ACTION_USB_AUDIO_DEVICE_PLUG)) { diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 5f1a1737333..2d6e1d6c81f 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -14,6 +14,7 @@ <uses-permission android:name="android.permission.STATUS_BAR" /> <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" /> <uses-permission android:name="android.permission.REMOTE_AUDIO_PLAYBACK" /> + <uses-permission android:name="com.android.alarm.permission.SET_ALARM" /> <!-- Networking and telephony --> <uses-permission android:name="android.permission.BLUETOOTH" /> diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_0.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_0.png Binary files differnew file mode 100644 index 00000000000..148887ccc23 --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_0.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_100.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_100.png Binary files differnew file mode 100644 index 00000000000..41114221949 --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_100.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_15.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_15.png Binary files differnew file mode 100644 index 00000000000..e62406c6b54 --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_15.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_28.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_28.png Binary files differnew file mode 100644 index 00000000000..4c5760c44c8 --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_28.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_43.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_43.png Binary files differnew file mode 100644 index 00000000000..d713085b32e --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_43.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_57.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_57.png Binary files differnew file mode 100644 index 00000000000..c29f1cf669b --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_57.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_71.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_71.png Binary files differnew file mode 100644 index 00000000000..4b5850700af --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_71.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_85.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_85.png Binary files differnew file mode 100644 index 00000000000..eb996596720 --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_85.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim0.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim0.png Binary files differnew file mode 100644 index 00000000000..5c7a33f30cd --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim0.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim100.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim100.png Binary files differnew file mode 100644 index 00000000000..a9b53db159f --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim100.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim15.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim15.png Binary files differnew file mode 100644 index 00000000000..0ed468f12ac --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim15.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim28.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim28.png Binary files differnew file mode 100644 index 00000000000..773cf9455e3 --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim28.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim43.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim43.png Binary files differnew file mode 100644 index 00000000000..8de60a2b386 --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim43.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim57.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim57.png Binary files differnew file mode 100644 index 00000000000..cca65cb8102 --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim57.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim71.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim71.png Binary files differnew file mode 100644 index 00000000000..589bacb308c --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim71.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim85.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim85.png Binary files differnew file mode 100644 index 00000000000..39223abf2e8 --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_charge_anim85.png diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_unknown.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_unknown.png Binary files differnew file mode 100644 index 00000000000..b480f7cfd2a --- /dev/null +++ b/packages/SystemUI/res/drawable-sw720dp-hdpi/stat_sys_kb_battery_unknown.png diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavbarEditor.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavbarEditor.java index 4ab85887c55..c5e960df121 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavbarEditor.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavbarEditor.java @@ -12,6 +12,7 @@ import android.content.res.Configuration; import android.database.DataSetObserver; import android.graphics.Color; import android.provider.Settings; +import android.util.DisplayMetrics; import android.view.HapticFeedbackConstants; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -56,6 +57,7 @@ public class NavbarEditor implements OnTouchListener { new LinkedHashMap<String,ButtonInfo>(); protected static int visibleCount = 4; + private static Boolean mIsDeviceHybrid = null; /** * Holds reference to the parent/root of the inflated view @@ -165,6 +167,21 @@ public class NavbarEditor implements OnTouchListener { } }; + protected static boolean isDeviceHybrid(Context con) { + if (mIsDeviceHybrid == null) { + WindowManager wm = (WindowManager)con.getSystemService(Context.WINDOW_SERVICE); + android.view.Display display = wm.getDefaultDisplay(); + int shortSize = Math.min(display.getRawHeight(), display.getRawWidth()); + int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / DisplayMetrics.DENSITY_DEVICE; + if (shortSizeDp < 720 && shortSizeDp >= 600) { + mIsDeviceHybrid = true; + } else { + mIsDeviceHybrid = false; + } + } + return mIsDeviceHybrid; + } + @Override public boolean onTouch(final View view, MotionEvent event) { if (!NavigationBarView.getEditMode() || (mDialog != null && mDialog.isShowing())) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index f1c0e7b1762..7a89816f87a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -70,7 +70,6 @@ public class NavigationBarView extends LinearLayout { private OnClickListener mRecentsClickListener; private RecentsPanelView mRecentsPanel; private OnTouchListener mHomeSearchActionListener; - private boolean mIs600dp; protected IStatusBarService mBarService; final Display mDisplay; @@ -181,9 +180,6 @@ public class NavigationBarView extends LinearLayout { mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size); mVertical = false; mShowMenu = false; - //Silly way to identify 600dp - //TODO come up with a better way - mIs600dp = res.getInteger(R.integer.notification_panel_layout_gravity) == 49; mDelegateHelper = new DelegateViewHelper(this); updateResources(); @@ -415,7 +411,7 @@ public class NavigationBarView extends LinearLayout { } mCurrentView = mRotatedViews[rot]; mCurrentView.setVisibility(View.VISIBLE); - if (!mIs600dp) { + if (!NavbarEditor.isDeviceHybrid(mContext)) { mVertical = (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270); } else { mVertical = getWidth() > 0 && getHeight() > getWidth(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CircleBattery.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CircleBattery.java index 8391cd1617c..76e984199f8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CircleBattery.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CircleBattery.java @@ -60,7 +60,8 @@ public class CircleBattery extends ImageView { private boolean mPercentage; // whether or not to show percentage number private boolean mIsCharging; // whether or not device is currently charging private int mLevel; // current battery level - private int mAnimLevel; // current level of charging animation + private int mAnimOffset; // current level of charging animation + private boolean mIsAnimating; // stores charge-animation status to reliably remove callbacks private int mCircleSize; // draw size of circle. read rather complicated from // another status bar icon, so it fits the icon size @@ -74,7 +75,6 @@ public class CircleBattery extends ImageView { private Paint mPaintGray; private Paint mPaintSystem; private Paint mPaintRed; - private Paint mPaintAnim; // runnable to invalidate view via mHandler.postDelayed() call private final Runnable mInvalidate = new Runnable() { @@ -196,7 +196,6 @@ public class CircleBattery extends ImageView { mPaintGray = new Paint(mPaintFont); mPaintSystem = new Paint(mPaintFont); mPaintRed = new Paint(mPaintFont); - mPaintAnim = new Paint(mPaintFont); mPaintFont.setColor(res.getColor(R.color.holo_blue_dark)); mPaintSystem.setColor(res.getColor(R.color.holo_blue_dark)); @@ -204,7 +203,6 @@ public class CircleBattery extends ImageView { // do not want to use static 0x404040 color value. would break theming. mPaintGray.setColor(res.getColor(R.color.darker_gray)); mPaintRed.setColor(res.getColor(R.color.holo_red_light)); - mPaintAnim.setColor(res.getColor(R.color.holo_blue_dark)); // font needs some extra settings mPaintFont.setTextAlign(Align.CENTER); @@ -255,24 +253,19 @@ public class CircleBattery extends ImageView { if (mLevel <= 14) { usePaint = mPaintRed; } - mPaintAnim.setColor(usePaint.getColor()); // pad circle percentage to 100% once it reaches 97% // for one, the circle looks odd with a too small gap, // for another, some phones never reach 100% due to hardware design int padLevel = mLevel; - if(mLevel>=97) { + if (mLevel >= 97) { padLevel=100; } // draw thin gray ring first canvas.drawArc(mCircleRect, 270, 360, false, mPaintGray); - // if charging, draw thin animated colored ring next - if (mIsCharging){ - canvas.drawArc(mCircleRect, 270, 3.6f * mAnimLevel, false, mPaintAnim); - } // draw thin colored ring-level last - canvas.drawArc(mCircleRect, 270, 3.6f * padLevel, false, usePaint); + canvas.drawArc(mCircleRect, 270+mAnimOffset, 3.6f * padLevel, false, usePaint); // if chosen by options, draw percentage text in the middle // always skip percentage when 100, so layout doesnt break if (mLevel < 100 && mPercentage){ @@ -287,22 +280,25 @@ public class CircleBattery extends ImageView { * uses mInvalidate for delayed invalidate() callbacks */ private void updateChargeAnim() { - if (!mIsCharging) { - if (mAnimLevel != -1) { - mAnimLevel = -1; + if (!mIsCharging || mLevel >= 97) { + if (mIsAnimating) { + mIsAnimating = false; + mAnimOffset = 0; mHandler.removeCallbacks(mInvalidate); } return; } - if (mAnimLevel > 100 || mAnimLevel < 0) { - mAnimLevel = mLevel; + mIsAnimating = true; + + if (mAnimOffset > 360) { + mAnimOffset = 0; } else { - mAnimLevel += 6; + mAnimOffset += 3; } mHandler.removeCallbacks(mInvalidate); - mHandler.postDelayed(mInvalidate, 750); + mHandler.postDelayed(mInvalidate, 50); } /*** @@ -321,7 +317,6 @@ public class CircleBattery extends ImageView { mPaintRed.setStrokeWidth(strokeWidth); mPaintSystem.setStrokeWidth(strokeWidth); mPaintGray.setStrokeWidth(strokeWidth / 3.5f); - mPaintAnim.setStrokeWidth(strokeWidth / 3.5f); // calculate rectangle for drawArc calls int pLeft = getPaddingLeft(); diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java index 9adb2c63687..32322f36910 100644 --- a/policy/src/com/android/internal/policy/impl/GlobalActions.java +++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java @@ -96,6 +96,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac private Action mSilentModeAction; private ToggleAction mAirplaneModeOn; + private ToggleAction mExpandDesktopModeOn; private MyAdapter mAdapter; @@ -188,6 +189,28 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } else { mSilentModeAction = new SilentModeTriStateAction(mContext, mAudioManager, mHandler); } + + mExpandDesktopModeOn = new ToggleAction( + R.drawable.ic_lock_expanded_desktop, + R.drawable.ic_lock_expanded_desktop, + R.string.global_actions_toggle_expanded_desktop_mode, + R.string.global_actions_expanded_desktop_mode_on_status, + R.string.global_actions_expanded_desktop_mode_off_status) { + + void onToggle(boolean on) { + changeExpandDesktopModeSystemSetting(on); + } + + public boolean showDuringKeyguard() { + return false; + } + + public boolean showBeforeProvisioning() { + return false; + } + }; + onExpandDesktopModeChanged(); + mAirplaneModeOn = new ToggleAction( R.drawable.ic_lock_airplane_mode, R.drawable.ic_lock_airplane_mode_off, @@ -324,6 +347,13 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac }); } + // next: expanded desktop toggle + // only shown if enabled, disabled by default + if(Settings.System.getInt(mContext.getContentResolver(), + Settings.System.POWER_MENU_EXPANDED_DESKTOP_ENABLED, 0) == 1){ + mItems.add(mExpandDesktopModeOn); + } + // next: airplane mode if (Settings.System.getInt(mContext.getContentResolver(), Settings.System.POWER_MENU_AIRPLANE_ENABLED, 1) == 1) { @@ -1075,6 +1105,14 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac mAirplaneModeOn.updateState(mAirplaneState); } + private void onExpandDesktopModeChanged() { + boolean expandDesktopModeOn = Settings.System.getInt( + mContext.getContentResolver(), + Settings.System.EXPANDED_DESKTOP_STATE, + 0) == 1; + mExpandDesktopModeOn.updateState(expandDesktopModeOn ? ToggleAction.State.On : ToggleAction.State.Off); + } + /** * Change the airplane mode system setting */ @@ -1092,6 +1130,16 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } } + /** + * Change the expand desktop mode system setting + */ + private void changeExpandDesktopModeSystemSetting(boolean on) { + Settings.System.putInt( + mContext.getContentResolver(), + Settings.System.EXPANDED_DESKTOP_STATE, + on ? 1 : 0); + } + private IWindowManager getWindowManager() { if (mIWindowManager == null) { IBinder b = ServiceManager.getService(Context.WINDOW_SERVICE); diff --git a/policy/src/com/android/internal/policy/impl/IconUtilities.java b/policy/src/com/android/internal/policy/impl/IconUtilities.java index e997355583a..a47c904c6b7 100644 --- a/policy/src/com/android/internal/policy/impl/IconUtilities.java +++ b/policy/src/com/android/internal/policy/impl/IconUtilities.java @@ -130,7 +130,7 @@ final class IconUtilities { int sourceWidth = icon.getIntrinsicWidth(); int sourceHeight = icon.getIntrinsicHeight(); - if (sourceWidth > 0 && sourceWidth > 0) { + if (sourceWidth > 0 && sourceHeight > 0) { // There are intrinsic sizes. if (width < sourceWidth || height < sourceHeight) { // It's too big, scale it down. diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 48d632c41d3..26dec41af7d 100755..100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -268,6 +268,42 @@ public class PhoneWindowManager implements WindowManagerPolicy { static public final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey"; static public final String SYSTEM_DIALOG_REASON_ASSIST = "assist"; + // Useful scan codes. + //private static final int SW_LID = 0x00; + private static final int SW_HEADPHONE_INSERT = 0x02; + private static final int SW_MICROPHONE_INSERT = 0x04; + //ToDo: This needs to be revisted once the kernel has support to report ANC event + private static final int SW_ANC_INSERT = 0x08; + private static final int SW_HEADSET_INSERT = (SW_HEADPHONE_INSERT|SW_MICROPHONE_INSERT); + private static final int SW_ANC_HEADPHONE_INSERT = 0x10; + private static final int SW_ANC_MICROPHONE_INSERT = 0x20; + private static final int SW_ANC_HEADSET_INSERT = (SW_ANC_HEADPHONE_INSERT|SW_ANC_MICROPHONE_INSERT); + private static final int BTN_MOUSE = 0x110; + + // Useful HeadSet codes... Same definition as WireAccessoryObserver.java + private static int mHeadsetJackState = 0; + private static boolean mIsAncOn = false; + private static final int BIT_HEADSET = (1 << 0); + private static final int BIT_HEADSET_SPEAKER_ONLY = (1 << 1); + //Useful Headset codes... QC added definitions + private static final int BIT_HEADSET_MIC_ONLY = (1 << 2); + private static final int BIT_ANC_HEADSET = (1 << 3); + private static final int BIT_ANC_HEADSET_SPEAKER_ONLY = (1 << 4); + private static final int BIT_ANC_HEADSET_MIC_ONLY = (1 << 5); + private static final int SUPPORTED_HEADSETS = (BIT_HEADSET|BIT_HEADSET_SPEAKER_ONLY|BIT_HEADSET_MIC_ONLY | + BIT_ANC_HEADSET|BIT_ANC_HEADSET_SPEAKER_ONLY|BIT_ANC_HEADSET_MIC_ONLY); + + private static final int BIT_HEADSET_NO_MIC = BIT_HEADSET_SPEAKER_ONLY; + private static final int BIT_ANC_HEADSET_NO_MIC = BIT_ANC_HEADSET_SPEAKER_ONLY; + private static final int ANC_HEADSETS_WITH_MIC = BIT_ANC_HEADSET; + private static final int HEADSETS_WITH_MIC = BIT_HEADSET; + + private String mHeadsetName = "Headset"; + private int mPrevHeadsetState = 0; + private int mCurHeadsetState = 0; + private boolean mHeadsetIntent = false; + private final Object mHeadsetLock = new Object(); + /** * These are the system UI flags that, when changing, can cause the layout * of the screen to change. @@ -678,6 +714,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { Settings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION), false, this); resolver.registerContentObserver(Settings.System.getUriFor( Settings.System.HARDWARE_KEY_REBINDING), false, this); + resolver.registerContentObserver(Settings.System.getUriFor( + Settings.System.EXPANDED_DESKTOP_STATE), false, this); if (SEPARATE_TIMEOUT_FOR_SCREEN_SAVER) { resolver.registerContentObserver(Settings.Secure.getUriFor( "screensaver_timeout"), false, this); @@ -2802,6 +2840,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // decided that it can't be hidden (because of the screen aspect ratio), // then take that into account. navVisible |= !mCanHideNavigationBar; + navVisible &= (Settings.System.getInt(mContext.getContentResolver(), Settings.System.EXPANDED_DESKTOP_STATE, 0) == 0); if (mNavigationBar != null) { // Force the navigation bar to its appropriate place and @@ -3364,7 +3403,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // and mTopIsFullscreen is that that mTopIsFullscreen is set only if the window // has the FLAG_FULLSCREEN set. Not sure if there is another way that to be the // case though. - if (topIsFullscreen) { + if (topIsFullscreen || Settings.System.getInt(mContext.getContentResolver(), Settings.System.EXPANDED_DESKTOP_STATE, 0) == 1) { if (DEBUG_LAYOUT) Log.v(TAG, "** HIDING status bar"); if (mStatusBar.hideLw(true)) { changes |= FINISH_LAYOUT_REDO_LAYOUT; @@ -3534,6 +3573,225 @@ public class PhoneWindowManager implements WindowManagerPolicy { setHdmiPlugged(!mHdmiPlugged); } + /** {@inheritDoc} */ + public void notifyJackSwitchChanged(long whenNanos, int switchCode, boolean switchState) { + Slog.d(TAG,"notifyJackSwitchChanged(): switchCode "+switchCode+" switchState "+switchState); + synchronized(mHeadsetLock) { + if(switchCode == SW_ANC_INSERT) { + if(switchState) { + mIsAncOn = true; + if((mHeadsetJackState & BIT_HEADSET) != 0) { + mHeadsetJackState &= ~BIT_HEADSET; + mHeadsetJackState |= BIT_ANC_HEADSET; + } + if((mHeadsetJackState & BIT_HEADSET_SPEAKER_ONLY) != 0) { + mHeadsetJackState &= ~BIT_HEADSET_SPEAKER_ONLY; + mHeadsetJackState |= BIT_ANC_HEADSET_SPEAKER_ONLY; + } + if((mHeadsetJackState & BIT_HEADSET_MIC_ONLY) != 0) { + mHeadsetJackState &= ~BIT_HEADSET_MIC_ONLY; + mHeadsetJackState |= BIT_ANC_HEADSET_MIC_ONLY; + } + } else { + mIsAncOn = false; + if((mHeadsetJackState & BIT_ANC_HEADSET) != 0) { + mHeadsetJackState &= ~BIT_ANC_HEADSET; + mHeadsetJackState |= BIT_HEADSET; + } + if((mHeadsetJackState & BIT_ANC_HEADSET_SPEAKER_ONLY) != 0) { + mHeadsetJackState &= ~BIT_ANC_HEADSET_SPEAKER_ONLY; + mHeadsetJackState |= BIT_HEADSET_SPEAKER_ONLY; + } + if((mHeadsetJackState & BIT_ANC_HEADSET_MIC_ONLY) != 0) { + mHeadsetJackState &= ~BIT_ANC_HEADSET_MIC_ONLY; + mHeadsetJackState |= BIT_HEADSET_MIC_ONLY; + } + } + } else if ( switchCode == SW_HEADPHONE_INSERT) { + if (switchState) { + if(mIsAncOn) { + mHeadsetJackState |= BIT_ANC_HEADSET_SPEAKER_ONLY; + } else { + mHeadsetJackState |= BIT_HEADSET_SPEAKER_ONLY; + } + } else if( (mHeadsetJackState & BIT_HEADSET) != 0 ) { + mHeadsetJackState &= ~BIT_HEADSET; + mHeadsetJackState |= BIT_HEADSET_MIC_ONLY; + } else if( (mHeadsetJackState & BIT_ANC_HEADSET) != 0 ) { + mHeadsetJackState &= ~BIT_ANC_HEADSET; + mHeadsetJackState |= BIT_ANC_HEADSET_MIC_ONLY; + } else { + if(mIsAncOn) { + mHeadsetJackState &= ~BIT_ANC_HEADSET_SPEAKER_ONLY; + } else { + mHeadsetJackState &= ~BIT_HEADSET_SPEAKER_ONLY; + } + } + } else if ( switchCode == SW_MICROPHONE_INSERT) { + if (switchState) { + if(mIsAncOn) { + mHeadsetJackState |= BIT_ANC_HEADSET_MIC_ONLY; + } else { + mHeadsetJackState |= BIT_HEADSET_MIC_ONLY; + } + } else if( (mHeadsetJackState & BIT_HEADSET) != 0 ) { + mHeadsetJackState &= ~BIT_HEADSET; + mHeadsetJackState |= BIT_HEADSET_SPEAKER_ONLY; + } else if( (mHeadsetJackState & BIT_ANC_HEADSET) != 0 ) { + mHeadsetJackState &= ~BIT_ANC_HEADSET; + mHeadsetJackState |= BIT_ANC_HEADSET_SPEAKER_ONLY; + } else { + if(mIsAncOn) { + mHeadsetJackState &= ~BIT_ANC_HEADSET_MIC_ONLY; + } else { + mHeadsetJackState &= ~BIT_HEADSET_MIC_ONLY; + } + } + } + + if( mHeadsetJackState == SW_HEADSET_INSERT ) { + // If both Speaker and Mic bits are set, remove them and + // set Headset bit to indicate Headset insertion + mHeadsetJackState = BIT_HEADSET; + } + + if( mHeadsetJackState == SW_ANC_HEADSET_INSERT ) { + mHeadsetJackState = BIT_ANC_HEADSET; + } + update(); + } // synchronized(mHeadsetLock) + } + + private final void update() { + + // Retain only relevant bits + int headsetState = mHeadsetJackState & SUPPORTED_HEADSETS; + // Set default delay to 10msec to allow all the events to reach before sending intent + int delay = 10; + // reject all suspect transitions: only accept state changes from: + // - a: 0 heaset to 1 headset + // - b: 1 headset to 0 headset + if (mCurHeadsetState == headsetState) { + return; + } + + if (headsetState == 0) { + Intent intent = new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY); + mContext.sendBroadcast(intent); + // It can take hundreds of ms flush the audio pipeline after + // apps pause audio playback, but audio route changes are + // immediate, so delay the route change by 1000ms. + // This could be improved once the audio sub-system provides an + // interface to clear the audio pipeline. + delay = 1000; + } else { + // Insert the same delay for headset connection so that the connection event is not + // broadcast before the disconnection event in case of fast removal/insertion + if ( mIntentHandler.hasMessages(0)) { + delay = 1000; + } + } + mBroadcastWakeLock.acquire(); + Slog.d(TAG,"update(): sending Message to IntentHander with delay of "+delay); + mIntentHandler.sendMessageDelayed( mIntentHandler.obtainMessage(0, mHeadsetName), + delay); + } + + private synchronized final void sendIntents(String headsetName) { + + Slog.d(TAG,"sendIntents(): mHeadsetJackState "+mHeadsetJackState+" mCurHeadsetState "+mCurHeadsetState+" mPrevHeadsetState "+mPrevHeadsetState); + int headsetState; + + synchronized(mHeadsetLock) { + headsetState = mHeadsetJackState & SUPPORTED_HEADSETS; + if (mCurHeadsetState == headsetState) { + return; + } + mPrevHeadsetState = mCurHeadsetState; + mCurHeadsetState = headsetState; + } + + int allHeadsets = SUPPORTED_HEADSETS; + //Handle unplug events first and then handle plug-in events + for (int curHeadset = 1; curHeadset < SUPPORTED_HEADSETS; curHeadset <<= 1) { + if (((headsetState & curHeadset) == 0) && ((mPrevHeadsetState & curHeadset) == curHeadset)) { + if ((curHeadset & allHeadsets) != 0) { + sendIntent(curHeadset, headsetState, mPrevHeadsetState, headsetName); + allHeadsets &= ~curHeadset; + } + } + } + + for (int curHeadset = 1; curHeadset < SUPPORTED_HEADSETS; curHeadset <<= 1) { + if (((headsetState & curHeadset) == curHeadset) && ((mPrevHeadsetState & curHeadset) == 0)) { + if ((curHeadset & allHeadsets) != 0) { + sendIntent(curHeadset, headsetState, mPrevHeadsetState, headsetName); + allHeadsets &= ~curHeadset; + } + } + } + } + + private final void sendIntent(int headset, int headsetState, int prevHeadsetState, String headsetName) { + + if ((headsetState & headset) != (prevHeadsetState & headset)) { + // Pack up the values and broadcast them to everyone + int state = 0; + int device = 0; + + + if ((headset & BIT_HEADSET) != 0) { + device = AudioManager.DEVICE_OUT_WIRED_HEADSET; + } else if ((headset & BIT_HEADSET_SPEAKER_ONLY) != 0) { + device = AudioManager.DEVICE_OUT_WIRED_HEADPHONE; + } else if ((headset & BIT_HEADSET_MIC_ONLY ) != 0) { + device = 0; + } else if ((headset & BIT_ANC_HEADSET) != 0) { + device = 0;//AudioManager.DEVICE_OUT_ANC_HEADSET; + } else if ((headset & BIT_ANC_HEADSET_SPEAKER_ONLY) != 0) { + device = 0;//AudioManager.DEVICE_OUT_ANC_HEADPHONE; + } else if ((headset & BIT_ANC_HEADSET_MIC_ONLY) != 0) { + device = 0; + } else { + Slog.e(TAG, "setDeviceState() invalid headset type: "+headset); + return; + } + + if ((headsetState & headset) != 0) { + state = 1; + } else { + state = 0; + } + + if (mSystemBooted) { + final AudioManager am = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE); + if (am == null) { + Log.e(TAG, "sendIntent: couldn't get AudioManager reference"); + return; + } + Slog.d(TAG,"sendIntent(): device "+device+" state "+state); + am.setWiredDeviceConnectionState(device, state, headsetName); + } else { + Slog.d(TAG,"system not booted yet, call setWiredDeviceConnectionState later"); + } + } + } + + private final Handler mIntentHandler = new Handler() { + @Override + public void handleMessage(Message msg) { + Slog.d(TAG,"Headset detect: Inside handleMessage() for IntentHandler" + (String)msg.obj); + if (mSystemBooted) { + sendIntents((String)msg.obj); + } else { + Log.e(TAG, "system not booted yet, send headset intent later"); + mHeadsetIntent = true; + mHeadsetName = (String)msg.obj; + } + mBroadcastWakeLock.release(); + } + }; + /** * @return Whether music is being played right now. */ @@ -4471,6 +4729,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { public void systemBooted() { synchronized (mLock) { mSystemBooted = true; + if (mHeadsetIntent) { + Log.e(TAG, "send headset intent after system booted"); + sendIntents(mHeadsetName); + } } } diff --git a/services/input/Android.mk b/services/input/Android.mk index b6fe44f9944..697f5783ae1 100644 --- a/services/input/Android.mk +++ b/services/input/Android.mk @@ -48,6 +48,10 @@ ifeq ($(BOARD_USE_LEGACY_TRACKPAD),true) LOCAL_CFLAGS += -DLEGACY_TRACKPAD endif +ifeq ($(BOARD_USES_ALSA_AUDIO),true) + LOCAL_CFLAGS += -DALSA_HEADSET_DETECTION +endif + LOCAL_MODULE:= libinput LOCAL_MODULE_TAGS := optional diff --git a/services/input/EventHub.cpp b/services/input/EventHub.cpp index f80ac18450c..6b6763591ea 100644 --- a/services/input/EventHub.cpp +++ b/services/input/EventHub.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005 The Android Open Source Project + * Copyright (C) 2012 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. @@ -30,6 +31,7 @@ #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <unistd.h> #include <fcntl.h> #include <memory.h> @@ -198,6 +200,7 @@ EventHub::EventHub(void) : mOpeningDevices(0), mClosingDevices(0), mNeedToSendFinishedDeviceScan(false), mNeedToReopenDevices(false), mNeedToScanDevices(true), + mNeedToSendHeadPhoneEvent(false), mNeedToSendMicroPhoneEvent(false), mHeadsetDeviceId(-1), mPendingEventCount(0), mPendingEventIndex(0), mPendingINotify(false) { acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID); @@ -693,6 +696,22 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz event->type = DEVICE_ADDED; event += 1; mNeedToSendFinishedDeviceScan = true; +#ifdef ALSA_HEADSET_DETECTION + if(device->classes == INPUT_DEVICE_CLASS_SWITCH) { + mLock.unlock(); + int state = getSwitchState(device->id, SW_HEADPHONE_INSERT); + if(state > 0) { + mNeedToSendHeadPhoneEvent = true; + } + + state = getSwitchState(device->id, SW_MICROPHONE_INSERT); + mLock.lock(); + if(state > 0) { + mNeedToSendMicroPhoneEvent = true; + } + mHeadsetDeviceId = device->id; + } +#endif if (--capacity == 0) { break; } @@ -708,6 +727,33 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz } } +#ifdef ALSA_HEADSET_DETECTION + if(mNeedToSendHeadPhoneEvent) { + event->type = EV_SW; + event->code = SW_HEADPHONE_INSERT; + event->value = 1; + event->deviceId = mHeadsetDeviceId; + event->when = systemTime(SYSTEM_TIME_MONOTONIC); + mNeedToSendHeadPhoneEvent = false; + event += 1; + if (--capacity == 0) { + break; + } + } + if(mNeedToSendMicroPhoneEvent) { + event->type = EV_SW; + event->code = SW_MICROPHONE_INSERT; + event->value = 1; + event->deviceId = mHeadsetDeviceId; + event->when = systemTime(SYSTEM_TIME_MONOTONIC); + mNeedToSendMicroPhoneEvent = false; + event += 1; + if (--capacity == 0) { + break; + } + } +#endif + // Grab the next input event. bool deviceChanged = false; while (mPendingEventIndex < mPendingEventCount) { @@ -932,6 +978,7 @@ static const int32_t GAMEPAD_KEYCODES[] = { status_t EventHub::openDeviceLocked(const char *devicePath) { char buffer[80]; + const char *temp1 = "Button Jack"; ALOGV("Opening device: %s", devicePath); @@ -947,6 +994,10 @@ status_t EventHub::openDeviceLocked(const char *devicePath) { if(ioctl(fd, EVIOCGNAME(sizeof(buffer) - 1), &buffer) < 1) { //fprintf(stderr, "could not get device name for %s, %s\n", devicePath, strerror(errno)); } else { + if((strstr(buffer, temp1)) != NULL) { + memset(buffer, 0, sizeof(buffer)); + strlcpy(buffer, temp1, sizeof(buffer)); + } buffer[sizeof(buffer) - 1] = '\0'; identifier.name.setTo(buffer); } @@ -1039,6 +1090,8 @@ status_t EventHub::openDeviceLocked(const char *devicePath) { // See if this is a keyboard. Ignore everything in the button range except for // joystick and gamepad buttons which are handled like keyboards for the most part. bool haveKeyboardKeys = containsNonZeroByte(device->keyBitmask, 0, sizeof_bit_array(BTN_MISC)) + || containsNonZeroByte(device->keyBitmask, sizeof_bit_array(BTN_MISC), + sizeof_bit_array(BTN_9)) || containsNonZeroByte(device->keyBitmask, sizeof_bit_array(KEY_OK), sizeof_bit_array(KEY_MAX + 1)); bool haveGamepadButtons = containsNonZeroByte(device->keyBitmask, sizeof_bit_array(BTN_MISC), diff --git a/services/input/EventHub.h b/services/input/EventHub.h index afc12ef1aa4..2419976bd39 100644 --- a/services/input/EventHub.h +++ b/services/input/EventHub.h @@ -389,6 +389,9 @@ private: bool mNeedToSendFinishedDeviceScan; bool mNeedToReopenDevices; bool mNeedToScanDevices; + bool mNeedToSendHeadPhoneEvent; + bool mNeedToSendMicroPhoneEvent; + int mHeadsetDeviceId; Vector<String8> mExcludedDevices; int mEpollFd; diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index 3d83a7ee0d8..cbfc40f01a9 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -2286,13 +2286,12 @@ public class LocationManagerService extends ILocationManager.Stub implements Run public void removeTestProvider(String provider) { checkMockPermissionsSafe(); synchronized (mLock) { - MockProvider mockProvider = mMockProviders.get(provider); + MockProvider mockProvider = mMockProviders.remove(provider); if (mockProvider == null) { throw new IllegalArgumentException("Provider \"" + provider + "\" unknown"); } long identity = Binder.clearCallingIdentity(); removeProvider(mProvidersByName.get(provider)); - mMockProviders.remove(mockProvider); // reinstall real provider if we were mocking GPS or network provider if (LocationManager.GPS_PROVIDER.equals(provider) && mGpsLocationProvider != null) { diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 4e46bd0e98f..14bc9782b5d 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -11882,7 +11882,7 @@ public final class ActivityManagerService extends ActivityManagerNative // r.record is null if findServiceLocked() failed the caller permission check if (r.record == null) { throw new SecurityException( - "Permission Denial: Accessing service " + r.record.name + "Permission Denial: Accessing service" + " from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid() + " requires " + r.permission); diff --git a/services/java/com/android/server/input/InputManagerService.java b/services/java/com/android/server/input/InputManagerService.java index acfeff2b238..eafa9b905a4 100644 --- a/services/java/com/android/server/input/InputManagerService.java +++ b/services/java/com/android/server/input/InputManagerService.java @@ -1244,6 +1244,11 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog. } // Native callback. + public void notifyJackSwitchChanged(long whenNanos,int switchCode, boolean jackOpen) { + mCallbacks.notifyJackSwitchChanged(whenNanos, switchCode, jackOpen); + } + + // Native callback. private void notifyInputChannelBroken(InputWindowHandle inputWindowHandle) { mCallbacks.notifyInputChannelBroken(inputWindowHandle); } @@ -1429,6 +1434,8 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog. public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen); + public void notifyJackSwitchChanged(long whenNanos,int switchCode, boolean jackOpen); + public void notifyInputChannelBroken(InputWindowHandle inputWindowHandle); public long notifyANR(InputApplicationHandle inputApplicationHandle, diff --git a/services/java/com/android/server/wm/InputMonitor.java b/services/java/com/android/server/wm/InputMonitor.java index 285d23035d4..b74272a3fa5 100644 --- a/services/java/com/android/server/wm/InputMonitor.java +++ b/services/java/com/android/server/wm/InputMonitor.java @@ -283,6 +283,11 @@ final class InputMonitor implements InputManagerService.Callbacks { mService.mPolicy.notifyLidSwitchChanged(whenNanos, lidOpen); } + /* Notifies that the Jack switch changed state. */ + public void notifyJackSwitchChanged(long whenNanos,int switchCode, boolean jackOpen) { + mService.mPolicy.notifyJackSwitchChanged(whenNanos, switchCode, jackOpen); + } + /* Provides an opportunity for the window manager policy to intercept early key * processing as soon as the key has been read from the device. */ public int interceptKeyBeforeQueueing( diff --git a/services/jni/Android.mk b/services/jni/Android.mk index 7e7ee49837c..cc394ca7751 100644 --- a/services/jni/Android.mk +++ b/services/jni/Android.mk @@ -25,8 +25,13 @@ LOCAL_C_INCLUDES += \ external/skia/include/core \ libcore/include \ libcore/include/libsuspend \ - $(call include-path-for, libhardware)/hardware \ - $(call include-path-for, libhardware_legacy)/hardware_legacy \ + $(call include-path-for, libhardware)/hardware \ + $(call include-path-for, libhardware_legacy)/hardware_legacy \ + +ifeq ($(BOARD_USES_ALSA_AUDIO),true) + LOCAL_CFLAGS += -DALSA_HEADSET_DETECTION + LOCAL_CFLAGS += -include linux/input.h +endif LOCAL_SHARED_LIBRARIES := \ libandroid_runtime \ diff --git a/services/jni/com_android_server_input_InputManagerService.cpp b/services/jni/com_android_server_input_InputManagerService.cpp index 6e253bfeaa5..7474fc2b725 100644 --- a/services/jni/com_android_server_input_InputManagerService.cpp +++ b/services/jni/com_android_server_input_InputManagerService.cpp @@ -64,6 +64,7 @@ static struct { jmethodID notifyConfigurationChanged; jmethodID notifyInputDevicesChanged; jmethodID notifyLidSwitchChanged; + jmethodID notifyJackSwitchChanged; jmethodID notifyInputChannelBroken; jmethodID notifyANR; jmethodID filterInputEvent; @@ -592,6 +593,18 @@ void NativeInputManager::notifySwitch(nsecs_t when, int32_t switchCode, when, switchValue == 0 /*lidOpen*/); checkAndClearExceptionFromCallback(env, "notifyLidSwitchChanged"); break; +#ifdef ALSA_HEADSET_DETECTION + case SW_HEADPHONE_INSERT: + case SW_MICROPHONE_INSERT: + //todo, add support for ANC HEADSET as well + //case SW_ANC_INSERT: + // ToDo: Handle ANC switch event as well + ALOGD("JACK-DETECT: In NativeInputManager-Before calling windowmanager service for HEADPHONE_INSERT"); + env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyJackSwitchChanged, + when, switchCode, switchValue); + checkAndClearExceptionFromCallback(env, "notifyJackSwitchChanged"); + break; +#endif } } @@ -1445,6 +1458,9 @@ int register_android_server_InputManager(JNIEnv* env) { GET_METHOD_ID(gServiceClassInfo.notifyLidSwitchChanged, clazz, "notifyLidSwitchChanged", "(JZ)V"); + GET_METHOD_ID(gServiceClassInfo.notifyJackSwitchChanged, clazz, + "notifyJackSwitchChanged", "(JIZ)V"); + GET_METHOD_ID(gServiceClassInfo.notifyInputChannelBroken, clazz, "notifyInputChannelBroken", "(Lcom/android/server/input/InputWindowHandle;)V"); diff --git a/telephony/java/com/android/internal/telephony/cdma/RuimRecords.java b/telephony/java/com/android/internal/telephony/cdma/RuimRecords.java index 2fefa3f53e0..9aeb5092bd5 100755 --- a/telephony/java/com/android/internal/telephony/cdma/RuimRecords.java +++ b/telephony/java/com/android/internal/telephony/cdma/RuimRecords.java @@ -231,10 +231,10 @@ public final class RuimRecords extends IccRecords { if (mImsi != null && (mImsi.length() < 6 || mImsi.length() > 15)) { loge("invalid IMSI " + mImsi); mImsi = null; + } else { + log("IMSI: " + mImsi.substring(0, 6) + "xxxxxxxxx"); } - log("IMSI: " + mImsi.substring(0, 6) + "xxxxxxxxx"); - String operatorNumeric = getRUIMOperatorNumeric(); if (operatorNumeric != null) { if(operatorNumeric.length() <= 6){ |