Commit Graph

5238 Commits

Author SHA1 Message Date
Jeff Sharkey
901c04270f Extend adoptable override to force on or off.
Virtual disks are adoptable by default, but for debugging purposes
we want to treat them as unadoptable in some cases.  Add the ability
for the "sm" shell command to force on/off, or return to default.

Bug: 77849654, 74132243
Test: manual
Change-Id: Ieda317396624ca081e5dd9568795483f684f9297
2018-04-20 13:11:23 -06:00
Mathew Inwood
c72ee1a4f2 Merge "StrictMode: fix non-SDK API usage detection." into pi-dev 2018-04-20 08:04:07 +00:00
TreeHugger Robot
dd61c7e8e7 Merge "Fix screen on count text dump" into pi-dev 2018-04-19 20:16:28 +00:00
TreeHugger Robot
3f8884829f Merge "Adjust media.codec process group upon request from mediaserver" into pi-dev 2018-04-19 17:40:39 +00:00
Mathew Inwood
d82a743002 StrictMode: fix non-SDK API usage detection.
The warning dedupe logic in the runtime meant that only the first usage of
each API was detected. Disable this logic when DETECT_VM_NON_SDK_API_USAGE
is enabled.

Test: m
Test: $ atest android.os.cts.StrictModeTest#testNonSdkApiUsage
Bug: 78268765
Change-Id: Iba1127b84180b9a5e5eb68abc4691ccad082b80e
2018-04-19 16:18:51 +01:00
Mathew Inwood
9f6bb5b761 Fail gracefully if we get a bad API whitelist.
If we send a bad API whitelist to the Zygote, it causes it to close the
socket. If we take no further action in AMS, it results in the same list
of exceptions being sent when we re-open the socket, resulting in it again
being closed. This results in no longer fork/start any new processes.
Since the list is persisted, this would result in the device entering a
boot loop upon reboot. Since no apps could be started, we cannot recover.

So in the case that the exemptions list causes problems, clear out the
list so we don't try to send it again next time. This means we will see
a single failure, but future attempts will succeed (obviously without
any whitelist). The device should not enter a boot loop.

Note, the test below relies on the fact that we can send at most 1024
arguments in a command to the Zygote (MAX_ZYGOTE_ARGC), and that each
item on the list is a separate argument.

Test: adb shell settings put global hidden_api_blacklist_exemptions \
Test:    $(for i in {1..1025}; do echo -n $i,; done)
Bug: 64382372
Change-Id: Ie47095d516c247ff6a8d667a2ac9b7be45f1acda
2018-04-19 10:12:28 +01:00
Tim Murray
a5843ebb59 Merge "ActivityManagerService: add restricted cpuset" into pi-dev 2018-04-18 23:43:53 +00:00
Chong Zhang
37520f0e06 Adjust media.codec process group upon request from mediaserver
Add method to allow dynamic adjustment of cpuset of media.codec
process. Only accept requests coming from mediaserver.

Bug: 72841545

Change-Id: Idb09d9a5162691503ecf6d811a528d9160326358
2018-04-18 13:23:24 -07:00
Chenjie Yu
e36018b272 add dump report reason to reports
+ also change uidmapping version numbers to int64_t

Bug: 78132855
Change-Id: Iac7ea93e4bf651bd65bd03383e7ab4971af4fc29
Fix: 78132855
Test: gts test
2018-04-18 20:19:21 +00:00
Tim Murray
fef10a47a8 ActivityManagerService: add restricted cpuset
Test: CTS
bug 78197570

Change-Id: I9dd8daba6426b42b7e7e9388dbdac7bd8110b6ca
2018-04-18 09:51:33 -07:00
Mike Ma
90902651b1 Fix screen on count text dump
dischargeScreenOffCount already includes dischargeScreenDozeCount.
Original code deducted dischargeScreenDozeCount twice. This only affects
text dump in bugreport. Proto and checkin dump are not affected.
Test: manual
Fixes: 78187276

Change-Id: Id93465ca75a4a1078e8f280a38b74b696ec62dd2
2018-04-17 21:12:56 +00:00
TreeHugger Robot
15d35c1274 Merge "Fixed power manager CTS test." into pi-dev 2018-04-17 10:39:30 +00:00
Jeff Sharkey
936c0868f8 Merge "Protect usage data with OP_GET_USAGE_STATS." into pi-dev 2018-04-17 00:04:53 +00:00
Jeff Sharkey
6b64925737 Protect usage data with OP_GET_USAGE_STATS.
APIs that return package usage data (such as the new StatsManager)
must ensure that callers hold both the PACKAGE_USAGE_STATS permission
and the OP_GET_USAGE_STATS app-op.

