Commit Graph

3883 Commits

Author SHA1 Message Date
Fyodor Kupolov
6e68706f67 Do not remove file_cache when exiting demo mode
When clearing /data/preloads directory, keep files in file_cache directory.
The content there will only be removed if systems runs low on storage.

Test: manual + RetailDemoModeServiceTest
Bug: 31008665
Change-Id: Id335d84940ee829617986f5345f169271a333de1
2017-01-25 12:33:47 -08:00
Adam Lesinski
9aa513bf95 Merge "Add support for Split APK dependcies" 2017-01-25 16:56:51 +00:00
Nicolas Prévot
38c2395078 Merge "Allow DO to provision even if it has set disallow remove mp." 2017-01-25 11:42:05 +00:00
Adam Lesinski
4e8628157a Add support for Split APK dependcies
Apps can now declare in their base APK AndroidManifest.xml
that they want to have their split APKs loaded in isolated
Contexts. This means code and resources from the split
get loaded into their own ClassLoader and AssetManager.

<manifest xmlns:android="..."
          ...
          android:isolatedSplits="true"
          ...

In order to make this more useful, splits can declare dependencies
on other splits, which will all get pulled in to the Context
and run as expected at runtime.

A split declares its dependency on another split by using the
tag <uses-split> in its AndroidManifest.xml:

<manifest xmlns:android="...">
    ...
    <uses-split android:name="feature_split_1" />
    ...

A split can have a single parent on which it depends on. This is
due to the limitation of having a single ClassLoader parent.
All splits depend on the base APK implicitly.

PackageManager verifies that no cycles exist and that each dependency
is present before allowing an installation to succeed.

The runtime will then load splits based on the dependencies.

Given the following APKs:

base <-- split A <-- split C
  ^----- split B

If an Activity defined in split C is launched, then the base,
split A, and split C will be loaded into the ClassLoader defined
for the Activity's Context. The AssetManager will similarly be loaded
with the resources of the splits.

A split can be manually loaded by creating a Context for that split, defined
by its name:

Context.createContextForSplit("my_feature_split_1");

All installed Activities, Services, Receivers, and Providers are accessible
to other apps via Intent resolution. When they are instantiated, they are
given the appropriate Context that satisfies any dependencies the split they
were defined in stipulated.

Test: WIP (CTS tests to come)
Change-Id: I8989712b241b7bc84381f2919d88455fcad62161
2017-01-24 18:34:08 -08:00
Jesse Hall
cb3cde5b5d Don't lower priority of EGL Init thread am: 37e63c705e
am: e8a5df8530

Change-Id: I5fe07a9c459e8be4e5ef19aca8d750eecfd44bb3
2017-01-24 18:59:00 +00:00
Jesse Hall
e8a5df8530 Don't lower priority of EGL Init thread
am: 37e63c705e

Change-Id: Icd21c9243558f4427d48f967f4ea4ae7aa1e2b02
2017-01-24 18:13:07 +00:00
Nicolas Prevot
d37c4a99b2 Allow DO to provision even if it has set disallow remove mp.
If the device owner has set DISALLOW_REMOVE_MANAGED_PROFILE,
and there is already a managed profile:
it should be allowed to provision a new managed profile by
deleting the old one.
Test: adb shell am instrument -e class
com.android.server.devicepolicy.DevicePolicyManagerTest
-w
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
BUG:34116228

Change-Id: I9e6f39924107aee40b57d22e638487a1ea3132de
2017-01-24 16:36:14 +00:00
Jesse Hall
37e63c705e Don't lower priority of EGL Init thread
The EGL Init thread spends a lot of time loading shared libraries,
which involves reading pages and adjusting VM pages. Previously it was
a low priority thread, which meant that when it blocked while holding
a VM lock, it might take a while to be scheduled again once ready, so
it would hold the VM lock longer than necessary, blocking other
threads waiting on soft faults, etc. Classic priority inversion.
Leaving the thread at normal priority causes it to interfere *less*
with critical-path Activity launch work.

Bug: 34611670
Test: go/platform-startup, specifically:
    ./tradefed.sh run google/template/local --template:map test
    google/test/performance/app-launch-perf
    --post-boot-command "service call persistent_data_block 6 i32 1"
    --post-boot-command "service call persistent_data_block 7 i32 1"
    --apps Clock alarmclock --trial-launch --launch-iteration 10
    --launch-order cyclic --drop-cache --trace-directory sdcard
    --trace-iteration 2 --simple-perf-cmd "simpleperf stat -a"
    --report-metrics all --force-skip-system-props --alt-dir `pwd`

