5324 Commits

Author SHA1 Message Date
junyulai
d27a1725e8 [SP01] Add NetworkStats to system API
In order to let external module report their network stats,
expose necessary APIs to construct NetworkStats object.

Test: atest FrameworksNetTests CtsUsageStatsTestCases
Test: m doc-comment-check-docs
Bug: 130855321
Change-Id: Id3ec8aaff3df67948c25eac2319a74cf33a27979
2020-01-09 03:11:22 +00:00
Andrei-Valentin Onea
e7194bfdfc Merge changes from topic "fix-policy"
* changes:
  Refactor CompatConfigTest and PlatformCompatTest
  Add test for OverrideValidatorImpl
  Enforce overriding methods for IPlatformCompat
2020-01-08 18:42:44 +00:00
Sunny Goyal
d92149a76a Merge "Remove AppWidgetManagerInternal instance before adding to global registry of LocalServices" 2020-01-08 15:22:09 +00:00
Neil Fuller
48247d9223 Merge "Change NetworkTimeUpdateServiceImpl behavior" 2020-01-07 10:07:08 +00:00
Hall Liu
13beb87783 Merge "Create new APIs for overriding APNs" 2020-01-06 23:14:44 +00:00
Neil Fuller
62ace8c46a Merge "Add new permissions" 2020-01-06 19:38:25 +00:00
Hall Liu
39839dc63b Create new APIs for overriding APNs
Create new APIs in TelephonyManager for DevicePolicyManager to add
override APNs, and use them in DevicePolicyManagerService instead of
directly accessing the APN database.

Bug: 146834818
Test: cts-tradefed run cts --module DevicePolicyManager --test
com.android.cts.devicepolicy.DeviceOwnerTest#testOverrideApn
Test: atest TelephonyManagerTest

Change-Id: I6c6214424169c05fd452db71a8c6593f8473b9d4
Merged-In: I6c6214424169c05fd452db71a8c6593f8473b9d4
2020-01-05 14:24:22 -08:00
Naga Venkata Durga Ashok Mutyala
64b3fce9bb Remove AppWidgetManagerInternal instance before adding to global registry
of LocalServices

b/69981755 introduces AppWidgetManagerInternal and added this instance
as key in Local Services. setup() phase of Second testcase onwards
throwing IllegalStateException as the AppWidgetManagerInternal interface
already added in the global registry of LocalServices in first time setup()
phase.

Bug: 147165870
Test: atest FrameworksServicesTests:com.android.server.appwidget.AppWidgetServiceImplTest

Change-Id: I9e74b1a06e1c9a4b0ee0cad982cecaac3059f7c9
Signed-off-by: Naga Venkata Durga Ashok Mutyala <quic_nmutya@quicinc.com>
2020-01-04 19:28:13 +05:30
Colin Cross
645ae56f43 Merge "Fix Error Prone errors" 2020-01-02 23:33:56 +00:00
Colin Cross
1f4620ac7a Fix Error Prone errors
Soong wasn't including android_app or android_test sources in the
javac-check target used for the Error Prone build, which allowed
some Error Prone errors to get in.  Fix them so Error Prone can be
re-enabled for these targets.

Fixes:
frameworks/base/core/tests/coretests/src/android/view/textclassifier/ActionsSuggestionsHelperTest.java:241: error: [JUnit4TestNotRun] This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility.
frameworks/base/core/tests/systemproperties/src/android/os/SystemPropertiesTest.java:97: error: [JUnit3TestNotRun] Test method will not be run; please correct method signature (Should be public, non-static, and method name should begin with "test").
frameworks/base/services/tests/servicestests/src/com/android/server/backup/utils/FileUtilsTest.java:64: error: [CheckReturnValue] Ignored return value of method that is annotated with @CheckReturnValue
frameworks/base/services/tests/servicestests/src/com/android/server/backup/utils/FileUtilsTest.java:68: error: [CheckReturnValue] Ignored return value of method that is annotated with @CheckReturnValue
frameworks/base/services/tests/servicestests/src/com/android/server/backup/utils/FileUtilsTest.java:78: error: [CheckReturnValue] Ignored return value of method that is annotated with @CheckReturnValue
frameworks/base/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystemTest.java:533: error: [JUnit4TestNotRun] This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility.
frameworks/base/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java:480: error: [JUnit4TestNotRun] This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility.
frameworks/base/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java:491: error: [JUnit4TestNotRun] This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility.
frameworks/base/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java:4196: error: [JUnit4TestNotRun] This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility.

