To fix fatal exception in system process due to NullPointerException.

Null pointer check added to avoid NullPointerException, that was
leading fatal exception in system process hence framework rebooting.

Change-Id: Ia83a6178bd575954345020ef3a792a3445323808
CRs-fixed: 483763
Reduce total number of background apps for low memory devices

Due to memory constraints, we anyway cannot fit the default number
of BG apps. So instead of killing background apps to
free up memory when launching, start with an already
reduced background set of apps.
Another side-effect is that launch latencies also improve.

Change-Id: I3ae54aa7d53ff1b81252212973646a95d2d82e8a
Note: This is for low memory devices. (~512MB RAM or less)
framework: packageinstaller :fix logical error in size calculation

fix logical error in available size calculation.

Change-Id: Ic6ce312cf1c146030a20187fcb27b24fbe4c321a
frameworks/base: Fix to remove exception in tonegenerator

- Framework reboot happens, if tonegenerator fails to create
  a track in audioflinger.
- The cause for framework reboot is, an exception thrown by
  tonegenerator if fails to init.
- Fix is to remove the exception and delete the tonegenerator
  instance.
CRs-fixed:466491

Change-Id: Ie7b87f787d8a885cc70be9af4ba9d04ecd691cc2
Fixed a leaked partial wakelock in AbstractThreadedSyncAdapter.

This fix ensures that onFinished() is always called in a syncClient
even if the application lacks the READ_SYNC_SETTINGS permission.

Change-Id: I944717e71ceae06a665f8a3b1199b41d73e12da4
Bluetooth: Disable bluetooth only if BT Sevice is connected

Bluetooth service is imidiately disconnected from the adapter
after SSR OR if any bluetooth services is crashed OR framework
is crashed. As Bluetooth  service is not connected OR Bluetooth
is not enabled, So BT disable should be ignored & bluetooth
persist setting should not be changed.

CRs-Fixed: 499116

Change-Id: I19de939346d014cdf918e11711f2d6066e55d054
platform: Remove mapping of android.permission.CAMERA to camera group

This mapping introduces security risk where any app with android.
permission.CAMERA can open camera driver directly without going
through mediaserver.

CRs-Fixed: 448868
Change-Id: Ic16880cfac0bc85a3e753ccd3261bfc455b02d1a
libaudioeffect_jni: GREF leak fix for JB

- Excessive JNI global reference in AudioEffects.
- Global references created during native setup
  are not deleted.
- Global references are deleted in setup failure
  and during native release.

(cherry picked from commit a04a2bf4563dc20c52f4d4239e01f80b220077a5)
CRs-fixed: 413633

Change-Id: Ia4340a2128850101b394e00c8e1db9db49f516fd
Pick default interface for upstream.

With multiple upstream interfaces active and connected,
we should choose the default interface for upstream.
CRs-fixed: 461266

Change-Id: Ia3bc32300a1f77f46237994d0e38e9c9886f4bea
Wifi: Fix for connection failure between third client and GC.

When third device sends a connection request to the group client, the
existing connection is terminating and also the ongoing connection not
successful.Currently as there is  no use case where third device is
connecting to GC,and the existing onnection getting terminated.This
is addressed by ignoring the new connection request from third client
to GC and the existing connection is intact.
CRs-Fixed: 467049

Change-Id: I784c38b9a4ca0c60b188b9697e3b4af4d09053cc