History log of /frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
a7778b065428af7f23605053f939a668dd297182 28-Jun-2016 Felipe Leme <felipeal@google.com> Fixed whitelistManager set on unbindServiceLocked()

It must call updateWhitelistManagerLocked() because the app might have
other services with the whitelistManager set, in which case the process
record should not have whitelistManager reset.

Fixes: 29480440

Change-Id: I268278c646aaa89a352f02178b294c02c3c11d35
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
a590d2be935ef502943a1e6615500aa10e67c85a 28-Jun-2016 Dianne Hackborn <hackbod@google.com> Fix bug where process whitelist manager state would not be correct.

We can't update this in updateOomAdjLocked(), because we very
deliberately only iterate through services in there as needed.
The correct thing to do is update the process as services/connections
are associated with it, so do that.

Now basically all of the logic for tracking the state is in
ActiveServices, as we bind and unbind services and add and removing
them from process records. It's a little messy because we don't
have a central place for removing them from process records, which
should be cleaned up in the future.

Part of fixes for issue #29480440

Change-Id: Iac96f002a5b4e3b0277df244ff7b90f59a6e8440
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
9b80b94167a7d218da28b357d1daabf5ab1f309d 17-Jun-2016 Fyodor Kupolov <fkupolov@google.com> Do not schedule restarts if the system is shutting down

Bug: 29357754
Change-Id: Id5cf43fb6c4c6ea04d60bd09e910a9cec194c753
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
9d97ee2ad26b248a1778c4ccb43859b63b24a7b1 31-May-2016 Joe Onorato <joeo@google.com> Turn this wtf into just a log.

We're seeing this a bunch, but the overhead from the WTF is concerning.
So turn it off. It means that somewhere there is a race in tearing
down the app, or maybe some place fails to call back in some scenario.

Bug: 28932059
Change-Id: Ice14ade95bb9377ad622d440fb022953ad51c34c
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
efa291a8605e91d775faf46ada349ec7f81fcdb9 27-May-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Allow apps to bypass Power Save restrictions when launched from a Notification's PendingIntent." into nyc-dev
a1b79bfd7a15006a93da933695359765e0fee495 24-May-2016 Felipe Leme <felipeal@google.com> Allow apps to bypass Power Save restrictions when launched from a Notification's PendingIntent.

This scenario typically happens when the device is on Doze Mode and a
notification action is triggered from a Wear device.

In a nutshell, the workflow is:

- ProcessRecord has a flag telling whether a process has "whitelist
management" privileges.
- When NotificationManager binds a new NotificationListenerService, it
sets the BIND_ALLOW_WHITELIST_MANAGEMENT flag.
- On bind(), ActiveService asserts that only system apps can set that
flag.
- On computeOomAdjLocked(), ActivityManagerService sets the
ProcessRecord flag if necessary.
- Upon creating a notification, NotificationManager calls AM to mark its
PendingIntents as coming from a notification.
- When PendingIntentRecord sends it to the target, it checks if it's
from a notification and if so calls AM to do the temp whitelist.
- On unbind(), ActiveService removes the ProcessRecord flag if necessary.

Fixes: 28818704

Change-Id: I00d46036a2cbb73f7f733fd35bf0b743a02807a1
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
d6ac76284d0a5a74988931d9a8d8c3785b5aa62a 26-May-2016 Wale Ogunwale <ogunwale@google.com> Protect against NPE while to updating service connection activities.

Bug: 28972558
Change-Id: I83f6e33248bb5b5c6ed34a3590d594bf82463a96
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
777a06d3c932277649ebeb6ccb3f20e80aa867b3 17-May-2016 Dianne Hackborn <hackbod@google.com> Fix issue #28641630: Service client dumps are timing out for no reason

Actually, no reason. The reason is that to do the dump we are doing
synchronous calls out to each service, but that is with the activity
manager lock held, so they can get blocked if their main thread does
any call back in to the activity manager.

To fix this, re-organize the dumping code so that the "with client"
path is separate, and doesn't require holding a lock the entire
time.

Change-Id: Ia96861c10da81048b3d2ac93a25760b68623cf34
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
d041822fe7ca70cdf1582d71cfb6ff9ab09b7c29 11-May-2016 Amith Yamasani <yamasani@google.com> Reduce wtf spam when a service onDestroy races with proc death

Only log a message if the ServiceRecord still has a non-null app

Bug: 28527548
Change-Id: I737679a6a0cd28d265919090c6a9e955ee454379
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
ca82e616d3131570bf2ee29778f4796f343720d5 20-Apr-2016 Brian Carlstrom <bdc@google.com> Add reasons to notifyPackageUse calls

This is so we can record more specific times in PackageUsage.
If file with only one timestamp per package is found, the value is
copied to all usage slots.

Bug: 27902702
Change-Id: I8affe43c735e54620a9204433aad367cfddfded7
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
67324c990c4fbad238119a4667341d5618b2bea2 18-Apr-2016 Dianne Hackborn <hackbod@google.com> Work on issue #28221912: Starting service as foreground might...

...kill previous notification.

Add new platform API to detach a notification from a service
without dismissing it.

Also, while I am here, add some more @IntDefs.

Change-Id: I3bb46d9cd3db7f73716c8ced19c20fea800eb30d
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
4fb9c4af59a3d3210f6ccb4b2952bd480d2d9a58 04-Apr-2016 Dianne Hackborn <hackbod@google.com> Fix issue #28001806: Background check is incorrectly restricting binding of services