Change-Id: I17647c657da64d15f40f8f2b97ee3400e1f0be7f
2017-01-24 00:09:27 -08:00
Jeff Sharkey
9bed070b09 More APIs for cache status and behavior.
Add APIs for apps to query their cache usage compared to their
currently allocated quota.  Since an app's private storage may live
on a different storage volume than the primary shared/external
storage, offer APIs to retrieve those values separately.

Add APIs to control two new cache purging behaviors:

-- setCacheBehaviorAtomic() which causes a marked directory and its
contents to be treated as an atomic unit.
-- setCacheBehaviorTombstone() which causes the OS to truncate
files instead of deleting them.

Test: builds, boots
Bug: 33811826, 33965858, 27948817
Change-Id: I45de165623775c359f78b4ee544c2b5831b8d483
2017-01-23 21:02:12 -07:00
Daichi Hirono
baa0116854 Remove StorageManager#mountAppFuse hidden API.
The API should be replaced with StorageManager#openProxyFileDescriptor.

Bug: 32891253
Test: build
Change-Id: Ibbf8b64f3a39900a1f05a52132aa931491d6fd48
2017-01-23 09:36:59 +09:00
TreeHugger Robot
af6668bc9d Merge "resolve merge conflicts of 5fa7fb1d9f to master" 2017-01-21 02:41:19 +00:00
TreeHugger Robot
5feefa54c4 Merge "Introduce RescueParty." 2017-01-21 02:22:43 +00:00
Jesse Hall
3bb7e5c909 resolve merge conflicts of 5fa7fb1d9f to master
Test: make
Change-Id: I7f119535a120303796fcd08f0274269f7d0dbaba
2017-01-20 17:04:48 -08:00
Jeff Sharkey
fe6f85cac9 Introduce RescueParty.
When a device gets stuck in a crash loop, it's pretty much unusable
and impossible for users to recover from.

To help rescue devices from this state, this change introduces a new
feature that watches for runtime restart loops and persistent app
crash loops, and escalates through a series of increasingly
aggressive rescue operations.  Currently these rescue levels walk
through clearing any experiments in SettingsProvider before finally
rebooting and prompting the user to wipe data.

Crash loops are detected based on a number of events in a specific
window of time.  App stats can be stored in memory, but boot stats
need to be stored in system properties to be more robust.

Start up RecoveryService much earlier during the boot so we can
reboot into recovery when needed.

Add properties tha push system_server or SystemUI into a crash loops
for testing purposes.

Test: builds, boots, forced crashing walks through modes
Bug: 24872457, 30951331
Change-Id: I6cdd37682973fe18de0f08521e88f70ee7d7728b
2017-01-20 17:36:38 -07:00
Jesse Hall
fd104e7fde Load EGL early in Activity launch, instead of in Zygote
Preloading EGL in Zygote was originally a memory footprint
optimization, but it turns out to be an important app startup time
optimization as well. Preloading EGL in Zygote is incompatible with
updatable graphics drivers, but we don't want to do it on-demand as
part of drawing the first frame either, since that increases
first-frame latency unacceptably.

This change removes Zygote preload, and instead loads EGL on a
low-priority background thread immediately after choosing which
graphics driver to use. This means it is usually done well before
drawing the first frame, without significantly disrupting other
activity launch work.

Test: observe systrace of Calculator launch on bullhead
Bug: 34404021
Change-Id: I6a0f6b90ade21848a10d51ddae62c936f70151b5
Merged-In: I887aa09bd35b088b16f53a89838a0c7c98f15761
2017-01-20 15:58:20 -08:00
Jesse Hall
0d3537c67b Merge "Load EGL early in Activity launch, instead of in Zygote" into nyc-mr2-dev-plus-aosp 2017-01-20 23:57:34 +00:00
Jeff Sharkey
f5d2c7278e Merge "Add Binder support for Parcelable exceptions." am: a2ef6b5741 am: c3fbf32011 am: 4a0a4664b9
am: 7bb9ccc1e5