Bug: 146455923
Test: m RUN_ERROR_PRONE=true javac-check
Change-Id: I829373d41c97962fe2122ea74cef12ba342ac33c
Merged-In: I829373d41c97962fe2122ea74cef12ba342ac33c
2019-12-20 10:32:49 -08:00
Neil Fuller
4ab8a199de Change NetworkTimeUpdateServiceImpl behavior
This change moves some logic associated with time detection out of the
NetworkTimeUpdateServiceImpl and moves it to the TimeDetectorStrategy
called by the TimeDetectorService.

The TimeDetectorStategy implementation now decides when to use an
NTP-derived time instead. The logic implemented here is effectively the
same as it was: NITZ takes priority over NTP until the latest NITZ
signal becomes "too old".

The motivating reasons for the change:
1) The "what signal is used when several are available?" logic should be
in one place: the TimeDetectoryStrategy not scattered around the
platform. Centralizing will enable different strategies and time sources
to be introduced over time.

2) It will allow removal of the ACTION_NETWORK_SET_TIME intent in a
follow-up commit; this intent was used to coordinate the NTP vs NITZ
logic should no longer be required.

The "bonus" effect of this change is that NetworkTimeUpdateServiceImpl
becomes more general: It can now be the authority for the NTP time on a
device independently of how the system clock should be set. e.g. it
could be used in future to back the
AlarmManager.currentNetworkTimeMillis() API call.  Anything that needs a
"what is the best time according to NTP?" answer could use this service.

Note: The NetworkTimeUpdateServiceImpl still observes the AUTO_TIME
setting and will perform an NTP lookup "on demand" (if required) when
the user enables the setting. This should be a temporary state and
likely to be removed in future; knowledge of AUTO_TIME shouldn't be
required for the NTP info to be correct and if
NetworkTimeUpdateServiceImpl is doing the right thing.

Bug: 140712361
Test: atest com.android.server.timedetector
Test: atest android.app.timedetector
Change-Id: I4b2936a42c552c4dd4cb55010306bb81bca0c712
2019-12-19 19:21:47 +00:00
Neil Fuller
0de8726e97 Extract an "ArrayMapWithHistory" support class
Extract a simple wrapper around ArrayMap called "ArrayMapWithHistory",
with associated tests. TimeDetectorStrategyImpl and
TimeZoneDetectorStrategy were duplicating some data structure logic.

ArrayMapWithHistory works the same as ArrayMap, but there is a (mostly
hidden) history of the values for each map entry. This is useful for
debugging.

A second class, ReferenceWithHistory, has been included to support the
ArrayMapWithHistory class and for use when extending the time / time
zone detector strategy implementations: this will be useful as
additional sources like GNSS / NTP are added to time detector, and
geo-location are added to time zone detection.

Bug: 146563025
Bug: 140712361
Test: atest com.android.server.timedetector
Test: atest com.android.server.timezonedetector
Change-Id: Ia6195cb628679a6a32c0118d2921e699514eed7d
2019-12-19 19:21:43 +00:00
Neil Fuller
09e8b7d841 Add new permissions
This adds new permissions required when setting the time /zone in
response to telephony signals and when setting the time / zone manually
along the lines of "principle of least privilege".

The intent is to later restrict the number of distinct processes that
can manipulate the device system clock / time zone property directly so
that all time changes go through the time / time zone detector services,
which can enforce policy, log the reasons for changes, and so on.