Change-Id: Ie79937d2696e28651c8ef2bdcc5c9c84f9f801c6
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
05c9ecc08a770e887d2c3d5da7153e252fdd8655 31-Mar-2016 Joe Onorato <joeo@google.com> Include process state in association tracking

Bug: 26165863
Change-Id: Ic1f3237d85dd9f9b55a412bc8609e60e6c2f3fd2
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
cba327969782e022882ef87f74a40003bce6246e 28-Mar-2016 Dianne Hackborn <hackbod@google.com> Merge "Fix issue #27776639: Background Check: Conn_Change..." into nyc-dev
e91f3e7e8d8aec8b880e6ed284a3889f849dfd91 26-Mar-2016 Dianne Hackborn <hackbod@google.com> Fix issue #27776639: Background Check: Conn_Change...

...shouldnt be received when app is awake

(Really any implicit broadcast.)

Fix up a few things so we are more strict when not in lenient
mode.

Change-Id: I3c711525787e07ea7c604d0f9bc123e02448fa68
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
4eb64fdbcf899a81d0a6a04dc3658d03d9df8247 21-Mar-2016 Joe Onorato <joeo@google.com> Refactor ProcessStats.

- Pull most of the inner classes out into their own files.
- Move everything to a new android.app.procstats package.
- Move all of the code that was manipulating the big list
of longs to use the new SparseMappingTable class rather
than doing everything by hand. The logic is unchanged.
- Add a sequence number check to SparseMappingTable so
when the big list of longs and the individual tables are
reset, which happens somewhat independently, we can
assert when one of them doesn't get reset.
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
f0ec2e005083808bf68f9f0049b801276c290ae2 21-Mar-2016 Jeff Sharkey <jsharkey@android.com> Mark even more Bundles as defusable.

Bug: 27766193
Change-Id: Ib027ac7b40c7a575a76f289faabde9655338865e
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
a49ad09c6f772fdbf829f85a6977fcde243c2b98 03-Mar-2016 Dianne Hackborn <hackbod@google.com> Work on issue #27381069: Master tracking bug: NYC is Sluggish

Have the activity manager us its own scheduling priority constants,
so that the new relative comparisons it is doing will work out
correctly.

Change-Id: I7bd1e5a3178ea491117bc497f87e4b75c92e0bc8
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
20d7df3c3ff0000678a208b25fcf7ddf90c5abe4 12-Jan-2016 Adrian Roos <roosa@google.com> Crash dialog improvements, move crash code to AppErrors

Factors out the crash and ANR handling code into separate
class and allows clearing cache and restarting app from
crash dialog.

Bug: 22692162
Change-Id: I2a08a4255ea02ab3c7441d351bf278128fcf5a5d
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
b9a8666eb5504f022343fef9087135b7d937ddf8 09-Dec-2015 Robert Sesek <rsesek@google.com> Add external services, a way to run isolated processes as a different package.

This adds android:externalService boolean attribute to <service>. If that
attribute is true, then bindService() may be called with
BIND_EXTERNAL_SERVICE to create the new service process under the calling
package's name and uid. The service will execute the code from the package in
which it is declared, but will appear to run as the calling application.

External services may only be used if android:exported="false" and
android:isolatedProcess="true".

Bug: 22084679
Bug: 21643067
Change-Id: I3c3a5f0ef58738316c5efeab9044e43e09220d01
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
c5967e9862489024c932b0c7fcb84ed0af2a7fd7 08-Jan-2016 Jeff Sharkey <jsharkey@android.com> More progress on triaging PackageManager callers.

Catch a bunch of simple cases where the PackageManager flags are
obvious. Add the ability to use the MATCH_SYSTEM_ONLY flag on
PackageInfo and ApplicationInfo queries.

Re-examine recent tasks after a user is unlocked, since some of the
activities may now be available and runnable.

Bug: 26471205, 26253870
Change-Id: I989d9f8409070e5cae13202b47e2c7de85bf4a5b
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
03a25bd2304b43c6798fb65457f2d4b57776cc26 07-Jan-2016 Dianne Hackborn <hackbod@google.com> Fix crashes in background check.

Stupid NPE.

Change-Id: I4df47f996dbf51e568a9e5dab4443b7d7c02774c
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
2639c4bf6b98fb60a47f7398966d184a0aea1950 04-Dec-2015 Dianne Hackborn <hackbod@google.com> New generic background restrictions.

This modifies the existing rigid background restriction to
a more moderate policy that we can (eventually) apply to all
apps:

- After N minutes no longer in the foreground, any background
services running in the app are stopped and no more can be
started.
- No manifest receivers for the application will be executed
if the broadcast is not being sent explicitly to that app and
the app is not running. (Eventually we should tighten this so
they won't be received if the app is past its N minute
background window.)
- Other non-background processes may still bind to services in
the background process, which will raise it to back to an
executing state... so things like syncs, jobs, live wallpapers,
accessibility services, etc still work.

Change-Id: I08ddbfdf640ef324a27b2eb9eecd9499f3ebddd9
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
9c165d76010d9f79f5cd71978742a335b6b8d1b4 02-Dec-2015 Svet Ganov <svetoslavganov@google.com> Add optional permission review for legacy apps - framework

For some markets we have to allow the user to review permissions
for legacy apps at runtime despite them not supporting the new
permission model. This is achieved by showing a review UI before
launching any app component. If an update is installed the user
should see a permission review UI for the newly requested
permissions.

