appops: Fix an off-by-one error that causes the location icon to stay on

Commit bdfde4fc820fad768dbc596b17507e4cdc84b850 added Bluetooth AppOps
capabilities, but it contained a subtle bug where the string representation
was added in the wrong place, offseting every operation after it by 1. This
broke the toString functionality but didn't have any consequence since this
was used for logging purposes only.

Commit b01b08928a42a626f5f1c6c18a20d786fb873d75 changed AppOps so that
operations are persisted by name instead of by index, this caused the string
representation offset to affect functionality and, among other things, one
of the consequences was that coarse location requests were being interpreted
by AppOps as high-energy location requests.

Change-Id: I319f1ac1c5910098689b4cb8645eb92c0e3538cb
Revert "Forward Port: Swap volume buttons when the screen is rotated by 90 or 180 degrees"

This reverts commit a05d448eed9b853196612c182641dad6cac6e423.
SystemUI: make long pressing recent switch to last app

With this patch, long pressing the recents key on the navigation bar
will attempt to switch to your last application in the activity stack
before the active one.

The user's current home launcher package is ignored as well as SystemUI (so that
RecentsActivity does not influence the behavior).

Change-Id: I38771e0fce16b55bb5186af47115b4e812cb60b0
Signed-off-by: Roman Birg <roman@cyngn.com>
Signed-off-by: Adnan Begovic <adnan@cyngn.com>
frameworks: allow last app action to be assigned to hardware keys

Also fix multi-user handling for 'switch to last app' and 'kill
foreground app' actions.

Change-Id: I1fb586d19b1198e6888b0f11e0a2813acf0bcd5b
Signed-off-by: Roman Birg <roman@cyngn.com>
Signed-off-by: Danny Baumann <dannybaumann@web.de>
Signed-off-by: Adnan Begovic <adnan@cyngn.com>
PowerManagerService: Optimize button illumination
The current implementation of button/keyboard illumination is a bit flaky
When the device goes into deepsleep before the illumination time has expired
the buttons stay illuminated all time

The issue is fixed with this commit by setting button and keyboard brightness
to 0 when wakefullness state is not WAKEFULNESS_AWAKE because there is no point
to still illuminate the buttons when device is already dozing or dreaming

Change-Id: I01e66462271df57a6840a9ab9f40a7b51228c736

Conflicts:
	services/core/java/com/android/server/power/PowerManagerService.java