Forward Port: Add Camera sound toggle [1/3]

Change-Id: I9e90f606d528eea08a41c35e75cd189e765c5d97

(cherry picked from commit 44dbdef0b7d91b508bf833667ce79d3f5ac89cbf)
Change SQL to improve performance.

To know the number of images, use "COUNT(*)" instead of "_id" in SQL.
Using "_id" gets all result set. and when getCount() is called, CursorWindow is filled.
But using "COUNT(*)" gets just 1by1 data.
So using "COUNT(*)" is more faster than now.
And this SQL is called everytime per a file during a file transfer in MTP
The better way is by using "EXIST".
But if using "EXIST", modify MediaProvider.call() method.
So i applied just a "COUNT(*)"

Change-Id: Ic5882af0fad2304f836b7b7043a4746359391609
Signed-off-by: muzbit.kim <muzbit.kim@lge.com>

(cherry picked from commit fe0765859e9fed912aec3efc45c885d5212324af)
MediaScanner behavior on boot (1/3)

Lets you enable/disable/ask (with a notification) media scanning on boot.
Can speed up boot and reduce initial boot lag from MediaScanner

Change-Id: I634ae96b1dcb493b966b4653589cd97523b63da7

(cherry picked from commit b2e664b047e41befcc452de766d9f54b4a92d9ec)
remove search bar in recents menu

Signed-off-by: Yashar Ahmedizadeh <yashade2001@gmail.com>
(cherry picked from commit 70d12420053e7d5277c9395a2abacf3f63bad07a)

(cherry picked from commit c185c83eebb1a3df9ed5ed414084730198de3894)
Default google backup - false

(cherry picked from commit 030bdd4bb1d52be7b3ae65ea11f514cbbaca74d3)
ANR caused by incorrect cleanup in BroadcastQueue.

Two broadcasts could be sent to the same app simultaneously:
one foreground, one background. For example, LOCALE_CHANGED
and PACKAGE_CHANGED are delievered to com.android.vending
at the same time.
1. AMS started new vending process to handle LOCALE_CHANGED.
   And set app.curReceiver = LOCALE_CHANGED.
2. Before LOCALE_CHANGED is handled by vending process,
   PACKAGE_CHANGED was delievered to vending process too.
   AMS set app.curReceiver = PACKAGE_CHANGED. Bad!
3. Vending process finished handling LOCALE_CHANGED.
   AMS clear app.curReceiver = NULL. Bad!
   And Vending process  killed itself without handling
   PACKAGE_CHANGED.
4. AMS known vending process has died, but didn't know that
   BgBroadcastQueue was still waiting for finish message
   for PACKAGE_CHANGED.
At last, BgBroadcastQueue reported ANR for PACKAGE_CHANGED.

This patch adds protection before clearing app.curReceiver,
only set to NULL if the finishing receiver = app.curReceiver
So handleAppDied would know that PACKAGE_CHANGED was not
finished yet, it will abort the broadcast and continue.

Change-Id: Ic4f31b35e21823d4a3c27712391ecbede213a494
Signed-off-by: Guobin Zhang <guobin.zhang@intel.com>

(cherry picked from commit 3eb195804271b36ce2a32172491c58b3f1c20202)
Fix Presentation window is removed on stack change

If an activity show a Presentation window and this activity is moved
to bottom or top, thus this Presentation window will be removed from
its display window list, and no chance to be added back into window
container; It will cause the incorrect state that Presentation window
is lost from secondary display window list(displayContent.mWindows),
but still exist in app token's window list(appWindowToken.allAppWindows);
Moreover, once this activity resume again, Presentation window is not
shown because it's lost.

In this way, don't remove non-target display app windows due to only
target(or called default) display windows are removed temporarily and
re-sorted then added back into window list later.

Change-Id: I8960ce191f6c662455cba5a0a5e6a1ff9ef03ae1
Signed-off-by: tingna_sung <tingna_sung@htc.com>

(cherry picked from commit 96625654ddc92d77cb997f60a444d4ce12f8f29f)
Sync focus stack frame and layer with focus app.

Update focus stack frame/layer when focus app is changed to avoid
focus stack/layer isn't updated synchronously with focus app, it's
due to performLayoutAndPlaceSurfacesLocked() is not necessarily
called on focus app change; it will cause sending mismatching
TAP_OUTSIDE_STACK message if there is effectual incoming pointer
event, hence may also result in focus stack is changed again,
therefore erroneous focus app is set by ActivityManager at final.

Change-Id: Ia0ec9a543be887b51a3b29b3e62fdd471c15edf2
Signed-off-by: tingna_sung <tingna_sung@htc.com>

(cherry picked from commit 261c239feb50bd102d8b9e54b22025017dbdbd7a)
Not include fullscreen opaque window on screenshot

Extend the fullscreen meaning by adding opaque drawn check on
screenshot application; if there is a fullscreen window but not
opaque, we will continue finding behind windows; otherwise ending up
including behind windows. It's able to help avoiding capturing BLACK
screenshot bitmap.

Change-Id: I1c7e8f513c366688ea8001c3d0c799f3522f0ffd
Signed-off-by: tingna_sung <tingna_sung@htc.com>

(cherry picked from commit 3170548c62abb6e2372d07a45589e954dc79925a)
Measure absolute value of pointer motion distance

If pointer is moving to the negative axis direction, pointer movement
distance will always less than pre-defined mMotionSlop, thus
TAP_OUTSIDE_STACK will have chance to be sent, will cause unnecessary
focus stack switch.

Change-Id: Ia4c066bebce250257c7361ef976907a0ca2c6461
Signed-off-by: tingna_sung <tingna_sung@htc.com>

(cherry picked from commit 66700c723b0125018795beea06bfab8af6f39f6e)
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: I6dec474266faa5de67449c1bbe6ef30791e5ecaa

(cherry picked from commit b461f80a6b94ff9266c6b01f46946790b025b98e)
Add window to child window list with correct order

The original logic of comparing with mBaseLayer of two child windows
of the same parent was wrong, because the mBaseLayer is always the
same.

After adding two child windows with the same positive sublayer, the
one added later should have greater z-order. The order should be
consistent with WindowManagerService.addAttachedWindowToListLocked()

Change-Id: I789179aee61d141fad86bd24262fabfb1e517e66

(cherry picked from commit e7cd76d5ecdd21f0f86ae4be1d8a32be22635d3f)
Intercept Home button press to wake device

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

(cherry picked from commit 3ddf1931eba0b1d9e7025d902fba04129cd32d85)

Conflicts:
	policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
Frameworks: Option to enable/disable HOME button wake

Dependency commit:

Intercept Home button press to wake device
https://github.com/temasek/android_frameworks_base/commit/3ddf1931eba0b1d9e7025d902fba04129cd32d85

(cherry picked from commit 56a65db31a0048aa4f07fe6d3fecc5b6e0613a37)

Conflicts:
	core/java/android/provider/Settings.java