Commit Graph

9932 Commits

Author SHA1 Message Date
Sudheer Shanka
b19b3f1a68 Merge "Pass the packageName to zygote when starting a new process." 2018-07-31 01:02:17 +00:00
Sudheer Shanka
154fe3f6a7 Pass the packageName to zygote when starting a new process.
This packageName is passed so that the process initialization
after the zygote fork can mount appropriate package sandbox.

Bug: 111890351
Test: n/a
Change-Id: I99d6c1b53fffd53d7387dc807106efe5e1dc9b07
2018-07-30 14:44:26 -07:00
Olivier Gaillard
7a2a98bb7f Store the runtime class instead of the class name.
This will be used by a follow up CL to call getTransactionCode lazily
instead of doing it during the binder call.

Test: unit tests
Change-Id: I11a997bb8a6268871daf4145a962886b43195c89
2018-07-30 17:59:30 +00:00
Olivier Gaillard
5536929078 Merge "Move a few method calls outside the BinderCallsStats lock." 2018-07-30 17:59:07 +00:00
Olivier Gaillard
8a760b9143 Move a few method calls outside the BinderCallsStats lock.
getThreadTimeMicro can take a few microseconds.

Change-Id: I3dc451ded2bde147c1b9061552210d499ec7d0e3
Test: unit tests
2018-07-30 11:19:49 +01:00
Jeff Sharkey
3ea5588f7c Merge "Support for appending "standalone" WHERE chunks." 2018-07-27 23:21:53 +00:00
TreeHugger Robot
ac70654f9d Merge "Procstats: keep track of per-proc state active time" 2018-07-27 21:26:41 +00:00
Jeff Sharkey
b89df9eac8 Support for appending "standalone" WHERE chunks.
The existing appendWhere() methods aren't very friendly for
developers, since they require manual tracking of state to decide if
subsequent standalone chunks should be prefixed with "AND".

While it's tempting to offer direct argument binding on the builder
class, we can't really deliver on that API in a secure way, so instead
add separate bindSelection() method which explicitly burns arguments
into a standalone selection string, which can then be appended to
the builder.

This was the last piece of new functionality being used by
SQLiteStatementBuilder, so we can delete that class and migrate
users back to SQLiteQueryBuilder.

Bug: 111268862
Test: atest frameworks/base/core/tests/coretests/src/android/database/DatabaseUtilsTest.java
Test: atest frameworks/base/core/tests/utiltests/src/com/android/internal/util/ArrayUtilsTest.java
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*
Test: atest cts/tests/tests/database/src/android/database/sqlite/cts/SQLiteQueryBuilderTest.java
Change-Id: I418f24338c90bae8a9dad473fa76329cea00a8c5
2018-07-27 13:45:51 -06:00
Sudheer Shanka
352a72ca09 Merge "Don't track per process state cpu times by default." 2018-07-27 17:21:41 +00:00
Olivier Gaillard
dd9e03a151 Merge "Disable collecting binder call stats by default." 2018-07-26 12:37:58 +00:00
Olivier Gaillard
a14d5b289c Disable collecting binder call stats by default.
It will help to figure out if calling Binder.getTransactionName has a
performance impact.

Test: manual
Change-Id: I0c9abd2ff3c5255bd67321645dfbf7eda54736bf
2018-07-26 11:51:38 +01:00
Olivier Gaillard
6f52d1572d Pull more data from binder calls.
Exceptions counts by class name and few new fields for binder calls.

> adb shell cmd stats pull-source 10023
Pull from 10023: { 1532528725000000000 49754068496 (10023)0x10000->java.lang.SecurityException[S] 0x20000->2[I]  }
Pull from 10023: { 1532528725000000000 49754068496 (10023)0x10000->java.lang.IllegalArgumentException[S] 0x20000->16[I]  }

Test: manual
Change-Id: I4d24528a7df8edde87f629837fb3117a0504d09e
2018-07-25 23:43:19 +01:00
Olivier Gaillard
289ba40237 Adds an Observer interface to observes binder API calls.
This is the first step to move BinderCallsStats implementation to the
server package in order to have an implementation more specific to the
system server (tracking charger on/off).

