1106 Commits

Author SHA1 Message Date
Hongwei Wang
050275cd83 Revert "Add maxTargetSdk restriction to unused APIs."
This reverts commit 72f07d6a8a32db4a0dedd7682a0b3385be2b9cd6.

Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397

Bug: 171886397
Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
2020-10-28 20:16:22 +00:00
Mathew Inwood
72f07d6a8a Add maxTargetSdk restriction to unused APIs.
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.

Bug: 170729553
Test: Treehugger
Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
2020-10-27 15:46:07 +00:00
TreeHugger Robot
8a531bb4af Merge "Make ListenerMultiplexer more flexible" 2020-10-27 00:13:04 +00:00
Soonil Nagarkar
3a983cb95f Make ListenerMultiplexer more flexible
Previously ListenerMultiplexer attempted to be perscriptive about when
individual listener invocations should be allowed, but this is not
proving flexible enough. So, we allow registrations to invoke listeners
at any time without being perscriptive about it instead.

Test: manual + presubmit
Change-Id: I6ff8c6bd4f3e3af15d6ebc4b484b971df5a8c0e2
2020-10-26 13:40:00 -07:00
Jeff Sharkey
1992cdb4de Merge changes from topic "oct16c"
* changes:
  Apply fixes for EfficientStrings.
  Apply fixes for EfficientStrings.
  Apply fixes for EfficientStringsChecker.
  Apply fixes for EfficientCollections.
  Trivial refactor for consistent naming.
  Expand formatSimple() to support widths.
  Refinement of EfficientStringsChecker.
2020-10-21 15:27:15 +00:00
Jeff Sharkey
1c08f48253 Apply fixes for EfficientStringsChecker.
The recently-built Error Prone checker has found many instances where
we're always paying the cost of StringBuilder concatenation, even in
the typical cases where preconditions are successfully met.

Benchmarks have shown that even when replacing these with varargs
formatter strings, the default case is 20x faster.

Bug: 170978902
Test: none
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: If8c00bc73467bfb91ec16c162969c9d26ca53646
2020-10-20 22:00:16 -06:00
Soonil Nagarkar
c73cecefc1 Improve QUALITY_* constant documentation
Given devs a better idea of how these quality constant may work.

Bug: 168624248
Test: n/a
Change-Id: I16910bc45d013b4a366d4e8036f63fdfbef55461
2020-10-20 11:36:22 -07:00
Anton Hansson
586a3cf229 Remove @TestApi from @SystemApi symbols
I ran these commands:
    cd frameworks/base
    grep -rl '@TestApi' --include '*.java' | xargs perl -i -p0e \
        's/\@SystemApi[\s\n]+(\@\w+[\s\n]+)?\@TestApi/\@SystemApi\1/gs'
    grep -rl '@TestApi' --include '*.java' | xargs perl -i -p0e \
        's/\@TestApi[\s\n]+(\@\w+[\s\n]+)?\@SystemApi/\1\@SystemApi/gs'

Bug: 171179806
Test: m checkapi
Change-Id: I772790b783b0a8730b8bf680c9e569a886b8d789
2020-10-20 09:04:03 +01:00
Anton Hansson
dd7d52f963 Remove @TestApi from @SystemApi symbols
I ran these commands:
    cd frameworks/base
    grep -rl '@TestApi' --include '*.java' | xargs perl -i -p0e \
        's/\@SystemApi[\s\n]+(\@\w+[\s\n]+)?\@TestApi/\@SystemApi\1/gs'
    grep -rl '@TestApi' --include '*.java' | xargs perl -i -p0e \
        's/\@TestApi[\s\n]+(\@\w+[\s\n]+)?\@SystemApi/\1\@SystemApi/gs'

Bug: 171179806
Test: m checkapi
Change-Id: I772790b783b0a8730b8bf680c9e569a886b8d789
Merged-In: I772790b783b0a8730b8bf680c9e569a886b8d789
2020-10-19 16:41:01 +01:00
Soonil Nagarkar
f6a861a34f Add quality to LocationRequest/ProviderRequest
Expose quality APIs publically after refactoring them to match external
usage of quality constants. Removes list of location requests from
provider request, as there is no client that really uses this, and it
feels like too much information to give to providers.

