2133 Commits

Author SHA1 Message Date
Phil Weaver
7a6cc9b5a7 Consolidate a11y unit tests and get them working
Moving tests for accessibility manager into the a11y
directory and getting them to use some of the newer
test infrastructure. Minor tweaks to
AccessibilityManager to make it testable.

Deleting the AccessibilityManagerService tests entirely.
This class is difficult to unit test with the current
infrastructure, but is covered in CTS tests to a large
degree. I wasn't able to get these working quickly, and
they rely on timeouts that make them run much slower than
the other tests. They also throw exceptions when their
mock accessibility services receive accessibility events,
which causes the system to blacklist those services, causing
the tests to fail differently until the system is reset.
I think it's better to focus on writing new, more robust
tests than on rewriting these tests to pass.

Bug: 36614219
Test: A11y unit tests now work.
Change-Id: I8effe44f22110d55ebb700dc46f59b7e7a1aa946
(cherry picked from commit 9213d23178183981c653714f8df5806aab458bb0)
2017-04-05 16:34:29 +00:00
TreeHugger Robot
0eea46e0e9 Merge "Consolidate a11y unit tests and get them working" 2017-04-05 16:30:37 +00:00
Bryce Lee
3115bdf15a Fix ActivityRecordTests.
Tests are not guaranteed to run on the same thread as setup methods.
Therefore, we must ensure any loopers used are already created by the
time the test runs. We do this now by creating a HandlerThread and
referencing its Looper later. Loopers are initialized per
HandlerThread, which will allow us to both isolate its usage and
guarantee the Looper initialization by test time.

Change-Id: If15494783959e5c399375033253cef69b921ff84
Fixes: 36916522
Test: bit FrameworksServicesTests:com.android.server.am.ActivityRecordTests
2017-04-05 08:39:40 -07:00
Wale Ogunwale
6a24cb89e8 Merge "Disable presubmit for ActivityRecordTests" into oc-dev am: ef3874ba91
am: 60366d2223

Change-Id: I71ea508d4ad4401ff17800faa1cc0ef4345df7e8
2017-04-05 03:44:33 +00:00
Wale Ogunwale
ef3874ba91 Merge "Disable presubmit for ActivityRecordTests" into oc-dev 2017-04-05 03:34:07 +00:00
Wale Ogunwale
4cb9b96d59 Disable presubmit for ActivityRecordTests
Failing in CI