Add noteOp() method that can be called from native code.

Also add missing security checks on command interface.

Bug: 77662908, 78121728
Test: builds, boots
Change-Id: Ie0d51e4baaacd9d7d36ba0c587ec91a870b9df17
2018-04-16 12:44:32 -06:00
Dan Gittik
26b030d829 Fixed power manager CTS test.
Added an annotation necessary to allow the power manager CTS test to
access the non-public method nap.

Test: adb install -r \
      out/host/linux-x86/cts/android-cts/testcases/CtsOsTestCases.apk
      adb shell am instrument -e class android.os.cts.PowerManagerTest \
      -w android.os.cts/android.support.test.runner.AndroidJUnitRunner

Change-Id: Ida939f074654bef351e2b8fd563c8463431ce9c6
Fixes: 77907164
2018-04-16 18:50:10 +01:00
David Chen
d37bc23f50 Adds a code when statsd sends intent to getData.
If the data receiver is experiencing delays, there may be a queue of
multiple intents to collect the same data. This timestamp makes it
easy in the receiver to de-dupe these requests to call getData.

Also, we update how StatsCompanionService gets the snapshot by
requesting data for all known apps. I notice that Keep seems to have
a uid active even when it appears uninstalled.

Bug: 77981668
Test: Flashed marlin-eng and manually verified.
Change-Id: I509e19383ec4a5da8746dd0c76ac71a948c6877d
2018-04-13 17:01:13 -07:00
Wale Ogunwale
3da5f3b2dd Finalizing P SDK
Bug: 77588754
Test: builds
Change-Id: Ic06cad790a3dc53d012a7c43dfac911fc6dc61e7
2018-04-12 15:26:31 -07:00
TreeHugger Robot
a26e755900 Merge "Add stats logging to ServiceManager and NPMS" into pi-dev 2018-04-12 01:13:07 +00:00
TreeHugger Robot
ba6f173cb1 Merge "Add API to compute charge time remaining." into pi-dev 2018-04-12 00:27:53 +00:00
Makoto Onuki
49392d335a Add stats logging to ServiceManager and NPMS
ServiceManager:
- Do an event log every N getService() calls with total time spent
in getService().
where N = 100 for core UIDs and 200 for other apps.

- Do an event log if getService() takes longer than N ms.
where N = 10 for core UIDs and 50 for other apps.

... with some extra throttling.

NPMS:
- Do the basic "stats logger" log for updateNetworkEnabledNL() and
isUidNetworkingBlocked()

This CL also enhances StatsLogegr so it now can show the slowest call
and the max # of calls per-second.

Bug: 77853238
Test: Manual test:
- Insert a SIM card
- Set data limit
- toggle airplane mode
- toggle wifi
- toggle mobile data

Then
- "dumpsys netpolicy" and "dumpsys activity processes" and check the stats
- also check "adb logcat -b all | grep ' service_manager'"

Change-Id: I5789541063f95d0eac501189816c8604a4571ba0
2018-04-11 16:37:57 -07:00
Michael Wright
928167e044 Add API to compute charge time remaining.
This is so unbundled applications (e.g. dreams) can present a charge
time indicator that is in sync with the rest of the system.

Bug: 77919650
Test: manual
Change-Id: I7d62dea4fd49eb173b4f052a0fc36f4e7ce5b6bb
2018-04-11 23:47:31 +01:00
TreeHugger Robot
5d9498a62c Merge "Updating BatteryStats to account for Ambient Display sipper." into pi-dev 2018-04-11 22:28:17 +00:00
Chet Haase
f24335ec85 Merge "Add targetSdk check around new LinearLayout weighted measure behavior" into pi-dev 2018-04-11 22:17:44 +00:00
TreeHugger Robot
9054656c20 Merge "Trim the invalid uids and tags when reading uids/tags from chain." into pi-dev 2018-04-11 18:29:40 +00:00
David Pursell
6f42d1bac2 Merge "MessageQueue: explicitly remove FD event listeners." into pi-dev 2018-04-11 18:05:52 +00:00
TreeHugger Robot
6b317915e8 Merge "StatsManager throws exceptions" into pi-dev 2018-04-11 17:02:06 +00:00
Chet Haase
cb8488822c Add targetSdk check around new LinearLayout weighted measure behavior
Bug: 73827180
Test: Existing CTS tests in LinearLayoutTest
Change-Id: I88dfde3743d0f954cd275be6a0032fe30ef55c03
(cherry picked from commit 28230e5efa)
2018-04-11 16:22:47 +00:00
Bookatz
4f71629002 StatsManager throws exceptions
When StatsManager fails to connect to statsd, it now throws an exception
for the caller to catch. It also throws an exception of the config being
added is of an unreadable format.