To allow distinguishing which permissions need a review we set
a special flag in the permission flags that a review is required.
This flag is set if a runtime permission is granted to a legacy
app and the system does not launch any app components until this
flag is cleared. Since install permissions are shared across all
users the dangerous permissions for legacy apps in review mode
are represented as always granted runtime permissions since the
reivew requirement is on a per user basis.

Whether the build supports permission review for legacy apps is
determined by a build constant allowing us to compile away the
unnecessary code for markets that do not require a permissions
review.

If an app launches an activity in another app that has some
permissions needing review, we launch the permissions review
UI and pass it a pending intent to launch the activity after
the review is completed.

If an app sends a broadcast to another app that has some permissions
needing review, we do not deliver the broadcast and if the sending
app is in the foreground plus the broadcast is explicit (has a
component) we launch the review UI giving it a pending intent to
send the broadcast after the review is completed.

If an app starts a service in another app that has some permissions
needing review, we do not start the service and if the calling app
is in the foreground we launch the review UI and pass it a pending
intent to start the service after the review is completed.

If an app binds to a service in another app that has some permissions
needing review, we schedule the binding but do not spin the target
service's process and we launch the review UI and pass it a callback
to invoke after the review is completed which spins the service
process and completes the binding.

If an app requests a content provider in another app that has some
permissions needing review we do not return the provider and if
the calling app is in the foreground we show the review UI.

Change-Id: I550f5ff6cadc46a98a1d1a7b8415eca551203acf
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
8fb0e1946bcd778332347f20bf2d39a639d5e74a 18-Nov-2015 Amith Yamasani <yamasani@google.com> Fix crash in bindService due to uncleared binder identity

Clear the calling identity in retrieveServiceLocked before
doing the appop check. It probably needs to be cleared sooner
in general in retrieveServiceLocked(), but that might be a risky
fix. Making this smaller fix to keep it surgical for now.

Bug: 25759739
Change-Id: I66a5f8ef9b2d914181925fa344c3f2962030583d
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
bef28feba57be7fd6a4d14a85a8229154338b2ed 30-Oct-2015 Dianne Hackborn <hackbod@google.com> Initial stab at background check.

Actually, this implementation is more what we want for ephemeral
apps. I am realizing the two are not really the same thing. :(

For this implementation, we now keep track of how long a uid has
been in the background, and after a certain amount of time
(currently 1 minute) we mark it as "idle". Any packages associated
with that uid are then no longer allowed to run in the background.
This means, until the app next goes in the foreground:

- No manifest broadcast receivers in the app will execute.
- No services can be started (binding services is still okay,
as this is outside dependencies on the app that should still
be represented).
- All alarms for the app are cancelled and no more can be set.
- All jobs for the app are cancelled and no more can be scheduled.
- All syncs for the app are cancelled and no more can be requested.

Change-Id: If53714ca4beed35faf2e89f916ce9eaaabd9290d
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
183501e1aaee9584f8f0c6ea2d983e3fc17429d1 11-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Merge "Remove performBootDexOpt and am's ensurePackageDexOpt."
27c073796978106746e4a51f2100b29068ab37f6 05-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Remove performBootDexOpt and am's ensurePackageDexOpt.

Except common shared libraries and boot image, all compilations
are now done through BackgroundDexOptService.

Change-Id: Ib736e253c38b0c8085bc94e45f4e61a048f66e26
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
e17ac1569793c333bb4dce86607a342e7c982ae7 07-Nov-2015 Jeff Sharkey <jsharkey@android.com> More APIs for encryption-aware apps.

Apps can mark manifest components as being encryption-aware, which
means they can safely be run before the credential encrypted storage
is available.

Start adding filtering logic so that we only return these components
when a user is running "with amnesia." That is to say, only device
encrypted storage is available, so the user is running but with only
partial knowledge of its data.

To avoid calling into ActivityManager with the PackageManager lock
held, we quickly determine user state and splice the state into the
flags for later per-component evaluation.

Bug: 22358539
Change-Id: Idc56ec29f1ef04da8963e004314d7f5e47400997
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
f63b89c0a10b4e3220b0a4aa1703be3aed0c5a98 28-Oct-2015 Fyodor Kupolov <fkupolov@google.com> UserController refactoring

Addressed comments from the previous cl. Added getters for UserController
fields, direct access is no longer allowed. Moved the following methods:
- getUserManagerLocked. Became getUserManager() - because locking is not
necessary, double checked locking will suffice.
- startUserInForeground /showUserSwitchDialog/sendUserSwitchBroadcastsLocked
- handleIncomingUser/unsafeConvertIncomingUserLocked/isUserRunningLocked/
getUsers/getProfileIds

Bug: 24745840
Change-Id: Id5a5cfb9604e08add29bd9a03c8fe5200bc51fef
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
610acda80a02317080ebaed79b0c1ce26835b8f9 20-Oct-2015 Fyodor Kupolov <fkupolov@google.com> Introduced UserController for multi-user functionality

The new helper class encapsulates user life-cycle management, provided by
ActivityManagerService.

Bug: 24745840
Change-Id: I8ebfa38febc4090390d1c45a9fc47398e52693ae
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
1b060e83c70703bc8d3fbe3e8abf94bd847d1401 22-Oct-2015 Dianne Hackborn <hackbod@google.com> Merge "Hopefully fix issue #25153459: Sandboxed_process1 thrashing" into mnc-dr-dev am: 676534e008 am: 75c2993c91 am: ca8e4ce5fc
am: 06496d0479

* commit '06496d04791f46a834a6d101068a1a999762d6a2':
Hopefully fix issue #25153459: Sandboxed_process1 thrashing
865907db099eed08cac7ab177161361f5c82e656 22-Oct-2015 Dianne Hackborn <hackbod@google.com> Hopefully fix issue #25153459: Sandboxed_process1 thrashing

There is a race where if you unbind to a service before its
process has come up, we would leave the service record active
and keep it running. Fix this by checking the service state
after its process up and proceed to bring it down if it is no
longer needed.

Also added a similar check when restarting a service, just in
case there are other ways we can get into this situation.

And while I am at it, I tweaked the broadcast queue dump output
a bit to hopefully make it a lot easier to figure out how long
it is taking to process broadcasts.

Change-Id: I46b98f1fe394ab8039ea4cc81fb5d3afb6391a31
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
0b65a9079edec71b28c64dff90d6e0debe8c69dd 03-Sep-2015 Wale Ogunwale <ogunwale@google.com> am c2f9e432: am 68025995: am 1942f8a7: am d4ef34ce: am 512141d5: Merge "Respect DONT_KILL_APP flag when bringing down a disabled service." into mnc-dev

* commit 'c2f9e4323cda3090cfa9197eb402f9279a72b224':
Respect DONT_KILL_APP flag when bringing down a disabled service.
2cb2dd40d6a84a3c113c1a858e85ca642d7faf77 02-Sep-2015 Wale Ogunwale <ogunwale@google.com> Respect DONT_KILL_APP flag when bringing down a disabled service.

Commit 540e123 introduce logic to clean up states when a component is
disabled. For services this included marking the process running the
service as removed so it can be killed later. However, this wasn't
respecting the Intent.EXTRA_DONT_KILL_APP flag where the caller
doesn't want the process of the disabled component to be killed.
This change now takes the flag into account.

Bug: 23491822
Bug: 15804187
Change-Id: I54a6e03cd66164dc8c4606a3c462114fe661ea8e
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
8b5cd9fda45bc57644dc0577cde3c39cc17c0f87 10-Jul-2015 Yasuhiro Matsuda <mazda@google.com> Fix a compile error with DEBUG_SERVICE enabled.

Fixes the following compile error that occurs when
DEBUG_SERVICE is set to true.

frameworks/base/services/core/java/com/android/server/am/\
ActiveServices.java:1624: error: variable si might not \
have been initialized
+ si.intent);