Change-Id: I9346a576d57c9f7093b875c4a43134f2ef095018
2017-01-20 23:12:19 +00:00
Jeff Sharkey
7bb9ccc1e5 Merge "Add Binder support for Parcelable exceptions." am: a2ef6b5741 am: c3fbf32011
am: 4a0a4664b9

Change-Id: I9b5667ca6e5497a4eedaaf88979a1a3d0e22c174
2017-01-20 23:03:40 +00:00
Jeff Sharkey
a2ef6b5741 Merge "Add Binder support for Parcelable exceptions." 2017-01-20 22:45:04 +00:00
Jesse Hall
5fa7fb1d9f Load EGL early in Activity launch, instead of in Zygote
Preloading EGL in Zygote was originally a memory footprint
optimization, but it turns out to be an important app startup time
optimization as well. Preloading EGL in Zygote is incompatible with
updatable graphics drivers, but we don't want to do it on-demand as
part of drawing the first frame either, since that increases
first-frame latency unacceptably.

This change removes Zygote preload, and instead loads EGL on a
low-priority background thread immediately after choosing which
graphics driver to use. This means it is usually done well before
drawing the first frame, without significantly disrupting other
activity launch work.

Test: observe systrace of Calculator launch on bullhead
Bug: 34404021
Change-Id: I887aa09bd35b088b16f53a89838a0c7c98f15761
2017-01-20 13:50:41 -08:00
Jeff Sharkey
8e8269fc11 Merge "StrictMode to detect untagged network traffic." 2017-01-20 17:31:59 +00:00
Jeff Sharkey
619a511d4f StrictMode to detect untagged network traffic.
Network usage is tracked by the kernel at the UID level, which is
granular enough for normal apps, but large components (such as the
system server) are impossible to debug without adding additional
socket tagging to help identify subsystems within a UID.

To help ensure that system components tag all their network traffic,
this change offers a new StrictMode option to detect and report
untagged sockets.

Test: builds, boots, all common traffic tagged
Bug: 30943431, 30414041
Change-Id: I825c7941076054732264690247de2863342638e2
2017-01-19 20:52:05 -07:00
Jeff Sharkey
032c08ad6b Simplify FileUtils.stringToFile().
Convert to byte[] directly instead of using heavier FileWriter.

Test: builds, boots
Bug: 34364961
Change-Id: If0c09a924cd73f2c4965ac9d206f9c060788d27c
2017-01-19 17:11:55 -07:00
TreeHugger Robot
b55db281da Merge changes I1606b184,Id78dd4ab
* changes:
  Publish StorageManager#openProxyFileDescriptor API.
  Add StorageManager#openProxyFileDescriptor.
2017-01-19 02:15:34 +00:00
Tao Bao
8fe4df9fba Merge "Revert "RecoverySystem: Fix the issue in installPackage()."" am: 9311dbf9e4 am: 731445ebf7 am: b20ce70cca
am: 0770c86e5c

Change-Id: If50d623f41ccf8b5fa8756957b3479fdedaffc41
2017-01-19 02:08:27 +00:00
Tao Bao
0770c86e5c Merge "Revert "RecoverySystem: Fix the issue in installPackage()."" am: 9311dbf9e4 am: 731445ebf7
am: b20ce70cca

Change-Id: I931ce2f47714032b27cb092699ae3fbc69563fc0
2017-01-19 02:04:18 +00:00
Tao Bao
cc76991f37 Revert "RecoverySystem: Fix the issue in installPackage()."
This reverts commit 9f7a0acd2d.

Bug: 34350643
Bug: 34396955
Test: installPackage() doesn't cause deadlock if it doesn't call
      processPackage() prior to that.
Change-Id: I1da055c86a3326ae341da1b4d5dc79ab4be256fb
2017-01-19 01:31:57 +00:00
Daichi Hirono
500bffdba9 Publish StorageManager#openProxyFileDescriptor API.
Bug: 29970149
Test: Build succeeded
Change-Id: I1606b184968839fb99744387dcc058f15f6521c8
2017-01-19 09:30:58 +09:00
Daichi Hirono
9fb00183a0 Add StorageManager#openProxyFileDescriptor.
The CL:

 * Adds StorageManager#openProxyFileDescriptor API.
 * Turns IProxyFileDescriptorCallback into a class so that it can provides
   default implementations.
 * Removes mActive state from FuseAppLoop, because the state will be managed at
   the MountService side.
 * Adds StorageManagerIntegrationTest to check if FUSE is correctly mounted or
   not. Since it's implementation details, CTS does not help to test the
   behavior.