Due to backwards compatibility issues, the old APIs could not be
changed, so new ones were made to replace the old ones. The old ones are
now temporary and will be removed when the compatibility issue is
resolved.

Bug: 77648233
Test: gts-tradefed run gts-dev --module GtsStatsdHostTestCases
Change-Id: Ibea05883a29b9b3ef9927d2f8fe295eb99832ab7
2018-04-10 19:07:32 -07:00
Kweku Adams
ef72895a48 Updating BatteryStats to account for Ambient Display sipper.
The sipper was added in http://ag/3667626 but BatteryStats wasn't
updated to properly output the data.

Bug: 77877717
Test: flash device and check batterystats output
Change-Id: Ibf98545a147f2d62dd29c57dd7efa14ed4c58aa6
2018-04-10 18:24:41 -07:00
Mathew Inwood
04194fef78 Configurable sampling rate for hidden API access log events.
To reduce log spam, we do not log all hidden API accesses. This CL allows
configuration of the sampling rate of the log events so it can be tweaked
later if necessary.

Test: m
Test: $ adb shell settings put global hidden_api_access_log_sampling_rate 65536
Bug: 64382372
Bug: 77517571
Change-Id: I659c22bd504564da58d972f94b774a9af4039386
2018-04-10 16:57:07 +01:00
Yangster-mac
5fa895ed7f Trim the invalid uids and tags when reading uids/tags from chain.
Test: manual test.

BUG: b/77817908
Change-Id: I5570c9bd0e76290e09ba84388db027dc272039a6
2018-04-09 14:45:28 -07:00
Jeff Sharkey
4627071291 Update storage wizard to latest UX mocks.
Changes to support Settings updates.

Bug: 76097999
Test: manual
Change-Id: I8944d4cb7be6a406d5cb6be25ff261b7631b3331
2018-04-09 13:05:48 -06:00
Philip P. Moltmann
f80809ffd7 Expose TestAPIs needed by GtsOsTestCases
Test: atest GtsOsTestCases on pi-dev:taimen and oc-mr1:sailfish
Bug: 77497338
Change-Id: I5de976991a857bfbed2faa943822af542601fa8b
2018-04-06 14:59:07 -07:00
Mathew Inwood
33d5138e13 Treat hidden API exemptions as whitelist.
Update docs accordingly.

Test: m
Bug: 64382372
Change-Id: Ief8daf3badeb046b0461a3ebcd289e242d559070
2018-04-06 12:14:16 +01:00
TreeHugger Robot
c8f5480981 Merge "StrictMode: Add support for warning on non SDK API usage." into pi-dev 2018-04-05 13:41:17 +00:00
David Pursell
5631f665a6 MessageQueue: explicitly remove FD event listeners.
When removing an FD listener from a MessageQueue, the MessageQueue waits
until the next event callback on that FD to remove it from the
underlying native Looper.

This works as expected most of the time, but due to the epoll rebuild
logic in the native Looper, there is a rare condition where FDs can get
stuck in the Looper:
  1. Register two or more FD listeners.
  2. Unregister FD1 listener and close FD1.
  3. Before the Looper processes FD1, get an event on FD2 and close it.
(3) will trigger a rebuild of the epoll set but as FD1 is no longer
valid it cannot be added back to the epoll set, and the MessageQueue
will never get the final callback to clean it up.

Each time this happens:
  * There is a small memory leak (24-32 bytes) in native Looper
  * Rebuilding the epoll set incurs slightly more processing
  * An error is logged for each lost FD on each epoll rebuild
This is fairly minimal, and does get cleaned up if the lost FDs is
re-opened during an epoll rebuild (since it can now be added back in),
but worst-case if a process somehow triggers this on a large number of
FDs it might be noticeable.

It seems worth it to just remove the FD explicitly right away to avoid
this case altogether.

Bug: 64083817
Test: [aosp_x86-userdebug emulator] adb shell am instrument -w \
        -e class android.os.cts.MessageQueueTest \
        android.os.cts/android.support.test.runner.AndroidJUnitRunner

Change-Id: I5093ca0d576473f490347ab4244af11a2835d23a
(cherry picked from commit 57f25ad657)
2018-04-03 21:20:47 +00:00
Takamasa Kuramitsu
2214b828e5 Fix reading exception from Parcel
It fails to read exception from Parcel using
Parcel#readException(int, String) because this method doesn't take into
account the remote stack trace info added in writeException().

Test: Manual
Bug: 77495513
Change-Id: I7b646b4a591306832897a42c4ed205d00019cc2b
2018-04-03 11:40:46 -07:00
Narayan Kamath
ad1b2a9cc1 StrictMode: Add support for warning on non SDK API usage.
Adds new API methods to enable and disable these warnings.