Change-Id: I62851d9d9de18294b555834e042025eeca0ad5ae
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
99b6043dad9d215cf15810b885b6b8c215dd5b5a 27-Jun-2015 Svet Ganov <svetoslavganov@google.com> Teach receivers, activities, providers, and services app ops.

Perform app op check in addition to the permisison check for all four
paltform components - activities, content providers, broadcast receivers,
services - if they are guarded by a permssion that has an associated app
op. This ensures that legacy apps will behave correctly if the permission
of the caller has been revoked, i.e. the app op for that permission was
disabled.

bug:22199666

Change-Id: Ia22d1c38d58b3cd6aabdc655cb7c7bddd85da7a2
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
5862c5f85e28efc370510d42680930ca73a3309f 19-May-2015 Christopher Desjardins <christopher.desjardins@tomtom.com> Fix null pointer dereference when security exception occurs

Just above the SecurityException is a check for r.record == null,
thus dereferencing r.record will cause a null pointer exception.

Found in Android 4.3 with the following steps:

1) Start the music app.
2) Switch to the restricted user.
3) Navigate to Settings->Apps->Running->Music.
4) Tap the stop button.

The security exception should be thrown which results in
a nice message to the user, but instead a null pointer
exception is thrown which results in the settings app
crashing.

Change-Id: I4a306c38650c9d366896e592767dde70adb71c57
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
540e123b14ef71f0bfda325e11773c1c510fb8ba 02-May-2015 Wale Ogunwale <ogunwale@google.com> Clean-up component states in AMS when component is disabled

Bug: 15804187
Change-Id: I2b5856c5a0a012f34698fb64f8596d32924bbd1f
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
bfac468ce907643eda50afa28f25538b9182e65e 08-Apr-2015 Wale Ogunwale <ogunwale@google.com> Throw caught DeadObjectException when trying to create a service.

We don't want to continue trying to start the service if the service
appliction is dead. This will lead to an NPE later on since we have
set ServiceRecord.app to null in the finally block.

Bug: 5227987
Change-Id: I3ee5111f4a20d9455fedbf41ac54d41c43aa8d76
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
94efe9172e4797fab1ab470d298cb62b7cd3ebe8 07-Apr-2015 Olawale Ogunwale <ogunwale@google.com> am bf39a6c6: am 43293fa8: am 437db610: Merge "[ActivityManager] Do not add service to reschedule after removing users."

* commit 'bf39a6c6605764100a29f96c69bca6fb6f907fc3':
[ActivityManager] Do not add service to reschedule after removing users.
437db6106b20d5a81f12a93593b5f623b3159f19 07-Apr-2015 Olawale Ogunwale <ogunwale@google.com> Merge "[ActivityManager] Do not add service to reschedule after removing users."
954850ce5db39324a9f6a4a1ac62a182d88dea83 06-Apr-2015 Olawale Ogunwale <ogunwale@google.com> am 00e1d5cf: am 1d065987: am 47c1cf4b: Merge "[ActivityManager] Fix ServiceRecord leakage"