Test: StorageManagerIntegrationTest
Bug: 29970149

Change-Id: Id78dd4abcf9325820e9c77c264f54bfa77b85a92
2017-01-19 09:24:00 +09:00
Pavel Grafov
eaed75d923 Merge "Make ENSURE_VERIFY_APPS global even when set by PO." 2017-01-18 11:15:28 +00:00
Xiaohui Chen
387c65f639 Add build flag for container builds
Test: lunch and build
Bug: 34350397
Change-Id: Ideb14200b5056449055ca17d868c615548445dc9
2017-01-17 15:12:26 -08:00
Jeff Sharkey
e628b7d446 Add Binder support for Parcelable exceptions.
If an Exception thrown by a Binder call implements the Parcelable
interface, then parcel it and rethrow back at the caller.  There is
strict requirement that these Parcelable exceptions must be defined
by the system (as determined by checking the ClassLoader).  We prefix
the Parcelable contents with a length so that native code can skip
over the blobs.

Define a new ParcelableException class that can be used to transport
exceptions that cannot be modified to add Parcelable behavior, and
switch ExceptionUtils to use this new class for sending IOExceptions.

Test: builds, boots, wrapped exceptions work
Bug: 33749182
Change-Id: I1352ea1566ddf01120d9d0e819ba6f70fc407e11
2017-01-17 14:22:07 -07:00
Lorenzo Colitti
e00c7dd3fc Merge "Delete dead code." am: cf59ff79c5 am: d305a7c894 am: 8cf7169564
am: bb79257dbf

Change-Id: I97102d587cfc8699fd36f18e4072a5baaa7e2d11
2017-01-17 07:01:18 +00:00
Tao Bao
877d099ab4 Merge "RecoverySystem: Fix the issue in installPackage()." am: 3b2fe9f7b9 am: 6bb3a9e6df am: 5c610492c8
am: 448716eec1

Change-Id: Ib36b7e990e7ae545f6b58f7a425c8f9aa19ad9aa
2017-01-17 06:55:46 +00:00
Martijn Coenen
c09025165a Merge "Add nullable parameter to readEmbeddedBuffer." am: c5e5442acd am: b529858c0b am: 714c8596ad
am: 098bbc455d

Change-Id: I44b1ed7a8561ee234d6a55a9ed02eb3876c4a7fc
2017-01-17 06:50:39 +00:00
Lorenzo Colitti
bb79257dbf Merge "Delete dead code." am: cf59ff79c5 am: d305a7c894
am: 8cf7169564

Change-Id: Ia662fd845fcfb4ade631d8aacf6bcff3c92a1543
2017-01-17 06:08:28 +00:00
Treehugger Robot
cf59ff79c5 Merge "Delete dead code." 2017-01-17 05:44:58 +00:00
Tao Bao
448716eec1 Merge "RecoverySystem: Fix the issue in installPackage()." am: 3b2fe9f7b9 am: 6bb3a9e6df
am: 5c610492c8

Change-Id: Ic9fa3bb8c7d4c04fa6e55b600cd7cccc9b186db1
2017-01-16 18:36:43 +00:00
Pavel Grafov
6a40f09083 Make ENSURE_VERIFY_APPS global even when set by PO.
Currently only device owner can set global user restrictions.
With this CL ENSURE_VERIFY_APPS will be global no matter who
enforces it, DO or PO.

To make it possible for system apps to check who enforces a
particular restriction in this case a new API method is added
to UserManager: getUserRestrictionSources which returns a list
of users who enforce the restriction.

Bug:31000521
Test: cts-tradefed run cts -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.UserRestrictionsTest (ag/1732744)
Test: runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
Test: runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/pm/UserRestrictionsUtilsTest.java
Test: runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceMigrationTest.java
Test: installed M on a Nexus5x device, created a managed profile with some user restrictions, and checked that after upgrading M->O all restrictions are preserved and split correctly into base, global and local.
Change-Id: I543d3ec9ef0cf2b730da6f7406021c0bba43b785
2017-01-16 18:29:01 +00:00
Tao Bao
3b2fe9f7b9 Merge "RecoverySystem: Fix the issue in installPackage()." 2017-01-16 18:19:25 +00:00
Martijn Coenen
098bbc455d Merge "Add nullable parameter to readEmbeddedBuffer." am: c5e5442acd am: b529858c0b
am: 714c8596ad