Bug: 168624248
Test: presubmits
Change-Id: Icf8a9f6096da0071d97190d3f7196948492e52a1
2020-10-14 16:53:50 -07:00
Taesu Lee
b40a55ccc9 Use TelephonyManager#isEmergencyNumber() instead
Replace deprecated PhoneNumberUtils#isLocalEmergencyNumber() and
isEmergencyNumber() with TelephonyManager#isEmergencyNumber().

Test: Build
Bug: 132703886

Signed-off-by: Taesu Lee <taesu82.lee@samsung.com>
Change-Id: I232d7f7d23efd963b6d30938f0fa304c90fca8a8
Merged-In: I232d7f7d23efd963b6d30938f0fa304c90fca8a8
2020-10-14 02:31:14 +00:00
Taesu Lee
902b89d936 Use TelephonyManager#isEmergencyNumber() instead
Replace deprecated PhoneNumberUtils#isLocalEmergencyNumber() and
isEmergencyNumber() with TelephonyManager#isEmergencyNumber().

Test: Build
Bug: 132703886

Signed-off-by: Taesu Lee <taesu82.lee@samsung.com>
Change-Id: I232d7f7d23efd963b6d30938f0fa304c90fca8a8
2020-10-13 15:52:20 -07:00
Soonil Nagarkar
de402cf5b1 Remove getTestProviderLocationRequests TestApi
This API is no longer necessary for testing, and inappropriately exposes
internals. Also updates battery saver TEST_MAPPING to include location
tests.

Bug: 170224294
Test: presubmits
Change-Id: I1322f21ced86d3622650ecf02dfa959a484660d0
2020-10-08 10:04:03 -07:00
TreeHugger Robot
58686805ae Merge "Various location fixes" 2020-10-06 09:41:06 +00:00
Neil Fuller
dcd5a9cbb2 Merge "Expose the LTZP in the location provider API" 2020-10-06 08:49:40 +00:00
Soonil Nagarkar
5d47f1e2cd Various location fixes
-Prevent PendingIntents from using LocationRequest SystemApis. We don't
track permission removal, so we don't current reset the request if the
permission is lost.
-Make LocationRequest.getWorkSource() NonNull. Small quality of life
change to reduce null checks all over.
-Don't spend CPU coarsening location until we actually need to. The vast
majority of locations will never need to be coarsened. Don't bother
doing so until we actually need to.

Bug: 169887240
Test: manual + presubmit
Change-Id: I7ad6fe886eaede3ed9f46cebe4246d29d6b6e187
2020-10-06 00:14:55 -07:00
Soonil Nagarkar
dbc7965fba Merge "Refactor background/system user behavior" 2020-10-05 23:31:58 +00:00
Soonil Nagarkar
8325967542 Refactor location event log
Log a much wider variety of important events in memory for bugreports
and dumpsys. This will make debugging much easier, hopefully at a
minimal memory cost. Memory cost could be improved in the future as
well.

Test: manual + presubmits
Change-Id: Iab867575f783f1c5f41a405da66f72d5f52691bf
2020-09-30 18:24:35 -07:00
Soonil Nagarkar
e963789b7f Refactor background/system user behavior
This is a breaking change so that providers are no longer disabled for
non-current (ie background users). Instead, location requests from
background users are now considered inactive. This brings provider
behavior more in line with other APIs (such as GNSS and geofencing),
and allows us to special case requests from the system UID.

Without this change, the system UID would see incorrect provider
enabled/disabled notifications. Impact on clients is expected to be
minimal, as by far the vast majority of android applications run on
single user devices. For multiuser devices, applications will no longer
see enabled/disabled notifications in response to current user changes.

