Fix the issue that the top of fullscreen dialog is clipped away

The visibility of status bar comes from the top fullscreen window,
not from the focused window.
That has to be taken into account during the calculation of the
decor rect. You can use mTopIsFullscreen for this purpose.

Change-Id: I6159eb2ee389885cf5ab507157f9451841364d2f
PIE: Use case upgrade and bugfixes:

1.Play with navigation bar height instead of view state. Just set navbar height to 0, even because
  swipe gesture is disabled aswell so it will never be called. This way we handle just one var
  that is height. PhoneWindowManager will take care to calculate decors since it uses height (width
  in landscape) as a param in the calculation.
2.Remove dependency from last systemui flags. Right now before this patch, pie showed no matter if you
  were in forced or native immersive mode. That made us bring a couple of hacks to keep this marriage,
  but there is no need in the end cause PIE is an alternative way you have to enable. That means apps will (should)
  use their own immersive mode at first unless you have already PIE mode on. Not all apps hide navigation bar,
  that means they can not cover the entire screen height (portrait). That's why there is forced mode, to supply this
  cause force the app to go immersive. Last but more important, immersive API works again now :)
3.Cleanup some vars not used anymore, just need observing main immersive mode now.

Change-Id: Ia17bb7ede36d5a14c8508841e32910e6e9595310
Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
ActivityInfo: Restore default behavior for screen size changes or layout changes

This was a change introduced with PIE intended to fix an aosp bug,
test to see if we still face one or more of current immersive issue(s).

Edit: revert for now along with the other PIE work.

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Fix null pointer exception in PhoneWindowManager

mKeyguardDelegate is null and is causing fatal exception

Change-Id: Iae14b969b7ff9ab0003e615f2f82eaac65a77985
Fix to NullPointerException on move back in ActivityStack.

In ActivityTask.moveTaskToBackLocked NullPointerException may occur
when moving back with only current Activity in stack. This due to a
condition that may trigger despite a TaskRecord being null and then
attempt accessing the TaskRecord.mOnTopOfHome variable.

TaskRecord task may be set to null when no resumed activity remain.

Resolved by assuring that flag mOnTopOfHome is instead set to false
for current TaskRecord in case where there are no remaining activities
above home.

The above bug has already been corrected in the following commit,
ada62fca51d314cefe2c5da4e007df5b9abf320d, but it does not set the
cottect value to mTopOfHome for the current taks, see below.

Variable mOnTopOfHome will not be set to false in situations where
stack is of size 1 or less and task is null, perhaps from already
having finished current activity.

To avoid current TaskRecord maintaining value mOnTopOfHome to true
after launching Home this variable is set to false.

Impact should not be major due to correction earlier that makes sure
that there is always a TaskRecord.mOnTopOfHome set to true above Home
activity but if not correctly set for current task still gives a
possibility of bad behavior.

Change-Id: Ie86ad99c188aaa05b0de9d58eaa16c42b6fc4341
Fix fatal exception due to missing looper for current thread.

While creating handler for the thread, there was fatal exception getting
thrown because the present thread does not have a looper. So passing the
applications looper to be used , while creating the handler to avoid this
exception.

Change-Id: Id2e3ed61f5691c8319eb7bc20ad970eb6758e765
(cherry picked from commit f5d1769b4357fb8d86fc31f7115b55b567a20ed1)
(cherry picked from commit d0a7c5833b90fe4d8fe8f968b53a7028720ffd8c)
Check for null in LocalSocketImpl.SocketInputStream.available()

Calling available() on a local socket after close() will cause a native
crash. Other methods that pass LocalSocketImpl.fd to native code copy
the fd and check for null.

https://android-review.googlesource.com/#/c/90900/

Change-Id: I2d0b573f34ae47a23009760bbb1c02933ab0a20e
Signed-off-by: houst0nn <houstonn@gmail.com>
Fix a NPE when putting a null-Bundle in an Intent

Happens frequently e.g. with GoogleAccountAuthenticator

Change-Id: I284bf153f40ee9cc3e70bce6efcc3b9e6706361b
AudioService: fix cross deadlock in VolumeStreamState

