Commit Graph

485440 Commits

Author SHA1 Message Date
Miranda Kephart
41a97a3fd7 [DO NOT MERGE] Close screenshot process on user switched
Currently, we keep the process up even if the user switches,
meaning that in some cases (if the user is switched while the
screenshot UI is up) we will save images to the wrong profile.
This change makes ScreenshotHelper listen for user switches and
close the screenshot service, so that a new screenshot is
guaranteed to be constructed with the correct user's context.

Bug: 170474245
Fix: 170474245
Test: manual -- verified bad state occurs if user switches within
the timeout period, ensured that screenshots work immediately
after switching with this change.

Change-Id: I9d32d0928e6c2bda161d04555438d0dd7afef0ba
(cherry picked from commit 7ef1a5dd15)
2021-01-28 14:36:00 +00:00
Miranda Kephart
19f28d7894 [DO NOT MERGE] Close screenshot process on user switched
Currently, we keep the process up even if the user switches,
meaning that in some cases (if the user is switched while the
screenshot UI is up) we will save images to the wrong profile.
This change makes ScreenshotHelper listen for user switches and
close the screenshot service, so that a new screenshot is
guaranteed to be constructed with the correct user's context.

Bug: 170474245
Fix: 170474245
Test: manual -- verified bad state occurs if user switches within
the timeout period, ensured that screenshots work immediately
after switching with this change.

Change-Id: I9d32d0928e6c2bda161d04555438d0dd7afef0ba
(cherry picked from commit 7ef1a5dd15)
2021-01-28 14:34:05 +00:00
Lorenzo Colitti
1255ddbc76 Backport test coverage from aosp/1547496.
This test coverage is necessary to fix an upcoming bug in R.
Backport it from the change that added it. The non-test portion
of that change is not necessary in R because it fixes a
bug that was introduced in S.

Bug: 172870110
Test: accompanying unit test shows lots of bugs removed
Change-Id: If7eb8857474d8b4f774f5fa5db2a3112e85c9cae
Merged-In: Ibf376a6fa4b34d1c96f8506fa8abbb7595a8c272
2021-01-28 19:44:00 +09:00
Lorenzo Colitti
be317557fe Backport some helpers in ConnectivityServiceTest.
These were added in aosp/1527378, which is impractical to
backport.

Bug: 172870110
Test: test-only change
Change-Id: Id3d12b23034b284c8f7dffb5167244e1e43987e2
Merged-In: I827543751dbf5e626a24ec02cd6f50b423f5f761
2021-01-28 19:44:00 +09:00
Lorenzo Colitti
9687fd7c3b Test for bugs with suspended VPN underlying networks.
Bug: 172870110
Test: atest --rerun-until-failure 100 ConnectivityServiceTest#testVpnSwitchFromSuspendedToNonSuspended
Change-Id: Ia52f9cafef3f49ae70ad135d017e207eb57fddfe
Merged-In: Ia52f9cafef3f49ae70ad135d017e207eb57fddfe
2021-01-28 19:44:00 +09:00
Lorenzo Colitti
9d680e7cd3 Fix legacy APIs when VPN switches to suspended underlying network.
Currently, when the VPN underlying network changes from a
network that is not suspended to one that is suspended (or vice
versa), some of the legacy APIs return incorrect results.

This is because the VPN's NetworkInfo can get into SUSPENDED
state even though the capabilities have the NOT_SUSPENDED
capability. This happens because the code in updateCapabilities
that checks for changes in NOT_SUSPENDED and NOT_ROAMING (which
are the capabilities that can affect the NetworkInfo state) is
only run when the capabilities change in a certain way.

Fix this by always checking for changes in these capabilities,
regardless of what else has changed.

This results in sending a lot more SUSPENDED and RESUMED
callbacks than the code sent previously. This should hopefully
not impact apps because those callback methods have never been
public API, though because they're just callbacks, it's possible
that apps found out via code inspection that the callbacks
existed and implemented them.

Bug: 172870110
Test: changes to existing tests in ConnectivityServiceTest
Change-Id: I6ec246a6a4e61f634956a165797fbb80296efd6a
Merged-In: I6ec246a6a4e61f634956a165797fbb80296efd6a
2021-01-28 19:44:00 +09:00
Lorenzo Colitti
cb2feba0fb Add a test for getDefaultNetworkCapabilitiesForUser.
Bug: 172870110
Test: test-only change
Test: new test passes 100 times in a row
Change-Id: I210284578e38cd25b8b95235d3390d5bd66a5a70
Merged-In: I210284578e38cd25b8b95235d3390d5bd66a5a70
2021-01-28 19:43:59 +09:00
Lorenzo Colitti
4a66aedf09 Improve testing of CONNECTIVITY_ACTION broadcasts.
We currently test CONNECTIVITY_ACTION broadcasts by directly
registering BroadcastReceivers with BroadcastInterceptingContext,
and making the receivers unregister themselves when all the
broadcasts they expect have been received.

