Commit Graph

10021 Commits

Author SHA1 Message Date
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
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
TreeHugger Robot
9c52638f19 Merge "Let LocaleInfo implements Serializable" 2018-07-16 19:04:30 +00:00
Jeff Sharkey
162d771709 Merge "Extend SQLiteQueryBuilder for update and delete." 2018-07-14 21:35:29 +00:00
Hui Yu
0ed84f1263 Better Handling of Battery Stats History Overflow
Previously battery history is kept in the in-memory mHistoryBuffer
with size of 512KB (96KB on low memory device). When the buffer is
close to full we drop certain types of history. When the buffer is
full the whole buffer is reset and we lost elder history. On a
device with long battery life this problem is more frequent.

This CL changes mHistoryBuffer to 128KB (64KB on low memory device).
When the buffer is full, it is saved to history file on file system.
By default we allow 32 history files (64 history files on low-memory
device) which gives us 4MB history (compare to 512KB today).

The MAX_HISTORY_BUFFER and MAX_HISTORY_FILES can be remote configured
through GServices or P/H.

In case of history exceeding 4MB, the oldest history file is deleted
and new history file is open.

This change increases battery history by using disk file and the
chance of losing history is greatly reduced.

Bug: 67297625
Test: adb shell dumpsys batterystats --history
Change-Id: Id9aafea761649d7323b97d1e44135f7880a95414
2018-07-13 17:31:19 -07:00
Jeff Sharkey
6adc98c09c Extend SQLiteQueryBuilder for update and delete.
Developers often accept selection clauses from untrusted code, and
SQLiteQueryBuilder already supports a "strict" mode to help catch
SQL injection attacks.  This change extends the builder to support
update() and delete() calls, so that we can help secure those
selection clauses too.

Extend it to support selection arguments being provided when
appending appendWhere() clauses, meaning developers no longer need
to manually track their local selection arguments along with
remote arguments.

Extend it to support newer ContentProvider.query() variant that
accepts "Bundle queryArgs", and have all query() callers flow
through that common code path.  (This paves the way for a future
CL that will offer to gracefully extract non-WHERE clauses that
callers have tried smashing into their selections.)

Updates ContentValues to internally use more efficient ArrayMap.

Bug: 111268862
Test: atest frameworks/base/core/tests/utiltests/src/com/android/internal/util/ArrayUtilsTest.java
Test: atest cts/tests/tests/database/src/android/database/sqlite/cts/SQLiteQueryBuilderTest.java
Change-Id: I60b6f69045766bb28d2f21a32c120ec8c383b917
2018-07-13 18:11:37 -06:00
tmfang
b2c5ac86ee Let LocaleInfo implements Serializable
Settings need LocaleInfo can be serializabled.
So, it can be passed by Intent.

Bug: 111373939
Test: manual test
Change-Id: Ie42c99583688be6fdcec5dd12b105bee90b2577e
2018-07-13 18:14:12 +08:00
Lucas Dupin
401ea1647a Merge "Dark Notification Shade" 2018-07-13 02:09:31 +00:00
TreeHugger Robot
af93684515 Merge "Fix a few issues with procstats associations:" 2018-07-13 00:56:29 +00:00
Lucas Dupin
f03e752407 Dark Notification Shade
Test: adb shell service call uimode 4 i32 1 # day
Test: adb shell service call uimode 4 i32 2 # night
Bug: 110758454
Change-Id: Ib6fce91d1aeff7e1fbfe8a7a528095487fbdb3f8
2018-07-12 17:30:34 -07:00
Dianne Hackborn
2fd8ce4933 Fix a few issues with procstats associations:
- Use the correct state when comparing the association
  with the process.  (Was causing warning spam as well.)

- Don't wtf if we call startAssociationIfNeeded() no a
  ServiceRecord that doesn't have a process...  that is normal
  when first bringing up a service.

Also add a switch to turn this all off, which for now is
leaving it on.

Test: manual
Bug: 111391911
Bug: 111302807
Bug: 111131998

Change-Id: I2d3f43fd99c7ade24c867ad80a728d898ab0e6c5
2018-07-12 15:45:48 -07:00
Olivier Gaillard
00bfb1b95a Collects binder call stats data through WestWorld.
We require binder calls detailed tracking to be enabled to collect the
stats (in addition to enabling it in WestWorld).