Removes the volatile keywords in BinderCallsStats.

Also exposes a clean API to StatsCompanionService instead of
BinderCallsStats directly.

Test: unit test
Change-Id: Ied98c555acc8489420104098561b4608346509b5
2018-07-25 21:20:59 +00:00
Dianne Hackborn
7aea7a4c22 Procstats: keep track of per-proc state active time
Associations now keep track of how long the association
was active for each process state that is seen in that
association.  This allows to better correlate how associations
are keeping the overall process in RAM.

Also do some cleanup of the dump output in various places
to make it more consistent.

For example, here is what we can now see about the contacts
provider:

Per-Package Stats:
  * com.android.providers.contacts / u0a13 / v28:
      Process android.process.acore (multi, 16 entries):
        SOff/Norm/    Imp Fg: +6s770ms
                      Imp Bg: +2s970ms
                     Service: +58ms
                    Receiver: +241ms
                  (Last Act): +2m55s844ms
                  (Cch Emty): +19m34s250ms
              Mod/(Last Act): +3s248ms
              Low/(Last Act): +4s585ms
             Crit/    Imp Fg: +1s273ms
                  (Last Act): +114ms
         SOn/Norm/       Top: +8m5s440ms
                      Imp Fg: +5s399ms
                      Imp Bg: +7s890ms
                     Service: +347ms
                  (Last Act): +12m28s564ms
                  (Cch Emty): +45s874ms
                  TOTAL  : +44m22s867ms
        PSS/USS (4 entries):
          SOff/Norm/(Last Act): 1 samples 10MB 10MB 10MB / 8.9MB 8.9MB 8.9MB / 60MB 60MB 60MB
                    (Cch Emty): 3 samples 8.2MB 9.2MB 11MB / 6.7MB 7.6MB 9.3MB / 6.7MB 24MB 57MB
           SOn/Norm/       Top: 4 samples 11MB 11MB 11MB / 9.8MB 9.8MB 9.8MB / 9.8MB 23MB 62MB
                    (Last Act): 3 samples 12MB 13MB 13MB / 11MB 11MB 11MB / 11MB 29MB 64MB
        myID=d0cbaa1 mCommonProcess=8ceb4c6 mPackage=com.android.providers.contacts
        Common Proc: android.process.acore/10013 pkg=com.android.providers.contacts
      Association com.android.providers.contacts.CallLogProvider:
        Process: android.process.acore
        mNumActive=0
          <- system / 1000:
             Total count 1: Duration +16ms / 0.00%
             Active count 1 (inline):
                Imp Fg: Duration +16ms / 0.00%
                 TOTAL: Duration +16ms / 0.00%
          <- com.google.android.dialer / u0a40:
             Total count 4: Duration +428ms / 0.02%
             Active count 1 (inline):
              Receiver: Duration +428ms / 0.02%
                 TOTAL: Duration +428ms / 0.02%
          <- com.google.android.as:nonpersistent / u0a48:
             Total count 8: Duration +287ms / 0.01%
          <- com.android.calllogbackup / u0a13:
             Total count 1: Duration +29ms / 0.00%
             Active count 1 (inline):
                Imp Bg: Duration +29ms / 0.00%
                 TOTAL: Duration +29ms / 0.00%
      Association com.android.providers.contacts.VoicemailContentProvider:
        Process: android.process.acore
        mNumActive=0
          <- com.google.android.dialer / u0a40:
             Total count 2: Duration +325ms / 0.01%
      Association com.android.providers.contacts.ContactsProvider2:
        Process: android.process.acore
        mNumActive=0
          <- com.google.android.apps.messaging / u0a129:
             Total count 5: Duration +12m49s649ms / 27%
             Active count 1 (inline):
                Imp Bg: Duration +12m49s649ms / 27%
                 TOTAL: Duration +12m49s649ms / 27%
          <- system / 1000:
             Total count 156: Duration +3s35ms / 0.11%
             Active count 2 (inline):
                Imp Fg: Duration +3s35ms / 0.11%
                 TOTAL: Duration +3s35ms / 0.11%
          <- com.google.android.googlequicksearchbox:search / u0a62:
             Total count 2: Duration +582ms / 0.02%
             Active count 2 (inline):
                Imp Bg: Duration +582ms / 0.02%
                 TOTAL: Duration +582ms / 0.02%
          <- com.google.android.gm / u0a83:
             Total count 3: Duration +97ms / 0.00%
          <- com.google.android.dialer / u0a40:
             Total count 3: Duration +21m31s285ms / 46%
          <- com.google.android.as:nonpersistent / u0a48:
             Total count 8: Duration +658ms / 0.02%
          <- com.google.android.contacts / u0a117:
             Total count 5: Duration +2s785ms / 0.10%
             Active count 3 (multi-field):
                Imp Bg: Duration +371ms / 0.01%
              Receiver: Duration +72ms / 0.00%
                 TOTAL: Duration +443ms / 0.02%
          <- com.google.android.gms / u0a36:
             Total count 208: Duration +8s924ms / 0.31%
             Active count 50 (multi-field):
                Imp Fg: Duration +3s329ms / 0.12%
                Imp Bg: Duration +67ms / 0.00%
               Service: Duration +10ms / 0.00%
                 TOTAL: Duration +3s406ms / 0.12%
          <- com.android.ims.rcsservice / 1001:
             Total count 4: Duration +387ms / 0.01%
             Active count 1 (inline):
                Imp Fg: Duration +387ms / 0.01%
                 TOTAL: Duration +387ms / 0.01%
          <- com.android.bluetooth / 1002:
             Total count 5: Duration +714ms / 0.03%
             Active count 4 (inline):
                Imp Fg: Duration +714ms / 0.03%
                 TOTAL: Duration +714ms / 0.03%
          <- com.google.process.gapps / u0a75:
             Total count 4: Duration +3m9s609ms / 6.7%
             Active count 16 (inline):
                Imp Bg: Duration +3m9s609ms / 6.7%
                 TOTAL: Duration +3m9s609ms / 6.7%