Bug: 157682495
Test: manual + presubmit
Change-Id: I0edb15f0792bf1426855baefcda8477ba3a32b28
2020-09-30 17:00:42 -07:00
Soonil Nagarkar
6e41050612 Fix background request throttling + jitter calculation
Prevent applications from bypassing background location throttling by
adding/removing requests. This allows provider managers to delay
requests in the event the interval has decreased so that power can be
saved. Clients that target S and above may now receive historical
locations in exchange, so that they are not losing locations overall.
Locationp providers can optionally implement delays themselves in the
event of an interval increase.

Also updates jitter calculation to be a capped percentage of the
request interval, rather than a flat cap.

Bug: 73144566
Test: manual + presubmits
Change-Id: I243e813f0c0c504850e2a3e777787f49fc6f7a57
2020-09-30 11:38:09 -07:00
Neil Fuller
0c59c9c166 Expose the LTZP in the location provider API
Expose the LocationTimeZoneProvider and associated classes in the
location lib API.

Bug: 152744911
Test: build only
Change-Id: Ib577bbdee10d7778e28fc1c6003cc97fdb15acb3
2020-09-25 12:50:48 +01:00
Soonil Nagarkar
2d6bcbecd3 DO NOT MERGE Local timeout should cancel remote work
Ensure that when getCurrentLocation() times out locally, remote work in
system server is also canceled.

Bug: 168666216
Test: manual
Change-Id: Idde2156323c3fca0ed94ff886a4277122c598753
2020-09-24 09:41:24 -07:00
Neil Fuller
3299f0913f Tidy up the "unbundled" provider API
This commit introduces a LocationTimeZoneEventUnbundled, as
LocationTimeZoneEvent will not be on another API surface so cannot be
reused. (The equivalent from LocationProvider is Location, which is
public API so there is no LocationUnbundled.)

Add an initialization timeout to LocationTimeZoneProviderRequest so that
providers can make intelligent choices about (for example) how long to
spend waiting for geolocation to happen passively.

Test: atest services/tests/servicestests/src/com/android/internal/location/timezone/
Test: atest services/tests/servicestests/src/com/android/server/location/timezone/
Bug: 152744911
Change-Id: Id3e9e6916e8c3a132d8fc892338578ab9d2ff574
2020-09-24 17:38:10 +01:00
Soonil Nagarkar
05f32ddfab DO NOT MERGE Fix bug in getCurrentLocation cancellation
Cancellation was not being propagated to the system server due to a
misunderstanding on how CancellationSignal functions. There is no
noticable impact for the user, as cancellation did properly prevent any
further locations, however this would have resulted in extra
power draw since the system server would not have canceled the
associated provider location request. This would have left
getCurrentLocation() as equivalent to requestSingleUpdate() where it was
supposed to be an all-around improvement that could save power.

Bug: 168666216
Test: manual + presubmits
Change-Id: I5c77db4cc56cce1b984587f65d2bcfb488436bb8
2020-09-22 10:33:11 -07:00
TreeHugger Robot
a44e3df0c9 Merge "Fix bug in getCurrentLocation cancellation" 2020-09-22 01:25:10 +00:00
Soonil Nagarkar
43a368dc19 Fix bug in getCurrentLocation cancellation
Cancellation was not being propagated to the system server due to a
misunderstanding on how CancellationSignal functions. There is no
noticable impact for the user, as cancellation did properly prevent any
further locations, however this would have resulted in limited extra
power draw since the system server would not have canceled the
associated provider location request. Impact is limited since
getCurrentLocation() was limited to a 30s duration anyways.

Bug: 168666216
Test: manual + presubmits
Change-Id: I5c77db4cc56cce1b984587f65d2bcfb488436bb8
2020-09-21 14:15:47 -07:00
Soonil Nagarkar
69d87137be Improve LocationRequest appcompat
Fix a bug where we were overstrict in validating legacy location
requests, and didn't cover all possible legacy inputs. Specifically,
clients that pass in Long.MAX_VALUE as the interval - unclear why any
client would want to do this, but nevertheless, it was allowed.