Test: unit test + manual

adb shell cmd stats pull-source 10022
Pull from 10022: { 1531240941000000000 25807560798 (10022)0x10000->0[I]
0x20000->com.android.server.StorageManagerService$3[S]
0x30000->onVolumePathChanged[S] 0x40000->1[L] 0x50000->0[L]
0x60000->18490[L] 0x70000->18490[L] 0x80000->2611[L] 0x90000->2611[L]
0xa0000->0[L]  } ...

Change-Id: I07cad5d8678426cdac45872cda028ea7a85d7d81
2018-07-11 10:44:49 +01:00
Olivier Gaillard
103aae2096 Resolve codes to method names for binder call stats.
Test: unit test

Change-Id: Ie2178e6f9ebb900251d7c9ab20587d3c01acda83
2018-07-10 12:56:08 +01:00
TreeHugger Robot
672763530c Merge "Now track "active time" in procstats." 2018-07-10 01:12:22 +00:00
Dianne Hackborn
95031ef2e6 Now track "active time" in procstats.
Associations now keep track of the time they are
actively involved in impacting their target application.
This is based on the procstate propagating through the
association being the same as the procstate of its target
process...  so it may count as active when there is
another reason for that process to be in the same state.

To do this, we now maintain a set of "tracking
associations" -- these are in-use associations that
we know we need to be tracking to determine whether
they are active.  This list is built based on whether
we at all consider an association during an oom_adj
computation, and at the end of that walked to determine
which of those associations are currently active.

Also add tracking of associations through external
provider references, with a tag name now needing to be
passed through so we can mark up the reason for the
external reference.

Test: manual
Bug: 110957691
Change-Id: I426a499834e20a9d7f2b439faf9cb398d9792fa2
2018-07-09 12:46:53 -07:00
Olivier Gaillard
d2af61a1e8 Merge "Add experiment flag to control binder call stats." 2018-07-09 19:09:47 +00:00
Olivier Gaillard
d202011c37 Transforms uid to packages for the raw data
Test: manual

Change-Id: I8d6ef245bb42a1f1c058dc43e23e82f2a8b70264
2018-07-06 16:10:44 +01:00
Neil Fuller
6e162540ab Merge "Track constructor changes in libcore/" am: f94eb29500 am: 67dcf6da3c
am: 9ca5d6f0a0

Change-Id: I7e7115799180d17e4ad6468e155aed79fc8600cb
2018-07-05 05:34:45 -07:00
Neil Fuller
9ca5d6f0a0 Merge "Track constructor changes in libcore/" am: f94eb29500
am: 67dcf6da3c

Change-Id: I1205219e1fead95ecdb8f9ce5d503ec416baf4c2
2018-07-05 05:25:35 -07:00
Neil Fuller
67dcf6da3c Merge "Track constructor changes in libcore/"
am: f94eb29500

Change-Id: I344d9210bd173f78651318366c852f65afe969d6
2018-07-05 05:14:26 -07:00
Neil Fuller
33e7250f1f Merge "Track changes in libcore to remove a constructor" 2018-07-05 10:27:40 +00:00
Olivier Gaillard
1d7f615eec Add experiment flag to control binder call stats.
For instance, to enabled detailed tracking locally.
adb shell settings put global binder_calls_stats detailed_tracking=true

Also adds the ability to turn off data collection completely and
changing the sampling interval. Uploading data through westworld can
re-use the same flag once implemented.

Test: Unit tested

Change-Id: I808c9902b8124ab643d9b197703d537da040ae3e
2018-07-04 13:36:46 +01:00
Neil Fuller
8a1683f0a2 Track changes in libcore to remove a constructor
Track changes in libcore to remove a constructor + lint
import order changes. Instead of the constructor a utility
method is introduced.

Test: Build / boot
Bug: 111055375
Change-Id: Id683a9d9d6e27d4c8df623dae189da9e74a6d410
2018-07-04 09:10:55 +01:00
TreeHugger Robot
9a8e27a915 Merge "Allow UiAutomation to adopt the shell permission indentity" 2018-07-04 03:00:14 +00:00
TreeHugger Robot
2a04303567 Merge "Update mMinLearnedBatteryCapacity when necessary." 2018-07-04 02:32:37 +00:00
Svet Ganov
d873ae62c4 Allow UiAutomation to adopt the shell permission indentity
For testing we often need to run shell commands. This can be done
today via running a shell command from an instrumentation test
started from the shell. However, this requires adding shell commands
which are not in the API contract, involve boilerplate code, require
string parsing, etc.