Bug: 110957691
Test: manual
Change-Id: I71bc15dbcc19da81157778e0ce1a91a848b59a04
2018-07-25 10:06:55 -07:00
Neil Fuller
f24692dd0c Merge "Break some dependencies on libcore internals" am: f672c2bcb8 am: 8d59399398 am: e3b9960277
am: f221bd013f

Change-Id: I4d64c0a3c3f3c10482f395b32c5f348383114b4f
2018-07-24 03:09:44 -07:00
Neil Fuller
f221bd013f Merge "Break some dependencies on libcore internals" am: f672c2bcb8 am: 8d59399398
am: e3b9960277

Change-Id: Ie28a471c402b9e6405a44ef8c9b5855158d12b80
2018-07-24 02:56:51 -07:00
Neil Fuller
e3b9960277 Merge "Break some dependencies on libcore internals" am: f672c2bcb8
am: 8d59399398

Change-Id: I06ccaff955d476cd6490729703b0000cbd4aa496
2018-07-24 02:47:25 -07:00
Neil Fuller
8d59399398 Merge "Break some dependencies on libcore internals"
am: f672c2bcb8

Change-Id: I234d938606b07a5116c39dfcc378d55bcd521c2d
2018-07-24 02:33:02 -07:00
Olivier Gaillard
2c13c6f37b Binder calls stats - random sampling.
Change the sampling method to be random. The previous mechanism recorded
one call for each key (uid/API name) and every X calls for each key:
- This is biased and will make it to interpret the data from
westworld.  It was especially unfair for apps using many different APIs
since the first call to each API was always recorded.
- It uses more memory since we will keep track of all the long tail

Simplify/unify the way we keep track of sampled calls.

Do not estimate the CPU usage of non-recorded calls
    long samplesCount = cs.callCount / mPeriodicSamplingInterval + 1;
    duration = cs.cpuTimeMicros / samplesCount;
It biases the results, let's use an example with 3 calls: 1ms, 3ms, 5ms
with an sampling interval of 2. With the previous algorithm we would get an
average per call of (1+1+3+2+5)/5=2.4ms. With the new one (1+3+5)/3=3ms.

