Notification Power Widget

Ported over from CM 7.1 into CM9

Rewrite by cvpcs
Requires configuration settings from CMParts. Will be done when settings app available.

Disabled WiMax button until WiMax support is added back in.

ToDo: Change default color to Cyan to match ICS default color Scheme.
      Make indicator bar smaller?

Requires:
      http://review.cyanogenmod.com/#change,10578    - Light Sensor Information.

Also requires CMSettings for Configuration:
      https://github.com/Pedlar/android_packages_apps_CMSettings

Change-Id: I657f459969c784164730e6b0660db40822d8c491

Conflicts:

	core/java/android/provider/Settings.java
Pimp automatic backlight.

Moving average filter for light sensor, support for custom levels, battery stats fix and dim fix.

Optimization: Don't compute the sum of all samples in filter window every run. Instead, keep track of the sum, subtract phased out sample, add new sample and divide new sum by number of valid samples. Massive CPU cycle savings.
Thanks to Jonathan (zenpoy on gmail dot com) for pointing me in the right direction!

Fix: The code for stopping the filter if the sensor has been stable the entire filter window time was only enabled if debug logging was enabled. Oops. CPU cycle savings in steady ambient light.

Tweak light sensor filter

1. Only allow decrease if user permitted it
2. Only perform filter reset on sensor increase and current average is below 1500 ("indoors")
3. Filter reset in 2. means pushing the filter half way towards new sample
4. Filter reset is disabled by default

This change requires commits from CMParts:

5f4026702b67b5d23c9a992f408e3861c90566db
f9238a01e4a4a64cb414dbdada36c97ae2a37db9
0a4b490035c333b3d77e6e59fcc0f7d16d78ebda
5036cc8217daf59aa9f2800bc3fa40e4dd4b3117
b43caaab217848668241681613ce8d54ceda69e9
cc0682a4cc43d0058db8b5195d4d329336f2d3fd

Change-Id: I9c88704484f4a23b3d643597f35b55d74cf36b56
Notification Power Widget:  ICS Icons

This commit changes the widget icons to match the ICS default drawables.  I used
as many of the stock icons as possible and made a few custom ones, where missing,
using stock icons as a base. This set includes XHDPI, HDPI and MDPI icons.

The icon olour is the default for ICS where 'on' = white, 20% transparent and
'off' = white, 70% transparent.

Patch set 4 - stat_ring_off and stat_silent now uses same icon
Patch set 5 - stat_vibrate_off uses same icon as _on.  Looks better.
Patch set 6 - media play/pause/next/previous  icons added
Patch set 7 - orientation icons added, removed 2 'broken' icons

This should be all of them now.

Change-Id: I8b90bed6ecd87ef48126452d53f826956d16cff4
Kill App on Long-Press Back Key (framework)

Change-Id: Ib78fff9e32d95a0a112ddd9274b79b3a3aa626b9
Notification Power Widget: Real rotation lock using ICS API:s

Old implementation of auto rotate button just toggles auto rotation.
New implementation use the new rotation freeze/thaw API:s. Accelerometer
is toggled like before, but current rotation is kept ("frozen"). This
means that AutoRotateButton now works like the rotation lock button
on iOS devices and the native rotation lock button in ICS on tablets.

Change-Id: I8e32bafe46f316194fdf77c375e1adbb7edcf50f
Fix automatic brightness when filtering is disabled

(Broke in I9c88704484f4a23b3d643597f35b55d74cf36b56)

- Do not mHandler.removeCallbacks(mAutoBrightnessTask) every time
  a value is received from the sensor because that will ensure that
  the task ever get ran! (We schedule it 2 seconds into the future
  but receives a value from the sensor every second.)
- Replace the algorithm for brightness change (non-filtering) with
  the original algorithm before the patch. (Not sure why the patch
  changed it.)

Change-Id: I71f6f23c53974fbb763d46ea4023623d2bbeb250
Notification Power Widget: Fix silent mode detection

