Frameworks: Policy: implement a pin keypad shuffler [1/2]

this is to further prevent people using the tablet guessing your pin based on fingerprints left on the screen
example of the expected outcome - https://www.dropbox.com/sh/r3xb2q53ksaqni9/Oz1Eu8Dm7O

- correct coding style
- added reload button

PatchSet:
- simplify shuffle code
- fix over shifting in some cases
- add reload button functionallity
- add lockscreenutils method to detect only PIN lock
  for settings
- exclude sim and simpuk PIN lock
- add drawables for reload button

PatchSet
- cleanup

PatchSet:
- fix shuffle NumKeyPad even if a theme replaces the xml
  and reload button is not present.

PatchSet:
- add mode disabled/always/on request

PatchSet:
- add nicer drawables

cheers

kufi

Ported to new keyguard package on LP

A bit rewrite of this feature + clean up and shorten aosp code

Conflicts:
	packages/Keyguard/res/layout/keyguard_pin_view.xml
	packages/Keyguard/src/com/android/keyguard/KeyguardPINView.java
	packages/Keyguard/src/com/android/keyguard/NumPadKey.java

Change-Id: I6cf23a70a24ff0d640850d35acd4584e2e8d2192
Keyguard: shuffler - be sure klondikeText is visible if needed and poke a wakelock...

if the user press the random key

Change-Id: I0f599928085f333e4f8d1ced06644c43917cc27f
Keyguard: Correctly set the visibility

What a day. Small derp due that the keyguard does not gets every time reinflated
we need to ensure that the visibilities are set correctly if the user changed the
configuration.

Sorry for 2 fix commits today

Change-Id: I2c7f4501c3ef589e515afe6d5ca07c1286bed5f3
Keyguard: Fix another derp and check against null

good night

Change-Id: Ia31af94024fa9884153015be807bfc89dc5502f7
Revert "Frameworks: Option to enable/disable HOME button wake"

This reverts commit 56a65db31a0048aa4f07fe6d3fecc5b6e0613a37.

Conflicts:
	policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
Revert "Intercept Home button press to wake device"

This reverts commit 3ddf1931eba0b1d9e7025d902fba04129cd32d85.
fw/base: allow home button to wake device [1/2]

Change-Id: I2b79561dcfa7e569b2e24bbabfffb11517d4d313

Conflicts:
	policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
Fix option to disable searchbar in recents
Keyguard: do not hide confirm button if quick unlock is enabled

We need it on the views for simPin and simPuk

Change-Id: I2ad6ae78a992edd9205203409db639e862e825b3
Keep deleteIntent when copying Notification attributes

Ensures that any previously registered deleteIntent is retained after a call
to Notification.setLatestEventInfo().

Currently, a call to setLatestEventInfo() effectively erases a previously
registered Notification.deleteIntent, which results in the app never being
notified when the user dismisses the notification.

This issue is described in detail in #73720:
https://code.google.com/p/android/issues/detail?id=73720

Change-Id: Ie58bf6a310058d40beb0d1af6506e9e1f4324b37
Signed-off-by: Sean Barbeau <sjbarbeau@gmail.com>
Consider RTL layout in DPAD navigation in AbsSeekBar

Changes the behavior of onKeyDown for DPAD_LEFT/RIGHT when in RTL
to move the progress in same direction as the DPAD key suggest.

Change-Id: I776a48711571884a10ef9315de78bf4ebffd6e4b
bug fix possible NPE while startProcessLocked()

In case, process doesn't create well while startingProcessLocked().
There is possibility to make NPE.
Setting app's crash handler needs to be assigned after null check routine.

Change-Id: I67fb6427f72d93f79fed36eb44c47d37eafdac31
[ActivityManager] Invalidate last screenshot when activity relaunched

Symptom:
The task thumbnail is not updated when activity relaunched.