Change-Id: I792c4ac6a20e4665b152a5ebea1227b549cca7ef
2017-01-16 15:06:01 +00:00
Jesse Hall
17ee3aac28 Create GraphicsEnvironment for communicating with driver loaders
The GraphicsEnvironment class is given information during application
start, and makes it available to EGL/GLES/Vulkan loaders that don't
have easy access to the VM or to the application Context. Currently
only the driver path is handled, but the existing support for setting
library paths (for Vulkan extensions) and cache directory information
should move here.

Bug: 33531483
Test: various apps w/ and w/o driver package installed
Change-Id: I5820d3d1301d5461e10706f551b268c54d4f8926
(cherry picked from commit b12249b671)
2017-01-15 05:55:46 +00:00
Jesse Hall
79bf392dc6 Create GraphicsEnvironment for communicating with driver loaders
The GraphicsEnvironment class is given information during application
start, and makes it available to EGL/GLES/Vulkan loaders that don't
have easy access to the VM or to the application Context. Currently
only the driver path is handled, but the existing support for setting
library paths (for Vulkan extensions) and cache directory information
should move here.

Bug: 33531483
Change-Id: I4e4e7fb21f1bcc67122e9173514af5f18c063991
Merged-In: I5820d3d1301d5461e10706f551b268c54d4f8926
2017-01-14 19:19:28 -08:00
Jesse Hall
b12249b671 Create GraphicsEnvironment for communicating with driver loaders
The GraphicsEnvironment class is given information during application
start, and makes it available to EGL/GLES/Vulkan loaders that don't
have easy access to the VM or to the application Context. Currently
only the driver path is handled, but the existing support for setting
library paths (for Vulkan extensions) and cache directory information
should move here.

Bug: 33531483
Test: various apps w/ and w/o driver package installed
Change-Id: I5820d3d1301d5461e10706f551b268c54d4f8926
2017-01-14 17:31:56 -08:00
Tao Bao
9f7a0acd2d RecoverySystem: Fix the issue in installPackage().
Commit 794c8b0b3f fixed the race condition
when requesting data wipes via uncrypt. We have similar issue with
RecoverySystem.installPackage(). It first requests to set up the BCB,
then triggers a reboot. These two steps should finish atomically.

This CL switches to calling
RecoverySystemService.rebootRecoveryWithCommand(), which guards the two
steps with synchronized blocks.

Bug: 34239871
Test: Having two apps: one calls RecoverySystem.cancelScheduledUpdate()
      continuously, and the other calls RecoverySystem.installPackage()
      just once. The install request should not be cancelled by the
      other.

Change-Id: I5ec56fcaa70eae7c33e3cc8e6cfc7472b935ce4e
2017-01-13 09:59:38 -08:00
Martijn Coenen
14fae06b60 Add nullable parameter to readEmbeddedBuffer.
To support reading embedded buffers that can be
nullptr (currently only in empty hidl_vec).

Bug: 34255213
Test: hidl_test_java
Change-Id: I72028f580b7863b6bfeb31a5c0f43deed36dfd64
2017-01-13 14:17:12 +01:00
TreeHugger Robot
b237ddcb84 Merge "Remove PO support from HardwarePropertiesManager" 2017-01-12 14:01:26 +00:00
Santos Cordon
f85ab8306f Add Brightness setting for VR Mode.
am: d6a5660a2c

Change-Id: If371f485471eb1ab0a3e07964c197cb9b8ef1c9f
2017-01-11 03:12:05 +00:00
Santos Cordon
e89ba5222c Merge "Add Brightness setting for VR Mode." 2017-01-11 03:02:02 +00:00
Santos Cordon
3107d29c8f Add Brightness setting for VR Mode.
This change saves and loads a different brightness setting when the user
goes in and out of VR Mode.

Test: runtests frameworks-core
Test: Turn vr mode on and change brightness (should remain separate from
normal brightness)

Bug: 30984614
Change-Id: If3c3e81b592e0c6fd037e5783559683e5cb58379
2017-01-10 17:16:04 -08:00