Recent upstream changes have broken detection of silent mode, so
when for example using the device vol keys to set silent mode the
wrong icon is displayed.
This is caused by a faulty assumption about vibration modes. When
ringer mode is set to silent, vibration mode is ignored by Android.
Thus, when comparing Ringers we can not compare vibration modes when
ringer mode is silent. This has been true since API level 1 but since
Google never can seem to decide how to handle silent/vibrate/ring
consistently it's understandable that bugs like this happen.

Change-Id: Ie3daddd51a7bba0dea86f3f58f6963d22e34cc6d
Long press to kill

Bring changes done in cm7 to ics.
- Vibrate on press
- Show message
- http://review.cyanogenmod.com/#change,5191,patchset=2

Conflicts:

	core/res/res/values/strings.xml

Change-Id: I59c6632a903695209a7ca5a3ac81b38eecf8e136
Notification Power Widget: fix xhdpi media icon scale

Change-Id: If9fa433510e68b2209158c176f9881f0fe7ccd1b
PowerWidget : Indicator observer / Hide onLongClick

Register an observer for indicator visibility.
Collapse statusbar on longClick of buttons
Remove highlight

Change-Id: I334446ca3328aeb25c50fe25f65be5a341c7318b
Corrected error in screen backlight level
This allows for backlight to decrease when changing to dimmer location
when phone is not connected to a dock.  Previouos setting had reversed.

Change-Id: I3f9e44dec8e3deb9ecb2aeb0f775383bbd7b3d57
Keyguard: Add accelerometer override to lockscreen

On ICS tablets, by default the lockscreen will rotate irrespective
of the auto-rotate switch. Go back to Honeycomb-like behavior of
the switch controlling the lockscreen.

Change-Id: I697fe588c6a7d20e03e0f8ff5927834f8819c871
set dns correctly for p2p case

the serverAddress is added as dns if dns1 is empty
in commit aea743aaa43a833fd8ff3dc56205197583152d5f
but it was reverted by commit 2c08ede34ceb0f847cc9f996db9832f5358f8726.
so partially revert it.

without this change p2p connection raise NullPointerException and kill
system services.

Change-Id: I194fb5e4d8fb577d18cb10f61782aec1cd80220e
Make statusBar settings Scrollable

This makes SystemUI's StatusBar Settings scrollable vertically.
This allows to have more settings, in less space.
This fix is advised if you added Bluetooth Setting in it.

Change-Id: I82108215f5bf684a88f87685aab60442cf1014ac
Bring back LCD disable brightness decrease

This reverts commit 5a63233c9ca4f7aa2e57c776fb275e5c3d78d2ff
and b1b664a242ea311c7a96d7e614cc95799aa0b8b3

Patch Set 2: Do not change default LIGHT_DECREASE setting

Change-Id: I17616d17c86a2954d5c530c356b0541af5664ad5

Conflicts:

	services/java/com/android/server/PowerManagerService.java
Added Wifi/Bluetooth toggle on SystemUI

This patch regroups my two precedent that doesn't merge.
It creates the Wifi toggle
And the Bluetooth item with toggle on Statusbar settings.

Change-Id: If7f558225e67f760bfe979d6e61ed55cdecefc67
Updated strings for SystemUI. Fixes SystemUI FC when disabling Notifications.

Change-Id: I3085200c953010c9d183bbf6ff190ae3767bb1f5

Conflicts:

	packages/SystemUI/res/values/strings.xml

Conflicts:

	packages/SystemUI/res/values/strings.xml
Added CombinedBar Auto Hide (1/2)

This allows to enable autoHiding of CombinedBar like on ICS phones.
It adds a Setting in Settings> Interface> System> Cobmined Bar

Change-Id: Idaf4ff23630353102cee585c6d43593167467057

Conflicts:

	core/java/android/provider/Settings.java
	policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
Added CombinedBar Auto Hide (3/2) (FIX)

This fix shows the bar again when touching screen, as it does on GN.

PatchSet 2 fixes crash on some fullscreen apps.

Change-Id: I8fbbbddd551ee2c053efe1cd6e0666f932200e93
Changed settings to show PowerMenu on Tablets

Shows powermenu on Tablet, instead of Instant Off

Change-Id: I47175f53a014e3593834765cc733da4462986416