Test: unit tests
Change-Id: I1dd7eb3c6c631b86a53485bccbfa397882cccc92
2018-07-23 17:39:22 +01:00
Neil Fuller
a84056a3d0 Break some dependencies on libcore internals
This commit swaps some internal details of libcore for some
abstractions on dedicated "internal facing" APIs. This reduces the
number of internal APIs used. There is an associated change in
libcore/

Bug: 111055375
Test: build / boot
Change-Id: Idddada1922701bd15475c840eaa76c505e545d33
2018-07-23 16:02:00 +01:00
Mike Ma
a31b0cf871 Merge "Fix a NPE in BatteryStatsImpl" into pi-dev
am: 0587bdd59f

Change-Id: I3bcc5d38995a38f068df6251826050fd59325e80
2018-07-20 21:14:10 -07:00
TreeHugger Robot
0587bdd59f Merge "Fix a NPE in BatteryStatsImpl" into pi-dev 2018-07-21 00:59:59 +00:00
Hui Yu
6fc752c737 Revert "Fix the memory leak in BatteryStatsImpl.Timebase.mObservers."
This reverts commit 420ed9ef22.

Reason for revert: The WeakReference change can prevent memory leak, but 
but the extra time spend on creating thousands of WeakReference objects has slowed down system_server startup as reported by b/111658334. Revert this CL for now, will find other approach to prevent memory leak. 

Change-Id: I07a5806e36159467459b841f63e2b0c55b6cc10b
2018-07-20 19:51:17 +00:00
TreeHugger Robot
49b58654c5 Merge "Revert "Use ArraySet for the list of observer WeakReference."" 2018-07-20 19:21:58 +00:00
Hui Yu
8eeac7d338 Revert "Use ArraySet for the list of observer WeakReference."
This reverts commit 3488f1afcb.

Reason for revert: The change to ArraySet increase system_server startup time by 20ms as reported in b/111658334. It is because add() operation into ArraySet takes much longer than ArrayList. 

Change-Id: I1523332a8c9fc74cfef29b119a3c4c54d55596ec
2018-07-20 17:24:36 +00:00
TreeHugger Robot
680d6df80e Merge "Merge pi-dev-plus-aosp-without-vendor into stage-dr1-aosp-master" into stage-dr1-aosp-master 2018-07-20 06:03:51 +00:00
Jinguang Dong
741d2fa757 Merge "Ensure dropbox could copy tombstone files to special folder." am: 12cdea59d3 am: 3034085dff am: 38c07c31dd
am: 7e49326439

Change-Id: I22b4da6b09985d99de20f6fe4602441d49c40993
2018-07-19 16:50:56 -07:00
Jinguang Dong
7e49326439 Merge "Ensure dropbox could copy tombstone files to special folder." am: 12cdea59d3 am: 3034085dff
am: 38c07c31dd

Change-Id: Id462f492b9a7882c700d090dcfe5eb366f44556f
2018-07-19 16:12:12 -07:00
Jinguang Dong
56bb0b7219 Ensure dropbox could copy tombstone files to special folder.
Process of tombstoned have changed the generation flow for
tombstone, and dropbox could not be notified when generating new
tombstone file any more, so dropbox could not copy and compress
tombstone file to /data/system/dropbox. We need to modify
observer events from CLOSE_WRITE to CREATE, and it could
work normally.

Bug: http://b/111608961
Test: 1 After tombstone is triggered, we could see the tombstone
      file in the data/system/dropbox directory.

Signed-off-by: Haoran Li <lihaoran5@huawei.com>

Change-Id: I9d6a31773e4a58658ffab214b1e337f27e9f3ae6
(cherry picked from commit fe8d2c9a8c)
2018-07-19 16:06:43 -07:00
Jinguang Dong
3034085dff Merge "Ensure dropbox could copy tombstone files to special folder."
am: 12cdea59d3

