DocumentsUI: Add a standalone File Manager

This commit adds a standalone mode to the DocumentsUI, to let
it act as a file manager/explorer.
You can browse your storage contents, open files, and delete them,
as well as do everything that the DocumentsUI can do (ie. sort
by name/size/type, list and grid view, recents, search, ...).

This gives us a consistent file browsing UX accross all apps
that uses the new documents API.

Change-Id: If73a3c100f010bdb766c843976d4fd3573ea805c
Signed-off-by: iceandfire <arhamjamal@gmail.com>

Conflicts:
	packages/DocumentsUI/res/drawable-xxhdpi/ic_filemanager.png
SystemUI: fix nav bar alignment with 4+ buttons

The menu button at the end is now a constant size,
so the separator in the front needs to also be constant now.

Change-Id: I83c33942509e6cf76750b806e828462f3df9c8a8
Signed-off-by: Roman Birg <romanbirg@gmail.com>
port: add custom bootanimation colors support

Change-Id: Icf242a584513cfe974ef42f21f37a5d10400518b
Feat: Allow users to disable safe headset volume warning (1/2)

Change-Id: I5da8e84215a7d6e4c2f9a1f21e7239826e6f9fda
Signed-off-by: Gergely Szell (sethyx) <szell@hu.ibm.com>
Signed-off-by: iceandfire <arhamjamal@gmail.com>

Conflicts:
	media/java/android/media/AudioService.java
Alarm: Add one more RTC alarm type for poweroff alarm.

Now we use type of RTC_WAKEUP for the poweroff alarm.
Actually lots of other applications also use this type.
But these applications never expect the device will
power on after it has been shut down. So we need to
add dedicated alarm type for the Deskclock or similar
applications.

Change-Id: I5df2465c46de8fe875d1581bdefe26021c8ffb33
Signed-off-by: iceandfire <arhamjamal@gmail.com>

Conflicts:
	services/java/com/android/server/AlarmManagerService.java
alarm: add JNI interface for clearing alarm

Add the JNI for clearing cancelled alarm, otherwise kernel driver
would know nothing about the alarm status. E.g. power-off alarm
would not be really cleared in alarm driver even it is cancelled
in the apps/framework.

Change-Id: I1250b3778de8961ba2a89d8ea8fa29d729bbc4e8
Signed-off-by: iceandfire <arhamjamal@gmail.com>

Conflicts:
	services/java/com/android/server/AlarmManagerService.java
	services/jni/com_android_server_AlarmManagerService.cpp
Bringup NSRM(network socket request manager).

NSRM is a feature to synchronize app socket requests
to reduce network signalling and there by save some power.

Change-Id: I6f23cc17e29e7ce12a138c747765e6bab8c126d9
Signed-off-by: iceandfire <arhamjamal@gmail.com>

Conflicts:
	services/java/com/android/server/AlarmManagerService.java
Fix alarm wakelock not being released.

Alarm wakelock was not released when the pending intent was served
by the package with a uid not the same as the one which created the
alarm.
Remove advanced for loop from PowerManagerService since the list is
modified during iteration and thus resulting to
ConcurrentModificationException error

Change-Id: I4e2ff1f4be1ad044aa350886a3ea69ee5a576f74
CRs-Fixed: 591170
CRs-Fixed: 591511
 Audio: SetForceUse config check in AudioService

 - Audio is routed to headset when BT is turned off while audio is
   played on speaker
 - Mediarouter does not have setForce device information when app forces
   audio to speaker. So while disconnecting BT, MediaRouter is routing
   audio to headset instead of speaker.
 - Added check for setforce config in AudioService.

 CRs-Fixed: 578316

Change-Id: Ie929f407bfa12eacd29cf36031024a4a6a979b63
Don't confuse stat and stat64.

Cherry-picked from AOSP: https://android-review.googlesource.com/#/c/79462/

Change-Id: I45e65036d86c58943b9c273777f3f8be79a6966f
Perform NTP lookup at Mobile data connections