Bug: 73896556
Test: StrictModeTest

Change-Id: I049812fcdc79f191ab627766f66fc6f51b82e3d1
Merged-In: I096ce4c355c79cde1b98c3f48d392cd0b2ea5d98
2018-04-03 12:40:11 +01:00
Remi NGUYEN VAN
6f5a8db2e9 Merge "Add method to NetworkStatsService for UID stats." into pi-dev 2018-04-02 05:40:04 +00:00
Remi NGUYEN VAN
b6a920124f Add method to NetworkStatsService for UID stats.
Useful for clients such as BatteryStats which currently rely
on NetworkStatsFactory. Data at that stage is incomplete as
it does not account for tethering, VT data and corresponding
464xlat corrections.

Test: runtest frameworks-net, CTS tests pass.
Bug: b/72107146
Merged-In: I31c5b9b4a7c6e72910152415894a137f000a5858
Merged-In: I2527d95000c7500c824ede70f87ecb38e21ed323
(cherry picked from aosp 088ff6824f)

Change-Id: Ie80f1bb21124241f3414f9be77aceac9a44ec6d1
2018-03-30 18:58:18 +09:00
TreeHugger Robot
ee1661f7cd Merge "Handle public volumes and otherwise invalid UUIDs." into pi-dev 2018-03-29 23:33:18 +00:00
TreeHugger Robot
2254fe2e04 Merge "Only return internal path when not visible." into pi-dev 2018-03-29 22:16:32 +00:00
Jeff Sharkey
18f325012d Handle public volumes and otherwise invalid UUIDs.
Public volumes have short UUIDs (which aren't valid 128-bit UUIDs),
so we can't pass them around.  Even if they were valid UUIDs, we
don't handle clearing cached data on them, and they most likely
don't support fallocate(), so don't match them.

Test: manual
Bug: 74132243
Change-Id: Ib855eb869a86392e96ced94a9926c0b32b87e57e
2018-03-29 14:29:29 -06:00
Jeff Sharkey
18bbed5865 Only return internal path when not visible.
When a volume is visible (wrapped in sdcardfs), we need all file
operations to go through that sdcardfs layer to keep it in sync.

Test: manual
Bug: 73922090
Change-Id: I14f1f4743f470a6cbc78030e1ea8411f9910a5b9
2018-03-29 14:20:50 -06:00
TreeHugger Robot
f3faf62adc Merge "Root (uid=0) should be core. Fix UserHandle.isCore()." into pi-dev 2018-03-29 17:17:23 +00:00
TreeHugger Robot
925a04b775 Merge "Fix StatsCompanionService pull on bucket ends" into pi-dev 2018-03-29 17:00:25 +00:00
Chenjie Yu
1a0a941c20 Fix StatsCompanionService pull on bucket ends
+ change StatsPullerManager internal time units to be consistent
+ use series of alarms for pullers, instead of use setRepeating

Bug: 76223345
Bug: 75970648
Test: cts test
Change-Id: I9e6ac0ce06541f5ceabd2a8fa444e13d40e36983
2018-03-29 00:11:13 -07:00
Makoto Onuki
cbc3ccec61 Root (uid=0) should be core. Fix UserHandle.isCore().
Bug: 77240427
Change-Id: I057e8f50370fb1cd74ff2ebdab41990a682cec6f
Fix: 77240427
Test: build & boot
Test: "am set-standby-bucket com.google.android.apps.docs 40" will override ACTIVE
2018-03-28 16:49:47 -07:00
Mathew Inwood
8faeab8735 Configurable hidden API exemptions.
Extend the existing hidden_api_blacklist_exemptions config to support a
list of API signature prefixes to exclude from hidden API enforcement.

Push this list down to the zygote process when that process is created,
and when the list changes. This minimizes overhead, but should also ensure
that all new processes get the latest whitelist.

Test: $ adb shell settings put global hidden_api_blacklist_exemptions \
Test:    Landroid/view/RemoteAnimationDefinition\\\;:Landroid/app/ActivityManager\\\$TaskDescription\\\;
Test: Manually verify logcat output from app which uses named APIs
Bug: 73337509

(cherry picked from commit 2c6f97d4c9)

Merged-In: Ib1245b69da4dac50c6968f1be62f1a74591dc433
Change-Id: I7b590f272fdcfcda5f18e216788ac34bc58beaed
2018-03-28 11:54:17 +01:00
Narayan Kamath
77e0b7b821 Merge "Build: Remove MIN_SUPPORTED_TARGET_SDK_INT from public API." into pi-dev 2018-03-28 08:43:08 +00:00