* commit '00e1d5cf5e717be8794381c2895893b41126f266':
[ActivityManager] Fix ServiceRecord leakage
cd005ebf76d9bde584987be4690b128f687bc46d 02-Apr-2015 younghwan1.kim <younghwan1.kim@lge.com> [ActivityManager] Do not add service to reschedule after removing users.

Some service which has persistent attribute has restarted again and
again after removing users.
but it dies right after launching because it is not valid in owner mode.

This patch will check service's userId whether userId is alive or not.
And then if userId is not alive, then service will bring down.

Change-Id: Id99bf3c651b88e377f1fd6bec8aaad81318d7579
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
40e259c34078945ac298c7b20f1df4bef25c3453 26-Mar-2015 louis_chang <louis_chang@htc.com> [ActivityManager] Fix ServiceRecord leakage

Symptom:
The first step of cleaning up application services is
to clear the app state from services (which set sr.app
to null). Then it clean up the service connections.
In some scenario, the Service might be removed during
the connection cleanup (i.e. the Service is no longer
needed). In that case, the Service will be removed from
ServiceMap, but won't be removed from r.app.services in
bringDownServiceLocked(line 1670) because the r.app is null.

Solution:
Remove the service connection first.

Change-Id: I644d73af58fe0e7c1c4a6c9779fe6b5d747b880d
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
5f2bb4c9bc27aee581bf888f1fd22c5c9311240d 13-Mar-2015 Craig Mautner <cmautner@google.com> Fix bad nesting count when remote calls fail.

The nesting count for services depends on callbacks decrementing
ServiceRecord.executeNesting in response to remote service calls. If a
remote call fails the callback does not get made and the nesting count
gets out of sync. This causes orphans in the executingServices set.

This fix makes the callback locally when the remote call fails.

TransactionTooLargeExceptions caused by Intents containing large
amounts of data were being caught and not propagated to the calling
methods.

This fix propagates TransactionTooLargeExceptions back to the calling
methods.

Fixes bug 19698308.

Change-Id: I9eb6ae414d14d6b3a2709abb1f2bdfbd4cbc3c03
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
d57969f6ec38c7633ca65bcd5bdd766cd972cfe4 16-Nov-2014 Wale Ogunwale <ogunwale@google.com> Made AM package debug log more configurable.

* Added class ActivityManagerDebugConfig.java for housing all debug
log configuration for activity manager package.
* Added ability for using default activity manager log tag or class
specified tag string which is very helpful during debugging.
* Added ability to prepend log category name to log tag that can
also be useful during debugging.
* Converted BroadcastQueue.java and ActiveService.java to use the
new log class. Other classes in the package will be gradually
converted.

Change-Id: I0e4b343da75cb2e539b5ad5f0f79f6bc7af46d7b
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
8e72aa8a41cf1395ce30a9f0c9416587d64b5ba9 27-Jan-2015 Craig Mautner <cmautner@google.com> am 603d30b1: Merge "Stop logging service starts and stops." into lmp-mr1-dev automerge: 49880ee

* commit '603d30b1cfe7be61e4e352b58342b86e5cfb7612':
Stop logging service starts and stops.
9851d03819bd960b285f28bf12b8ffa3422c46e2 26-Jan-2015 Craig Mautner <cmautner@google.com> Stop logging service starts and stops.

Completes work on bug 18201239.

Change-Id: I80686351ac91e48bf113976a000b351b423d8dd2
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
f6b4b1a43253d5ea94763cf9750224c7b7b618c0 21-Jan-2015 Dianne Hackborn <hackbod@google.com> Merge "Work on issue #18201239: ANRs in com.google.process.gapps:" into lmp-mr1-dev automerge: 2132695
automerge: 5346a21

* commit '5346a21bad95796611760d40c1540d1659038216':
Work on issue #18201239: ANRs in com.google.process.gapps:
455625e298204a27d3958eb56ff155f27562eec8 21-Jan-2015 Dianne Hackborn <hackbod@google.com> Work on issue #18201239: ANRs in com.google.process.gapps:

Reason: Executing service com.google.android.syncadapters.contacts
/.SyncHighResPhotoIntentService

Make the code more robust when destroying services, so that if
the nesting count gets out of sync we don't just hang.

Change-Id: If117d5ef242e7c148fd9576bd89a1a092583d6ad
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
734f68439ed7e0fb6fbd521f961cebf31baf5b6d 21-Jan-2015 Dianne Hackborn <hackbod@google.com> Merge "Fix issue #19020826: Including timing issues in ANR reason breaks clustering" into lmp-mr1-dev automerge: 66f8d9b
automerge: 8781dbf

* commit '8781dbf3dfa79c39fc0410521dff04156fae876a':
Fix issue #19020826: Including timing issues in ANR reason breaks clustering
cff1bbf46ce79e370b80298522b0c2e23f3bdccc 20-Jan-2015 Dianne Hackborn <hackbod@google.com> Fix issue #19020826: Including timing issues in ANR reason breaks clustering

Also improve service ANR debugging.

Change-Id: I2118ef2811ca3ba676c110639f58d5c21abfb8eb
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
62e815bf7b154fe984e1a2aa8d615a2f04f71785 16-Jan-2015 Craig Mautner <cmautner@google.com> am 02c7c97a: am ac70b2d1: Merge "More debugging for bug 18201239." into lmp-mr1-dev