This change allows an instrumentation started from the shell to
adopt the shell UID permission state. As a result one can call APIs
protected by permissions normal apps cannot get by are granted to
the shell. This enables adding dedicated test APIs protected by
signatures permissions  granted to the shell.

Test: cts-tradefed run cts-dev -m CtsUiAutomationTestCases
          -t android.app.uiautomation.cts.UiAutomationTest#testAdoptShellPermissions

bug:80415658

Change-Id: I4bfd4b475225125512abf80ea98cd8fcacb6a1be
2018-07-03 16:39:44 -07:00
zhouwenjie
8a871d818b Update mMinLearnedBatteryCapacity when necessary.
Currently mMinLearnedBatteryCapacity is only updated once (when it's
-1). We check the minimum of mMinLearnedBatteryCapacity and the new
chargeFullUah reading but never update mMinLearnedBatteryCapacity to the
new value.

Bug: 111132682
Test: manual
Change-Id: I1680e7a4bdf9176feb2a2dcc9f2c10c829202bda
2018-07-03 16:17:02 -07:00
Olivier Gaillard
f82d2e7369 Tracks exception count by class name.
The goal is to figure out if it would be worth monitoring these
exceptions. If exception types are only caller issues like
SecurityException and IllegalArgumentException, it is probably not worth
it. If we can find NPE or internal exceptions it would be worth
uploading the exceptions through dropbox.

Test: unit test

Change-Id: I779d43a0e6ca1a33535b90809491675420a51726
2018-07-03 22:22:42 +01:00
Neil Fuller
038b20c99b Track constructor changes in libcore/
The 2-arg constructor is being removed.

Test: build / boot
Bug: 111055375
Change-Id: I72413a8c7885f9514a88f59deb649fa755deff92
2018-07-03 19:22:45 +01:00
TreeHugger Robot
9445ca3ab9 Merge "Bugreport: Fix SystemUI service from being dumped twice 1/2" 2018-07-03 17:42:25 +00:00
TreeHugger Robot
e026b408b5 Merge "Track max CPU and latency of binder calls" 2018-07-03 11:11:27 +00:00
Vishnu Nair
c69cd4480e Bugreport: Fix SystemUI service from being dumped twice 1/2
Bug: 110490179
Fix: 110490179

Test: Manual test dumpsys activity
  adb shell dumpsys activity service all-platform-non-critical
  adb shell dumpsys activity service all-platform
  adb shell dumpsys activity service
  Take bugreport and check contents

Test: atest FrameworksCoreTests:DumpUtilsTest

Change-Id: I9173d3fa0cc3aaf42e3ab03e7e2892cf4188b13b
2018-07-02 14:29:31 -07:00
TreeHugger Robot
c0b67c9385 Merge "Add more data (fg services, associations) to procstats." 2018-07-02 17:30:22 +00:00
Olivier Gaillard
11965ede90 Track max CPU and latency of binder calls
Test: unit tested