Test: ActivityRecordTests
Bug: 36916522
Change-Id: Id5571b722cc5c14f2897fcc65d52d35bf4a78105
2017-04-04 20:30:18 -07:00
Jeremy Joslin
f1acc1e811 Restore @VisibleForTesting on NetworkScorerAppManager.
The NetworkScoreService tests fail (Mockito doesn't work) without
those methods being public :/

Also removed a failing test from NetworkScoreServiceTest since a
recent CL changed the behavior of dump (no longer throws).

Test: runtest frameworks-services -c com.android.server.NetworkScoreServiceTest
Change-Id: Id3fb9451027db3685b16b659a00a6a52b7a1e523
2017-04-04 17:28:23 -07:00
Sudheer Shanka
9d3f668d09 Fix testWaitForNetworkStateUpdate.
Bug: 36899583
Test: runtest -c com.android.server.am.ActivityManagerServiceTest frameworks-services
Change-Id: I9fd94bc74403b173770dd7ec2483780bf6698640
2017-04-04 15:33:37 -07:00
Sudheer Shanka
bce47223cb Don't populate a setting instead of defaulting to 0 when not set.
Currently in CoreSettingsObserver while populating settings, when a
setting is not found, it's value is defaulted to 0. Instead don't
populate the setting when it is not found.

Bug: 34735550
Test: runtest -c com.android.server.am.CoreSettingsObserverTest frameworks-services
Change-Id: I9d231330c6db2636e4aa2f0caae455ddfc3e63a2
2017-04-04 15:07:14 -07:00
Dmitry Dementyev
9fc6f574b4 Clear calling identity before getUserAccounts in
AccountManagerService

Fix accountsDb tests.

Bug: 36860606
Test: manual
Change-Id: Iad86d1bf7edd0f847262562ace9c2d5c9fdff978
2017-04-04 15:05:24 -07:00
Bryce Lee
92b7b65939 Do not try to restore a task id if it does not exist.
Previously, we were trying to restore the recent task regardless of
if it was found in recents or a stack. This would lead to
referencing a null object later.

Change-Id: I014a751d3254ad267c32ac0b54783b31b8d17e93
Test: bit FrameworksServicesTests:com.android.server.am.ActivityStackSupervisorTests
Fixes: 36688598
2017-04-04 14:45:26 -07:00
Tony Wickham
a41da04b2d Add AppWidgetManager#getInstalledProvidersForPackage()
This allows more fine-grained control than getting all installed
providers for a user, when you might only want to check for a particular
package. For instance, Launcher can use this API to surface widgets per
app without having to ask for all the widgets.

Test: Unit test on AppWidgetServiceImplTest
$ runtest --path=services/tests/servicestests/src/com/android/server/appwidget/AppWidgetServiceImplTest.java

Bug: 34940468
Change-Id: I182bf1c012d31182024422fc4a63f57f151c3ee5
2017-04-04 14:13:01 -07:00
Jeremy Joslin
1b331bdd67 Merge "Migrate the NETWORK_SCORER_APP Setting." into oc-dev am: 0bbde28dd4
am: a1670692ac

Change-Id: If9134de003ad02fea1f3dbcb16c101ee0653ad13
2017-04-04 19:53:59 +00:00
TreeHugger Robot
0bbde28dd4 Merge "Migrate the NETWORK_SCORER_APP Setting." into oc-dev 2017-04-04 19:37:20 +00:00
Jeremy Joslin
b0fe21782f Migrate the NETWORK_SCORER_APP Setting.
Migrate the value of NETWORK_SCORER_APP to the USE_OPEN_WIFI_PACKAGE
Setting if the following conditions are true:
  * NETWORK_SCORER_APP has a value
  * An active scorer/recommender is present.
  * The active scorer specifies a valid UseOpenWifiActivity.
  * The NETWORK_SCORER_APP value matches the package name of the
    UseOpenWifiActivity or the active scorer.

Test: runtest frameworks-services -c com.android.server.NetworkScorerAppManagerTest
Bug: 36718516
Change-Id: I7d7a56c62b4a7f4a0e43824fbb2075e80d7a753b
2017-04-04 10:25:57 -07:00
Jorim Jaggi
cdfca9c3d2 Merge "Handle case when snapshot dimensions don't match" into oc-dev am: 1edadac465
am: 05ca99b43b

Change-Id: Ie5364d5617a159344d5232e48957ffd79a89a175
2017-04-04 09:32:02 +00:00
Jorim Jaggi
1edadac465 Merge "Handle case when snapshot dimensions don't match" into oc-dev 2017-04-04 09:14:38 +00:00
Bryce Lee
22036364ec Merge "Clean up activity/stack associations." into oc-dev am: 9f467df804
am: a36f50fa5d

Change-Id: Ide2e36cb9d8082415da9b2f423345bc80c1e434e
2017-04-04 03:21:10 +00:00
Bryce Lee
9f467df804 Merge "Clean up activity/stack associations." into oc-dev 2017-04-04 03:01:50 +00:00
Bryce Lee
af691c0be7 Clean up activity/stack associations.
The stack currently holds a reference to resuming and pausing
activities. These are usually cleaned up when the activity ends or
the task is reparented. However, it is possible for an activity to
lose its reference to its task in other areas (such as
ActivityStarter), which can lead to the stack not being updated
correctly.

This changelist adds a method to the ActivityStack to disassociate
the stack from an ActivityRecord. In addition to places where this is
called when an activity ends, this method is invoked on the children
of a task when the task is reparented. The task member variable of
ActivityRecord is also now surrounded by a setter/getter, with the
setter always invoking the dissociation logic on a previous stack.

Test: bit FrameworksServicesTests:com.android.server.am.ActivityRecordTests
Change-Id: Iffeccdb6f011958896271673946acfed28856f53
Fixes: 36387417
2017-04-03 16:33:36 -07:00
Makoto Onuki
0303797e1b Merge "Remove/fix broken test due to change to DUMP permission check." into oc-dev am: 6a7a967b71
am: eeb6197d39

Change-Id: Ief58d7cf855babdda0ae0a0933051ee8a1ee2b53
2017-04-03 22:30:19 +00:00
TreeHugger Robot
6a7a967b71 Merge "Remove/fix broken test due to change to DUMP permission check." into oc-dev 2017-04-03 22:13:34 +00:00
Makoto Onuki
b3f05c90a1 Merge "Revert "Push chooser targets to the shortcut manager."" into oc-dev am: ef7dff2563
am: be3ee7ee30

Change-Id: I13a0dd37dfb4475866535abb514aa4a8dcd2f6a6
2017-04-03 20:01:58 +00:00
Makoto Onuki
c4361e34ad Remove/fix broken test due to change to DUMP permission check.
Bug 36854321
Test: adb shell am instrument -e class 'com.android.server.pm.ShortcutManagerTest2' -w com.android.frameworks.servicestests

Change-Id: I80f2a326b70f8d0598246732510e3725a0c58871
2017-04-03 13:00:39 -07:00
Makoto Onuki
ef7dff2563 Merge "Revert "Push chooser targets to the shortcut manager."" into oc-dev 2017-04-03 19:45:18 +00:00
Andrii Kulian
5a63cdf50d Merge "Fix some WM unit tests" into oc-dev am: 2c93764bee
am: 45d534bf93

Change-Id: Ia81653887fbf9a712d0ed285fa91a0e3afe1bff6
2017-04-03 18:23:58 +00:00
Bryce Lee
126159a88f Merge "Add app bounds to configuration." into oc-dev am: 7efe56b779
am: 59d1f8a024

Change-Id: Iae8e43872eee11214347cfb935793e9356a50e08
2017-04-03 18:00:08 +00:00
Andrii Kulian
2c93764bee Merge "Fix some WM unit tests" into oc-dev 2017-04-03 17:34:01 +00:00
Bryce Lee
7efe56b779 Merge "Add app bounds to configuration." into oc-dev 2017-04-03 14:30:49 +00:00
Jorim Jaggi
aea6b74e17 Handle case when snapshot dimensions don't match
If the snapshot starting window has different dimensions than the
snapshots we have taken, we do the following:

- Create a child Surface that has exactly the dimensions of the
snapshot.
- We fill the parent surface with the app background color, as well
as all screen background decorations (status bar background,
navigation bar background).
- We also clip of the status bar/navigation bar background in some
cases, as it looks ugly if it's not behind the system bars.
- Furthermore, we inherit all layout flags on the window and all
layout relevant SystemUI flags on the window such that it's very
likely that the size will match, and the system bars are drawn
correctly.
- In order to make the transition from the snapshot to the real
window a bit more predictable/less messy, we enforce a minimum
duration the snapshot is visible, which is slightly more than our
app transitions.

Test: TaskSnapshotSurfaceTest
Test: Open app, go home, go landscape, open app again
Test: Go to multi-window, open app from recents with a snapshot
taken in fullscreen.

Fixes: 36703868
Change-Id: Ia2d4add6971a18ab7aa2942d2b644d6e87a402af
2017-04-03 15:36:29 +02:00
Bryce Lee
7566d76c61 Add app bounds to configuration.
The system previously overrode the display size for a specific scope
(task/activity/etc.) by setting the associated Configuration's
screenWidthDp/screenHeightDp. This leads to two issues. First, the
conversion of screen size from pixels to display independent pixels
and then upconverting later on leads to rounding errors. Secondly,
the screenWidthDp and screenHeightDp values account for insets, such
as the status bar. These however are not reflected in the display
size when returned from Display#getMetrics/getSize.

This changelist addresses the issue by adding a Rect value to
Configuration which stores the app display bounds. This is always set
at the display level and overridden as appropriate. As the proper
app insets are accounted for at the root configuration, all overrides
(outside of specific exceptions) are the result of the intersection
between the requested bound and the parent bound.

Change-Id: I2c4fcd0bee92af12aabbca258de05b4ec061d0e1
Fixes: 34338931
Bug: 36812336
Bug: 36676979
Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test CtsAppTestCases android.app.cts.AspectRatioTests
Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test CtsServicesHostTestCases android.server.cts.ActivityManagerDisplayTests
Test: bit FrameworksServicesTests:com.android.server.wm.AppBoundsTests
2017-03-31 21:34:30 -07:00
Makoto Onuki
224f95a32d Merge "Handle disabled packages as removed." into oc-dev am: 2f8f5ffc4b
am: 202c0418b1

Change-Id: I9c0ba823fa4007ab75d7ff2d5b860e716b2f36a0
2017-04-01 03:28:08 +00:00
TreeHugger Robot
2f8f5ffc4b Merge "Handle disabled packages as removed." into oc-dev 2017-04-01 03:16:38 +00:00
Andrii Kulian
a95bfff746 Fix some WM unit tests
WindowFrameTests#testLayoutNonfullscreenTask and
sizes because test assumed that frame for window was always
bigger than screen size. Now we calculate all frames relative
to real display size.

TestWindowManagerPolicy used in WM unit tests reported incorrect
value from rotationHasCompatibleMetricsLw(), which lead to
DisplayContent#mAltOrientation set to "true" after any rotation
and resulted in shrinked display metrics.

DisplayContentTests#testDefaultDisplayOverrideConfigUpdate was
not restoring the config applied to default display because
it was trying update values in config from non-empty to empty,
which is considered a no-diff.

Test: com.android.server.wm.WindowFrameTests
Test: #testCalculatePolicyCrop
Test: #testLayoutNonfullscreenTask
Test: com.android.server.wm.AppWindowTokenTests
Test: #testLandscapeSeascapeRotationByApp
Test: com.android.server.wm.DisplayContentTests
Test: #testDefaultDisplayOverrideConfigUpdate
Change-Id: Ia0ed46307f67f6b47859209ebcf13253b59b8002
2017-03-31 19:00:57 -07:00
TreeHugger Robot
9b4a020d35 Merge "Change test type from InstrumentationTest to AndroidJUnitTest" 2017-04-01 01:22:46 +00:00
Makoto Onuki
82fb2eb057 Handle disabled packages as removed.
Bug 36600272
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest1 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest2 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest3 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest4 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest5 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest6 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest7 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest8 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest9 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest10 -w com.android.frameworks.servicestests

Change-Id: I272334cef00337d5ba01ce4b878c799d9476432f
2017-03-31 16:58:26 -07:00
TreeHugger Robot
2af994ec03 Merge "Ensure we show the PiP menu in response to KEYCODE_WINDOW." into oc-dev 2017-03-31 23:07:23 +00:00
Dan Shi
1fee398b88 Change test type from InstrumentationTest to AndroidJUnitTest
Details about test configs changes are tracked in doc
https://docs.google.com/document/d/1EWUjJ7fjy8ge_Nk0YQbFdRp8DSHo3z6GU0R8jLgrAcw/edit#

Bug: 35882476
Test: local test

Change-Id: Ic3c4c7a9d29ef9d32a407f31cfc93c5e43650297
2017-03-31 16:02:33 -07:00
Makoto Onuki
99302b55c6 Revert "Push chooser targets to the shortcut manager."
This reverts commit 58fc95dc578244b7beb687a48184045dcce788b8.

Bug 36186790
Test: cts-tradefed run cts-dev --skip-device-info --skip-preconditions --skip-system-status-check com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker -a armeabi-v7a -l INFO -m CtsShortcutHostTestCases
Test: cts-tradefed run cts-dev --skip-device-info --skip-preconditions --skip-system-status-check com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker -a armeabi-v7a -l INFO -m CtsShortcutManagerTestCases

Also all unit tests, except for the known failrues.
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest1 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest2 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest3 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest4 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest5 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest6 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest7 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest8 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest9 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest10 -w com.android.frameworks.servicestests

Change-Id: I733ee7e12a419ee7ea17ca67c56afe7b039d189a
2017-03-31 15:16:43 -07:00
Winson Chung
ac52f2892d Ensure we show the PiP menu in response to KEYCODE_WINDOW.
Bug: 36687605
Test: android.server.cts.ActivityManagerPinnedStackTests
Test: #testWindowButtonEntersPip
Change-Id: I0bb35fd666eb6a438e4676267f6726b44bffb3db
2017-03-31 10:42:53 -07:00
TreeHugger Robot
554c5946ce Merge "Fix broken unit tests due to mockito upgrade." into oc-dev 2017-03-31 00:41:04 +00:00
Sudheer Shanka
20959b2d40 Merge "Don't increment procStateSeq if uid doesn't have internet permission." into oc-dev 2017-03-30 23:34:07 +00:00
Makoto Onuki
d0010c5ef1 Fix broken unit tests due to mockito upgrade.
Bug 36781317

Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest1 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest2 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest3 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest4 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest5 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest6 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest7 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest8 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest9 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest10 -w com.android.frameworks.servicestests

Change-Id: Ie9abcd8bdf5353c96ebade0e8489f667ef9904ee
2017-03-30 15:42:01 -07:00
Phil Weaver
9213d23178 Consolidate a11y unit tests and get them working
Moving tests for accessibility manager into the a11y
directory and getting them to use some of the newer
test infrastructure. Minor tweaks to
AccessibilityManager to make it testable.

Deleting the AccessibilityManagerService tests entirely.
This class is difficult to unit test with the current
infrastructure, but is covered in CTS tests to a large
degree. I wasn't able to get these working quickly, and
they rely on timeouts that make them run much slower than
the other tests. They also throw exceptions when their
mock accessibility services receive accessibility events,
which causes the system to blacklist those services, causing
the tests to fail differently until the system is reset.
I think it's better to focus on writing new, more robust
tests than on rewriting these tests to pass.

Bug: 36614219
Test: A11y unit tests now work.
Change-Id: I8effe44f22110d55ebb700dc46f59b7e7a1aa946
2017-03-30 09:45:39 -07:00
Sudheer Shanka
ed25ce6d59 Fix flaky tests in NetworkPolicyManagerServiceTest.
Test: runtest -c com.android.server.NetworkPolicyManagerServiceTest frameworks-services
Change-Id: I0a6f0d11e3922bfeb2bd3784f23e10ae45e5e40c
2017-03-29 20:46:30 -07:00
Sudheer Shanka
f4923ea0b2 Don't increment procStateSeq if uid doesn't have internet permission.
Bug: 27803922
Test: runtest -c com.android.server.am.ActivityManagerServiceTest frameworks-services
      and manual

Change-Id: I02bfd86837813cc79f37301d91489485c6a1d056
2017-03-29 18:04:47 -07:00
Sudheer Shanka
686bb2d337 Add tests for verifying network availability on activity start.
Bug: 27803922
Test: runtest -c com.android.server.net.ConnOnActivityStartTest frameworks-services
Change-Id: I771e1fd9edbe14f1ff7a7a84c3896af6dd6f20a0
2017-03-29 01:00:37 +00:00
Ammar Aijazi
6ce48e25e5 NetworkPolicy gets updated due to CarrierConfigManager updates.
Bug: b/34385985
Test: Added unit tests to NetworkPolicyManagerServiceTest
Change-Id: I1d8249081c478e6484c8011d3eab73a53f105fac
2017-03-28 15:43:34 -07:00
Ammar Aijazi
f6af6e9097 Merge "NetworkPolicy gets updated due to CarrierConfigManager updates." 2017-03-28 22:28:50 +00:00
Bryce Lee
27cec32496 Add configuration for maximum UI width.
This changelist adds config_maxUiWidth, a new system resource
configuration which specifies the maximum width the user interface
can operate in. If the physical or specified width is greater than
this value, dimensions and density are scaled down accordingly. The
native mode resolution can be still discovered through
Display.Mode#getPhysicalWidth/getPhysicalHeight.

Test: Defined override for development device and verified values.
Test: bit FrameworksServicesTests:com.android.server.wm.DisplayContentTests#testMaxUiWidth
Change-Id: I12e7ad52f2aa8014e143bc7e80b020c9b24ed9c8
Fixes: 25820708
2017-03-28 20:23:45 +00:00