* commit '02c7c97a62ba9b79e56d1f7e206615e6eaca0689':
More debugging for bug 18201239.
66c4a824b9b11a47c7bd1bf858d92fe207409ab9 16-Jan-2015 Craig Mautner <cmautner@google.com> More debugging for bug 18201239.

Fixes bug 19045133.

Change-Id: I2ef2b8600278ed91df59db4acf4740dac970ee3a
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
b523c55d76ef3215538158a65bdea70c9897993e 16-Jan-2015 Craig Mautner <cmautner@google.com> am 41d54237: am 92cf3608: Merge "Debug for bug 18201239." into lmp-mr1-dev

* commit '41d54237380d5f3c06ab2a71715e22f048278ecf':
Debug for bug 18201239.
9776ad41b900c6c7da0a3b6baf91b609be27f9b9 15-Jan-2015 Craig Mautner <cmautner@google.com> Debug for bug 18201239.

Change-Id: I06281bd76b8c1d887324d3efa39b6cb11c9e71ae
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
d362d1936434148f332ab8c6c9c92c38aac0dac8 12-Jan-2015 Olawale Ogunwale <ogunwale@google.com> am cacf5564: am e3f85985: Merge "bindService can\'t start up service process"

* commit 'cacf55647f64076f840f37537a5edb979fe2c3ab':
bindService can't start up service process
7158ea25cd255d48febb8c8ba7203c79eb9c4213 21-Dec-2014 chad <guochongscut@gmail.com> bindService can't start up service process

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

Change-Id: I28645445ee5c46b2ab4cf78189f143ea97df63dd
Signed-off-by: chad <guochongscut@gmail.com>
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
ab2df067fc9757f19061b968c53953ca90a4c384 07-Jan-2015 Dianne Hackborn <hackbod@google.com> Add new debug feature to track associations between processes. Also
add some debugging for spurious service ANRs.

Bug: 18201239
Change-Id: Icd43f35c696d71453e1d4deea855984b2d14b347
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
f85e7af4d009862fc799c7232ec5cf9e2dc9fa34 14-Oct-2014 Dianne Hackborn <hackbod@google.com> Fix issue #10034864: Define YouTube application as the preferred...

...handler for its Intents

Fix bug when a third party app is installed as an additional but
worse match for the intent.

Also raise up the limit for when we start printing logs about
overly large strict mode data.

And turn off the logs about services being created and destroyed,
since with the way things are using services these days these have
become way too spammy.

Change-Id: I8fe301dfd80fb4b70213cb7783b7c5426245278d
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
955d8d69ea6caabce1461dc25b339b9bf9dc61a6 08-Oct-2014 Dianne Hackborn <hackbod@google.com> Put in real "code" (aka marketing) name.

Change-Id: Idb3976edfae37293ed75cb5b869b4b42d8042bbe
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
7622a0f8e4198adf0aae5d4e167ee132b34f4cdb 30-Sep-2014 Dianne Hackborn <hackbod@google.com> Maybe fix issue #17700474: manta: high occurrence of device booted...

...but dev.bootcomplete flag is not set

Rework things to address a few issues I found:

- When the activity goes idle, the way we were handling finishing the
boot there was calling finishBooting() with the lock held, but it
shouldn't. We now dispatch that and turning on the screen together
in a separate message.

- Make sure we don't try to start the home activity until we have
reached the point of the system being ready and mBooting being set.
This ensures we don't do any work prematurely.

Change-Id: If30c1f287af73bc2164e7aadbe98022ae42cc5e7
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
cd97c96734ac00a6a800724fe5d8e81ee0ee134c 26-Sep-2014 Dianne Hackborn <hackbod@google.com> Fix issue #17574819: Chrome browser process is killed...

...in background due to dying renderer process

Completely turn this off, for now.

Change-Id: I028eefc9b7e627d29569ef72d9ab940ac5960c7c
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
ff072725e39b8c6928d6ca2d7e263d7d081a2288 24-Sep-2014 Dianne Hackborn <hackbod@google.com> Work on issue #17624121: Settings crash while launching on wiped device

Cleaner paths and better error reporting when a problem goes wrong
while binding an application. This gets rid of the (recently added)
error about removing a process that hasn't been killed, and cleanly
kills the process along with more detailed errors about where things
failed.

Change-Id: I710a209c14da1515929e6254396b793177eee115
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
d0e0154c1f0be7786f12aea60add7ed4fb7c4e6c 23-Sep-2014 Dianne Hackborn <hackbod@google.com> Merge "Maybe fix issue #17614177 APR: system process restarting due to infinite loop" into lmp-dev
25e1ecaabbde4741663c8e5a777d9df9b939572c 23-Sep-2014 Dianne Hackborn <hackbod@google.com> Maybe fix issue #17614177 APR: system process restarting due to infinite loop

Also try to get rid of a huge wtf we are seeing across a lot of devices
where we incorrectly change real states on a service that is restarting,
and get rid of one of the noisier boot logs in the package manager.

Change-Id: I2510b6fb082eac3f6168cbd57bc3b70ad006114d
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
c2f6f947b6f3ebc5df5ac0a3d2c9f959b9c5e6c5 22-Sep-2014 Dianne Hackborn <hackbod@google.com> Fix issue #17609716: Frequent crash in system_server (RT restarts)

There was some code here locking on the lock object instead of
the main activity manager lock...!!!