Bug: 140712361
Test: atest com.android.server.timedetector
Change-Id: Iabd3a5f449ad2ef2b6581475ef2535a4a8a88ef9
2019-12-19 11:11:48 +00:00
Andrei Onea
7ec97ff1d5 Refactor CompatConfigTest and PlatformCompatTest
Use the convenience builders.

Bug: 144552011
Test: atest PlatformCompatTest
Test: atest CompatConfigTest
Change-Id: I984ea4fd043c354dbbe3ff764798e52f68d1c750
2019-12-18 17:12:19 +00:00
Andrei Onea
1828d218d6 Add test for OverrideValidatorImpl
Also add some helper builders for testing.

Bug: 144552011
Test: atest OverrideValidatorImplTest
Change-Id: Ia66638e13df14c72c242ce14041f982b2ce707ac
2019-12-18 15:11:32 +00:00
Andrei Onea
465b214383 Enforce overriding methods for IPlatformCompat
Restrict the ability of callers to IPlatformCompat.setOverrides and
IPlatformCompat.clearOverride, depending on the type of build and/or
whether the app is debuggable.

Bug: 144552011
Test: atest PlatformCompatTest
Test: atest CompatConfigTest
Change-Id: Ibff7db73d7867735853aa2ddde7c14a12625b3dc
2019-12-18 15:10:25 +00:00
Treehugger Robot
e6d84c0d97 Merge "Don't depend on annotation processors XmlWriter." 2019-12-18 08:17:32 +00:00
Mathew Inwood
5249eca1bd Don't depend on annotation processors XmlWriter.
The annotation processor is being modified to produce an intermediate
output that will then be processed to produce the config that ends up on
device. As such, using XmlWriter in frameworks test code no longer makes
sense.

Instead, hard-code XML config in the test to break this problematic
dependency.

Test: atest CompatConfigTest
Change-Id: I371ba32bd83d6a84de94d594169dbb5c63f3d9be
Merged-In: I371ba32bd83d6a84de94d594169dbb5c63f3d9be
2019-12-17 16:33:09 +00:00
Oli Lan
e340ecdc89 Merge "Pass ApexSessionParams when submitting sessions to apex service." 2019-12-17 10:31:26 +00:00
Kevin Chyn
d856937569 Add OWNERS to biometrics projects
Test: Builds

Change-Id: I5979d2d22bb84cb7ada7c431a64343af9a55a4b8
2019-12-16 18:21:41 -08:00
Neil Fuller
6d84974246 Fix TimeZoneDetectorStrategyTest
Fix TimeZoneDetectorStrategyTest#testFirstPlausiblePhoneSuggestionAcceptedWhenTimeZoneUninitialized.
A test that isn't run by treehugger. Broken by commit
9a81291281f16e1adbc2b260bebed91306649c83.

Test: atest com.android.server.timezonedetector
Bug: 140712361
Change-Id: Id1c867caf45055c22d6b8462534624cc82032293
2019-12-16 17:17:18 +00:00
Oli Lan
285976f50d Pass ApexSessionParams when submitting sessions to apex service.
This is a minimal change to allow ApexManager to work with the apex
service API change in aosp/1189340.

Bug: 141148175
Test: atest CtsRollbackManagerHostTestCases
Test: atest CtsStagedInstallHostTestCases
Change-Id: If0065516cfb32ee6c3dcaafeae7b8546a8cae903
Merged-In: I560ee4ed6dd82277892a511909378d5a5a8502ff
2019-12-16 14:32:42 +00:00
Neil Fuller
a140717213 Fix TimeDetectorServiceTest permissions
Fix TimeDetectorServiceTest permissions test. The suggestManualTime()
call was changed from enforceCallingPermission() to
enforceCallingOrSelfPermission() in commit 44fcf29.