Reproduce Steps:
1. Put device in portrait
2. Launch Calculator
3. Launch Recent App (the Calculator's screenshot is correct)
4. Rotate device to landscape
5. Click Calculator in Recent App to return to Calculator (Calculator has relaunched to landsacpe ui)
6. Launch Recent App again (the Calculator's screenshot is not updated)

Change-Id: I92e951ea2ee215c52ca6e50cf6f9e02deb787bce
Avoid capture all black screenshot bitmap

Captured screenshot bitmap is all black one if none of windows is
surface shown.

Change-Id: I651b2ade1865926d61f945167d60219535fa8bf8
Signed-off-by: tingna_sung <tingna_sung@htc.com>
[ActivityManager] Ensure provider external access count will be released.

Sympton: Oom-adj of provider process will be always 0.

Root Cause: Exception happend in openContentUri
may not call removeContentProviderExternalUnchecked.

Flow:
application [MediaPlayer.setDataSource(Context context, Uri uri)]
    uri is invalid, IOException will be caught and below log will appear:
    "Couldn't open file on client side, trying server side"
    Continue to call setDataSource(String path, Map<String, String> headers)
 ->mediaserver [MediaPlayerService::Client::setDataSource]
    setDataSource(httpService, url, headers) calls openContentProviderFile
 ->system_server (ActivityManagerService) [openContentUri]
    Increase externalProcessNoHandleCount for media provider.
    Call [openFile] to media provider.
 ->android.process.media [check permission for openFile]
    enforceReadPermissionInner
 ->system_server [checkComponentPermission]
    Use mediaserver's uid to check READ_EXTERNAL_STORAGE
      -> not granted due to it is pure native process, not a known package.
    Throw security exception then the flow of openContentUri is broke.
    And externalProcessNoHandleCount is unable to decrease.

Application sample code:
 String invalidId = "54321";
 Uri externalUri = MediaStore.Files.getContentUri("external");
 Uri uri = Uri.withAppendedPath(externalUri, invalidId);
 mediaPlayer.setDataSource(mContext, uri);

Solution: Move removeContentProviderExternalUnchecked to finally block.

Change-Id: I75eec1f9631e9c6bb18449946d707d51ac21e8a7
[ActivityManager] Prevent provider from been created twice.

Root Cause:
If a process which contains provider is starting but not
from accessing provider, e.g. service/activity/receiver,
its providers' will be created during handleBindApplication.
And before the process complete publish provider to
ActivityManagerService, if there is an access call to
process provider before the process completes publishing
providers to ActivityManagerService, then the providers
will be created again.

Solution:
Don't schedule install provider if the provider record
already exist and will be published later.

Change-Id: Ic200ceae042c014c86e7edee0acd013b513af334
Fix pointer index out of range exception

Avoid pointer index out of range error if return value is -1 of
findPointerIndex() when there is no data available for that pointer
identifier.

Change-Id: I2a08f04c678164e220852094baa124ba157e2e42
Signed-off-by: tingna_sung <tingna_sung@htc.com>
[ActivityManager] Avoid system server crash due to package removed

Symptom:
When application is not responding, an ANR dialog will shown.
In certain timing, user uninstall the application when the ANR
occurs, but before ANR dialog shown. The system server will crash
when looking up the errorReportReceiver because the package is removed.

Here shows how the exception occurs.
java.lang.IllegalArgumentException: Unknown package: app.package.name
 at com.android.server.pm.Settings.getInstallerPackageNameLPr
 at com.android.server.pm.PackageManagerService.getInstallerPackageName
 at android.app.ApplicationPackageManager.getInstallerPackageName
 at android.app.ApplicationErrorReport.getErrorReportReceiver
 at com.android.server.am.ActivityManagerService.startAppProblemLocked
 at com.android.server.am.ActivityManagerService.makeAppNotRespondingLocked
 at com.android.server.am.ActivityManagerService.appNotResponding

Change-Id: Iced4287bd44dc25b1db2c1e3a583892eb6c041a2
Reset killedByAm flag at attachApplicationLocked

ActivityManager reuses a process record object that killed
by him under some situation. That reused process record inherits
a killedByAm flag unexpectedly.
The killedByAm flag must be reset otherwise ActivityManager can't
judge the process can be killed or not.

Change-Id: If95137d91939cc44882ad2813131bcde0edd0c1b
Prevent showing immersive confirmation unexpectedly

By design, if the user presses the power key twice within 5 seconds
(panic), it will show immersive confirmation again at the next time
entering immersive mode.

But there is a bug on calculating the time between pressing the power
key. The time get from event.getDownTime() will stop when the device
is sleeping without being charged.

So here uses SystemClock.elapsedRealtime() instead.

https://code.google.com/p/android/issues/detail?id=80772

Change-Id: I4dca9dc260904f1c5b60464834781e2a82a9bcf4