Merge tag 'android-5.0.0_r6' into lollipop

Android 5.0.0 release 6
Merge tag 'android-5.0.0_r7' into lollipop

Android 5.0.0 release 7
Start MountService before performBootDexOpt

This change is to start Mountservice before starting
performBootDexOpt, as in one case, in performBootDexOpt
when system upgrade happens, StorageManager will be started to
get the low threshold of DataDir. But, at this point, as
Mountservice is still not up, StorageManager will end up
having a null object of Mountservice.

Change-Id: If2b5e1b58e7d2a72c6313f196e98a68738295ec6
Be increasingly aggressive about fstrim if it isn't being run

The current heuristics depend on devices being alive at midnight+ in
order to run periodic background fstrim operations.  This unfortunately
means that people who routinely turn their devices off overnight wind
up with their devices *never* running fstrim, and this causes major
performance and disk-life problems.

We now backstop this very-friendly schedule with an increasingly
aggressive one.  If the device goes a defined time without a background
fstrim, we then force the fstrim at the next reboot.  Once the
device hits the midnight+ idle fstrim request time, then we already
aggressively attempt to fstrim at the first available moment
thereafter, even if it's days/weeks later without a reboot.

'Available' here means charging + device idle.  If the device never
becomes idle then we can't do much without rendering an in-use device
inoperable for some number of minutes -- but we have no evidence of
devices ever failing to run fstrim due to this usage pattern.

A new Settings.Global element (type 'long', called
"fstrim_mandatory_interval") is the source of the backstop time.  If
this element is zero or negative, no mandatory boot-time fstrim will
ever be performed.  If the element is not supplied on a given device,
the default backstop is 3 days.

Adds a new string to display in the upgrading dialog when doing
the fstrim.  Note it is too late for this to be localized, but since
this operation can take a long time it is probably better to have
it show *something* even if not localized, rather than just sit there.

Bug 18486922

Change-Id: I5b265ca0a65570fb8931251aa1ac37b530635a2c
Properly recognize repeating wakeup alarms

cherry-pick from lmp-mr1-dev

The code in place was inappropriately treating all recurring alarms
as non-wakeup for purposes of deferral.  Worse, it was overriding the
"this deliverable batch of alarms includes a wakeup alarm" bookkeeping,
so could potentially cause inappropriate deferral of even standalone
wakeup alarms.

Bug 18591317

Change-Id: I2a62ed4badcaeb549c1ac4f086014aa829e45427
(cherry picked from commit 864d42eb96a9127b7d2f10ad11e709c24b4b4304)
Tune delivery and batching of alarms

cherry-pick from lmp-mr1-dev

* Inexact alarms no longer coalesce with exact alarms.  The motivation here
is that exact alarms are far more likely to be wall-clock aligned, and in
general pulling all alarms toward wall-clock alignment is a bad idea.

* Wakeup times are now fuzzed within the target batch's allowed window
rather than being hard pinned at the start of the window.

Bug 18631821

Change-Id: Iefaf34eee3f2a6546abefc27e177ee2fdcff935f
(cherry picked from commit 81f9882b5aadd6a2289c9f521a06a7af5f35ebf0)
Revert "SystemUI: Add data type and signal icons"

* These aren't used anywhere and are still Holo

This reverts commit 4e5e6d4cd8e56755d3e4cdaf08ede0e7ee3c82dc.

Change-Id: I39c6060766b2f75dd1362d945be31f6f9d20f59d

(cherry picked from commit e3a5a496e1bbe3a8e9b3e82b61b465e828c09b5b)
Status bar: Add HSPA+ icons

Forward port H+ icon in the status bar when connected to HSPA+
Uses new vector drawables by @blunden

PS1: Initial commit
PS2: New vectors (thanks @blunden)
PS3: Cleanup
PS4: Use correct indentation (oops)
PS5: Show correct icon in status bar (thanks @mikeNG)
PS6: Remove leftover Holo icons (thanks @mikeNG)
PS7: Rebase to depend on Holo icon removal (thanks @mikeNG)
PS8: Update commit message

Change-Id: Ia745c524d5e2530f50f12f961ea8533a4c8f5842

(cherry picked from commit a3531ba579cbab8d103fa0db8e1b197ef031c103)
platform/framework/base: Fix Half Blank screen issue in Wallpaper

Issue: Start Any Full Screen Activity/ VideoView Activity in
       portrait mode, change to landscape mode and then perform
       suspend and resume. Only Half of the screen has display,
       the other half is blank screen

Fix: Added a check to update surface size on both rotation change
     and surface size change.

Change-Id: Iba77dfdb778ea3c60bbb1df33188fd4f792ab77c
CRs-Fixed: 712741

(cherry picked from commit 7a57a1381df2bec3c92ec62a4fd6c8b0c1538ae4)
VideoView: Add logs for video start/stop profiling

Add logs to profile video start and stop latencies.

Change-Id: Ic7f6237ee932a5c07828b1d0010dcb0fd3175411

(cherry picked from commit be613aabe03fa922f63db63e5658a8f0694d43c4)
Revert "MediaMuxer: handle expection for add track"

This reverts commit 0e57858602657ccbb22d6f592831f6e2547cc4ef

Change-Id: Ia9b4969a660a9816b1698fabd5456400fca84563

(cherry picked from commit 3aafaaff4a4adb65e1c302fb90b57ed22846ccf4)
audio: fix unresolved link error for javadoc

- Remove @link comments for extended audio
  formats to fix unresolved link error while
  compiling Javadoc