This works for current test cases, but does not work if anything
registers another receiver for CONNECTIVITY_ACTION. In that case,
when we unregister the receiver in the receiver's onReceive
method, BroadcastInterceptingContext will throw a
ConcurrentModificationException because the list of receivers is
being modified during iteration.

Fix this by adding an ExpectedBroadcast class that stores the
receiver and unregisters the receiver only when the test checks
that the broadcast was received, which happens after the receiver
runs. This is easier to use and also guarantees that the receiver
is unregistered even if the test is expecting that the broadcast
is never fired. Accordingly, remove mRegisteredReceivers and the
code that uses it; it's no longer necessary now that
ExpectedBroadcast always unregisters its receivers.

Also add a convenience expectConnectivityAction method to expect
a CONNECTIVITY_ACTION broadcast with specific contents. This
makes the test easier to read and more detailed. Convert some
existing tests to this method.

While I'm at it, fix a test that was using "mCellNetworkAgent" to
represent a wifi network.

R backport notes: added import for NetworkInfo.DetailedState.
That was added in aosp/1527378, which is impractical to backport.

Bug: 172870110
Test: test-only change
Change-Id: Ibada8b4215625e1016d9fd170526206920af76f5
Merged-In: Ibada8b4215625e1016d9fd170526206920af76f5
2021-01-28 19:43:59 +09:00
Lorenzo Colitti
1a05734c87 Test passing an underlying network array with null network in it.
Current code treats these nulls as if they weren't there.

Bug: 172870110
Test: test-only change
Change-Id: Id4632e1b004c09910b4b7613f7233d2c19e2f0ac
Merged-In: Id4632e1b004c09910b4b7613f7233d2c19e2f0ac
2021-01-28 19:43:59 +09:00
Lorenzo Colitti
d2adbfbf40 Make testVpnNetworkActive more deterministic.
This test is a bit brittle because it sets the underlying
networks while the VPN is undergoing validation by
NetworkMonitor. The test does attempt to disable validation,
but that's not actually possible - the only thing that's possible
is to tell NetworkMonitor to validate immediately without sending
any probes. So the underlying network change races with the
validation. I'm not sure why the test isn't flaky. It might be
because both the network change and the validation result in a
capabilities change, and the test expects "a capabilities change"
without expressing what change that should be.

Make this a bit more predictable by ensuring that the network
validates before the underlying networks are set.

This is useful because an upcoming CL will change the way
underlying network capabilities are propagated. With this test
CL, both the old and the new code pass.

Bug: 172870110
Test: test-only change
Change-Id: I319858228e8d097c0b60a107029f296385f91269
Merged-In: I319858228e8d097c0b60a107029f296385f91269
2021-01-28 19:43:59 +09:00
Lorenzo Colitti
f3d35fdeaa Make MockVpn more realistic and easier to use.
MockVpn is very difficult to use because it requires the test
caller keeping track of both the MockVpn object and an
accompanying TestNetworkAgentWrapper.

It's also not very realistic: for example, connect() doesn't
actually connect anything, it just makes it so that if
ConnectivityService tries to update the capabilities, the attempt
will not be ignored. Also, unlike the real code in Vpn, it
connects with empty NetworkCapabilities (in particular, with
empty UID ranges).

Make this easier to use and a bit more realistic by:
- Allowing TestNetworkAgentWrapper to take a "NetworkCapabilities
  template" that will form the initial capabilities sent when the
  agent registers with ConnectivityService. This allows the VPN
  to register its agent with its UID ranges already set, like the
  production code does.
- Providing separate methods to register the NetworkAgent and
  mark it connected for cases where the test needs to make
  changes to the NetworkAgent before connecting (e.g., poking
  NetworkMonitor).
- Putting the TestNetworkAgentWrapper inside MockVpn and driving
  it through MockVpn's methods. In order not to have too many
  wrapper functions (and because we can't delegate like in
  Kotlin), there's still an agent() method that returns the
  TestNetworkAgentWrapper.

Bug: 172870110
Test: test-only change
Change-Id: I749ff325bc13ac96f512270b86d1f67686eec378
Merged-In: I749ff325bc13ac96f512270b86d1f67686eec378
2021-01-28 19:43:59 +09:00
Lorenzo Colitti
d10299582a Increase test coverage for VPN info sent to NetworkStatsService.
Bug: 172870110
Test: test-only change
Change-Id: I3711b362f31cb92b759e9f5c9d244fb88d9bd5e7
Merged-In: I3711b362f31cb92b759e9f5c9d244fb88d9bd5e7
2021-01-28 19:43:59 +09:00
Lorenzo Colitti
7c4ae16b94 Simplify MockVpn.
This CL removes four methods in MockVpn by slightly changing the
test code to leverage the actual methods implemented by the
(production) Vpn superclass.