Synchronize modifications of volume index by VolumeStreamState
class mutex instead of using synchronized methods.
This avoids possible cross deadlock when modifying volume on
two stream types simultaneously and one is slave to the other.

Bug: 13730145.

https://android-review.googlesource.com/#/c/94255/

Change-Id: I13406c71010ce0c2e2f08f660b6101f310396c98
Signed-off-by: houst0nn <houstonn@gmail.com>
Activity chooser "Always" button is not working

When ResolverActivity is created with a custom list of matching
applications (rList) as in NFC case, and the alwaysUseOption is
set to true, the prferredActivity is not saved even if the user
presses the "always" button.

When a list is provided the variable mBaseResolveList will be
!= null. This will set mOrigResolveList = null.

When an activity is choosen and one of the buttons are pressed
onIntentSelected is called. The first thing this method does
is to check mAdapter.mOrigResolveList != null, however in this
case mOrigResolveList is always null, and the value is not
saved as PreferredActivity.

This problem was introduced in
6d8dfbd8149942f25f2b9643a12f1fb38f3be834.

https://android-review.googlesource.com/#/c/95336/

Change-Id: I9eac41b7861b5e68ad3978af0dc0285f2a34eb88
Signed-off-by: houst0nn <houstonn@gmail.com>
Minor cleanup of UsageStatsService

code cleanup, whitespaces

https://android-review.googlesource.com/#/c/92738/

Change-Id: Idea0e29f347d14e48e87aad38a261d0493bd5fd3
Signed-off-by: houst0nn <houstonn@gmail.com>
Keydispatching timeout while finish Activity

If there is input to be handled during finish activity we can get a
keydispatching timeout ANR. The reason is that finish activity is some
times not possible, and the activity is instead put on a finish queue.
The activity will then be finished sometime in the future. When we add
the activity to the finish queue, key dispatching is paused, and there
is an ANR timer waiting for it to be resumed again. Since it can take a
long time before the activity is actually finished, we need to resume
the key dispatching to avoid the ANR.

Change-Id: Icea4ab3b5ad05c8bfbadf8f5cece1a59ec621469
SystemUI: Fix missing top task in recent panel.

If preloadRecentTasksList was not called or was called too
late and RecentsActivty already started and last top activity has
excludeFromRecents flag setted it might be missing
from recent application list.

Change-Id: Idf7153824805ceea9fcaf04ac645b73a5e93a4d9
Quicksettings: Set proper dual tiles visibility when recreating them

Every time QS are recreated, set back visibility to GONE, so after applying
a theme with transparent background QS front tile doesn't show its back one behind.

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
PIE: Improve assistant handling

Run it from SearchPanelView and determinate before, at PieMenu creation,
if we have any assistant available or not.

Some cleanup too.

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Change-Id: I986a5e5257f432acd58dd2d75fc13f2b772c7453

Conflicts:
	packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
Quicksettings: Add separate dimension for dual switch icon

Support Themers (for ex the ones who change QS icon sizes).
Right now it streams default one that is themed, and a bigger icon
theme will mess it up.

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>

Conflicts:
	packages/SystemUI/res/values/blak_dimens.xml
Quicksettings: quick pulldown: try to fix pulling down the wrong side

getWidth() may return 0 when NotificationPanelView isn't laid out yet.

Change-Id: I32f423decf42d08466cbe73bd23ccf70ce66e093
Signed-off-by: David96 <xD_e-mail@gmx.de>
PackageManagerService: Fix concurrent access to shared state

Stop multiple threads from all calling add on the same HashMap.

Cleanup the use of a boolean flag by removing concurrent writes
to it.

Change-Id: I8d61fe7294dcb67ee7d0d7de88d90d2051c310e6
NotificationHelper: Define Peek app broadcast intents

Continue this https://gerrit.paranoidandroid.co/#/c/4369/

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>

Conflicts:
	packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHelper.java
PEEK: Sensors improvements

- Bring some fixes to the algorithm thanks to @D4rKn3sSyS
- Cleanup

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>