Change-Id: I8b7f1b2d07629af4cc0008679cd8daf7d1e0464f
2018-07-19 15:52:33 -07:00
Treehugger Robot
12cdea59d3 Merge "Ensure dropbox could copy tombstone files to special folder." 2018-07-19 21:10:43 +00:00
Xin Li
ef7cd8095c Merge pi-dev-plus-aosp-without-vendor into stage-dr1-aosp-master
Bug: 111615259
Change-Id: I0f2e2a580ade052b309802599141315c16e59aa2
2018-07-19 13:50:26 -07:00
Andreas Gampe
41d4a9b0dd Merge "Frameworks: Let GuardedBy accept multiple locks" am: 940a9e95df am: b32933c3cc am: a48b21a802
am: 02f0c20563

Change-Id: I5c04744e0b53b98a6e8cf7a11d1af43a2ff21593
2018-07-19 12:40:09 -07:00
Andreas Gampe
02f0c20563 Merge "Frameworks: Let GuardedBy accept multiple locks" am: 940a9e95df am: b32933c3cc
am: a48b21a802

Change-Id: I59fd2f34f26a036387e909b6ad9f6c78b6bdc897
2018-07-19 12:27:03 -07:00
Neil Fuller
44b035185c Merge "Use Base64 from android.util in LocalTransport" am: 8b9f98536e am: ec99ee195c
am: a234b4579c

Change-Id: I5b7caa54102f2334e6b15699bb0846c721cd9922
2018-07-19 12:15:37 -07:00
Andreas Gampe
b32933c3cc Merge "Frameworks: Let GuardedBy accept multiple locks"
am: 940a9e95df

Change-Id: Ic74f0c274873d4573bb2ae9a38e91d43df79280d
2018-07-19 11:38:07 -07:00
Treehugger Robot
940a9e95df Merge "Frameworks: Let GuardedBy accept multiple locks" 2018-07-19 17:29:03 +00:00
Jinguang Dong
fe8d2c9a8c Ensure dropbox could copy tombstone files to special folder.
Process of tombstoned have changed the generation flow for
tombstone, and dropbox could not be notified when generating new
tombstone file any more, so dropbox could not copy and compress
tombstone file to /data/system/dropbox. We need to modify
observer events from CLOSE_WRITE to CREATE, and it could
work normally.

Bug: http://b/111608961
Test: 1 After tombstone is triggered, we could see the tombstone
      file in the data/system/dropbox directory.

Signed-off-by: Haoran Li <lihaoran5@huawei.com>

Change-Id: I9d6a31773e4a58658ffab214b1e337f27e9f3ae6
2018-07-19 17:01:53 +00:00
Neil Fuller
ec99ee195c Merge "Use Base64 from android.util in LocalTransport"
am: 8b9f98536e

Change-Id: I8178aea431b41a521346fd40a81ae79a253e5554
2018-07-19 09:58:06 -07:00
Andreas Gampe
7e9236873c Frameworks: Let GuardedBy accept multiple locks
Widen the definition to take advantage of errorprone support.

Bug: 72666911
Test: m
Test: m RUN_ERROR_PRONE=true javac-check
Change-Id: Id792ee70b41b786da717f916e143786fe6308937
2018-07-19 08:12:43 -07:00
TreeHugger Robot
f931eb8fd1 Merge "Support rotation on secondary displays (1/N)" 2018-07-19 14:09:57 +00:00
Hui Yu
3488f1afcb Use ArraySet for the list of observer WeakReference.
On a real device, the mObservers list size can be close to 20k.
Previously mObservers is an ArrayList of strong Reference and there
is memory leak from it. This is why we changed to WeakReference. It
takes 2ms to remove an Reference element from a 20k ArrayList. But It
takes 9ms to remove a WeakReference element from a 20k ArrayList
. This increases chance of ANR. Now we change from ArrayList to
ArraySet, removing a WeakReference element from a 20k ArraySet only
takes 0.1ms. The memory difference between ArrayList and ArraySet is
minimum.

Fix: 111555898
Test: compare time takes to remove WeakReference element from ArrayList
and ArraySet.

Change-Id: If77633549197bcb3cf5269b537288f0189f2fcf3
2018-07-19 00:35:48 +00:00
Bernardo Rufino
cef59b95c9 Use Base64 from android.util in LocalTransport
Stop using bouncycastle as requested in the bug.

