Media process is crashing with NullPointer exception

Sometime, while creating thumnails list of media files in
compose MMS->attach file,  filepath may be null due to
synchronization issue.
Adding NULL check to avoid NUllPointer exception.

Change-Id: Id6cf5612a959b3ae15b44bc60dbbcbe40c624f09
CRs-Fixed: 636494
wallpapercropper: OOM issue while opening *.bmp image

This change manages setting of large images as
wallpapers without encountering OOM.

CRs-fixed: 619815
Change-Id: I3a32ec4b42050b146076f0adf6b6e65afd6fae4e

Conflicts:
	packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java
frameworks/base: Fix change propagating issue

destroyLayer() function has been modified in kk. It is not correct
to propagate the UI corruption fix from jb to kk without considering
the new changes made in kk. This change is to make it align with
the new code in kk.

Change-Id: I34d11b230b9390fe8a989ab6f9c7d3a48d586205
Fix a NPE when putting a null-Bundle in an Intent

Happens frequently e.g. with GoogleAccountAuthenticator

Change-Id: I284bf153f40ee9cc3e70bce6efcc3b9e6706361b
Bluetooth: Adds check to verify Bluetooth adapter state

This checks whether bluetooth is turned ON or not in
BLE stop scan process. BLE scan apis are called from applications
so need to check if BT adapter state is ON to avoid Bluetooth
crash

Change-Id: Ifc472be9b3f8baf978d6cdca2e4743a75b951635
CRs-Fixed: 634617
Bluetooth:Settings:Handled ACTION_STATE_CHANGED intent at boot time

BluetoothAdapter.ACTION_STATE_CHANGED intent is added to foreground
activity to handle BT sync issue with  Power widget at the boot time

Change-Id: Ib26cb4630c711587da789dc920aa66ded97a9a3b
CRs-Fixed: 576879
Send Media button events as foreground Intent

Send foreground intent for Media Button events to Music Player
so that there is no delay in handling these Intents after the
device is rebooted.

Change-Id: I952a8af93586cb96c0a9f6dc910bfb49287f4b9a
CRs-fixed: 611219
Fix Javadoc link for getModifierBehavior()

Change-Id: I571db5147a081fcd7190483ba9e7a45b46db224d
resume: fix recents showing up when waking the device with the home button

Screen is on but dispatcher is not enabled yet.

Change-Id: Ib98d595563ed3df5c7a1e6e4d5a4da83a721537c
Fix problem with BootAnimation exit

After the completion of each animation part, the boot animation must
sleep for the number of frames specified in part.pause. If this is
done in a single sleep statement, it is possible that the boot animation
will continue to display long after surface flinger has finished booting.

To address that, the pause between parts is done in a loop and on each
iteration, the property that surface flinger sets to indicate that animation
should exit is checked.  This minimizes, but doesn't remove, the likelihood
that the bootanimation is visible when the UI comes up.

Change-Id: Ib71df0a72c0a47a1f7231b02379dc951c1f93e52
Signed-off-by: Russell Webb <russell.webb@intel.com>
Fix issue in PhoneNumberUtils.compareLoosely

There is an issue with MMS delivery report where
even if the report was received the status is shown
as pending.

If the number of matched digits is greater than or
equal to MIN_MATCH and if one of the input strings
index has reached the lower limit,
PhoneNumberUtils.compareLoosely should return true.
Currently, it doesn't return true as it is expecting
the index to be < 0 which will not happen for the
following case where country code + number is without
"+" prefix or the number is without country code-

This patch fixes the issue by checking the index <= 0.

Change-Id: Ia16723f8d2b94ddf282ab6b0ab9892d34323902d
Signed-off-by: Jeevaka Badrappan <jeevaka.badrappan@intel.com>
Signed-off-by: Arun Ravindran <arun.ravindran@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 64234
Tunning max allowed background services

The serialize running of background services feature
delay some services startup when system bootup, and
lead some abnormal behaivor at the early of system startup.
Tunning will be disabled after system complete bootup.

Change-Id: I834607d9156253bee13848586a8136e24760fdf4
SpellChecker: bound check for string end

Check whether spell check result is out of end of string
Use strict one to avoid IndexOutOfBoundsException.

Change-Id: I6acac77e1e9750258ed364817a8615a6f56bebe4
[ActivityManager] Ensure consistency behavior when a background activity brings another existed activity to front.