Change-Id: Ic85151fbef915f6fb8fd5ce3c1a7e9b810412cb6
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
cf456e3c225fa736914cca1f51eb5311fa16fb88 20-Sep-2014 Dianne Hackborn <hackbod@google.com> Merge "Fix issue #17574819: Chrome browser process is killed in background..." into lmp-dev
0fe3c2565833914b7e30df1dc82e3e26fa6de978 20-Sep-2014 Dianne Hackborn <hackbod@google.com> Fix issue #17574819: Chrome browser process is killed in background...

...due to dying renderer process

Don't kill processes if they are bound to a service but not impacting
oom adjustment.

Change-Id: I1cc44e633feaeaad6e996b79a6cfd7b386c04095
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
365e4c38d58d38bb61d1fdd870346f2f594825fd 18-Sep-2014 Christoph Studer <chstuder@google.com> Remove FLAG_FOREGROUND_SERVICE on Service.stopForeground()

When services call Service.stopForeground(), remove
FLAG_FOREGROUND_SERVICE from the notification that was supplied
to Service.startForeground().

This enables services to post notifications that become user
dismissable when they switch to being a background service.

Restrict this to targetSdk=L apps to reduce the risk of breaking
existing apps.

Bug: 17551106
Change-Id: Iff8541e5bb2a23ad1fbc9ad80df5fd6eb683148b
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
24c98e8cf88f6edc3d5bdf2ce40a51f158f36884 15-Sep-2014 Dianne Hackborn <hackbod@google.com> A little more work on issue ##16907799.

I got distracted in the middle of it, and forget to finish
up with the test to not kill processes if they aren't using
an auto create binding.

Change-Id: Ieecfe97fa3208e50cb91ba94be2a8659d128b0de
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
465fa3963534e41ead0dce1273b71fd50c58c973 14-Sep-2014 Dianne Hackborn <hackbod@google.com> Fix issue #16907799: Processes containing bound services...

...are killed over eagerly.

When the current foreground activity is moving to the background,
it was briefly going through the CACHED_ACTIVITY state before the
correct LAST_ACTIVITY state, allowing its bound service processes
to be killed (because they went in to the cached list). To solve
this, as long as a process has stopping activities, it won't go
lower than LAST_ACTIVITY.

Also fixed a problem where we could put a process in CACHED_EMPTY
instead of CACHED_ACTIVITY_CLIENT. There were a number of cases
in the binding flow and also the client process state transitions
where we would not correctly updateing the bound client activity
state.

And add some sanity code so that if a process hosting a
service is killed, and a client process of that service is in the
cached state, we kill the client process. This avoids situations
where we can start thrashing around in the cached list because we
are restarting process for no reason -- since they will just
continue to be cached.

Finally, tune the process LRU list to allow twice as many cached
activity processes (from 8 to 16), so we can make better use of
the RAM we have available these days.

Change-Id: Ib0cdf78c321cbb035259fc9dd6ee27b5ba1f90c5
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
eddeb49a734a524347587e7654025c489fb6331e 09-Sep-2014 Adam Lesinski <adamlesinski@google.com> ActivityManager shouldn't return null for getCurrentUser

There was a race where ActivityManager would return null
for getCurrentUser() when switching between guest accounts.
This is because the Guest account was marked for deletion
while it was still active.

Bug:17290209

Change-Id: I224fb4b6836380e5acb7dbeb8f3343d74505f88a
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
4a8dddbf18fedb33bb2c725db489669a141e1d73 13-Aug-2014 Craig Mautner <cmautner@google.com> Clean up app following death when creating service

If an app has died, run through the cleanup before relaunching its
service.

Also a little simplifying refactor.

Fixes bug 16979752.

Change-Id: I376cbef2ea00fc626588386317f092cc6dea0bdc
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
409297da182267465adbc21cfb75a23e8d678117 11-Jul-2014 Dianne Hackborn <hackbod@google.com> Allow INTERACT_ACROSS_USERS for service access.

But only if the two users are in the same profile. Also
apply the same rule for the recently allowed interaction
across content providers.

The activity manager now keeps track of which users are in
the same profile group, and the handleIncomingUser function has
an option to allow a non-full caller to do the interaction
if the two users are in the same profile group.

Spread this joy all over the place.

Also turn off multi-user on Svelte devices.

Change-Id: I231484ea2a6bfccbb3cd51357d7a387bd75039ea
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
f7097a5b697fedb6976774e55a51471405a23c0e 13-May-2014 Dianne Hackborn <hackbod@google.com> Add kernel and native memory data to procstats.

We now collect memory use data in the kernel and native
application for aggregation in procstats. This should
allows us to do aggregated summaries of how memory use
is distributed across the system -- how much is free vs.
how much is in use.

Fix a bug in how we were tracking per-app version codes:
apps that used a shared user id to have multiple packages
run in the same process could get their version codes
cross-wired. Now we keep track of version codes in the
list of packages associated with a process.

Bumped the checkin version code to 5, so that we can
distinguish checkins that have this corrected data.

Also fix a bug in battery stats monitoring radio state.

Change-Id: I1c849f2df442df679a34ad7b0ca0c5870bfac8df
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
8b466c19d6306c508aeaa2ad349f8c3225f62f0e 30-May-2014 Dianne Hackborn <hackbod@google.com> am f6550f0a: Merge "More work on voice interaction visuals." into lmp-preview-dev

* commit 'f6550f0ab2fb1abae6f9d694c87ccba9bede57f4':
More work on voice interaction visuals.
20d94749043d0851f1da10c7749fd7eb13a35081 30-May-2014 Dianne Hackborn <hackbod@google.com> More work on voice interaction visuals.