- These extended audio formats are not standard
  AOSP definition and should not be updated for
  javadoc

Change-Id: I34fec0d9709a7def0f92660b6ec0a8e971529161

(cherry picked from commit 0f7840f0db84cf12e0a55a06c7d8f06f27ea4266)
Download: use "control" column to mark paused/resumed status

Before, column "status" is directly updated when user pauses/resumes
download, this causes status shown to user is not same as real status
because pausing/resuming needs a little time not instantly, and then
causes some status error.

The column "control" is updated instead of "status". When user pauses
download, will update "control" as CONTROL_PAUSED and set "status" as
STATUS_PAUSED_BY_APP until pausing operation is finished; and when
user resumes download, will update "control" as CONTROL_RUN and change
the status as STATUS_RUNNING until DownloadThread is started to run.
Then the status shown to user will be same with real download status.

Change-Id: I2204b972d24b809f7914b0981cad11e9175f4ae6
CRs-Fixed: 737182

(cherry picked from commit b575b8c8c37d8fad39ae26187293b5282e9e71ea)
Revert "camera2-legacy: Workaround max jpeg/preview size AR mismatch"

- This reverts commit a0496d34ffc5153bf933cacbd4be71a4a1bd4041,
  because it breaks CTS test cases:
  'android.hardware.camera2.cts.RecordingTest#testBasicRecording'
  and 'android.app.cts.SystemFeaturesTest#testCameraFeatures'.
- Above change causes all video sizes that doesn't match
  the largest still image aspect ratio to be threated as
  non-supported (not looking reasonable).

CRs-Fixed: 747378
Change-Id: Ib38b39e6ba575b4644cdaeb94391068845337044

(cherry picked from commit 0d057bc737730b2867fead3ab4416855d96cdf6e)
SystemUI: kill MSim logspew

Change-Id: I64ce4e61402d43d4d12ef6a80a9cb42b2fb2979a

(cherry picked from commit d2b03e3e2af9b2a45d4ada0df35b6163e4a118da)
WiFi : Fix to DHCP to static IP configuration problem

WiFiStateMachine shall update the IP address configuration to
the kernel through NetworkManagementService.This notification
from the kernel is again sent to the connectivity service
through the NetLinkStateTracker and WiFiStateMachine.
Thus ,if the interface is down during this IP address
reconfiguration (for the case of DHCP to Static IP configuration),
Connectivity service shall be notified with old IP address ,NULL(0)
IP address(signifying interface down) and the latest IP address.
This notification was done by updating the IP address using a local
variable , and hence the second notification on the interface down
is over ridden by the last notification , resulting in missed
interface down notification to the connectivity service.This
resulted in failed data connection when IP address is changed from
DHCP to IP on the fly.
Hence ,this gerrit enhances the design and also pass the updated
IP address to the connectivity service.

Change-Id: I50cd0502c5f8259b1325ed68de870b592d96ae22
CRs-Fixed: 750277

(cherry picked from commit 8a1edcd0d8b35dfcd75675c51830df75933df23e)
Wifi: Add a flag to indicate duplicate network

Add a flag to indicate if a wifiConfiguration is duplicate or not
This flag decides whether the previous network history along
with IP and proxy configurations are required to be copied
or not.

Change-Id: I663d985031c82e64f889044441daee70d17e5ddc
CRs-Fixed: 760505

(cherry picked from commit ad840fa2748552b153f16853ad8330dbc4b93705)
Revert "wlan: Provide runtime option to enable or disable rssi threshold (base)"

This reverts commit b95c030a6ffa22b8c96d5358ee34ed835085a172.

RSSI threshold parameters are now user configurable.Below are the
parameters.
THRESHOLD_UNBLACKLIST_HARD_5G
THRESHOLD_UNBLACKLIST_SOFT_5G
THRESHOLD_UNBLACKLIST_HARD_24G
THRESHOLD_UNBLACKLIST_SOFT_24G
THRESHOLD_INITIAL_AUTO_JOIN_ATTEMPT_RSSI_MIN_5G
THRESHOLD_INITIAL_AUTO_JOIN_ATTEMPT_RSSI_MIN_24G

Hence reverting the gerrit

Change-Id: I0d589cd494a488a4618434314e76fefde1275abd
CRs-Fixed: 757958

(cherry picked from commit 314b196cdc366824f025f8f0a614f878391a26f3)
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
Fix bad alarm delivery

The man bent over his hourglass,
A programmer of sorts. The day was green.

They said, "You have a blue hourglass,
You do not fire alarms when they're asked."

The man replied, "Alarms as they're asked
are changed within the blue hourglass."

And they said then, "But fire, you must
Alarms beyond us, yet themselves,

Alarms within the blue hourglass
That trigger exactly when they're asked."

 ---

Fix the delivery-fuzzing semantics that had been introduced in
81f9882b5aadd6a2289c9f521a06a7af5f35ebf0.  That patch turned out
to be incomplete; in particular, alarms scheduled later might require
the validity of an already-scheduled kernel alarm even if they did
not affect the head alarm batch directly, and this was not being
addressed.  For now, roll back the fuzzed delivery logic entirely.
(This is not a full revert because that patch also caused exact alarms
to be considered standalone for batching purposes, and we need to
preserve that new policy.)

Bug 18726690
Bug 18765436

This is a 'git revert' of 81f9882b5aadd6a2289c9f521a06a7af5f35ebf0
*except* that this CL preserves the "exact alarms are treated as
standalone" portion of the original patch.

Change-Id: I54c763775877de5b6eeb5617544aa6100bb17526