Bug: 111440841
Test: 1. Without changes
         a. adb shell bmgr transport android/com.android.internal.backup.LocalTransport
         b. adb shell bmgr backupnow com.android.providers.settings
         c. adb shell ls /cache/backup/1/_delta/<kv_package> #=> Base64 encoded keys
      2. Build and flash this CL
         a. adb shell bmgr restore 1 com.android.providers.settings #=> verify stuff restored
         b. adb shell rm /cache/backup/1/_delta/com.android.providers.settings/* /data/backup/com.android.internal.backup.LocalTransport/com.android.providers.settings
	 c. adb shell bmgr backupnow com.android.providers.settings
	 d. adb shell ls
	 /cache/backup/1/_delta/com.android.providers.settings # Verify same keys as 1c

Merged-In: I305bbae0e0af3639c1d45def19872e6da84624df
Change-Id: I305bbae0e0af3639c1d45def19872e6da84624df
(cherry picked from commit 7a6e032719)
2018-07-18 17:26:24 +01:00
Riddle Hsu
654a6f90b0 Support rotation on secondary displays (1/N)
- Allow to apply rotation animation on non-default display.
- Separate by display:
    Rotation related timeout.
    Pause/resume rotation.
- Able to get/watch non-default display orientation/rotation.

Bug: 111361251
Test: atest FrameworksServicesTests:DisplayContentTests
Test: go/wm-smoke
Change-Id: I9533f1b90b9969d455b6dc235c5318e39f63ab12
2018-07-18 23:48:13 +08:00
TreeHugger Robot
38cfe4e34c Merge "Use Base64 from android.util in LocalTransport" 2018-07-18 11:59:59 +00:00
Sudheer Shanka
7f6857eb80 Merge "Fix potential crash when per-procstate cpu times tracking is turned on." 2018-07-18 05:03:12 +00:00
Hui Yu
b7956e07ad BatteryStatsHistory needs to public for unit test to work.
Otherwise BatteryStatsHistoryTest gets "Illegal class access" error.

Test: atest BatteryStatsHistoryTest.java
Change-Id: I6efc9df24e1fd15cc3cdc4611a65d3e41efa63da
2018-07-17 10:46:34 -07:00
Sudheer Shanka
020239df85 Fix potential crash when per-procstate cpu times tracking is turned on.
When per-procstate cpu times tracking is turned on,
BatteryStatsImpl tries to access mKernelSingleUidTimeReader but
it's possible that mKernelSingleUidTimeReader hasn't been initialized
yet after a reboot and this could lead to a system_server crash.

Bug: 111523951
Test: manual
Change-Id: Id014f23fbe31fed64fba769f14ba4396a003092e
2018-07-17 17:24:06 +00:00
Bernardo Rufino
7a6e032719 Use Base64 from android.util in LocalTransport
Stop using bouncycastle as requested in the bug.

Bug: 111440841
Test: 1. Without changes
         a. adb shell bmgr transport android/com.android.internal.backup.LocalTransport
         b. adb shell bmgr backupnow com.android.providers.settings
         c. adb shell ls /cache/backup/1/_delta/<kv_package> #=> Base64 encoded keys
      2. Build and flash this CL
         a. adb shell bmgr restore 1 com.android.providers.settings #=> verify stuff restored
         b. adb shell rm /cache/backup/1/_delta/com.android.providers.settings/* /data/backup/com.android.internal.backup.LocalTransport/com.android.providers.settings
	 c. adb shell bmgr backupnow com.android.providers.settings
	 d. adb shell ls
	 /cache/backup/1/_delta/com.android.providers.settings # Verify same keys as 1c

Change-Id: I305bbae0e0af3639c1d45def19872e6da84624df
2018-07-17 10:17:43 +01:00
Sudheer Shanka
71f62497e3 Don't track per process state cpu times by default.
Fixes: 111441812
Test: manual
Change-Id: If91cbb29fe8a4fa267c530e62fde026febc34a7f
2018-07-16 18:55:05 -07:00