There is now a special theme for voice interaction activities
to use, so they can be a panel that is better intergrated with
the rest of the voice interaction experience. This is still
not completely working, I have some hacks in the demo app to
get it right; I'll fix that in a future change.

Also improve VoiceInteractor to be retained across activity
instances, for things like rotation.

And bump up the number of concurrent broadcasts that are allowed
on non-svelte devices, since they can handle more and this makes
the boot experience better when dispatching BOOT_COMPLETED.

Change-Id: Ie86b5fd09b928da20d645ec2200577dee3e6889d
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
1015efb143b51a5d31f2f932528f295cfa1add1f 29-May-2014 Nicolas Prevot <nprevot@google.com> Merge "Making the content resolver work with result intents."
c6cf95c0f5f7250c65e40c441fe58d8cbfd114c9 29-May-2014 Nicolas Prevot <nprevot@google.com> Making the content resolver work with result intents.

prepareToLeaveUser is called if necessary on result intents.
Adding the targetUserId to grantUriPermissionFromIntentLocked
This allows the GET_CONTENT intent to work across profiles.

Change-Id: Id81280c23247aeda7ad56e34af9b12a6f3a00a3c
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
4b9d79c30eccb61645d98a4f0d49b7769e8c7ccc 22-May-2014 Amith Yamasani <yamasani@google.com> Fix singleUser attribute

Make it work correctly for singleton content providers.
Relax which apps can export singleton content providers.

Change-Id: I43d315c25ed76a876bfa6d5e0d1351bc19c9bdba
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
40c8725804f46c9d53f2815e0ee69e6cfb0152cc 20-Mar-2014 Dianne Hackborn <hackbod@google.com> batstats: fix wake lock tracking, service bug

- Fix bug I introduced in handling wake lock changes where
we weren't iterating over the new work sources correctly.
- Fix bug in ActiveServices that would wtf too much.
- Prepare to start tracking uptime in the battery history.

Change-Id: Ia94316be51bc6eab7b02f214a5c40c08e99cc3b1
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
f0f94d129b6eb3c48624e915898d86d4f2de59ff 18-Mar-2014 Dianne Hackborn <hackbod@google.com> Treat IME processes as hosting activities

When we stop using an IME process, we still treat that
process as if it is hosting activities (in the activity part
of the LRU list), to try to keep it around. This is intended
to help the experience of switching between IMEs, reducing
the chance of your previous IME process being killed and thus
requiring much more time to switch.

Change-Id: Ie5793fd9b40d980fa18f80246326511ed6ae0597
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
08c9db7363a45e2e86f3f69f52758c37775cea7e 19-Feb-2014 Craig Mautner <cmautner@google.com> am 6ed1c96b: am a1baf028: am 23ef1b5e: am 16ea3e6a: Merge "A background started service is removed from mStartingBackground when timeout. Fix is to make sure mStartingBackground is updated to remove one."

* commit '6ed1c96b7253d2590ffe339714bdcaf8c77217c0':
A background started service is removed from mStartingBackground when timeout. Fix is to make sure mStartingBackground is updated to remove one.
a1baf0288407c17737cf92bba5c7fccb8c8c55ed 19-Feb-2014 Craig Mautner <cmautner@google.com> am 23ef1b5e: am 16ea3e6a: Merge "A background started service is removed from mStartingBackground when timeout. Fix is to make sure mStartingBackground is updated to remove one."

* commit '23ef1b5e0b84e3bb726454b97846f91f2efad212':
A background started service is removed from mStartingBackground when timeout. Fix is to make sure mStartingBackground is updated to remove one.
eaf2ac464b1cd741d7d0fe700771b1b7c00ddb29 07-Feb-2014 Dianne Hackborn <hackbod@google.com> Battery stats: more events, fixes.

Add new history events for top application package and
foreground application packages.

Doing this involved a fair amount of improvement to history
events. The event code is now separated out to have "start"
and "finish" identifies, and we use that to now keep track
of which events are active. With that, when resetting the
stats, we can spit out all of the currently active events at
the front of the new history.

Also fixed some problems when I re-arranged the history delta
int bits that were conflicting with the packing of the battery
status bits. These packing structures are changed to work
together correctly.

Change-Id: Ic8b815060dd8a50ff4a0a209efc2e1044215cd88
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
6873e17d4b565aa1d4ea2a8f1ac261f517dcc2ff 14-Jan-2014 Dianne Hackborn <hackbod@google.com> am 305c61a1: am 3a8a8ddd: am 8c359bf4: am c174288d: Fix issue #12031685: Sticky Service Breakage in Android 4.4.1

* commit '305c61a1c6816549b225719518df5b29a17f0f42':
Fix issue #12031685: Sticky Service Breakage in Android 4.4.1
49782e46c0eb85a25ae2abcf80880c48dbab5aea 20-Dec-2013 Amith Yamasani <yamasani@google.com> am 9158825f: Move some system services to separate directories

* commit '9158825f9c41869689d6b1786d7c7aa8bdd524ce':
Move some system services to separate directories
9158825f9c41869689d6b1786d7c7aa8bdd524ce 22-Nov-2013 Amith Yamasani <yamasani@google.com> Move some system services to separate directories

Refactored the directory structure so that services can be optionally
excluded. This is step 1. Will be followed by another change that makes
it possible to remove services from the build.

Change-Id: Ideacedfd34b5e213217ad3ff4ebb21c4a8e73f85
/frameworks/base/services/core/java/com/android/server/am/ActiveServices.java