If NITZ isn't supported by the current carrier the Android framework
relies instead on a remote NTP server to set the system clock. The
NetworkTimeUpdateService class polls for NTP time during the first 4
minutes after boot, failing to get NTP time within these minutes will
increase the polling interval to 24 hours. Hence, if a data connection
isn't activated directly after boot it can take a long time for the
system clock to be updated. To prevent this situation, NTP lookup is
scheduled as soon as a Mobile data connection has been established.

Change-Id: I046e0330147e7ace4b720a7e70f9d5047d42cfe6
UI not updated correctly in expanded statusbar

Sometimes when getting status changes in expanded statusbar the
text disappear. Both NetworkController and PhoneStatusBar handles
UI updates and they are not in sync. This fix allows PhoneStatusBar
to update UI when NetworkController is updating the UI.

Change-Id: I46b8a24ecc732e441f836692c6584a78d8108dff
Signed-off-by: iceandfire <arhamjamal@gmail.com>

Conflicts:
	packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
Frameworks: Update DocumentsUI for theme chooser combatibility

PS2: credit: djdarkknight96
PS3: this time, use the correct owner info
PS:4 fix typo in styles.xml

Change-Id: I121099de6c09d33ef9f02019996eac1c6f1d3731
Fix dest == src bugs in Matrix.cpp.

The main bug was that the AutoJavaFloatArray autoSrc was not passing in
read only. This meant that the destructor overwrote the data which
the autoDst AutoJavaFloatArray had written in it's destructor.
This case only happened if src == dest and the arrays were copies.
Also improved performance by passing in read only a few other places.

Bug: 12570144

Change-Id: Idc8764087dc165433c584b87a0f9d4ed0ec795e8
Secure screenshot and screenrecord

* Partial port-forward of Screenshot toggle
* Creates an android:permission for both screenshot and screenrecord,
  as well as corresponding Intents. This disallows rogue apps to access these
  methods in PhoneWindowManager ( takeScreenshot() and takeScreenrecord() ) and
  hijack our system, by locking them down to System and SystemUI with said permissions.

* This is required for the Screenshot toggle, and reimplementation of screenshot navbar action.

Change-Id: I4adac71a0ce924de96c9a7d495b42ae68441e4ad
Signed-off-by: Brandon McAnsh <brandon.mcansh@gmail.com>
Signed-off-by: iceandfire <arhamjamal@gmail.com>

Conflicts:
	packages/SystemUI/AndroidManifest.xml
	packages/SystemUI/res/values/custom_strings.xml
Screenshot Toggle

PS 3: Rebase
PS 4: Rebase

Change-Id: Ie5bdd6834a3ce4c2d2fba9bff3cce220b16ada14
Signed-off-by: Brandon McAnsh <brandon.mcansh@gmail.com>
Signed-off-by: iceandfire <arhamjamal@gmail.com>

Conflicts:
	policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
Screenrecord Toggle

* Secured with secure intent

Change-Id: Ib545d915d961e07f9a22378c8f7e5beccd5b4e1e
Signed-off-by: Brandon McAnsh <brandon.mcansh@gmail.com>
server: Treat non-default route as host route

When constructing ip route command in addRouteWithMetric,
we used to check whether the given route is a host route.
In some cases, the isHostRoute() check can return false for
non-default routes. To make this check more foolproof,
check whether a route is non-default in order to treat it
as a host route.

Change-Id: I5e396e67e1c82bbe22600c47f1e52cc7c750cdc6
ProcessCpuTracker: Fix ArrayIndexOutofBoundsException in tempSpeeds

If time_in_state file is not available mCpuSpeeds is created with size 0
and subsequent call if the file becomes available there is an
ArrayIndexOutofBoundsException.
This change avoids the crash by breaking out of the loop, also adds error
logging

CRs-Fixed: 553569
Change-Id: Id5e219ca1cd3f058f714aecd5902ec2f6c11ae03
Revert "DocumentsUI: Add a standalone File Manager"

This reverts commit 8c7ade9188c9327640fd95434d1893b5e9a11506.