Bug: 168927418
Test: presubmit
Change-Id: Iaa604da6dee9e860f13abe0a74853579f757e249
2020-09-21 09:22:57 -07:00
Soonil Nagarkar
87b8cc3866 Refactor ListenerMultiplexer with new capabilities
-Store tag string in multiplexer rather than duplicating in every
registration.
-Add support for failure callbacks at listener operation submission
time, in addition to within the listener operation itself.
-Extract request out of ListenerRegistration and into subclass, so that
the multiplexer does not need to have any knowledge of requests.
-New multiplexer specific execute and failure callbacks within
registrations objects, with strongly typed listener operation objects.
-Fixed resetService() to work properly even if the service is still
registered.
-Added registration info as an argument to registerWithService() so that
this doesn't need to be duplicated if a client wants access to this
information.
-Narrow exception handling so that only the proper exception
(RemoteException for binder calls for instance) results in registration
removal, and other unexpected checked exceptions should still crash the
process.
-Various other minor fixes.

Test: manual + presubmit
Change-Id: I6fdec313222ff1ef01a1aa4d27d8ee56b4be25d4
2020-09-18 10:08:11 -07:00
TreeHugger Robot
559bf65528 Merge "Additional API change after feedback" 2020-09-16 17:47:03 +00:00
Soonil Nagarkar
f2bc6ba3a0 Fix up provider internal/external APIs
-Encapsulate various fields
-Bring naming in line with API guidelines
-Minor refactoring

Bug: 168621146
Test: manual
Change-Id: I55681a3d84d7833c98569a13a57e6c4f0b728a67
2020-09-15 17:13:46 -07:00
Soonil Nagarkar
12c2c5c949 Additional API change after feedback
Bug: 168624248
Test: manual
Change-Id: I61a85b84af20f339d68541f45ad53fe09e8d176c
2020-09-15 13:24:40 -07:00
Soonil Nagarkar
7926062e1f Merge "Make LocationRequest a public API" 2020-09-14 16:20:23 +00:00
Soonil Nagarkar
757380517b Make LocationRequest a public API
LocationRequest and associated APIs have historically always been
SystemApi, for no real reason. In keeping with the Android-wide push to
clean up API surfaces like this, we make LocationRequest a public API.

Bug: 166692379
Test: manual + presubmits
Change-Id: I6a93fca1a5613c96bf35da158bc542e47864dbff
2020-09-11 12:29:50 -07:00
Neil Fuller
a32bde83cd Merge "Small docs fix" 2020-09-08 18:13:27 +00:00
Neil Fuller
076aaa5e81 Merge "Small fixes to basic classes and refactorings" 2020-09-04 15:57:03 +00:00
Neil Fuller
7c552b3786 Small fixes to basic classes and refactorings
Small fixes to basic classes and refactorings noticed while preparing a
later change. These changes are fairly "obvious" fixes and refactorings,
removed from the later change to make it smaller.

Test: atest services/tests/servicestests/src/com/android/server/timezonedetector/
Bug: 149014708
Change-Id: If9bcb567778d82f49b3481c50a64c0d739ce2ace
2020-09-04 13:55:57 +01:00
Neil Fuller
05dc9327d3 Small docs fix
Fix for a typo in LocationManager docs.

Test: None
Change-Id: I6c91dda634054f181bb9e46ee8ba4fe438ec6f9f
2020-09-04 13:38:30 +01:00
Soonil Nagarkar
bb7c92cdca Add SdkConstant annotations to public API
Test: presubmits
Change-Id: I3a433a1ca086ba856055048c02ca4fb309c9f255
2020-08-25 10:22:19 -07:00
Soonil Nagarkar
6af009ab20 DO NOT MERGE: Fix NPE bug in LocationManager
Both null and non-null GnssRequest objects may be present in the list of
requests to merge.

Bug: 165375330
Test: presubmits
Change-Id: I13284b1c32f1ad1fce39ad1ca2e4298194197015
2020-08-20 09:11:37 -07:00
Neil Fuller
376a91befa Basic changes to the LocationTimeZoneProvider API
These changes have been broken out as they stand alone and should be
relatively uncontroversial.