Change-Id: I1429e8c34e9cb0572975fda3ec18e85d6caf3cad
2018-07-02 15:50:57 +01:00
TreeHugger Robot
c984df9763 Merge "Fix a NPE in BatteryStatsImpl" 2018-06-30 01:50:19 +00:00
Mike Ma
31cdfb401d Fix a NPE in BatteryStatsImpl
ServiceManager.getService("batteryproperties")) may return null for some
devices right after boot. (We don't know why, need further investigation)
This causes async batterystats update to crash, leaving BatteryStats in a
bad state (OnBattery() == true, but mOnBatteryTimeBase is not running),
which does not accept aggregated stats update anymore.

Bug: 109930230
Test: manual
Change-Id: I0654beff95f0a2b9df2567f1a2efffd3330e58ff
2018-06-29 16:55:17 -07:00
Dianne Hackborn
2aec55a658 Add more data (fg services, associations) to procstats.
- Keep track of foreground services.
- Keep track of associations between processes.

The big part of this is the second, tracking associations.
We have have procstats keeping continual track of associations
between processes, much like the "am track-associations"
command.  Currently the data kept on them is very minimal
(just the count and total duration, not separated by other
states) due to the potential number of them that there can be,
but we can look in to trying to maintain more data going
forward if it is feasible.

The way this is incorporated into the activity manager makes
it a little different than "am track-associations," with
potentially some new interesting data available.  These
associations are tied with the connection objects in the
activity manager, so they only count while the target
process is actually running (so their duration should match
with the lifecycle of the target).  They are tied to the
target package, since that is what we know all of the
information we need for rooting data in procstats (package
name, uid, and version code of that package); only the process
name and uid are available for the source of the association

Since these are tied to the connection components, it is
possible that we could even maintain data on the duration per
proc state that is flowing from that association in to the
target process.  That would be very useful, but would add
a fair amount more overhead in data being tracked.

English output of the new association data looks like:

  * com.android.providers.downloads / u0a17 / v28:
      * Prc android.process.media / u0a17 / v28:
               TOTAL: 0.45%
              Imp Bg: 0.26%
             Service: 0.18%
            Receiver: 0.01%
          (Last Act): 0.78%
            (Cached): 37% (5.2MB-5.8MB-8.2MB/3.9MB-4.4MB-6.0MB/3.9MB-7.0MB-50MB over 18)
      * Svc com.android.providers.downloads.DownloadIdleService:
        Process: android.process.media
            Running count 3 / time 0.01%
            Bound count 3 / time 0.01%
            Executing count 6 / time 0.00%
      * Svc com.android.providers.downloads.DownloadJobService:
        Process: android.process.media
            Running count 6 / time 0.21%
            Bound count 6 / time 0.21%
            Executing count 12 / time 0.00%
      * Asc com.android.providers.downloads.DownloadIdleService:
        Process: android.process.media
          <- system / 1000:
             Count 3 / time 0.01%
      * Asc com.android.providers.downloads.DownloadStorageProvider:
        Process: android.process.media
          <- com.android.documentsui / u0a10:
             Count 1 / time 0.00%
      * Asc com.android.providers.downloads.DownloadProvider:
        Process: android.process.media
          <- com.android.vending / u0a11:
             Count 39 / time 2.6%
          <- system / 1000:
             Count 3 / time 0.00%
          <- com.google.android.gms / u0a36:
             Count 8 / time 0.01%
      * Asc com.android.providers.downloads.DownloadJobService:
        Process: android.process.media
          <- system / 1000:
             Count 6 / time 0.21%

And the corresponding checkin:

pkgproc,com.android.providers.downloads,10017,28,android.process.media,0nf:717,0nb:71332,0ns:48335,0nr:3652,0nl:218034,0ne:10103500,0mf:21,0ms:614,0me:185,1ne:100236
pkgpss,com.android.providers.downloads,10017,28,android.process.media,0ne:18:5310:5950:8434:4036:4522:6140:4036:7127:51056
pkgsvc-run,com.android.providers.downloads,10017,28,.DownloadIdleService,3,0n:1849
pkgsvc-bound,com.android.providers.downloads,10017,28,.DownloadIdleService,3,0n:1794
pkgsvc-exec,com.android.providers.downloads,10017,28,.DownloadIdleService,6,0n:89
pkgsvc-run,com.android.providers.downloads,10017,28,.DownloadJobService,6,0n:58224
pkgsvc-bound,com.android.providers.downloads,10017,28,.DownloadJobService,6,0n:58154
pkgsvc-exec,com.android.providers.downloads,10017,28,.DownloadJobService,12,0n:187
pkgasc,com.android.providers.downloads,10017,28,.DownloadIdleService,system,1000,3,1790
pkgasc,com.android.providers.downloads,10017,28,.DownloadStorageProvider,com.android.documentsui,10010,1,80
pkgasc,com.android.providers.downloads,10017,28,.DownloadProvider,com.android.vending,10011,39,1067022
pkgasc,com.android.providers.downloads,10017,28,.DownloadProvider,system,1000,3,96
pkgasc,com.android.providers.downloads,10017,28,.DownloadProvider,com.google.android.gms,10036,8,1951
pkgasc,com.android.providers.downloads,10017,28,.DownloadJobService,system,1000,6,58149

Bug: 110957691
Test: manual
Change-Id: Id466b085303527e7bf7354f7f33a0fbaa768fb7b
2018-06-29 09:36:19 -07:00
Hui Yu
420ed9ef22 Fix the memory leak in BatteryStatsImpl.Timebase.mObservers.
The observer does not always remove themself after adding themself into
mObservers list. The strong reference in mObservers causes memory leak.
The fix is to change mObservers to hold WeakReference.

Fix: 80443940
Test: "adb shell cmd battery unplug" and "adb shell cmd battery set ac",
observe memory usage from Android Monitor.

Change-Id: I27436e350fa0d211c4c64114411a6603824ce599
2018-06-28 20:09:12 +00:00
Dan Sandler
69baf0d2a4 Merge "P is for PAINT." into pi-dev
am: bed68535c0

Change-Id: Ibf1f14dea6efd09f5d2777d663bdfa69254d572d
2018-06-27 21:10:03 -07:00
Dan Sandler
45f17c5bef P is for PAINT.
Bug: 109925861
Test: adb shell am start \
        -a android.intent.action.MAIN \
        -c com.android.internal.category.PLATLOGO
Merged-In: Ic3020007c716be264e9523d6dbae9e13a95fa571
Change-Id: Ic3020007c716be264e9523d6dbae9e13a95fa571
2018-06-27 18:58:59 -04:00
Dan Sandler
d1f9f5338f P is for PAINT.
Bug: 109925861
Test: adb shell am start \
        -a android.intent.action.MAIN \
        -c com.android.internal.category.PLATLOGO
Change-Id: Ic3020007c716be264e9523d6dbae9e13a95fa571
2018-06-27 18:58:14 -04:00
Yohei Yukawa
99e1f6e04b Notify new IME target before IME starts interacting
Previously, there was a time window between when an IME starts new
input and when the IME issues an IPC IMM#setImeWindowStatus() so that
WindowManagerService (WMS) can be notified about the new IME target
window.

With this CL, it is now guaranteed that WindowManagerService (WMS) is
always notified about the new IME target window before IME starts
interacting with that window.

Note that WMS is not using notified IME target window yet hence there
should be no user-visible behavior change.

Bug: 110531072
Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases
Change-Id: I032b91ce722a16b17518a5d88015c574d7d3e51b
2018-06-22 17:33:19 -07:00
TreeHugger Robot
abe78cd313 Merge changes from topic "biometrics-face"
* changes:
  5/n: Move FaceService to biometrics directory
  4/n: Add face authentication framework
2018-06-22 18:44:27 +00:00
Gilad Bretter
cb51b8b847 4/n: Add face authentication framework
This change is cherry-picked and rebased from AOSP
https://android-review.googlesource.com/c/platform/frameworks/base/+/660242

Add face recognition as an identification method, following fingerprint
design. Unlike fingerprint, only one face template can be enrolled per
user, and a vendor message is passed from the HAL all the way to the
client callback to allow GUI indication about the enrolled face
templates.

Add FaceAuthenticationManager and FaceService.
Add face authentication capability to TrustManager and Keyguard.
Modify TrustManager and KeyguardUpdateMonitorCallback fingerprint code
to support generic biometric method to eliminate duplications.
Add BiometricSourceType enum to keep track of the specific biometric
method.

Test: biometric authentication still works on the device

Fixes: 110385761

Change-Id: I5d04fe69a112c13d3ef7330b9c08c146e36c5335
Signed-off-by: Gilad Bretter <gilad.bretter@intel.com>
2018-06-21 17:00:07 -07:00
Arthur Hung
b03ab2eea1 Merge "Get mime type from getDocumentType instead of from file name" 2018-06-20 03:57:50 +00:00
Yohei Yukawa
1235c24a0f Remove unused parameter from TSMS IPC
TextServicesManager always sets null to the "locale" parameter in
ITextServicesManager#getCurrentSpellCheckerSubtype then
TextServicesManagerService always ignores that parameter.  It can be
safely removed.

Bug: 110275412
Test: Manually verified that spell checker still works
Change-Id: I5d85089899b0bd077f69971d77095859086a8d52
2018-06-17 20:52:37 -07:00