Bug: 140712361
Test: atest com.android.server.timedetector
Change-Id: Ice263c7605c2ef7a04031404a25e2696f16b075c
2019-12-12 13:48:21 +00:00
Neil Fuller
19b4e5ac63 Rename SimpleTimeZoneDetectorStrategy
Rename SimpleTimeZoneDetectorStrategy to TimeZoneDetectorStrategyImpl.
Its defining characteristic is not simplicity - it's currently the
only implementation.

There are also some small cleanups around the
TimeDetectorStrategy.Callback not being needed by TimeDetectorService.

Bug: 140712361
Test: treehugger only
Change-Id: Icdf365a6a123574fb2cd21b89a9749a2f386c5fd
2019-12-10 19:15:38 +00:00
Neil Fuller
312da9b9fc Handle multiple phoneIds in time detection
Android has dual sim devices, which means multiple "phone" time
signals. NITZ is generally trusted and considered "good enough" in the
absence of better signals, but it is provided by carriers and it's not
unusual for the signals to be incorrect by minutes. We don't want the
device system clock just flicking to the latest signal received.

The changes to the SimpleTimeDetectorStrategy try to balance recency and
provide some consistency / determinism. See comments in the code for
details. The time zone detection works in a similar way, particularly
with respect to choosing the lowest phoneId in the event of a tie.

There will be a follow-up change to remove the word "Simple" from
SimpleTimeDetectorStrategy as it no longer applies.

Test: atest services/tests/servicestests/src/com/android/server/timedetector/SimpleTimeDetectorStrategyTest.java
Test: atest android.app.timedetector
Bug: 140712361
Change-Id: I228aff8709eabfcec910af22f7ab08fee32d566a
2019-12-10 19:15:38 +00:00
Treehugger Robot
78b90b3a76 Merge "Remove broadcast of NETWORK_SET_TIMEZONE intent" 2019-12-10 16:54:49 +00:00
Meng Wang
52b8e3e448 Merge "Remove usage of hidden API PhoneConstants.SUBSCRIPTION_KEY" 2019-12-09 21:18:02 +00:00
sqian
22f5749ccc Make getPackagesWithPriviligesForAllActiveSubscriptions system API
Test: build
Bug: 145550382
Change-Id: Ia7efb9e4b22b24f3c87c7cd631548c7254b28926
Merged-In: Ia7efb9e4b22b24f3c87c7cd631548c7254b28926
(cherry picked from commit 6f27c5769d8c5b5c76d143f590a8c4d1c5d8ccee)
2019-12-06 12:07:57 -08:00
Meng Wang
dcff8689db Remove usage of hidden API PhoneConstants.SUBSCRIPTION_KEY
The extra key for subscription ID of ACTION_CARRIER_CONFIG_CHANGED is
CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX.

Bug: 140908357
Test: make
Change-Id: I437ebf67bd27e2ac69b2b7784d98d7683350652c
Merged-In: I437ebf67bd27e2ac69b2b7784d98d7683350652c
2019-12-06 11:44:16 -08:00
Neil Fuller
6e3020490d Merge "TimeDetector improvements" 2019-12-06 11:53:14 +00:00
Neil Fuller
63d5f12489 Merge "Add suggestManualTimeZoneSuggestion to the client" 2019-12-05 13:51:34 +00:00
Neil Fuller
9a81291281 Remove broadcast of NETWORK_SET_TIMEZONE intent
android.intent.action.NETWORK_SET_TIMEZONE is not used by anything in
the platform so it can be removed. It was previously broadcast when
telephony made a time zone change, presumably as a way to coordinate
time zone detection logic if there were other, lower-priority detection
mechanisms on the device. The logic for time zone detection is now
centralized in the system server so coordination can be done more
directly when needed.

All the APK usages appear to be only manifest entries for
<protected-broadcast> in apps that don't send the intent themselves,
which doesn't make a lot of sense.

Note: There is a separate commit to remove the broadcast from the old
(disabled) NITZ logic.