The LocationTimeZoneEvent is having UserHandle added, mostly for
logging at this point so we can debug issues with multi-user providers.

Bug: 152744911
Bug: 149014708
Test: atest services/tests/servicestests/src/android/location/timezone/LocationTimeZoneEventTest.java
Change-Id: Iafbd5bc9778d68bc9c3046244e7dca6d9892519e
2020-08-20 08:52:41 +00:00
TreeHugger Robot
275fd7ede6 Merge "Extract LocationProviderManager" 2020-08-04 23:33:20 +00:00
Soonil Nagarkar
d6158258e6 Extract LocationProviderManager
This extracts LocationProviderManager as a completely stand-alone class,
substantially reducing the complexity in LMS, and in
LocationProviderManager. Core AOSP location code is now unit testable
for the first time, and we begin adding unit tests.

Test: extensive manual tests + presubmits
Change-Id: I0fb17ddbf91bdd26ed7855110026b3dd09612a5c
2020-08-04 11:09:55 -07:00
Sasha Kuznetsov
8f0b3f2631 Update GnssAntennaInfo docs and formatting
Bug: 162611455
Test: n/a
Change-Id: I176adae52f0d776a8d2862f1cf3178ae1b919bab
2020-08-03 09:55:19 -07:00
Soonil Nagarkar
afec5ccf72 Assorted cleanup and refactoring
Will minimize future changes:
-Never return null GpsStatus to avoid breaking legacy clients
-Allow null location callback complete callbacks
-Return void from sendExtraCommand
-Combine appops and permissions checks into a single helper
-Allow passive provider to remember last locations even when there is
no active passive request.
-Add a couple new injectable helpers to support future changes along
with fakes for testing.

Test: presubmits + manual
Change-Id: If22bee787c5ab5c8c09d20e4742a8b5d1b7f0b59
2020-07-23 13:50:15 -07:00
Soonil Nagarkar
d9df33d1c0 DO NOT MERGE: Always return non null from getGpsStatus
Even though getGpsStatus is marked Nullable, some applications expect it
to always return non-null.

Bug: 161311411
Test: presubmits
Change-Id: I8d58621588253af1dc917711e230cfd176afec37
2020-07-15 13:12:54 -07:00
Salud Lemus
3d655ad09e Replace manual creation of StatsEvent objects with their appropriate buildStatsEvent() method
Currently, Java clients are manually creating the StatsEvent objects
which can lead to errors. Now that there is support for pulled atoms for
stats-log-api-gen for Java clients, use the appropriate buildStatsEvent
method that was auto generated by stats-log-api-gen.

Bug: 160368804
Test: Ran `m` and completed successfully
Test: Ran `atest statsd_test` and all CTS tests passed
Test: Ran `atest UidAtomTests` and all CTS tests passed except for the CTS tests related to a SIM card because the device does not have a SIM card

Change-Id: Id229ba5ca94203135a8a5e2607de9844e0432ce1
2020-07-14 23:00:57 +00:00
Kevin Hufnagle
ab5d24346a Merge "docs: Fix link to loc. Google Play services API" into rvc-dev am: 4bef972b77 am: 9a16d1a934 am: aacf1ce9ac am: 941fb17fd4
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12063133

Change-Id: If4bed43797bc1756ec575e7571e8d61594595cf1
2020-07-13 23:36:39 +00:00
Kevin Hufnagle
4bef972b77 Merge "docs: Fix link to loc. Google Play services API" into rvc-dev 2020-07-13 22:24:25 +00:00
Soonil Nagarkar
00af9a3205 Ask location provider for its package name
The package name from the service watcher may be inconsistent with the
package name of the currently bound service.

Test: none
Change-Id: Iede437d2e61a0da0b853fdbb133a29add04f6bf3
2020-07-09 16:57:25 -07:00
Soonil Nagarkar
f71511387c Deprecate high power location broadcast
This can be replaced by listening directly for appops changes.

Test: manual + presubmit
Change-Id: Ib84fbeebd7be25f4a1b097b65137777030805132
2020-07-09 11:13:51 -07:00