This works because setting mInterface results in
isRunningLocked() returning true, which makes a number of methods
behave as if the VPN is connected (which is what the test
expects).

The more realistic behaviour exposes a minor bug in the treatment
of underlying networks. Add a TODO to fix it.

Bug: 172870110
Test: test-only change
Change-Id: I49421183538ba61ca790af71e309ece36b653bf9
Merged-In: I49421183538ba61ca790af71e309ece36b653bf9
2021-01-28 19:43:58 +09:00
Lorenzo Colitti
334a66342c Test a VPN with an underlying network that does not yet exist.
This test checks that if a VPN declares an underlying network
that does not exist, the capabilities of that network are applied
to the VPN as soon as the network starts to exist.

Bug: 172870110
Test: test-only change
Change-Id: Icc0701cb4cea7d91f7738c1e426e94cd26686b74
Merged-In: Icc0701cb4cea7d91f7738c1e426e94cd26686b74
2021-01-28 19:43:55 +09:00
Bill Yi
b3b59ca8f1 Import translations. DO NOT MERGE ANYWHERE
Auto-generated-cl: translation import
Change-Id: I73ea44fb5825466fa227e9d22c41696bd89cf922
2021-01-27 01:15:24 -08:00
Rob Carr
aad0ef5fff [automerger skipped] Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into oc-mr1-dev am: e3f7644490 -s ours am: aa682dec92 -s ours am: a22cfe0b46 am: d3eb04e729 -s ours am: 03ca6d9014
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13210727

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: If385d245cf97b062737933fa97d5c1cd1c819164
2021-01-26 20:18:48 +00:00
Rob Carr
7153136e74 [automerger skipped] Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into pi-dev am: 4f162df18e -s ours am: bbd4d45090 am: 74f95bbb51 -s ours am: b8e01656c0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13206662

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I2ead89e690db264ab1af5c8db23dc0668bab7dad
2021-01-26 20:18:38 +00:00
Rob Carr
b7802cf79e [automerger skipped] Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into qt-dev am: 525770f7e8 am: 9089b9f175 -s ours am: bc0cd4a148
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13205849

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I6e7023cde5fae17585bcc6b2d883c2c78cd09fa2
2021-01-26 20:18:29 +00:00
Robert Carr
e95f39b077 [automerger skipped] DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL. am: 514b329776 am: f5aa61a735 -s ours am: 027e0beec5
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13205849

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id4a5136a8fcdb8c65a43a9923db324ebe641f71f
2021-01-26 20:18:28 +00:00
Rob Carr
fa7eadf02e [automerger skipped] Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into qt-qpr1-dev am: 735a40b06b -s ours am: e058131d53
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13211149

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I4d06374bf40ead72b436c6b549e082f93f322195
2021-01-26 20:18:17 +00:00
Rob Carr
03ca6d9014 [automerger skipped] Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into oc-mr1-dev am: e3f7644490 -s ours am: aa682dec92 -s ours am: a22cfe0b46 am: d3eb04e729 -s ours
am skip reason: subject contains skip directive

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13210727

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I8bbdf308d354d716f4e4e8349cd4eed3cff4cb9a
2021-01-26 20:06:23 +00:00
Rob Carr
b8e01656c0 [automerger skipped] Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into pi-dev am: 4f162df18e -s ours am: bbd4d45090 am: 74f95bbb51 -s ours
am skip reason: subject contains skip directive

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13206662

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie40d88988fbbf7f246820d519e13227f7793168b
2021-01-26 20:06:10 +00:00
Rob Carr
d3eb04e729 [automerger skipped] Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into oc-mr1-dev am: e3f7644490 -s ours am: aa682dec92 -s ours am: a22cfe0b46
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13210727

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I1cb556ca775bbfbe4346eab371a1cc5b77acac31
2021-01-26 20:05:45 +00:00
Rob Carr
bc0cd4a148 [automerger skipped] Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into qt-dev am: 525770f7e8 am: 9089b9f175 -s ours
am skip reason: subject contains skip directive

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13205849

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I9be06dd024415698db9252f9e7badadaddb4f587
2021-01-26 20:05:36 +00:00
Rob Carr
74f95bbb51 [automerger skipped] Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into pi-dev am: 4f162df18e -s ours am: bbd4d45090
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13206662

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I9118e44b35a309a57bbab3073dad028c69fe705f
2021-01-26 20:05:33 +00:00
Robert Carr
027e0beec5 [automerger skipped] DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL. am: 514b329776 am: f5aa61a735 -s ours
am skip reason: subject contains skip directive

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13205849

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I47435f2d060c8e33ba7284e0e8ba7355f7f24e09
2021-01-26 20:05:26 +00:00
Rob Carr
a22cfe0b46 [automerger skipped] Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into oc-mr1-dev am: e3f7644490 -s ours am: aa682dec92 -s ours
am skip reason: subject contains skip directive

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13210727

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ia295a8f7839dc362ca05c4141aaeca0d0fc58fe5
2021-01-26 19:55:00 +00:00
Rob Carr
bbd4d45090 [automerger skipped] Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into pi-dev am: 4f162df18e -s ours
am skip reason: subject contains skip directive

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13206662

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I9ea5c9bb7a472f04cf6b65f6efe31e7c1223e873
2021-01-26 19:54:43 +00:00
Rob Carr
aa682dec92 [automerger skipped] Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into oc-mr1-dev am: e3f7644490 -s ours
am skip reason: subject contains skip directive

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13210727

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I505e9e636e908e23e3b229262e522dd628d2faff
2021-01-26 19:53:27 +00:00
Rob Carr
9089b9f175 Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into qt-dev am: 525770f7e8
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13205849

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I40066702ef4d4952e4bb3a7d533d9fddb4f53715
2021-01-26 19:53:24 +00:00
Robert Carr
f5aa61a735 DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL. am: 514b329776
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13205849

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I4168daaae9fb5972dcea0245e49d1759df7127f5
2021-01-26 19:53:21 +00:00
Rob Carr
e058131d53 [automerger skipped] Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into qt-qpr1-dev am: 735a40b06b -s ours
am skip reason: subject contains skip directive

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13211149

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I232a503efc439c40a01e4ae9c319bf4a44603489
2021-01-26 19:53:14 +00:00
Rob Carr
525770f7e8 Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into qt-dev 2021-01-26 19:27:40 +00:00
Rob Carr
e3f7644490 Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into oc-mr1-dev 2021-01-26 19:27:37 +00:00
Rob Carr
4f162df18e Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into pi-dev 2021-01-26 19:27:19 +00:00
Rob Carr
735a40b06b Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into qt-qpr1-dev 2021-01-26 19:27:19 +00:00
Bill Yi
5721118fe9 Merge "Import translations. DO NOT MERGE ANYWHERE" into mainline-prod 2021-01-26 17:50:20 +00:00
Bill Yi
27bd904ac7 Import translations. DO NOT MERGE ANYWHERE
Auto-generated-cl: translation import
Change-Id: Ief64fc5ee74146f310f4aa8554428dd10031bee7
2021-01-26 04:53:21 -08:00
Bill Yi
1dfbc75ba2 Merge "Import translations. DO NOT MERGE ANYWHERE" into mainline-prod 2021-01-26 02:04:12 +00:00
Bill Yi
1be3d32626 Merge "Import translations. DO NOT MERGE ANYWHERE" into mainline-prod 2021-01-26 01:41:40 +00:00
Bill Yi
0bd3d50429 Merge "Import translations. DO NOT MERGE ANYWHERE" into mainline-prod 2021-01-25 22:39:13 +00:00
Bill Yi
63c8bbabb9 Merge "Import translations. DO NOT MERGE ANYWHERE" into mainline-prod 2021-01-25 22:38:51 +00:00
Bill Yi
c57d88c305 Merge "Import translations. DO NOT MERGE ANYWHERE" into mainline-prod 2021-01-25 22:37:53 +00:00
Bill Yi
c1e6066fd3 Merge "Import translations. DO NOT MERGE ANYWHERE" into mainline-prod 2021-01-25 22:37:30 +00:00
Bill Yi
60dc313099 Merge "Import translations. DO NOT MERGE ANYWHERE" into mainline-prod 2021-01-25 22:37:06 +00:00
Bill Yi
db05037faa Merge "Import translations. DO NOT MERGE ANYWHERE" into mainline-prod 2021-01-25 22:36:38 +00:00
Bill Yi
3db1bd359e Merge "Import translations. DO NOT MERGE ANYWHERE" into mainline-prod 2021-01-25 21:27:42 +00:00
Bill Yi
8cd9312533 Merge "Import translations. DO NOT MERGE ANYWHERE" into mainline-prod 2021-01-25 21:27:34 +00:00
Bill Yi
3771a9fd37 Import translations. DO NOT MERGE ANYWHERE
Auto-generated-cl: translation import
Change-Id: Ibdac234dbde81a99c121e26ab76338799b498bdf
2021-01-25 11:45:36 -08:00
Bill Yi
8fb48004f7 Import translations. DO NOT MERGE ANYWHERE
Auto-generated-cl: translation import
Change-Id: I05d6ccfdf40e0b1d8ca9b5495db55b2737e20959
2021-01-25 11:15:55 -08:00