Bug: 140712361
Test: treehugger
Change-Id: Iab629778e45815f4632359e90d920b7751c1a199
2019-12-05 13:09:19 +00:00
Neil Fuller
106f18a666 Add suggestManualTimeZoneSuggestion to the client
Add TimeZoneDetector.suggestManualTimeZone() to set the time zone
"manually" and switch the device policy manager code over to using
it.

Add RequiredPermission annotations to TimeZoneDetector while there.

Bug: 140712361
Test: treehugger only
Test: atest services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
Change-Id: Id247fddfdd793732dd88294ee215eda37cd0be4c
2019-12-05 12:12:14 +00:00
atrost
23886e7b2c Add descriptions to compat changes.
Capture the comment above a definition of a compat change and make it
the description.
Next: make sure existing changes use supported format (only /**
comments, only above the annotations), and use in developer UI.

Bug: 144927670
Test: atest com.android.server.compat.CompatConfigTest
Change-Id: Ib23f341baa171599654c351693e4b0ddf4b2515c
2019-12-04 17:17:16 +00:00
paulhu
59148b7938 Replace the permission of internal connectivity checks
A number of connectivity checks that protect system-only methods
check for CONNECTIVITY_INTERNAL, but CONNECTIVITY_INTERNAL is a
signature|privileged permission. We should audit the permission
checks, and convert checks that protect code that should not be
called outside the system to a signature permission. So replace
all CONNECTIVITY_INTERNAL to other proper permissions.

Bug: 32963470
Test: atest FrameworksNetTests NetworkPolicyManagerServiceTest
Change-Id: I8f2dd1cd0609056494eaf612d39820e273ae093f
Merged-In: I8f2dd1cd0609056494eaf612d39820e273ae093f
2019-12-04 11:44:45 +08:00
Treehugger Robot
2b65793cd6 Merge "Merge Android10 QPR1 into AOSP master" 2019-12-03 23:15:02 +00:00
Neil Fuller
0db51fc310 TimeDetector improvements
TimeDetector improvements for production code and tests. Many of these
are based on feedback given for TimeZoneDetector and to improve
consistency across the two.

1) Add a builder for PhoneTimeSuggestion, making it immutable (except
for debug info that doesn't affect behavior).
2) Improve debug logging.
3) Improve comments / annotations.

Test: atest android.app.timedetector
Test: atest com.android.server.timedetector
Bug: 140712361
Change-Id: Ibd0d357c536d512ffe4995c4e6560e483a260ae5
2019-12-03 20:22:05 +00:00
Neil Fuller
7fcab2dba8 Merge "Add a manual path for setting time zone" 2019-12-03 20:17:09 +00:00
Neil Fuller
77d5009778 Merge "Make TimeDetectorService / Strategy consistent" 2019-12-03 19:26:07 +00:00
Neil Fuller
2c6d510e45 Add a manual path for setting time zone
Add a mechanism for suggesting the "manual" time zone setting to the
TimeZoneDetectorStrategy, e.g. for the settings app to use. This
involves various changes / renames to TimeZoneDetectorStrategy to
introduce a distinction between 3 things:
1) General detection code, applicable for anything that changes device
time zone.
2) Phone detection code, applicable for setting the device time zone
from phone signals.
3) Automatic detection code, applicable for setting the device time zone
automatically (of which telephony signals is currently the only example,
but could be joined by new things in future).

Adds tests for the new ManualTimeZoneSuggestion and makes improvements
to the existing tests for PhoneTimeZoneSuggestionTest.

Test: atest android.app.timezonedetector
Test: atest com.android.server.timezonedetector
Bug: 140712361
Change-Id: I9c3a18e47b157cccabda74855e5c91b45fa93b92
2019-12-03 16:38:03 +00:00
Dario Freni
c7a4eec435 Merge changes from topic "aosp-apk-in-apex"
* changes:
  DO NOT MERGE: Fixes NPE when preparing app data during init
  Support privileged apps installed in APEX.
  Support non-privileged APKs in APEX.
  Refactors initial directory scan to be dryer
2019-12-03 11:45:55 +00:00
Neil Fuller
7d8a624085 Merge "Add a new time zone detection service" 2019-12-03 08:40:07 +00:00
Kenny Root
cec994c03f Merge "Convert LockSettingsService tests to JUnit4"
am: 78056c77f3

Change-Id: Ia3e6556eaebc346434abc84ee9d76287f77a7130
2019-12-02 11:25:12 -08:00
Treehugger Robot
78056c77f3 Merge "Convert LockSettingsService tests to JUnit4" 2019-12-02 19:18:23 +00:00
Neil Fuller
3352cfce2f Add a new time zone detection service
Add a new time zone detection service. Much of the code is from
frameworks/opt/telephony with some changes for naming, threading and
to modify the interaction with the "Callback" class.

Overall goal:

Implementing the service in the system server means it will be easier to
add new time zone detection logic unrelated to telephony in future.

Bug: 140712361
Test: atest com.android.server.timezonedetector
Test: atest android.app.timezonedetector
Change-Id: I89505fc4fecbd3667b60f8e1479b8f177eaa60ae
Merged-In: I89505fc4fecbd3667b60f8e1479b8f177eaa60ae
(cherry picked from commit 3e3b5405b6c5e77a640ad9450eb1cac5b7c80ff1)
2019-11-28 13:27:55 +00:00
Neil Fuller
40cf2957e4 Make TimeDetectorService / Strategy consistent
Make TimeDetectorService / Strategy consistent with time zone detection
code, improve logging and generally tidy up.

1) Turn off debug logging / shorten log tags.
2) Add LocalLog for recording time changes.
3) Move to using FgThread for calls that can be done async / change
synchronization model (responsibility moves from service to strategy).
4) Move responisibility for determining current auto-time state to the
strategy.
5) Rename the strategy test to be correct(!)

Bug: 140712361
Test: atest services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java
Test: atest services/tests/servicestests/src/com/android/server/timedetector/SimpleTimeDetectorStrategyTest.java
Change-Id: I4902f6b360c168ec16a1595359153488a310a91a
2019-11-28 12:11:17 +00:00
Patrick Baumann
ecccf009ea Refactors initial directory scan to be dryer
This change collapses a bunch of manual calls to scanDir with a map and
a loop. This makes things a little more readable and easier to update
going forward.

Bug: NA
Test: boots without issue.
Merged-In: I81fb7a9474894d0bceecb6b0ef7a64d047a40c14
Change-Id: I81fb7a9474894d0bceecb6b0ef7a64d047a40c14
2019-11-28 18:26:05 +08:00
Neil Fuller
b07f90adb8 Merge "Add a new method to set time"
am: 5f01cb6ddc

Change-Id: If92a40f84971a663f99d7d764cd45e8d3510bfda
2019-11-28 00:54:46 -08:00
Neil Fuller
3aedd49238 Add a new method to set time
Before this change there are a various components that set the system
clock by directly calling AlarmManager.setTime(). This change exposes a
new method on TimeDetector to use when setting the device time manually
(e.g. via settings) and modifies some callers to use it.

The intent is to later restrict the number of distinct processes that
can manipulate the device system clock directly so that all time changes
go through the time detector service, which can enforce policy, log
the reasons for changes, and so on.

Bug: 140712361
Test: atest com.android.server.timedetector
Change-Id: I9300dba868ed61249d0848b0dd4b953996161bda
Merged-In: I9300dba868ed61249d0848b0dd4b953996161bda
(cherry picked from commit e376756b0c0e3164300c3fd624f9221181e82553)
2019-11-27 16:34:53 +00:00
Anna Trostanetski
aa7b68930a Merge "Add Listeners to PlatformCompat"
am: e14d7099a9

Change-Id: Id187394dc3f52f560faac6b9c73dea40119a5eff
2019-11-27 06:20:13 -08:00