Symptom: ANR occurs on previous activity.
Root Cause:
In KK, when a background activity starts another existed background activity (bring to front),
if current focused stack is not the same as the stack of target starting activity,
it will still resume the top of target stack, even the top activity on the target stack may not the same as target activity.
And it will result incorrect focus, press back key will send to previous stack's top then popup ANR on previous activity:
"Reason: Waiting because no window has focus but there is a focused application".

By original code comment, it looks 'bring to front' should not happen in this issue case.
// If the target task is not in the front, then we need
// to bring it to the front...  except...  well, with
// SINGLE_TASK_LAUNCH it's not entirely clear.  We'd like
// to have the same behavior as if a new instance was
// being started, which means not bringing it to the front
// if the caller is not itself in the front.

If the caller and target are in the same stask, it will just deliver new intent without changing task order (the same behavior as JellyBean).
So the patch concept is just to avoid to use target stack to resume top when caller and target are in different stack.

Solution: Do not allow to resume another stack top if non-top activity try to bring existed activity to front.
It may not be a good solution, just a reminder for the issue case.

Reproduce steps:
Assume A, B, C are different app tasks.
When the application stack is like:
  Top C
      B
      A

 #Case 1: Home is foreground
  A starts B with NEW_TASK, C will resume, focus still stays at Home, and window order does not update.
  Then press back key or volumn key will result ANR on Home.

 #Case 2: App is foreground (Resumed activity is C)
  A starts Home, Home will resume, focus still stays at C, and window order does did not update.
  Then press back key or volumn key will result ANR on C.

Change-Id: If05070123b248e2335791e43a4d4ddee6db11d84
WallpaperManager: add NULL pointer check for getCropAndSetWallpaperIntent

Originally the api 'getCropAndSetWallpaperIntent' does not check
whether the parsed parameter is a NULL pointer, as leads to the
whole app crash if it call this api with a null parameter accidentally.
A null pointer check logic is added into its original parameter check
logic, so that this API will throw an IllegalArgumentException if it
is parsed with a null pointer

Change-Id: Ib7de40e571419d09e1a744edc969eb7162766b75
Signed-off-by: houst0nn <houstonn@gmail.com>
Release DrmManagerClient resources

Call release for DrmManagerClient to avoid resource leaks

Introduced by following commit (5d143ad4a8f...),
"Media scanner support for FL(Forward Lock) DRM file types"

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

Change-Id: Ic3c458579f4e99b3b072a2e13362d1996b982589
Signed-off-by: houst0nn <houstonn@gmail.com>
Add the calling package name to requestRouteToHost

The calling package name will be used to check if an application is a
system application when deciding if a route should be exempt from VPN
routing rules...

Bug: 12937545
Change-Id: I2c09c875fe9bb9685871a0a801ddcbb32fc17405
Only allow System apps to make VPN exempt routes

requestRouteToHost will only allow system applications to make routes
exempt from the VPN's routing rules.

If a VPN is currently running and a non-system app requests a route it
will only succeed if that host is currently covered by a VPN exempt
routing rule. Otherwise it will fail.

For example, if a VPN is running and the MMS network is brought online
those routes will be added as VPN exempt. If an application then tries
to request a route to a MMS endpoint it will succeed because the routes
already exist. If an application tries to request a route to a host
covered by the VPN the call will fail.

Bug: 12937545
Change-Id: If7bcec91bbb96c62c8fb69748c975847e6c00b6f
Update LinkProperties with MTU value

Use the MTU provided by network as part of Data Call Response.
If it is not present, use the static value from config file

Change-Id: I9d03cc9b355d09a93883fbf4ddc93fae0077641c
CRs-Fixed: 634747
Connectivity: Set TCP delayed ACK and User Configuration Flag

Provide a Mechanism to set tcp delayed ack settings from
Connectivity Service. The tcp_use_userconfig flag is set to
override the default tcp delayed ack configuration in tcp stack.
tcp_use_userconfig flag is reset when the TCP stack is required
to use default delayed ack settings. Currently the delayed ack
settings are overridden for Wifi and LTE networks only. Other
network types continue to use default delayed ack settings

Change-Id: I282ef0f6b6278b6efcef3870242974f7ee93e508
CRs-Fixed: 628139