diff options
113 files changed, 1111 insertions, 1552 deletions
diff --git a/Android.bp b/Android.bp index 037c29c39cb0..be832108097c 100644 --- a/Android.bp +++ b/Android.bp @@ -169,8 +169,6 @@ java_library { "core/java/android/hardware/location/IActivityRecognitionHardwareClient.aidl", "core/java/android/hardware/location/IActivityRecognitionHardwareSink.aidl", "core/java/android/hardware/location/IActivityRecognitionHardwareWatcher.aidl", - "core/java/android/hardware/location/IFusedLocationHardware.aidl", - "core/java/android/hardware/location/IFusedLocationHardwareSink.aidl", "core/java/android/hardware/location/IGeofenceHardware.aidl", "core/java/android/hardware/location/IGeofenceHardwareCallback.aidl", "core/java/android/hardware/location/IGeofenceHardwareMonitorCallback.aidl", @@ -409,7 +407,6 @@ java_library { "location/java/android/location/IBatchedLocationCallback.aidl", "location/java/android/location/ICountryDetector.aidl", "location/java/android/location/ICountryListener.aidl", - "location/java/android/location/IFusedProvider.aidl", "location/java/android/location/IGeocodeProvider.aidl", "location/java/android/location/IGeofenceProvider.aidl", "location/java/android/location/IGnssStatusListener.aidl", diff --git a/apct-tests/perftests/core/src/android/os/BinderCallsStatsPerfTest.java b/apct-tests/perftests/core/src/android/os/BinderCallsStatsPerfTest.java new file mode 100644 index 000000000000..28d40969aa21 --- /dev/null +++ b/apct-tests/perftests/core/src/android/os/BinderCallsStatsPerfTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package android.os; + +import android.perftests.utils.BenchmarkState; +import android.perftests.utils.PerfStatusReporter; +import android.support.test.filters.LargeTest; +import android.support.test.runner.AndroidJUnit4; + +import com.android.internal.os.BinderCallsStats; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.assertNull; + + +/** + * Performance tests for {@link BinderCallsStats} + */ +@RunWith(AndroidJUnit4.class) +@LargeTest +public class BinderCallsStatsPerfTest { + + @Rule + public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + private BinderCallsStats mBinderCallsStats; + + @Before + public void setUp() { + mBinderCallsStats = new BinderCallsStats(true); + } + + @After + public void tearDown() { + } + + @Test + public void timeCallSession() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + Binder b = new Binder(); + int i = 0; + while (state.keepRunning()) { + BinderCallsStats.CallSession s = mBinderCallsStats.callStarted(b, i % 100); + mBinderCallsStats.callEnded(s); + i++; + } + } + + @Test + public void timeCallSessionTrackingDisabled() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + Binder b = new Binder(); + mBinderCallsStats = new BinderCallsStats(false); + assertNull(mBinderCallsStats.callStarted(b, 0)); + while (state.keepRunning()) { + BinderCallsStats.CallSession s = mBinderCallsStats.callStarted(b, 0); + mBinderCallsStats.callEnded(s); + } + } + +} diff --git a/api/current.txt b/api/current.txt index 6a9f00e46b07..5cfd29ad97dd 100644 --- a/api/current.txt +++ b/api/current.txt @@ -21818,7 +21818,6 @@ package android.location { method public void unregisterGnssMeasurementsCallback(android.location.GnssMeasurementsEvent.Callback); method public void unregisterGnssNavigationMessageCallback(android.location.GnssNavigationMessage.Callback); method public void unregisterGnssStatusCallback(android.location.GnssStatus.Callback); - field public static final java.lang.String GNSS_HARDWARE_MODEL_NAME_UNKNOWN = "Model Name Unknown"; field public static final java.lang.String GPS_PROVIDER = "gps"; field public static final java.lang.String KEY_LOCATION_CHANGED = "location"; field public static final java.lang.String KEY_PROVIDER_ENABLED = "providerEnabled"; diff --git a/api/system-current.txt b/api/system-current.txt index 6d43d27355d6..a0561153c640 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4236,7 +4236,7 @@ package android.provider { public static final class Settings.Global extends android.provider.Settings.NameValueTable { method public static boolean putString(android.content.ContentResolver, java.lang.String, java.lang.String, java.lang.String, boolean); method public static void resetToDefaults(android.content.ContentResolver, java.lang.String); - field public static final java.lang.String AUTOFILL_COMPAT_ALLOWED_PACKAGES = "autofill_compat_allowed_packages"; + field public static final java.lang.String AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES = "autofill_compat_mode_allowed_packages"; field public static final java.lang.String CARRIER_APP_NAMES = "carrier_app_names"; field public static final java.lang.String CARRIER_APP_WHITELIST = "carrier_app_whitelist"; field public static final java.lang.String DEFAULT_SM_DP_PLUS = "default_sm_dp_plus"; @@ -4371,6 +4371,7 @@ package android.security.keystore.recovery { method public int[] getRecoverySecretTypes() throws android.security.keystore.recovery.InternalRecoveryServiceException; method public deprecated int getRecoveryStatus(java.lang.String, java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException; method public int getRecoveryStatus(java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException; + method public java.util.Map<java.lang.String, java.security.cert.X509Certificate> getRootCertificates(); method public java.security.Key importKey(java.lang.String, byte[]) throws android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.LockScreenRequiredException; method public deprecated void initRecoveryService(java.lang.String, byte[]) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException; method public void initRecoveryService(java.lang.String, byte[], byte[]) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException; @@ -4388,9 +4389,11 @@ package android.security.keystore.recovery { public class RecoverySession implements java.lang.AutoCloseable { method public void close(); - method public java.util.Map<java.lang.String, byte[]> recoverKeys(byte[], java.util.List<android.security.keystore.recovery.WrappedApplicationKey>) throws android.security.keystore.recovery.DecryptionFailedException, android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.SessionExpiredException; + method public java.util.Map<java.lang.String, java.security.Key> recoverKeyChainSnapshot(byte[], java.util.List<android.security.keystore.recovery.WrappedApplicationKey>) throws android.security.keystore.recovery.DecryptionFailedException, android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.SessionExpiredException; + method public deprecated java.util.Map<java.lang.String, byte[]> recoverKeys(byte[], java.util.List<android.security.keystore.recovery.WrappedApplicationKey>) throws android.security.keystore.recovery.DecryptionFailedException, android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.SessionExpiredException; method public deprecated byte[] start(byte[], byte[], byte[], java.util.List<android.security.keystore.recovery.KeyChainProtectionParams>) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException; - method public byte[] start(java.security.cert.CertPath, byte[], byte[], java.util.List<android.security.keystore.recovery.KeyChainProtectionParams>) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException; + method public deprecated byte[] start(java.security.cert.CertPath, byte[], byte[], java.util.List<android.security.keystore.recovery.KeyChainProtectionParams>) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException; + method public byte[] start(java.lang.String, java.security.cert.CertPath, byte[], byte[], java.util.List<android.security.keystore.recovery.KeyChainProtectionParams>) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException; } public class SessionExpiredException extends java.security.GeneralSecurityException { diff --git a/api/test-current.txt b/api/test-current.txt index 70e3cf34f6b0..31e3e7c242fe 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -570,7 +570,7 @@ package android.provider { } public static final class Settings.Global extends android.provider.Settings.NameValueTable { - field public static final java.lang.String AUTOFILL_COMPAT_ALLOWED_PACKAGES = "autofill_compat_allowed_packages"; + field public static final java.lang.String AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES = "autofill_compat_mode_allowed_packages"; field public static final java.lang.String HIDDEN_API_BLACKLIST_EXEMPTIONS = "hidden_api_blacklist_exemptions"; field public static final java.lang.String LOCATION_GLOBAL_KILL_SWITCH = "location_global_kill_switch"; field public static final java.lang.String LOW_POWER_MODE = "low_power"; diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index 40eff4c2bd03..99611f4121d7 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -23,6 +23,7 @@ option java_outer_classname = "AtomsProto"; import "frameworks/base/cmds/statsd/src/atom_field_options.proto"; import "frameworks/base/core/proto/android/app/enums.proto"; +import "frameworks/base/core/proto/android/app/job/enums.proto"; import "frameworks/base/core/proto/android/bluetooth/enums.proto"; import "frameworks/base/core/proto/android/os/enums.proto"; import "frameworks/base/core/proto/android/server/enums.proto"; @@ -362,7 +363,10 @@ message ScheduledJobStateChanged { } optional State state = 3; - // TODO: Consider adding the stopReason (int) + // The reason a job has stopped. + // This is only applicable when the state is FINISHED. + // The default value is CANCELED. + optional android.app.job.StopReasonEnum stop_reason = 4; } /** diff --git a/config/boot-image-profile.txt b/config/boot-image-profile.txt index 40b266fe29d7..87fb99807ebc 100644 --- a/config/boot-image-profile.txt +++ b/config/boot-image-profile.txt @@ -3375,8 +3375,6 @@ HPLandroid/location/ICountryListener$Stub;-><init>()V HPLandroid/location/ICountryListener$Stub;->asBinder()Landroid/os/IBinder; HPLandroid/location/ICountryListener$Stub;->asInterface(Landroid/os/IBinder;)Landroid/location/ICountryListener; HPLandroid/location/ICountryListener;->onCountryDetected(Landroid/location/Country;)V -HPLandroid/location/IFusedProvider$Stub;-><init>()V -HPLandroid/location/IFusedProvider;->onFusedLocationHardwareChange(Landroid/hardware/location/IFusedLocationHardware;)V HPLandroid/location/IGeocodeProvider$Stub$Proxy;-><init>(Landroid/os/IBinder;)V HPLandroid/location/IGeocodeProvider$Stub$Proxy;->getFromLocation(DDILandroid/location/GeocoderParams;Ljava/util/List;)Ljava/lang/String; HPLandroid/location/IGeocodeProvider$Stub;-><init>()V diff --git a/config/hiddenapi-light-greylist.txt b/config/hiddenapi-light-greylist.txt index e238f0609da5..e4df85bf2dee 100644 --- a/config/hiddenapi-light-greylist.txt +++ b/config/hiddenapi-light-greylist.txt @@ -823,7 +823,6 @@ Landroid/location/Country;->getCountryIso()Ljava/lang/String; Landroid/location/Country;->getSource()I Landroid/location/GeocoderParams;->getClientPackage()Ljava/lang/String; Landroid/location/GeocoderParams;->getLocale()Ljava/util/Locale; -Landroid/location/IFusedProvider$Stub;-><init>()V Landroid/location/IGeocodeProvider$Stub;-><init>()V Landroid/location/IGeofenceProvider$Stub;-><init>()V Landroid/location/ILocationManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/location/ILocationManager; diff --git a/config/hiddenapi-vendor-list.txt b/config/hiddenapi-vendor-list.txt index fe9a5dbb1c24..0230ad924d75 100644 --- a/config/hiddenapi-vendor-list.txt +++ b/config/hiddenapi-vendor-list.txt @@ -113,7 +113,6 @@ Landroid/hardware/display/DisplayManagerGlobal;->getInstance()Landroid/hardware/ Landroid/hardware/display/DisplayManagerGlobal;->getRealDisplay(I)Landroid/view/Display; Landroid/hardware/location/GeofenceHardware;-><init>(Landroid/hardware/location/IGeofenceHardware;)V Landroid/hardware/location/IActivityRecognitionHardwareClient;->onAvailabilityChanged(ZLandroid/hardware/location/IActivityRecognitionHardware;)V -Landroid/location/IFusedProvider;->onFusedLocationHardwareChange(Landroid/hardware/location/IFusedLocationHardware;)V Landroid/location/IGeocodeProvider;->getFromLocation(DDILandroid/location/GeocoderParams;Ljava/util/List;)Ljava/lang/String; Landroid/location/IGeocodeProvider;->getFromLocationName(Ljava/lang/String;DDDDILandroid/location/GeocoderParams;Ljava/util/List;)Ljava/lang/String; Landroid/location/IGeofenceProvider;->setGeofenceHardware(Landroid/hardware/location/IGeofenceHardware;)V diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index c6568e16086c..5d21be50d4a9 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -2631,8 +2631,8 @@ public class Notification implements Parcelable if (!Objects.equals(firstRs[j].getLabel(), secondRs[j].getLabel())) { return true; } - CharSequence[] firstCs = firstRs[i].getChoices(); - CharSequence[] secondCs = secondRs[i].getChoices(); + CharSequence[] firstCs = firstRs[j].getChoices(); + CharSequence[] secondCs = secondRs[j].getChoices(); if (firstCs == null) { firstCs = new CharSequence[0]; } diff --git a/core/java/android/app/job/JobParameters.java b/core/java/android/app/job/JobParameters.java index c71bf2e65731..d67f11bb6c2b 100644 --- a/core/java/android/app/job/JobParameters.java +++ b/core/java/android/app/job/JobParameters.java @@ -36,15 +36,16 @@ import android.os.RemoteException; public class JobParameters implements Parcelable { /** @hide */ - public static final int REASON_CANCELED = 0; + public static final int REASON_CANCELED = JobProtoEnums.STOP_REASON_CANCELLED; // 0. /** @hide */ - public static final int REASON_CONSTRAINTS_NOT_SATISFIED = 1; + public static final int REASON_CONSTRAINTS_NOT_SATISFIED = + JobProtoEnums.STOP_REASON_CONSTRAINTS_NOT_SATISFIED; //1. /** @hide */ - public static final int REASON_PREEMPT = 2; + public static final int REASON_PREEMPT = JobProtoEnums.STOP_REASON_PREEMPT; // 2. /** @hide */ - public static final int REASON_TIMEOUT = 3; + public static final int REASON_TIMEOUT = JobProtoEnums.STOP_REASON_TIMEOUT; // 3. /** @hide */ - public static final int REASON_DEVICE_IDLE = 4; + public static final int REASON_DEVICE_IDLE = JobProtoEnums.STOP_REASON_DEVICE_IDLE; // 4. /** @hide */ public static String getReasonName(int reason) { diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java index ce7d3af8404a..440103a6d8a4 100644 --- a/core/java/android/content/ContentResolver.java +++ b/core/java/android/content/ContentResolver.java @@ -2464,8 +2464,9 @@ public abstract class ContentResolver { * @param account the account to specify in the sync * @param authority the provider to specify in the sync request * @param extras extra parameters to go along with the sync request - * @param pollFrequency how frequently the sync should be performed, in seconds. A minimum value - * of 1 hour is enforced. + * @param pollFrequency how frequently the sync should be performed, in seconds. + * On Android API level 24 and above, a minmam interval of 15 minutes is enforced. + * On previous versions, the minimum interval is 1 hour. * @throws IllegalArgumentException if an illegal extra was set or if any of the parameters * are null. */ diff --git a/core/java/android/hardware/location/IFusedLocationHardware.aidl b/core/java/android/hardware/location/IFusedLocationHardware.aidl deleted file mode 100644 index 2ea4d2374958..000000000000 --- a/core/java/android/hardware/location/IFusedLocationHardware.aidl +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2013, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/license/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.hardware.location; - -import android.hardware.location.IFusedLocationHardwareSink; -import android.location.FusedBatchOptions; - -/** - * Fused Location hardware interface. - * This interface is the basic set of supported functionality by Fused Hardware - * modules that offer Location batching capabilities. - * - * @hide - */ -interface IFusedLocationHardware { - /** - * Registers a sink with the Location Hardware object. - * - * @param eventSink The sink to register. - */ - void registerSink(in IFusedLocationHardwareSink eventSink) = 0; - - /** - * Unregisters a sink with the Location Hardware object. - * - * @param eventSink The sink to unregister. - */ - void unregisterSink(in IFusedLocationHardwareSink eventSink) = 1; - - /** - * Provides access to the batch size available in Hardware. - * - * @return The batch size the hardware supports. - */ - int getSupportedBatchSize() = 2; - - /** - * Requests the Hardware to start batching locations. - * - * @param id An Id associated with the request. - * @param batchOptions The options required for batching. - * - * @throws RuntimeException if the request Id exists. - */ - void startBatching(in int id, in FusedBatchOptions batchOptions) = 3; - - /** - * Requests the Hardware to stop batching for the given Id. - * - * @param id The request that needs to be stopped. - * @throws RuntimeException if the request Id is unknown. - */ - void stopBatching(in int id) = 4; - - /** - * Updates a batching operation in progress. - * - * @param id The Id of the operation to update. - * @param batchOptions The options to apply to the given operation. - * - * @throws RuntimeException if the Id of the request is unknown. - */ - void updateBatchingOptions(in int id, in FusedBatchOptions batchOptions) = 5; - - /** - * Requests the most recent locations available in Hardware. - * This operation does not dequeue the locations, so still other batching - * events will continue working. - * - * @param batchSizeRequested The number of locations requested. - */ - void requestBatchOfLocations(in int batchSizeRequested) = 6; - - /** - * Flags if the Hardware supports injection of diagnostic data. - * - * @return True if data injection is supported, false otherwise. - */ - boolean supportsDiagnosticDataInjection() = 7; - - /** - * Injects diagnostic data into the Hardware subsystem. - * - * @param data The data to inject. - * @throws RuntimeException if injection is not supported. - */ - void injectDiagnosticData(in String data) = 8; - - /** - * Flags if the Hardware supports injection of device context information. - * - * @return True if device context injection is supported, false otherwise. - */ - boolean supportsDeviceContextInjection() = 9; - - /** - * Injects device context information into the Hardware subsystem. - * - * @param deviceEnabledContext The context to inject. - * @throws RuntimeException if injection is not supported. - */ - void injectDeviceContext(in int deviceEnabledContext) = 10; - - /** - * Requests all batched locations currently available in Hardware - * and clears the buffer. Any subsequent calls will not return any - * of the locations returned in this call. - */ - void flushBatchedLocations() = 11; - - /** - * Returns the version of this FLP HAL implementation. - */ - int getVersion() = 12; -} diff --git a/core/java/android/hardware/location/IFusedLocationHardwareSink.aidl b/core/java/android/hardware/location/IFusedLocationHardwareSink.aidl deleted file mode 100644 index a7dd0351010d..000000000000 --- a/core/java/android/hardware/location/IFusedLocationHardwareSink.aidl +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2013, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/license/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.hardware.location; - -import android.location.Location; - -/** - * Fused Location hardware event sink interface. - * This interface defines the set of events that the FusedLocationHardware provides. - * - * @hide - */ -oneway interface IFusedLocationHardwareSink { - /** - * Event generated when a batch of location information is available. - * - * @param locations The batch of location information available. - */ - void onLocationAvailable(in Location[] locations) = 0; - - /** - * Event generated from FLP HAL to provide diagnostic data to the platform. - * - * @param data The diagnostic data provided by FLP HAL. - */ - void onDiagnosticDataAvailable(in String data) = 1; - - /** - * Event generated from FLP HAL to provide a mask of supported - * capabilities. Should be called immediatly after init. - */ - void onCapabilities(int capabilities) = 2; - - /** - * Event generated from FLP HAL when the status of location batching - * changes (location is successful/unsuccessful). - */ - void onStatusChanged(int status) = 3; -} diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java index 44bd35aa896f..0ae5394e6cb9 100644 --- a/core/java/android/os/Binder.java +++ b/core/java/android/os/Binder.java @@ -23,6 +23,7 @@ import android.util.Log; import android.util.Slog; import android.util.SparseIntArray; +import com.android.internal.os.BinderCallsStats; import com.android.internal.os.BinderInternal; import com.android.internal.util.FastPrintWriter; import com.android.internal.util.FunctionalUtils.ThrowingRunnable; @@ -712,6 +713,8 @@ public class Binder implements IBinder { // Entry point from android_util_Binder.cpp's onTransact private boolean execTransact(int code, long dataObj, long replyObj, int flags) { + BinderCallsStats binderCallsStats = BinderCallsStats.getInstance(); + BinderCallsStats.CallSession callSession = binderCallsStats.callStarted(this, code); Parcel data = Parcel.obtain(dataObj); Parcel reply = Parcel.obtain(replyObj); // theoretically, we should call transact, which will call onTransact, @@ -756,6 +759,7 @@ public class Binder implements IBinder { // to the main transaction loop to wait for another incoming transaction. Either // way, strict mode begone! StrictMode.clearGatheredViolations(); + binderCallsStats.callEnded(callSession); return res; } diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 8cb8b0ed0ad4..87babc00ad89 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -9650,6 +9650,21 @@ public final class Settings { public static final String WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED = "wifi_connected_mac_randomization_enabled"; + /** + * Parameters to adjust the performance of framework wifi scoring methods. + * <p> + * Encoded as a comma-separated key=value list, for example: + * "rssi5=-80:-77:-70:-57,rssi2=-83:-80:-73:-60,horizon=15" + * This is intended for experimenting with new parameter values, + * and is normally unset or empty. The example does not include all + * parameters that may be honored. + * Default values are provided by code or device configurations. + * Errors in the parameters will cause the entire setting to be ignored. + * @hide + */ + public static final String WIFI_SCORE_PARAMS = + "wifi_score_params"; + /** * The maximum number of times we will retry a connection to an access * point for which we have failed in acquiring an IP address from DHCP. @@ -11610,8 +11625,8 @@ public final class Settings { */ @SystemApi @TestApi - public static final String AUTOFILL_COMPAT_ALLOWED_PACKAGES = - "autofill_compat_allowed_packages"; + public static final String AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES = + "autofill_compat_mode_allowed_packages"; /** * Exemptions to the hidden API blacklist. diff --git a/core/java/android/security/keystore/recovery/RecoveryController.java b/core/java/android/security/keystore/recovery/RecoveryController.java index 10c1c9ee1b90..503387aa154e 100644 --- a/core/java/android/security/keystore/recovery/RecoveryController.java +++ b/core/java/android/security/keystore/recovery/RecoveryController.java @@ -35,6 +35,7 @@ import java.security.Key; import java.security.UnrecoverableKeyException; import java.security.cert.CertPath; import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -578,7 +579,7 @@ public class RecoveryController { if (grantAlias == null) { throw new InternalRecoveryServiceException("Null grant alias"); } - return getKeyFromGrant(alias); + return getKeyFromGrant(grantAlias); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } catch (UnrecoverableKeyException e) { @@ -654,6 +655,11 @@ public class RecoveryController { return RecoverySession.newInstance(this); } + @RequiresPermission(android.Manifest.permission.RECOVER_KEYSTORE) + public Map<String, X509Certificate> getRootCertificates() { + return TrustedRootCertificates.getRootCertificates(); + } + InternalRecoveryServiceException wrapUnexpectedServiceSpecificException( ServiceSpecificException e) { if (e.errorCode == ERROR_SERVICE_INTERNAL_ERROR) { diff --git a/core/java/android/security/keystore/recovery/RecoverySession.java b/core/java/android/security/keystore/recovery/RecoverySession.java index 744bfa3029be..208b9b2c2dd8 100644 --- a/core/java/android/security/keystore/recovery/RecoverySession.java +++ b/core/java/android/security/keystore/recovery/RecoverySession.java @@ -77,7 +77,7 @@ public class RecoverySession implements AutoCloseable { } /** - * @deprecated Use {@link #start(CertPath, byte[], byte[], List)} instead. + * @deprecated Use {@link #start(String, CertPath, byte[], byte[], List)} instead. */ @Deprecated @RequiresPermission(android.Manifest.permission.RECOVER_KEYSTORE) @@ -108,25 +108,9 @@ public class RecoverySession implements AutoCloseable { } /** - * Starts a recovery session and returns a blob with proof of recovery secret possession. - * The method generates a symmetric key for a session, which trusted remote device can use to - * return recovery key. - * - * @param verifierCertPath The certificate path used to create the recovery blob on the source - * device. Keystore will verify the certificate path by using the root of trust. - * @param vaultParams Must match the parameters in the corresponding field in the recovery blob. - * Used to limit number of guesses. - * @param vaultChallenge Data passed from server for this recovery session and used to prevent - * replay attacks. - * @param secrets Secrets provided by user, the method only uses type and secret fields. - * @return The recovery claim. Claim provides a b binary blob with recovery claim. It is - * encrypted with verifierPublicKey and contains a proof of user secrets, session symmetric - * key and parameters necessary to identify the counter with the number of failed recovery - * attempts. - * @throws CertificateException if the {@code verifierCertPath} is invalid. - * @throws InternalRecoveryServiceException if an unexpected error occurred in the recovery - * service. + * @deprecated Use {@link #start(String, CertPath, byte[], byte[], List)} instead. */ + @Deprecated @RequiresPermission(android.Manifest.permission.RECOVER_KEYSTORE) @NonNull public byte[] start( @NonNull CertPath verifierCertPath, @@ -179,8 +163,6 @@ public class RecoverySession implements AutoCloseable { * @throws CertificateException if the {@code verifierCertPath} is invalid. * @throws InternalRecoveryServiceException if an unexpected error occurred in the recovery * service. - * - * @hide */ @RequiresPermission(android.Manifest.permission.RECOVER_KEYSTORE) @NonNull public byte[] start( @@ -215,17 +197,9 @@ public class RecoverySession implements AutoCloseable { } /** - * Imports keys. - * - * @param recoveryKeyBlob Recovery blob encrypted by symmetric key generated for this session. - * @param applicationKeys Application keys. Key material can be decrypted using recoveryKeyBlob - * and session. KeyStore only uses package names from the application info in {@link - * WrappedApplicationKey}. Caller is responsibility to perform certificates check. - * @return Map from alias to raw key material. - * @throws SessionExpiredException if {@code session} has since been closed. - * @throws DecryptionFailedException if unable to decrypt the snapshot. - * @throws InternalRecoveryServiceException if an error occurs internal to the recovery service. + * @deprecated Use {@link #recoverKeyChainSnapshot(byte[], List)} instead. */ + @Deprecated @RequiresPermission(android.Manifest.permission.RECOVER_KEYSTORE) public Map<String, byte[]> recoverKeys( @NonNull byte[] recoveryKeyBlob, @@ -257,8 +231,6 @@ public class RecoverySession implements AutoCloseable { * @throws SessionExpiredException if {@code session} has since been closed. * @throws DecryptionFailedException if unable to decrypt the snapshot. * @throws InternalRecoveryServiceException if an error occurs internal to the recovery service. - * - * @hide */ @RequiresPermission(Manifest.permission.RECOVER_KEYSTORE) public Map<String, Key> recoverKeyChainSnapshot( diff --git a/core/java/android/security/keystore/recovery/TrustedRootCertificates.java b/core/java/android/security/keystore/recovery/TrustedRootCertificates.java index 4bdde8a2f5b2..a65b40f7b10c 100644 --- a/core/java/android/security/keystore/recovery/TrustedRootCertificates.java +++ b/core/java/android/security/keystore/recovery/TrustedRootCertificates.java @@ -32,7 +32,7 @@ import java.util.Map; * * @hide */ -public class TrustedRootCertificates { +public final class TrustedRootCertificates { public static final String GOOGLE_CLOUD_KEY_VAULT_SERVICE_V1_ALIAS = "GoogleCloudKeyVaultServiceV1"; @@ -83,7 +83,7 @@ public class TrustedRootCertificates { /** * Returns all available root certificates, keyed by alias. */ - public static Map<String, X509Certificate> listRootCertificates() { + public static Map<String, X509Certificate> getRootCertificates() { return new ArrayMap(ALL_ROOT_CERTIFICATES); } @@ -114,4 +114,7 @@ public class TrustedRootCertificates { throw new RuntimeException(e); } } + + // Statics only + private TrustedRootCertificates() {} } diff --git a/core/java/android/service/autofill/AutofillService.java b/core/java/android/service/autofill/AutofillService.java index 41e41819526f..0f7cea21c052 100644 --- a/core/java/android/service/autofill/AutofillService.java +++ b/core/java/android/service/autofill/AutofillService.java @@ -518,7 +518,7 @@ import android.view.autofill.AutofillValue; * <intent-filter> * <action android:name="android.service.autofill.AutofillService" /> * </intent-filter> - * <meta-data android:name="android.autofillservice" android:resource="@xml/autofillservice" /> + * <meta-data android:name="android.autofill" android:resource="@xml/autofillservice" /> * </service></pre> * * <P>In the XML file you can specify one or more packages for which to enable compatibility diff --git a/core/java/android/service/autofill/AutofillServiceHelper.java b/core/java/android/service/autofill/AutofillServiceHelper.java new file mode 100644 index 000000000000..bbaebff439fb --- /dev/null +++ b/core/java/android/service/autofill/AutofillServiceHelper.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.service.autofill; + +import android.annotation.Nullable; +import android.view.autofill.AutofillId; + +import com.android.internal.util.Preconditions; + +/** @hide */ +final class AutofillServiceHelper { + + static AutofillId[] assertValid(@Nullable AutofillId[] ids) { + Preconditions.checkArgument(ids != null && ids.length > 0, "must have at least one id"); + return Preconditions.checkArrayElementsNotNull(ids, "ids"); + } + + private AutofillServiceHelper() { + throw new UnsupportedOperationException("contains static members only"); + } +} diff --git a/core/java/android/service/autofill/FillResponse.java b/core/java/android/service/autofill/FillResponse.java index 3a4b6bb8037e..be84ba9d837d 100644 --- a/core/java/android/service/autofill/FillResponse.java +++ b/core/java/android/service/autofill/FillResponse.java @@ -16,6 +16,7 @@ package android.service.autofill; +import static android.service.autofill.AutofillServiceHelper.assertValid; import static android.service.autofill.FillRequest.INVALID_REQUEST_ID; import static android.view.autofill.Helper.sDebug; @@ -245,10 +246,15 @@ public final class FillResponse implements Parcelable { * @param ids id of Views that when focused will display the authentication UI. * * @return This builder. - - * @throws IllegalArgumentException if {@code ids} is {@code null} or empty, or if - * both {@code authentication} and {@code presentation} are {@code null}, or if - * both {@code authentication} and {@code presentation} are non-{@code null} + * + * @throws IllegalArgumentException if any of the following occurs: + * <ul> + * <li>{@code ids} is {@code null}</li> + * <li>{@code ids} is empty</li> + * <li>{@code ids} contains a {@code null} element</li> + * <li>both {@code authentication} and {@code presentation} are {@code null}</li> + * <li>both {@code authentication} and {@code presentation} are non-{@code null}</li> + * </ul> * * @throws IllegalStateException if a {@link #setHeader(RemoteViews) header} or a * {@link #setFooter(RemoteViews) footer} are already set for this builder. @@ -263,16 +269,13 @@ public final class FillResponse implements Parcelable { throw new IllegalStateException("Already called #setHeader() or #setFooter()"); } - if (ids == null || ids.length == 0) { - throw new IllegalArgumentException("ids cannot be null or empry"); - } if (authentication == null ^ presentation == null) { throw new IllegalArgumentException("authentication and presentation" + " must be both non-null or null"); } mAuthentication = authentication; mPresentation = presentation; - mAuthenticationIds = ids; + mAuthenticationIds = assertValid(ids); return this; } diff --git a/core/java/android/service/autofill/SaveInfo.java b/core/java/android/service/autofill/SaveInfo.java index a5a6177dedc3..1be1be64548a 100644 --- a/core/java/android/service/autofill/SaveInfo.java +++ b/core/java/android/service/autofill/SaveInfo.java @@ -16,6 +16,7 @@ package android.service.autofill; +import static android.service.autofill.AutofillServiceHelper.assertValid; import static android.view.autofill.Helper.sDebug; import android.annotation.IntDef; @@ -405,17 +406,6 @@ public final class SaveInfo implements Parcelable { mRequiredIds = null; } - private AutofillId[] assertValid(AutofillId[] ids) { - Preconditions.checkArgument(ids != null && ids.length > 0, - "must have at least one id: " + Arrays.toString(ids)); - for (int i = 0; i < ids.length; i++) { - final AutofillId id = ids[i]; - Preconditions.checkArgument(id != null, - "cannot have null id: " + Arrays.toString(ids)); - } - return ids; - } - /** * Sets flags changing the save behavior. * diff --git a/core/java/android/util/FeatureFlagUtils.java b/core/java/android/util/FeatureFlagUtils.java index 38ab6f24f41d..9687009dc64e 100644 --- a/core/java/android/util/FeatureFlagUtils.java +++ b/core/java/android/util/FeatureFlagUtils.java @@ -42,7 +42,7 @@ public class FeatureFlagUtils { DEFAULT_FLAGS.put("settings_zone_picker_v2", "true"); DEFAULT_FLAGS.put("settings_about_phone_v2", "true"); DEFAULT_FLAGS.put("settings_bluetooth_while_driving", "false"); - DEFAULT_FLAGS.put("settings_data_usage_v2", "false"); + DEFAULT_FLAGS.put("settings_data_usage_v2", "true"); DEFAULT_FLAGS.put("settings_audio_switcher", "false"); } diff --git a/core/java/android/view/textclassifier/TextClassifierImpl.java b/core/java/android/view/textclassifier/TextClassifierImpl.java index a09982053091..89e6262257c5 100644 --- a/core/java/android/view/textclassifier/TextClassifierImpl.java +++ b/core/java/android/view/textclassifier/TextClassifierImpl.java @@ -355,12 +355,10 @@ public final class TextClassifierImpl implements TextClassifier { final List<Locale.LanguageRange> languageRangeList = Locale.LanguageRange.parse(languages); ModelFile bestModel = null; - int bestModelVersion = -1; for (ModelFile model : listAllModelsLocked()) { if (model.isAnyLanguageSupported(languageRangeList)) { - if (model.getVersion() >= bestModelVersion) { + if (model.isPreferredTo(bestModel)) { bestModel = model; - bestModelVersion = model.getVersion(); } } } @@ -482,6 +480,7 @@ public final class TextClassifierImpl implements TextClassifier { private final String mName; private final int mVersion; private final List<Locale> mSupportedLocales; + private final boolean mLanguageIndependent; /** Returns null if the path did not point to a compatible model. */ static @Nullable ModelFile fromPath(String path) { @@ -496,12 +495,14 @@ public final class TextClassifierImpl implements TextClassifier { Log.d(DEFAULT_LOG_TAG, "Ignoring " + file.getAbsolutePath()); return null; } + final boolean languageIndependent = supportedLocalesStr.equals("*"); final List<Locale> supportedLocales = new ArrayList<>(); for (String langTag : supportedLocalesStr.split(",")) { supportedLocales.add(Locale.forLanguageTag(langTag)); } closeAndLogError(modelFd); - return new ModelFile(path, file.getName(), version, supportedLocales); + return new ModelFile(path, file.getName(), version, supportedLocales, + languageIndependent); } catch (FileNotFoundException e) { Log.e(DEFAULT_LOG_TAG, "Failed to peek " + file.getAbsolutePath(), e); return null; @@ -525,7 +526,7 @@ public final class TextClassifierImpl implements TextClassifier { /** Returns whether the language supports any language in the given ranges. */ boolean isAnyLanguageSupported(List<Locale.LanguageRange> languageRanges) { - return Locale.lookup(languageRanges, mSupportedLocales) != null; + return mLanguageIndependent || Locale.lookup(languageRanges, mSupportedLocales) != null; } /** All locales supported by the model. */ @@ -533,6 +534,25 @@ public final class TextClassifierImpl implements TextClassifier { return Collections.unmodifiableList(mSupportedLocales); } + public boolean isPreferredTo(ModelFile model) { + // A model is preferred to no model. + if (model == null) { + return true; + } + + // A language-specific model is preferred to a language independent + // model. + if (!mLanguageIndependent && model.mLanguageIndependent) { + return true; + } + + // A higher-version model is preferred. + if (getVersion() > model.getVersion()) { + return true; + } + return false; + } + @Override public boolean equals(Object other) { if (this == other) { @@ -555,11 +575,13 @@ public final class TextClassifierImpl implements TextClassifier { mPath, mName, mVersion, localesJoiner.toString()); } - private ModelFile(String path, String name, int version, List<Locale> supportedLocales) { + private ModelFile(String path, String name, int version, List<Locale> supportedLocales, + boolean languageIndependent) { mPath = path; mName = name; mVersion = version; mSupportedLocales = supportedLocales; + mLanguageIndependent = languageIndependent; } } diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 9a99963e9374..298c61e403ab 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -89,7 +89,7 @@ import java.util.List; /** * Base class that can be used to implement virtualized lists of items. A list does - * not have a spatial definition here. For instance, subclases of this class can + * not have a spatial definition here. For instance, subclasses of this class can * display the content of the list in a grid, in a carousel, as stack, etc. * * @attr ref android.R.styleable#AbsListView_listSelector diff --git a/core/java/android/widget/MediaControlView2.java b/core/java/android/widget/MediaControlView2.java index 3ec8ab9240bd..dab0f7357e4b 100644 --- a/core/java/android/widget/MediaControlView2.java +++ b/core/java/android/widget/MediaControlView2.java @@ -150,7 +150,7 @@ public class MediaControlView2 extends ViewGroupHelper<MediaControlView2Provider public MediaControlView2(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super((instance, superProvider, privateProvider) -> - ApiLoader.getProvider(context).createMediaControlView2( + ApiLoader.getProvider().createMediaControlView2( (MediaControlView2) instance, superProvider, privateProvider, attrs, defStyleAttr, defStyleRes), context, attrs, defStyleAttr, defStyleRes); diff --git a/core/java/android/widget/VideoView2.java b/core/java/android/widget/VideoView2.java index 6f08dc22aff1..214ff3a93538 100644 --- a/core/java/android/widget/VideoView2.java +++ b/core/java/android/widget/VideoView2.java @@ -143,7 +143,7 @@ public class VideoView2 extends ViewGroupHelper<VideoView2Provider> { @NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super((instance, superProvider, privateProvider) -> - ApiLoader.getProvider(context).createVideoView2( + ApiLoader.getProvider().createVideoView2( (VideoView2) instance, superProvider, privateProvider, attrs, defStyleAttr, defStyleRes), context, attrs, defStyleAttr, defStyleRes); diff --git a/core/java/com/android/internal/inputmethod/InputMethodUtils.java b/core/java/com/android/internal/inputmethod/InputMethodUtils.java index d3b4dbf1bd82..9a082ec21b3d 100644 --- a/core/java/com/android/internal/inputmethod/InputMethodUtils.java +++ b/core/java/com/android/internal/inputmethod/InputMethodUtils.java @@ -320,8 +320,8 @@ public class InputMethodUtils { return builder; } - public static ArrayList<InputMethodInfo> getDefaultEnabledImes(final Context context, - final ArrayList<InputMethodInfo> imis) { + public static ArrayList<InputMethodInfo> getDefaultEnabledImes( + Context context, ArrayList<InputMethodInfo> imis, boolean onlyMinimum) { final Locale fallbackLocale = getFallbackLocaleForDefaultIme(imis, context); // We will primarily rely on the system locale, but also keep relying on the fallback locale // as a last resort. @@ -329,11 +329,19 @@ public class InputMethodUtils { // then pick up suitable auxiliary IMEs when necessary (e.g. Voice IMEs with "automatic" // subtype) final Locale systemLocale = getSystemLocaleFromContext(context); - return getMinimumKeyboardSetWithSystemLocale(imis, context, systemLocale, fallbackLocale) - .fillImes(imis, context, true /* checkDefaultAttribute */, systemLocale, - true /* checkCountry */, SUBTYPE_MODE_ANY) - .fillAuxiliaryImes(imis, context) - .build(); + final InputMethodListBuilder builder = + getMinimumKeyboardSetWithSystemLocale(imis, context, systemLocale, fallbackLocale); + if (!onlyMinimum) { + builder.fillImes(imis, context, true /* checkDefaultAttribute */, systemLocale, + true /* checkCountry */, SUBTYPE_MODE_ANY) + .fillAuxiliaryImes(imis, context); + } + return builder.build(); + } + + public static ArrayList<InputMethodInfo> getDefaultEnabledImes( + Context context, ArrayList<InputMethodInfo> imis) { + return getDefaultEnabledImes(context, imis, false /* onlyMinimum */); } public static Locale constructLocaleFromString(String localeStr) { diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 06230c1f8145..bbff515646bb 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -19,6 +19,7 @@ package com.android.internal.os; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityManager; +import android.app.job.JobProtoEnums; import android.bluetooth.BluetoothActivityEnergyInfo; import android.bluetooth.UidTraffic; import android.content.ContentResolver; @@ -10045,7 +10046,8 @@ public class BatteryStatsImpl extends BatteryStats { if (t != null) { t.startRunningLocked(elapsedRealtimeMs); StatsLog.write_non_chained(StatsLog.SCHEDULED_JOB_STATE_CHANGED, getUid(), null, - name, StatsLog.SCHEDULED_JOB_STATE_CHANGED__STATE__STARTED); + name, StatsLog.SCHEDULED_JOB_STATE_CHANGED__STATE__STARTED, + JobProtoEnums.STOP_REASON_CANCELLED); } } @@ -10055,7 +10057,8 @@ public class BatteryStatsImpl extends BatteryStats { t.stopRunningLocked(elapsedRealtimeMs); if (!t.isRunningLocked()) { // only tell statsd if truly stopped StatsLog.write_non_chained(StatsLog.SCHEDULED_JOB_STATE_CHANGED, getUid(), null, - name, StatsLog.SCHEDULED_JOB_STATE_CHANGED__STATE__FINISHED); + name, StatsLog.SCHEDULED_JOB_STATE_CHANGED__STATE__FINISHED, + stopReason); } } if (mBsi.mOnBatteryTimeBase.isRunning()) { diff --git a/core/java/com/android/internal/os/BinderCallsStats.java b/core/java/com/android/internal/os/BinderCallsStats.java new file mode 100644 index 000000000000..2c48506494bc --- /dev/null +++ b/core/java/com/android/internal/os/BinderCallsStats.java @@ -0,0 +1,272 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.internal.os; + +import android.os.Binder; +import android.os.SystemClock; +import android.util.ArrayMap; +import android.util.SparseArray; + +import com.android.internal.annotations.VisibleForTesting; +import com.android.internal.util.Preconditions; + +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; + +/** + * Collects statistics about CPU time spent per binder call across multiple dimensions, e.g. + * per thread, uid or call description. + */ +public class BinderCallsStats { + private static final int CALL_SESSIONS_POOL_SIZE = 100; + private static final BinderCallsStats sInstance = new BinderCallsStats(); + + private volatile boolean mTrackingEnabled = false; + private final SparseArray<UidEntry> mUidEntries = new SparseArray<>(); + private final Queue<CallSession> mCallSessionsPool = new ConcurrentLinkedQueue<>(); + + private BinderCallsStats() { + } + + @VisibleForTesting + public BinderCallsStats(boolean trackingEnabled) { + mTrackingEnabled = trackingEnabled; + } + + public CallSession callStarted(Binder binder, int code) { + if (!mTrackingEnabled) { + return null; + } + + return callStarted(binder.getClass().getName(), code); + } + + private CallSession callStarted(String className, int code) { + CallSession s = mCallSessionsPool.poll(); + if (s == null) { + s = new CallSession(); + } + s.mCallStat.className = className; + s.mCallStat.msg = code; + + s.mStarted = getThreadTimeMicro(); + return s; + } + + public void callEnded(CallSession s) { + if (!mTrackingEnabled) { + return; + } + Preconditions.checkNotNull(s); + final long cpuTimeNow = getThreadTimeMicro(); + final long duration = cpuTimeNow - s.mStarted; + s.mCallingUId = Binder.getCallingUid(); + + synchronized (mUidEntries) { + UidEntry uidEntry = mUidEntries.get(s.mCallingUId); + if (uidEntry == null) { + uidEntry = new UidEntry(s.mCallingUId); + mUidEntries.put(s.mCallingUId, uidEntry); + } + + // Find CallDesc entry and update its total time + CallStat callStat = uidEntry.mCallStats.get(s.mCallStat); + // Only create CallStat if it's a new entry, otherwise update existing instance + if (callStat == null) { + callStat = new CallStat(s.mCallStat.className, s.mCallStat.msg); + uidEntry.mCallStats.put(callStat, callStat); + } + uidEntry.time += duration; + uidEntry.callCount++; + callStat.callCount++; + callStat.time += duration; + } + if (mCallSessionsPool.size() < CALL_SESSIONS_POOL_SIZE) { + mCallSessionsPool.add(s); + } + } + + public void dump(PrintWriter pw) { + Map<Integer, Long> uidTimeMap = new HashMap<>(); + Map<Integer, Long> uidCallCountMap = new HashMap<>(); + long totalCallsCount = 0; + long totalCallsTime = 0; + int uidEntriesSize = mUidEntries.size(); + List<UidEntry> entries = new ArrayList<>(); + synchronized (mUidEntries) { + for (int i = 0; i < uidEntriesSize; i++) { + UidEntry e = mUidEntries.valueAt(i); + entries.add(e); + totalCallsTime += e.time; + // Update per-uid totals + Long totalTimePerUid = uidTimeMap.get(e.uid); + uidTimeMap.put(e.uid, + totalTimePerUid == null ? e.time : totalTimePerUid + e.time); + Long totalCallsPerUid = uidCallCountMap.get(e.uid); + uidCallCountMap.put(e.uid, totalCallsPerUid == null ? e.callCount + : totalCallsPerUid + e.callCount); + totalCallsCount += e.callCount; + } + } + pw.println("Binder call stats:"); + pw.println(" Raw data (uid,call_desc,time):"); + entries.sort((o1, o2) -> { + if (o1.time < o2.time) { + return 1; + } else if (o1.time > o2.time) { + return -1; + } + return 0; + }); + StringBuilder sb = new StringBuilder(); + for (UidEntry uidEntry : entries) { + List<CallStat> callStats = new ArrayList<>(uidEntry.mCallStats.keySet()); + callStats.sort((o1, o2) -> { + if (o1.time < o2.time) { + return 1; + } else if (o1.time > o2.time) { + return -1; + } + return 0; + }); + for (CallStat e : callStats) { + sb.setLength(0); + sb.append(" ") + .append(uidEntry.uid).append(",").append(e).append(',').append(e.time); + pw.println(sb); + } + } + pw.println(); + pw.println(" Per UID Summary(UID: time, total_time_percentage, calls_count):"); + List<Map.Entry<Integer, Long>> uidTotals = new ArrayList<>(uidTimeMap.entrySet()); + uidTotals.sort((o1, o2) -> o2.getValue().compareTo(o1.getValue())); + for (Map.Entry<Integer, Long> uidTotal : uidTotals) { + Long callCount = uidCallCountMap.get(uidTotal.getKey()); + pw.println(String.format(" %5d: %11d %3.0f%% %8d", + uidTotal.getKey(), uidTotal.getValue(), + 100d * uidTotal.getValue() / totalCallsTime, callCount)); + } + pw.println(); + pw.println(String.format(" Summary: total_time=%d, " + + "calls_count=%d, avg_call_time=%.0f", + totalCallsTime, totalCallsCount, + (double)totalCallsTime / totalCallsCount)); + } + + private static long getThreadTimeMicro() { + return SystemClock.currentThreadTimeMicro(); + } + + public static BinderCallsStats getInstance() { + return sInstance; + } + + public void setTrackingEnabled(boolean enabled) { + mTrackingEnabled = enabled; + } + + public boolean isTrackingEnabled() { + return mTrackingEnabled; + } + + private static class CallStat { + String className; + int msg; + long time; + long callCount; + + CallStat() { + } + + CallStat(String className, int msg) { + this.className = className; + this.msg = msg; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + + CallStat callStat = (CallStat) o; + + return msg == callStat.msg && (className == callStat.className); + } + + @Override + public int hashCode() { + int result = className.hashCode(); + result = 31 * result + msg; + return result; + } + + @Override + public String toString() { + return className + "/" + msg; + } + } + + public static class CallSession { + int mCallingUId; + long mStarted; + CallStat mCallStat = new CallStat(); + } + + private static class UidEntry { + int uid; + long time; + long callCount; + + UidEntry(int uid) { + this.uid = uid; + } + + // Aggregate time spent per each call name: call_desc -> cpu_time_micros + Map<CallStat, CallStat> mCallStats = new ArrayMap<>(); + + @Override + public String toString() { + return "UidEntry{" + + "time=" + time + + ", callCount=" + callCount + + ", mCallStats=" + mCallStats + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + + UidEntry uidEntry = (UidEntry) o; + return uid == uidEntry.uid; + } + + @Override + public int hashCode() { + return uid; + } + } + +} diff --git a/core/proto/android/app/jobparameters.proto b/core/proto/android/app/job/enums.proto index 4f6a2a247e72..0f14f20e586a 100644 --- a/core/proto/android/app/jobparameters.proto +++ b/core/proto/android/app/job/enums.proto @@ -15,19 +15,18 @@ */ syntax = "proto2"; -option java_multiple_files = true; -package android.app; +package android.app.job; -/** - * An android.app.JobParameters object. - */ -message JobParametersProto { - enum CancelReason { - REASON_CANCELLED = 0; - REASON_CONSTRAINTS_NOT_SATISFIED = 1; - REASON_PREEMPT = 2; - REASON_TIMEOUT = 3; - REASON_DEVICE_IDLE = 4; - } +option java_outer_classname = "JobProtoEnums"; +option java_multiple_files = true; + +// Reasons a job is stopped. +// Primarily used in android.app.job.JobParameters.java. +enum StopReasonEnum { + STOP_REASON_CANCELLED = 0; + STOP_REASON_CONSTRAINTS_NOT_SATISFIED = 1; + STOP_REASON_PREEMPT = 2; + STOP_REASON_TIMEOUT = 3; + STOP_REASON_DEVICE_IDLE = 4; } diff --git a/core/proto/android/os/batterystats.proto b/core/proto/android/os/batterystats.proto index 345c8ef18603..8e98ac9e0e40 100644 --- a/core/proto/android/os/batterystats.proto +++ b/core/proto/android/os/batterystats.proto @@ -19,7 +19,7 @@ option java_multiple_files = true; package android.os; -import "frameworks/base/core/proto/android/app/jobparameters.proto"; +import "frameworks/base/core/proto/android/app/job/enums.proto"; import "frameworks/base/core/proto/android/os/powermanager.proto"; import "frameworks/base/core/proto/android/telephony/enums.proto"; import "frameworks/base/libs/incident/proto/android/privacy.proto"; @@ -637,7 +637,7 @@ message UidProto { message ReasonCount { option (android.msg_privacy).dest = DEST_AUTOMATIC; - optional android.app.JobParametersProto.CancelReason name = 1; + optional android.app.job.StopReasonEnum name = 1; optional int32 count = 2; } repeated ReasonCount reason_count = 2; diff --git a/core/proto/android/providers/settings.proto b/core/proto/android/providers/settings.proto index 4e781d67d693..4bb970799b18 100644 --- a/core/proto/android/providers/settings.proto +++ b/core/proto/android/providers/settings.proto @@ -466,7 +466,7 @@ message GlobalSettingsProto { // skipped. optional SettingProto override_settings_provider_restore_any_version = 355 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto chained_battery_attribution_enabled = 356 [ (android.privacy).dest = DEST_AUTOMATIC ]; - optional SettingProto autofill_compat_allowed_packages = 357 [ (android.privacy).dest = DEST_AUTOMATIC ]; + optional SettingProto autofill_compat_mode_allowed_packages = 357 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto hidden_api_blacklist_exemptions = 358 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto sound_trigger_detection_service_op_timeout = 387 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto max_sound_trigger_detection_service_ops_per_day = 388 [ (android.privacy).dest = DEST_AUTOMATIC ]; diff --git a/core/proto/android/server/jobscheduler.proto b/core/proto/android/server/jobscheduler.proto index 9193129def11..122e5c48214d 100644 --- a/core/proto/android/server/jobscheduler.proto +++ b/core/proto/android/server/jobscheduler.proto @@ -20,7 +20,7 @@ package com.android.server.job; option java_multiple_files = true; -import "frameworks/base/core/proto/android/app/jobparameters.proto"; +import "frameworks/base/core/proto/android/app/job/enums.proto"; import "frameworks/base/core/proto/android/content/clipdata.proto"; import "frameworks/base/core/proto/android/content/component_name.proto"; import "frameworks/base/core/proto/android/content/intent.proto"; @@ -465,7 +465,7 @@ message DataSetProto { message StopReasonCount { option (.android.msg_privacy).dest = DEST_AUTOMATIC; - optional .android.app.JobParametersProto.CancelReason reason = 1; + optional .android.app.job.StopReasonEnum reason = 1; optional int32 count = 2; } repeated StopReasonCount stop_reasons = 9; @@ -516,7 +516,7 @@ message JobPackageHistoryProto { optional int32 job_id = 4; optional string tag = 5 [ (.android.privacy).dest = DEST_EXPLICIT ]; // Only valid for STOP_JOB or STOP_PERIODIC_JOB Events. - optional .android.app.JobParametersProto.CancelReason stop_reason = 6; + optional .android.app.job.StopReasonEnum stop_reason = 6; } repeated HistoryEvent history_event = 1; } diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 6ae368394b56..bbb0b0a778b7 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -3364,8 +3364,4 @@ <!-- Package name for ManagedProvisioning which is responsible for provisioning work profiles. --> <string name="config_managed_provisioning_package" translatable="false">com.android.managedprovisioning</string> - - <!-- When device is in power save mode, whether we should disable signal strength update from - modem.--> - <bool name="config_disable_signal_strength_update_in_powersave_mode">false</bool> </resources> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 1b110701cce0..f0f7270253fd 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -4578,14 +4578,14 @@ <!-- Displayed when the USSD/SS request is modified by STK CC to a different request. This will be displayed in a toast. --> - <string name="stk_cc_ussd_to_dial">USSD request is modified to DIAL request.</string> - <string name="stk_cc_ussd_to_ss">USSD request is modified to SS request.</string> - <string name="stk_cc_ussd_to_ussd">USSD request is modified to new USSD request.</string> - <string name="stk_cc_ussd_to_dial_video">USSD request is modified to Video DIAL request.</string> - <string name="stk_cc_ss_to_dial">SS request is modified to DIAL request.</string> - <string name="stk_cc_ss_to_dial_video">SS request is modified to Video DIAL request.</string> - <string name="stk_cc_ss_to_ussd">SS request is modified to USSD request.</string> - <string name="stk_cc_ss_to_ss">SS request is modified to new SS request.</string> + <string name="stk_cc_ussd_to_dial">USSD request changed to regular call</string> + <string name="stk_cc_ussd_to_ss">USSD request changed to SS request</string> + <string name="stk_cc_ussd_to_ussd">Changed to new USSD request</string> + <string name="stk_cc_ussd_to_dial_video">USSD request changed to video call</string> + <string name="stk_cc_ss_to_dial">SS request changed to regular call</string> + <string name="stk_cc_ss_to_dial_video">SS request changed to video call</string> + <string name="stk_cc_ss_to_ussd">SS request changed to USSD request</string> + <string name="stk_cc_ss_to_ss">Changed to new SS request</string> <!-- Content description of the work profile icon in the notification. --> <string name="notification_work_profile_content_description">Work profile</string> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 05e53b19cbc0..4cf50f5f4f80 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2779,7 +2779,6 @@ <java-symbol type="drawable" name="ic_user_secure" /> <java-symbol type="string" name="android_upgrading_notification_title" /> - <java-symbol type="string" name="android_upgrading_notification_body" /> <java-symbol type="string" name="usb_mtp_launch_notification_title" /> <java-symbol type="string" name="usb_mtp_launch_notification_description" /> @@ -3305,5 +3304,4 @@ <java-symbol type="string" name="notification_app_name_system" /> <java-symbol type="string" name="notification_app_name_settings" /> - <java-symbol type="bool" name="config_disable_signal_strength_update_in_powersave_mode" /> </resources> diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java index deafbd3271ef..87a9bd0e5e5f 100644 --- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java +++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java @@ -117,7 +117,7 @@ public class SettingsBackupTest { Settings.Global.APP_STANDBY_ENABLED, Settings.Global.ASSISTED_GPS_ENABLED, Settings.Global.AUDIO_SAFE_VOLUME_STATE, - Settings.Global.AUTOFILL_COMPAT_ALLOWED_PACKAGES, + Settings.Global.AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES, Settings.Global.BATTERY_DISCHARGE_DURATION_THRESHOLD, Settings.Global.BATTERY_DISCHARGE_THRESHOLD, Settings.Global.BATTERY_SAVER_DEVICE_SPECIFIC_CONSTANTS, @@ -450,6 +450,7 @@ public class SettingsBackupTest { Settings.Global.WIFI_SAVED_STATE, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, Settings.Global.WIFI_SCAN_INTERVAL_WHEN_P2P_CONNECTED_MS, + Settings.Global.WIFI_SCORE_PARAMS, Settings.Global.WIFI_SLEEP_POLICY, Settings.Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS, Settings.Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED, diff --git a/core/tests/coretests/src/android/security/keystore/recovery/TrustedRootCertificatesTest.java b/core/tests/coretests/src/android/security/keystore/recovery/TrustedRootCertificatesTest.java index 3b4ad3801135..a5a3ca90d9ac 100644 --- a/core/tests/coretests/src/android/security/keystore/recovery/TrustedRootCertificatesTest.java +++ b/core/tests/coretests/src/android/security/keystore/recovery/TrustedRootCertificatesTest.java @@ -16,7 +16,7 @@ package android.security.keystore.recovery; -import static android.security.keystore.recovery.TrustedRootCertificates.listRootCertificates; +import static android.security.keystore.recovery.TrustedRootCertificates.getRootCertificates; import static org.junit.Assert.assertTrue; @@ -36,8 +36,8 @@ public class TrustedRootCertificatesTest { "GoogleCloudKeyVaultServiceV1"; @Test - public void listRootCertificates_listsGoogleCloudVaultV1Certificate() { - Map<String, X509Certificate> certificates = listRootCertificates(); + public void getRootCertificates_listsGoogleCloudVaultV1Certificate() { + Map<String, X509Certificate> certificates = getRootCertificates(); assertTrue(certificates.containsKey(GOOGLE_CLOUD_KEY_VAULT_SERVICE_V1_ALIAS)); } diff --git a/core/tests/coretests/src/com/android/internal/inputmethod/InputMethodUtilsTest.java b/core/tests/coretests/src/com/android/internal/inputmethod/InputMethodUtilsTest.java index e6ac68294564..1fd24e3f237e 100644 --- a/core/tests/coretests/src/com/android/internal/inputmethod/InputMethodUtilsTest.java +++ b/core/tests/coretests/src/com/android/internal/inputmethod/InputMethodUtilsTest.java @@ -99,6 +99,10 @@ public class InputMethodUtilsTest { assertDefaultEnabledImes(getImesWithoutDefaultVoiceIme(), LOCALE_EN_US, "DummyDefaultEnKeyboardIme", "DummyNonDefaultAutoVoiceIme0", "DummyNonDefaultAutoVoiceIme1"); + assertDefaultEnabledMinimumImes(getImesWithDefaultVoiceIme(), LOCALE_EN_US, + "DummyDefaultEnKeyboardIme"); + assertDefaultEnabledMinimumImes(getImesWithoutDefaultVoiceIme(), LOCALE_EN_US, + "DummyDefaultEnKeyboardIme"); // locale: en_GB assertDefaultEnabledImes(getImesWithDefaultVoiceIme(), LOCALE_EN_GB, @@ -106,6 +110,10 @@ public class InputMethodUtilsTest { assertDefaultEnabledImes(getImesWithoutDefaultVoiceIme(), LOCALE_EN_GB, "DummyDefaultEnKeyboardIme", "DummyNonDefaultAutoVoiceIme0", "DummyNonDefaultAutoVoiceIme1"); + assertDefaultEnabledMinimumImes(getImesWithDefaultVoiceIme(), LOCALE_EN_GB, + "DummyDefaultEnKeyboardIme"); + assertDefaultEnabledMinimumImes(getImesWithoutDefaultVoiceIme(), LOCALE_EN_GB, + "DummyDefaultEnKeyboardIme"); // locale: ja_JP assertDefaultEnabledImes(getImesWithDefaultVoiceIme(), LOCALE_JA_JP, @@ -113,6 +121,10 @@ public class InputMethodUtilsTest { assertDefaultEnabledImes(getImesWithoutDefaultVoiceIme(), LOCALE_JA_JP, "DummyDefaultEnKeyboardIme", "DummyNonDefaultAutoVoiceIme0", "DummyNonDefaultAutoVoiceIme1"); + assertDefaultEnabledMinimumImes(getImesWithDefaultVoiceIme(), LOCALE_JA_JP, + "DummyDefaultEnKeyboardIme"); + assertDefaultEnabledMinimumImes(getImesWithoutDefaultVoiceIme(), LOCALE_JA_JP, + "DummyDefaultEnKeyboardIme"); } @Test @@ -120,34 +132,49 @@ public class InputMethodUtilsTest { // locale: en_US assertDefaultEnabledImes(getSamplePreinstalledImes("en-rUS"), LOCALE_EN_US, "com.android.apps.inputmethod.latin", "com.android.apps.inputmethod.voice"); + assertDefaultEnabledMinimumImes(getSamplePreinstalledImes("en-rUS"), LOCALE_EN_US, + "com.android.apps.inputmethod.latin"); // locale: en_GB assertDefaultEnabledImes(getSamplePreinstalledImes("en-rGB"), LOCALE_EN_GB, "com.android.apps.inputmethod.latin", "com.android.apps.inputmethod.voice"); + assertDefaultEnabledMinimumImes(getSamplePreinstalledImes("en-rGB"), LOCALE_EN_GB, + "com.android.apps.inputmethod.latin"); // locale: en_IN assertDefaultEnabledImes(getSamplePreinstalledImes("en-rIN"), LOCALE_EN_IN, "com.android.apps.inputmethod.hindi", "com.android.apps.inputmethod.latin", "com.android.apps.inputmethod.voice"); + assertDefaultEnabledMinimumImes(getSamplePreinstalledImes("en-rIN"), LOCALE_EN_IN, + "com.android.apps.inputmethod.hindi", + "com.android.apps.inputmethod.latin"); // locale: hi assertDefaultEnabledImes(getSamplePreinstalledImes("hi"), LOCALE_HI, "com.android.apps.inputmethod.hindi", "com.android.apps.inputmethod.latin", "com.android.apps.inputmethod.voice"); + assertDefaultEnabledMinimumImes(getSamplePreinstalledImes("hi"), LOCALE_HI, + "com.android.apps.inputmethod.hindi", "com.android.apps.inputmethod.latin"); // locale: ja_JP assertDefaultEnabledImes(getSamplePreinstalledImes("ja-rJP"), LOCALE_JA_JP, "com.android.apps.inputmethod.japanese", "com.android.apps.inputmethod.voice"); + assertDefaultEnabledMinimumImes(getSamplePreinstalledImes("ja-rJP"), LOCALE_JA_JP, + "com.android.apps.inputmethod.japanese"); // locale: zh_CN assertDefaultEnabledImes(getSamplePreinstalledImes("zh-rCN"), LOCALE_ZH_CN, "com.android.apps.inputmethod.pinyin", "com.android.apps.inputmethod.voice"); + assertDefaultEnabledMinimumImes(getSamplePreinstalledImes("zh-rCN"), LOCALE_ZH_CN, + "com.android.apps.inputmethod.pinyin"); // locale: zh_TW // Note: In this case, no IME is suitable for the system locale. Hence we will pick up a // fallback IME regardless of the "default" attribute. assertDefaultEnabledImes(getSamplePreinstalledImes("zh-rTW"), LOCALE_ZH_TW, "com.android.apps.inputmethod.latin", "com.android.apps.inputmethod.voice"); + assertDefaultEnabledMinimumImes(getSamplePreinstalledImes("zh-rTW"), LOCALE_ZH_TW, + "com.android.apps.inputmethod.latin"); } @Test @@ -785,6 +812,18 @@ public class InputMethodUtilsTest { } } + private void assertDefaultEnabledMinimumImes(final ArrayList<InputMethodInfo> preinstalledImes, + final Locale systemLocale, String... expectedImeNames) { + final Context context = createTargetContextWithLocales(new LocaleList(systemLocale)); + final String[] actualImeNames = getPackageNames( + InputMethodUtils.getDefaultEnabledImes(context, preinstalledImes, + true /* onlyMinimum */)); + assertEquals(expectedImeNames.length, actualImeNames.length); + for (int i = 0; i < expectedImeNames.length; ++i) { + assertEquals(expectedImeNames[i], actualImeNames[i]); + } + } + private static List<InputMethodInfo> cloneViaParcel(final List<InputMethodInfo> list) { Parcel p = null; try { diff --git a/location/java/android/location/IFusedProvider.aidl b/location/java/android/location/IFusedProvider.aidl deleted file mode 100644 index e86ad1ac5147..000000000000 --- a/location/java/android/location/IFusedProvider.aidl +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.location; - -import android.hardware.location.IFusedLocationHardware; - -/** - * Interface definition for Location providers that require FLP services. - * @hide - */ -oneway interface IFusedProvider { - /** - * Provides access to a FusedLocationHardware instance needed for the provider to work. - * - * @param instance The FusedLocationHardware available for the provider to use. - */ - void onFusedLocationHardwareChange(in IFusedLocationHardware instance); -} diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index c16876b966bc..a523958080d3 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -23,6 +23,7 @@ import static android.Manifest.permission.WRITE_SECURE_SETTINGS; import android.Manifest; import android.annotation.NonNull; +import android.annotation.Nullable; import android.annotation.RequiresFeature; import android.annotation.RequiresPermission; import android.annotation.SuppressLint; @@ -236,12 +237,6 @@ public class LocationManager { "android.location.HIGH_POWER_REQUEST_CHANGE"; /** - * The value returned by {@link LocationManager#getGnssHardwareModelName()} when the hardware - * does not support providing the actual value. - */ - public static final String GNSS_HARDWARE_MODEL_NAME_UNKNOWN = "Model Name Unknown"; - - /** * Broadcast intent action for Settings app to inject a footer at the bottom of location * settings. * @@ -2206,7 +2201,9 @@ public class LocationManager { /** * Returns the model year of the GNSS hardware and software build. * - * May return 0 if the model year is less than 2016. + * <p> More details, such as build date, may be available in {@link #getGnssHardwareModelName()}. + * + * <p> May return 0 if the model year is less than 2016. */ public int getGnssYearOfHardware() { try { @@ -2220,10 +2217,12 @@ public class LocationManager { * Returns the Model Name (including Vendor and Hardware/Software Version) of the GNSS hardware * driver. * - * Will return {@link LocationManager#GNSS_HARDWARE_MODEL_NAME_UNKNOWN} when the GNSS hardware - * abstraction layer does not support providing this value. + * <p> No device-specific serial number or ID is returned from this API. + * + * <p> Will return null when the GNSS hardware abstraction layer does not support providing + * this value. */ - @NonNull + @Nullable public String getGnssHardwareModelName() { try { return mService.getGnssHardwareModelName(); diff --git a/location/lib/Android.mk b/location/lib/Android.mk index 8424601a57ef..6642134ec32b 100644 --- a/location/lib/Android.mk +++ b/location/lib/Android.mk @@ -42,3 +42,25 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions LOCAL_SRC_FILES := $(LOCAL_MODULE) include $(BUILD_PREBUILT) + +# ==== Stub library =========================================== +include $(CLEAR_VARS) +LOCAL_MODULE := com.android.location.provider-stubs-gen +LOCAL_MODULE_CLASS := JAVA_LIBRARIES +LOCAL_SRC_FILES := $(call all-java-files-under,java) +LOCAL_DROIDDOC_STUB_OUT_DIR := $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/com.android.location.provider.stubs_intermediates/src +LOCAL_DROIDDOC_OPTIONS:= \ + -hide 111 -hide 113 -hide 125 -hide 126 -hide 127 -hide 128 \ + -stubpackages com.android.location.provider \ + -nodocs +LOCAL_UNINSTALLABLE_MODULE := true +include $(BUILD_DROIDDOC) +com_android_nfc_extras_gen_stamp := $(full_target) + +include $(CLEAR_VARS) +LOCAL_MODULE := com.android.location.provider.stubs +LOCAL_SOURCE_FILES_ALL_GENERATED := true +LOCAL_SDK_VERSION := current +LOCAL_ADDITIONAL_DEPENDENCIES := $(com_android_nfc_extras_gen_stamp) +com_android_nfc_extras_gen_stamp := +include $(BUILD_STATIC_JAVA_LIBRARY) diff --git a/location/lib/java/com/android/location/provider/ActivityChangedEvent.java b/location/lib/java/com/android/location/provider/ActivityChangedEvent.java index c7dfc887bbbb..843dd670315a 100644 --- a/location/lib/java/com/android/location/provider/ActivityChangedEvent.java +++ b/location/lib/java/com/android/location/provider/ActivityChangedEvent.java @@ -23,6 +23,7 @@ import java.util.List; /** * A class representing an event for Activity changes. + * @hide */ public class ActivityChangedEvent { private final List<ActivityRecognitionEvent> mActivityRecognitionEvents; diff --git a/location/lib/java/com/android/location/provider/ActivityRecognitionEvent.java b/location/lib/java/com/android/location/provider/ActivityRecognitionEvent.java index a39cff228567..e54dea40d690 100644 --- a/location/lib/java/com/android/location/provider/ActivityRecognitionEvent.java +++ b/location/lib/java/com/android/location/provider/ActivityRecognitionEvent.java @@ -18,6 +18,7 @@ package com.android.location.provider; /** * A class that represents an Activity Recognition Event. + * @hide */ public class ActivityRecognitionEvent { private final String mActivity; diff --git a/location/lib/java/com/android/location/provider/ActivityRecognitionProvider.java b/location/lib/java/com/android/location/provider/ActivityRecognitionProvider.java index bc2dae14be38..0eff7d3f2014 100644 --- a/location/lib/java/com/android/location/provider/ActivityRecognitionProvider.java +++ b/location/lib/java/com/android/location/provider/ActivityRecognitionProvider.java @@ -28,6 +28,7 @@ import java.util.HashSet; /** * A class that exposes {@link IActivityRecognitionHardware} functionality to unbundled services. + * @hide */ public final class ActivityRecognitionProvider { private final IActivityRecognitionHardware mService; diff --git a/location/lib/java/com/android/location/provider/ActivityRecognitionProviderClient.java b/location/lib/java/com/android/location/provider/ActivityRecognitionProviderClient.java index 0b878d7c1f2b..326d901b9daa 100644 --- a/location/lib/java/com/android/location/provider/ActivityRecognitionProviderClient.java +++ b/location/lib/java/com/android/location/provider/ActivityRecognitionProviderClient.java @@ -27,6 +27,7 @@ import android.util.Log; /** * A client class for interaction with an Activity-Recognition provider. + * @hide */ public abstract class ActivityRecognitionProviderClient { private static final String TAG = "ArProviderClient"; diff --git a/location/lib/java/com/android/location/provider/ActivityRecognitionProviderWatcher.java b/location/lib/java/com/android/location/provider/ActivityRecognitionProviderWatcher.java index 7139025d2722..42f77b42766f 100644 --- a/location/lib/java/com/android/location/provider/ActivityRecognitionProviderWatcher.java +++ b/location/lib/java/com/android/location/provider/ActivityRecognitionProviderWatcher.java @@ -30,6 +30,7 @@ import android.util.Log; * A watcher class for Activity-Recognition instances. * * @deprecated use {@link ActivityRecognitionProviderClient} instead. + * @hide */ @Deprecated public class ActivityRecognitionProviderWatcher { diff --git a/location/lib/java/com/android/location/provider/FusedLocationHardware.java b/location/lib/java/com/android/location/provider/FusedLocationHardware.java deleted file mode 100644 index eb3b2f4609e7..000000000000 --- a/location/lib/java/com/android/location/provider/FusedLocationHardware.java +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.location.provider; - -import android.hardware.location.IFusedLocationHardware; -import android.hardware.location.IFusedLocationHardwareSink; - -import android.location.Location; - -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.os.RemoteException; -import android.util.Log; - -import java.util.HashMap; -import java.util.Map; - -/** - * Class that exposes IFusedLocationHardware functionality to unbundled services. - */ -public final class FusedLocationHardware { - private static final String TAG = "FusedLocationHardware"; - - private IFusedLocationHardware mLocationHardware; - - // the list uses a copy-on-write pattern to update its contents - HashMap<FusedLocationHardwareSink, DispatcherHandler> mSinkList = - new HashMap<FusedLocationHardwareSink, DispatcherHandler>(); - - private IFusedLocationHardwareSink mInternalSink = new IFusedLocationHardwareSink.Stub() { - @Override - public void onLocationAvailable(Location[] locations) { - dispatchLocations(locations); - } - - @Override - public void onDiagnosticDataAvailable(String data) { - dispatchDiagnosticData(data); - } - - @Override - public void onCapabilities(int capabilities) { - dispatchCapabilities(capabilities); - } - - @Override - public void onStatusChanged(int status) { - dispatchStatus(status); - } - }; - - /** - * @hide - */ - public FusedLocationHardware(IFusedLocationHardware locationHardware) { - mLocationHardware = locationHardware; - } - - /* - * Methods to provide a Facade for IFusedLocationHardware - */ - public void registerSink(FusedLocationHardwareSink sink, Looper looper) { - if(sink == null || looper == null) { - throw new IllegalArgumentException("Parameter sink and looper cannot be null."); - } - - boolean registerSink; - synchronized (mSinkList) { - // register only on first insertion - registerSink = mSinkList.size() == 0; - // guarantee uniqueness - if(mSinkList.containsKey(sink)) { - return; - } - - HashMap<FusedLocationHardwareSink, DispatcherHandler> newSinkList = - new HashMap<FusedLocationHardwareSink, DispatcherHandler>(mSinkList); - newSinkList.put(sink, new DispatcherHandler(looper)); - mSinkList = newSinkList; - } - - if(registerSink) { - try { - mLocationHardware.registerSink(mInternalSink); - } catch(RemoteException e) { - Log.e(TAG, "RemoteException at registerSink"); - } - } - } - - public void unregisterSink(FusedLocationHardwareSink sink) { - if(sink == null) { - throw new IllegalArgumentException("Parameter sink cannot be null."); - } - - boolean unregisterSink; - synchronized(mSinkList) { - if(!mSinkList.containsKey(sink)) { - //done - return; - } - - HashMap<FusedLocationHardwareSink, DispatcherHandler> newSinkList = - new HashMap<FusedLocationHardwareSink, DispatcherHandler>(mSinkList); - newSinkList.remove(sink); - //unregister after the last sink - unregisterSink = newSinkList.size() == 0; - - mSinkList = newSinkList; - } - - if(unregisterSink) { - try { - mLocationHardware.unregisterSink(mInternalSink); - } catch(RemoteException e) { - Log.e(TAG, "RemoteException at unregisterSink"); - } - } - } - - public int getSupportedBatchSize() { - try { - return mLocationHardware.getSupportedBatchSize(); - } catch(RemoteException e) { - Log.e(TAG, "RemoteException at getSupportedBatchSize"); - return 0; - } - } - - public void startBatching(int id, GmsFusedBatchOptions batchOptions) { - try { - mLocationHardware.startBatching(id, batchOptions.getParcelableOptions()); - } catch(RemoteException e) { - Log.e(TAG, "RemoteException at startBatching"); - } - } - - public void stopBatching(int id) { - try { - mLocationHardware.stopBatching(id); - } catch(RemoteException e) { - Log.e(TAG, "RemoteException at stopBatching"); - } - } - - public void updateBatchingOptions(int id, GmsFusedBatchOptions batchOptions) { - try { - mLocationHardware.updateBatchingOptions(id, batchOptions.getParcelableOptions()); - } catch(RemoteException e) { - Log.e(TAG, "RemoteException at updateBatchingOptions"); - } - } - - public void requestBatchOfLocations(int batchSizeRequest) { - try { - mLocationHardware.requestBatchOfLocations(batchSizeRequest); - } catch(RemoteException e) { - Log.e(TAG, "RemoteException at requestBatchOfLocations"); - } - } - - public void flushBatchedLocations() { - try { - mLocationHardware.flushBatchedLocations(); - } catch(RemoteException e) { - Log.e(TAG, "RemoteException at flushBatchedLocations"); - } - } - - public boolean supportsDiagnosticDataInjection() { - try { - return mLocationHardware.supportsDiagnosticDataInjection(); - } catch(RemoteException e) { - Log.e(TAG, "RemoteException at supportsDiagnisticDataInjection"); - return false; - } - } - - public void injectDiagnosticData(String data) { - try { - mLocationHardware.injectDiagnosticData(data); - } catch(RemoteException e) { - Log.e(TAG, "RemoteException at injectDiagnosticData"); - } - } - - public boolean supportsDeviceContextInjection() { - try { - return mLocationHardware.supportsDeviceContextInjection(); - } catch(RemoteException e) { - Log.e(TAG, "RemoteException at supportsDeviceContextInjection"); - return false; - } - } - - public void injectDeviceContext(int deviceEnabledContext) { - try { - mLocationHardware.injectDeviceContext(deviceEnabledContext); - } catch(RemoteException e) { - Log.e(TAG, "RemoteException at injectDeviceContext"); - } - } - - - /** - * Returns the version of the FLP HAL. - * - * <p>Version 1 is the initial release. - * <p>Version 2 adds the ability to use {@link #flushBatchedLocations}, - * {@link FusedLocationHardwareSink#onCapabilities}, and - * {@link FusedLocationHardwareSink#onStatusChanged}. - * - * <p>This method is only available on API 23 or later. Older APIs have version 1. - */ - public int getVersion() { - try { - return mLocationHardware.getVersion(); - } catch(RemoteException e) { - Log.e(TAG, "RemoteException at getVersion"); - } - return 1; - } - - /* - * Helper methods and classes - */ - private class DispatcherHandler extends Handler { - public static final int DISPATCH_LOCATION = 1; - public static final int DISPATCH_DIAGNOSTIC_DATA = 2; - public static final int DISPATCH_CAPABILITIES = 3; - public static final int DISPATCH_STATUS = 4; - - public DispatcherHandler(Looper looper) { - super(looper, null /*callback*/ , true /*async*/); - } - - @Override - public void handleMessage(Message message) { - MessageCommand command = (MessageCommand) message.obj; - switch(message.what) { - case DISPATCH_LOCATION: - command.dispatchLocation(); - break; - case DISPATCH_DIAGNOSTIC_DATA: - command.dispatchDiagnosticData(); - break; - case DISPATCH_CAPABILITIES: - command.dispatchCapabilities(); - break; - case DISPATCH_STATUS: - command.dispatchStatus(); - break; - default: - Log.e(TAG, "Invalid dispatch message"); - break; - } - } - } - - private class MessageCommand { - private final FusedLocationHardwareSink mSink; - private final Location[] mLocations; - private final String mData; - private final int mCapabilities; - private final int mStatus; - - public MessageCommand( - FusedLocationHardwareSink sink, - Location[] locations, - String data, - int capabilities, - int status) { - mSink = sink; - mLocations = locations; - mData = data; - mCapabilities = capabilities; - mStatus = status; - } - - public void dispatchLocation() { - mSink.onLocationAvailable(mLocations); - } - - public void dispatchDiagnosticData() { - mSink.onDiagnosticDataAvailable(mData); - } - - public void dispatchCapabilities() { - mSink.onCapabilities(mCapabilities); - } - - public void dispatchStatus() { - mSink.onStatusChanged(mStatus); - } - } - - private void dispatchLocations(Location[] locations) { - HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks; - synchronized (mSinkList) { - sinks = mSinkList; - } - - for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) { - Message message = Message.obtain( - entry.getValue(), - DispatcherHandler.DISPATCH_LOCATION, - new MessageCommand(entry.getKey(), locations, null /*data*/, 0, 0)); - message.sendToTarget(); - } - } - - private void dispatchDiagnosticData(String data) { - HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks; - synchronized(mSinkList) { - sinks = mSinkList; - } - - for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) { - Message message = Message.obtain( - entry.getValue(), - DispatcherHandler.DISPATCH_DIAGNOSTIC_DATA, - new MessageCommand(entry.getKey(), null /*locations*/, data, 0, 0)); - message.sendToTarget(); - } - } - - private void dispatchCapabilities(int capabilities) { - HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks; - synchronized(mSinkList) { - sinks = mSinkList; - } - - for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) { - Message message = Message.obtain( - entry.getValue(), - DispatcherHandler.DISPATCH_CAPABILITIES, - new MessageCommand(entry.getKey(), null /*locations*/, null, capabilities, 0)); - message.sendToTarget(); - } - } - - private void dispatchStatus(int status) { - HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks; - synchronized(mSinkList) { - sinks = mSinkList; - } - - for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) { - Message message = Message.obtain( - entry.getValue(), - DispatcherHandler.DISPATCH_STATUS, - new MessageCommand(entry.getKey(), null /*locations*/, null, 0, status)); - message.sendToTarget(); - } - } -} diff --git a/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java b/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java deleted file mode 100644 index 01d37acde7b8..000000000000 --- a/location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.location.provider; - -import android.location.Location; - -/** - * Base class for sinks to interact with FusedLocationHardware. - * - * <p>Default implementations allow new methods to be added without crashing - * clients compiled against an old library version. - */ -public class FusedLocationHardwareSink { - /** - * Called when one or more locations are available from the FLP - * HAL. - */ - public void onLocationAvailable(Location[] locations) { - // default do nothing - } - - /** - * Called when diagnostic data is available from the FLP HAL. - */ - public void onDiagnosticDataAvailable(String data) { - // default do nothing - } - - /** - * Called when capabilities are available from the FLP HAL. - * Should be called once right after initialization. - * - * @param capabilities A bitmask of capabilities defined in - * fused_location.h. - */ - public void onCapabilities(int capabilities) { - // default do nothing - } - - /** - * Called when the status changes in the underlying FLP HAL - * implementation (the ability to compute location). This - * callback will only be made on version 2 or later - * (see {@link FusedLocationHardware#getVersion()}). - * - * @param status One of FLP_STATUS_LOCATION_AVAILABLE or - * FLP_STATUS_LOCATION_UNAVAILABLE as defined in - * fused_location.h. - */ - public void onStatusChanged(int status) { - // default do nothing - } -}
\ No newline at end of file diff --git a/location/lib/java/com/android/location/provider/FusedProvider.java b/location/lib/java/com/android/location/provider/FusedProvider.java index c966adeadc6f..78a593b6670b 100644 --- a/location/lib/java/com/android/location/provider/FusedProvider.java +++ b/location/lib/java/com/android/location/provider/FusedProvider.java @@ -16,8 +16,6 @@ package com.android.location.provider; -import android.hardware.location.IFusedLocationHardware; -import android.location.IFusedProvider; import android.os.IBinder; /** @@ -26,17 +24,12 @@ import android.os.IBinder; * <p>Fused providers can be implemented as services and return the result of * {@link com.android.location.provider.FusedProvider#getBinder()} in its getBinder() method. * - * <p>IMPORTANT: This class is effectively a public API for unbundled applications, and must remain - * API stable. See README.txt in the root of this package for more information. + * @deprecated This class should no longer be used. The location service does not uses this. + * This class exist here just to prevent existing apps having reference to this class from + * breaking. */ +@Deprecated public abstract class FusedProvider { - private IFusedProvider.Stub mProvider = new IFusedProvider.Stub() { - @Override - public void onFusedLocationHardwareChange(IFusedLocationHardware instance) { - setFusedLocationHardware(new FusedLocationHardware(instance)); - } - }; - /** * Gets the Binder associated with the provider. * This is intended to be used for the onBind() method of a service that implements a fused @@ -45,13 +38,6 @@ public abstract class FusedProvider { * @return The IBinder instance associated with the provider. */ public IBinder getBinder() { - return mProvider; + return null; } - - /** - * Sets the FusedLocationHardware instance in the provider.. - * @param value The instance to set. This can be null in cases where the service connection - * is disconnected. - */ - public abstract void setFusedLocationHardware(FusedLocationHardware value); } diff --git a/location/lib/java/com/android/location/provider/GeocodeProvider.java b/location/lib/java/com/android/location/provider/GeocodeProvider.java index d7a34af332ca..f7f3d82169a7 100644 --- a/location/lib/java/com/android/location/provider/GeocodeProvider.java +++ b/location/lib/java/com/android/location/provider/GeocodeProvider.java @@ -33,6 +33,7 @@ import java.util.List; * <p>IMPORTANT: This class is effectively a public API for unbundled * applications, and must remain API stable. See README.txt in the root * of this package for more information. + * @hide */ public abstract class GeocodeProvider { diff --git a/location/lib/java/com/android/location/provider/GeofenceProvider.java b/location/lib/java/com/android/location/provider/GeofenceProvider.java index fafaa8462dd9..43690ab87cf2 100644 --- a/location/lib/java/com/android/location/provider/GeofenceProvider.java +++ b/location/lib/java/com/android/location/provider/GeofenceProvider.java @@ -31,6 +31,7 @@ import android.location.IGeofenceProvider; * <p>IMPORTANT: This class is effectively a public API for unbundled * applications, and must remain API stable. See README.txt in the root * of this package for more information. + * @hide */ public abstract class GeofenceProvider { diff --git a/location/lib/java/com/android/location/provider/GmsFusedBatchOptions.java b/location/lib/java/com/android/location/provider/GmsFusedBatchOptions.java deleted file mode 100644 index 29818ecb85cb..000000000000 --- a/location/lib/java/com/android/location/provider/GmsFusedBatchOptions.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.location.provider; - -import android.location.FusedBatchOptions; - -/** - * Class that exposes FusedBatchOptions to the GmsCore . - */ -public class GmsFusedBatchOptions { - private FusedBatchOptions mOptions = new FusedBatchOptions(); - - /* - * Methods that provide a facade for properties in FusedBatchOptions. - */ - public void setMaxPowerAllocationInMW(double value) { - mOptions.setMaxPowerAllocationInMW(value); - } - - public double getMaxPowerAllocationInMW() { - return mOptions.getMaxPowerAllocationInMW(); - } - - public void setPeriodInNS(long value) { - mOptions.setPeriodInNS(value); - } - - public long getPeriodInNS() { - return mOptions.getPeriodInNS(); - } - - public void setSmallestDisplacementMeters(float value) { - mOptions.setSmallestDisplacementMeters(value); - } - - public float getSmallestDisplacementMeters() { - return mOptions.getSmallestDisplacementMeters(); - } - - public void setSourceToUse(int source) { - mOptions.setSourceToUse(source); - } - - public void resetSourceToUse(int source) { - mOptions.resetSourceToUse(source); - } - - public boolean isSourceToUseSet(int source) { - return mOptions.isSourceToUseSet(source); - } - - public int getSourcesToUse() { - return mOptions.getSourcesToUse(); - } - - public void setFlag(int flag) { - mOptions.setFlag(flag); - } - - public void resetFlag(int flag) { - mOptions.resetFlag(flag); - } - - public boolean isFlagSet(int flag) { - return mOptions.isFlagSet(flag); - } - - public int getFlags() { - return mOptions.getFlags(); - } - - /** - * Definition of enum flag sets needed by this class. - * Such values need to be kept in sync with the ones in fused_location.h - */ - - public static final class SourceTechnologies { - public static int GNSS = 1<<0; - public static int WIFI = 1<<1; - public static int SENSORS = 1<<2; - public static int CELL = 1<<3; - public static int BLUETOOTH = 1<<4; - } - - public static final class BatchFlags { - public static int WAKEUP_ON_FIFO_FULL = 1<<0; - public static int CALLBACK_ON_LOCATION_FIX = 1<<1; - } - - /* - * Method definitions for internal use. - */ - - /* - * @hide - */ - public FusedBatchOptions getParcelableOptions() { - return mOptions; - } -} diff --git a/location/lib/java/com/android/location/provider/LocationProviderBase.java b/location/lib/java/com/android/location/provider/LocationProviderBase.java index d717f40cab59..30655f5bbf10 100644 --- a/location/lib/java/com/android/location/provider/LocationProviderBase.java +++ b/location/lib/java/com/android/location/provider/LocationProviderBase.java @@ -56,6 +56,7 @@ import com.android.internal.util.FastPrintWriter; public abstract class LocationProviderBase { private final String TAG; + /** @hide */ protected final ILocationManager mLocationManager; private final ProviderProperties mProperties; private final IBinder mBinder; diff --git a/location/lib/java/com/android/location/provider/ProviderPropertiesUnbundled.java b/location/lib/java/com/android/location/provider/ProviderPropertiesUnbundled.java index 9ee4df21c894..b1a1bda45f39 100644 --- a/location/lib/java/com/android/location/provider/ProviderPropertiesUnbundled.java +++ b/location/lib/java/com/android/location/provider/ProviderPropertiesUnbundled.java @@ -41,6 +41,7 @@ public final class ProviderPropertiesUnbundled { mProperties = properties; } + /** @hide */ public ProviderProperties getProviderProperties() { return mProperties; } diff --git a/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java b/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java index ad3d1df35548..6a8e61877e46 100644 --- a/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java +++ b/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java @@ -33,6 +33,7 @@ import com.android.internal.location.ProviderRequest; public final class ProviderRequestUnbundled { private final ProviderRequest mRequest; + /** @hide */ public ProviderRequestUnbundled(ProviderRequest request) { mRequest = request; } diff --git a/media/java/android/media/AudioPresentation.java b/media/java/android/media/AudioPresentation.java index 4652c180936c..e39cb7db3480 100644 --- a/media/java/android/media/AudioPresentation.java +++ b/media/java/android/media/AudioPresentation.java @@ -17,6 +17,9 @@ package android.media; import android.annotation.IntDef; +import android.annotation.NonNull; + +import com.android.internal.annotations.VisibleForTesting; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -88,10 +91,14 @@ public final class AudioPresentation { */ public static final int MASTERED_FOR_HEADPHONE = 4; - AudioPresentation(int presentationId, + /** + * @hide + */ + @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) + public AudioPresentation(int presentationId, int programId, - Map<String, String> labels, - String language, + @NonNull Map<String, String> labels, + @NonNull String language, @MasteringIndicationType int masteringIndication, boolean audioDescriptionAvailable, boolean spokenSubtitlesAvailable, @@ -112,6 +119,7 @@ public final class AudioPresentation { * decoder. Presentation id is typically sequential, but does not have to be. * @hide */ + @VisibleForTesting public int getPresentationId() { return mPresentationId; } @@ -121,13 +129,14 @@ public final class AudioPresentation { * Program id can be used to further uniquely identify the presentation to a decoder. * @hide */ + @VisibleForTesting public int getProgramId() { return mProgramId; } /** * @return a map of available text labels for this presentation. Each label is indexed by its - * locale corresponding to the language code as specified by ISO 639-2 [42]. Either ISO 639-2/B + * locale corresponding to the language code as specified by ISO 639-2. Either ISO 639-2/B * or ISO 639-2/T could be used. */ public Map<Locale, String> getLabels() { diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java index 2d5fad5dde5b..9c48e09ea399 100644 --- a/media/java/android/media/AudioTrack.java +++ b/media/java/android/media/AudioTrack.java @@ -2012,9 +2012,10 @@ public class AudioTrack extends PlayerBase * If the audio presentation is invalid then {@link #ERROR_BAD_VALUE} will be returned. * If a multi-stream decoder (MSD) is not present, or the format does not support * multiple presentations, then {@link #ERROR_INVALID_OPERATION} will be returned. + * {@link #ERROR} is returned in case of any other error. * @param presentation see {@link AudioPresentation}. In particular, id should be set. - * @return error code or success, see {@link #SUCCESS}, {@link #ERROR_BAD_VALUE}, - * {@link #ERROR_INVALID_OPERATION} + * @return error code or success, see {@link #SUCCESS}, {@link #ERROR}, + * {@link #ERROR_BAD_VALUE}, {@link #ERROR_INVALID_OPERATION} * @throws IllegalArgumentException if the audio presentation is null. * @throws IllegalStateException if track is not initialized. */ diff --git a/media/java/android/media/MediaBrowser2.java b/media/java/android/media/MediaBrowser2.java index cf3395858534..f24600562278 100644 --- a/media/java/android/media/MediaBrowser2.java +++ b/media/java/android/media/MediaBrowser2.java @@ -142,8 +142,8 @@ public class MediaBrowser2 extends MediaController2 { @Override MediaBrowser2Provider createProvider(Context context, SessionToken2 token, Executor executor, ControllerCallback callback) { - return ApiLoader.getProvider(context) - .createMediaBrowser2(context, this, token, executor, (BrowserCallback) callback); + return ApiLoader.getProvider().createMediaBrowser2( + context, this, token, executor, (BrowserCallback) callback); } /** diff --git a/media/java/android/media/MediaController2.java b/media/java/android/media/MediaController2.java index 20c320947f45..14dccedd449b 100644 --- a/media/java/android/media/MediaController2.java +++ b/media/java/android/media/MediaController2.java @@ -366,8 +366,8 @@ public class MediaController2 implements AutoCloseable { MediaController2Provider createProvider(@NonNull Context context, @NonNull SessionToken2 token, @NonNull Executor executor, @NonNull ControllerCallback callback) { - return ApiLoader.getProvider(context) - .createMediaController2(context, this, token, executor, callback); + return ApiLoader.getProvider().createMediaController2( + context, this, token, executor, callback); } /** diff --git a/media/java/android/media/MediaItem2.java b/media/java/android/media/MediaItem2.java index b50c3e4bcd0b..8d62bd470136 100644 --- a/media/java/android/media/MediaItem2.java +++ b/media/java/android/media/MediaItem2.java @@ -81,7 +81,7 @@ public class MediaItem2 { } public static MediaItem2 fromBundle(Context context, Bundle bundle) { - return ApiLoader.getProvider(context).fromBundle_MediaItem2(context, bundle); + return ApiLoader.getProvider().fromBundle_MediaItem2(context, bundle); } public String toString() { @@ -164,8 +164,7 @@ public class MediaItem2 { * @param flags */ public Builder(@NonNull Context context, @Flags int flags) { - mProvider = ApiLoader.getProvider(context).createMediaItem2Builder( - context, this, flags); + mProvider = ApiLoader.getProvider().createMediaItem2Builder(context, this, flags); } /** diff --git a/media/java/android/media/MediaLibraryService2.java b/media/java/android/media/MediaLibraryService2.java index 6cab43017034..f3684d6fc36e 100644 --- a/media/java/android/media/MediaLibraryService2.java +++ b/media/java/android/media/MediaLibraryService2.java @@ -210,9 +210,8 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 { public Builder(@NonNull MediaLibraryService2 service, @NonNull @CallbackExecutor Executor callbackExecutor, @NonNull MediaLibrarySessionCallback callback) { - super((instance) -> ApiLoader.getProvider(service) - .createMediaLibraryService2Builder(service, (Builder) instance, - callbackExecutor, callback)); + super((instance) -> ApiLoader.getProvider().createMediaLibraryService2Builder( + service, (Builder) instance, callbackExecutor, callback)); } @Override @@ -309,7 +308,7 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 { @Override MediaSessionService2Provider createProvider() { - return ApiLoader.getProvider(this).createMediaLibraryService2(this); + return ApiLoader.getProvider().createMediaLibraryService2(this); } /** @@ -403,7 +402,7 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 { */ public LibraryRoot(@NonNull Context context, @NonNull String rootId, @Nullable Bundle extras) { - mProvider = ApiLoader.getProvider(context).createMediaLibraryService2LibraryRoot( + mProvider = ApiLoader.getProvider().createMediaLibraryService2LibraryRoot( context, this, rootId, extras); } diff --git a/media/java/android/media/MediaMetadata2.java b/media/java/android/media/MediaMetadata2.java index fb1206515ef5..2ba66b2510fd 100644 --- a/media/java/android/media/MediaMetadata2.java +++ b/media/java/android/media/MediaMetadata2.java @@ -684,7 +684,7 @@ public final class MediaMetadata2 { */ public static @NonNull MediaMetadata2 fromBundle(@NonNull Context context, @Nullable Bundle bundle) { - return ApiLoader.getProvider(context).fromBundle_MediaMetadata2(context, bundle); + return ApiLoader.getProvider().fromBundle_MediaMetadata2(context, bundle); } /** @@ -699,8 +699,7 @@ public final class MediaMetadata2 { * {@link MediaMetadata2} must be added. */ public Builder(@NonNull Context context) { - mProvider = ApiLoader.getProvider(context).createMediaMetadata2Builder( - context, this); + mProvider = ApiLoader.getProvider().createMediaMetadata2Builder(context, this); } /** @@ -711,8 +710,7 @@ public final class MediaMetadata2 { * @param source */ public Builder(@NonNull Context context, @NonNull MediaMetadata2 source) { - mProvider = ApiLoader.getProvider(context).createMediaMetadata2Builder( - context, this, source); + mProvider = ApiLoader.getProvider().createMediaMetadata2Builder(context, this, source); } /** diff --git a/media/java/android/media/MediaPlaylistAgent.java b/media/java/android/media/MediaPlaylistAgent.java index 6b3620b62dc3..12508108b3bf 100644 --- a/media/java/android/media/MediaPlaylistAgent.java +++ b/media/java/android/media/MediaPlaylistAgent.java @@ -148,7 +148,7 @@ public abstract class MediaPlaylistAgent { } public MediaPlaylistAgent(@NonNull Context context) { - mProvider = ApiLoader.getProvider(context).createMediaPlaylistAgent(context, this); + mProvider = ApiLoader.getProvider().createMediaPlaylistAgent(context, this); } /** diff --git a/media/java/android/media/MediaSession2.java b/media/java/android/media/MediaSession2.java index 66478318eb3b..472d9427f3cc 100644 --- a/media/java/android/media/MediaSession2.java +++ b/media/java/android/media/MediaSession2.java @@ -431,16 +431,16 @@ public class MediaSession2 implements AutoCloseable { private final CommandProvider mProvider; public Command(@NonNull Context context, int commandCode) { - mProvider = ApiLoader.getProvider(context) - .createMediaSession2Command(this, commandCode, null, null); + mProvider = ApiLoader.getProvider().createMediaSession2Command( + this, commandCode, null, null); } public Command(@NonNull Context context, @NonNull String action, @Nullable Bundle extras) { if (action == null) { throw new IllegalArgumentException("action shouldn't be null"); } - mProvider = ApiLoader.getProvider(context) - .createMediaSession2Command(this, COMMAND_CODE_CUSTOM, action, extras); + mProvider = ApiLoader.getProvider().createMediaSession2Command( + this, COMMAND_CODE_CUSTOM, action, extras); } /** @@ -488,7 +488,7 @@ public class MediaSession2 implements AutoCloseable { * @hide */ public static Command fromBundle(@NonNull Context context, @NonNull Bundle command) { - return ApiLoader.getProvider(context).fromBundle_MediaSession2Command(context, command); + return ApiLoader.getProvider().fromBundle_MediaSession2Command(context, command); } } @@ -499,13 +499,13 @@ public class MediaSession2 implements AutoCloseable { private final CommandGroupProvider mProvider; public CommandGroup(@NonNull Context context) { - mProvider = ApiLoader.getProvider(context) - .createMediaSession2CommandGroup(context, this, null); + mProvider = ApiLoader.getProvider().createMediaSession2CommandGroup( + context, this, null); } public CommandGroup(@NonNull Context context, @Nullable CommandGroup others) { - mProvider = ApiLoader.getProvider(context) - .createMediaSession2CommandGroup(context, this, others); + mProvider = ApiLoader.getProvider().createMediaSession2CommandGroup( + context, this, others); } /** @@ -559,8 +559,7 @@ public class MediaSession2 implements AutoCloseable { * @hide */ public static @Nullable CommandGroup fromBundle(Context context, Bundle commands) { - return ApiLoader.getProvider(context) - .fromBundle_MediaSession2CommandGroup(context, commands); + return ApiLoader.getProvider().fromBundle_MediaSession2CommandGroup(context, commands); } } @@ -1010,7 +1009,7 @@ public class MediaSession2 implements AutoCloseable { // This workarounds javadoc issue described in the MediaSession2.BuilderBase. public static final class Builder extends BuilderBase<MediaSession2, Builder, SessionCallback> { public Builder(Context context) { - super((instance) -> ApiLoader.getProvider(context).createMediaSession2Builder( + super((instance) -> ApiLoader.getProvider().createMediaSession2Builder( context, (Builder) instance)); } @@ -1062,9 +1061,8 @@ public class MediaSession2 implements AutoCloseable { */ public ControllerInfo(@NonNull Context context, int uid, int pid, @NonNull String packageName, @NonNull IInterface callback) { - mProvider = ApiLoader.getProvider(context) - .createMediaSession2ControllerInfo( - context, this, uid, pid, packageName, callback); + mProvider = ApiLoader.getProvider().createMediaSession2ControllerInfo( + context, this, uid, pid, packageName, callback); } /** @@ -1192,8 +1190,8 @@ public class MediaSession2 implements AutoCloseable { private final CommandButtonProvider.BuilderProvider mProvider; public Builder(@NonNull Context context) { - mProvider = ApiLoader.getProvider(context) - .createMediaSession2CommandButtonBuilder(context, this); + mProvider = ApiLoader.getProvider().createMediaSession2CommandButtonBuilder( + context, this); } public @NonNull Builder setCommand(@Nullable Command command) { diff --git a/media/java/android/media/MediaSessionService2.java b/media/java/android/media/MediaSessionService2.java index 32caf4b5a0e7..b83069469018 100644 --- a/media/java/android/media/MediaSessionService2.java +++ b/media/java/android/media/MediaSessionService2.java @@ -123,7 +123,7 @@ public abstract class MediaSessionService2 extends Service { } MediaSessionService2Provider createProvider() { - return ApiLoader.getProvider(this).createMediaSessionService2(this); + return ApiLoader.getProvider().createMediaSessionService2(this); } /** @@ -220,9 +220,8 @@ public abstract class MediaSessionService2 extends Service { */ public MediaNotification(@NonNull Context context, int notificationId, @NonNull Notification notification) { - mProvider = ApiLoader.getProvider(context) - .createMediaSessionService2MediaNotification( - context, this, notificationId, notification); + mProvider = ApiLoader.getProvider().createMediaSessionService2MediaNotification( + context, this, notificationId, notification); } public int getNotificationId() { diff --git a/media/java/android/media/Rating2.java b/media/java/android/media/Rating2.java index 29bd9220bdc1..5f7a3340603a 100644 --- a/media/java/android/media/Rating2.java +++ b/media/java/android/media/Rating2.java @@ -131,7 +131,7 @@ public final class Rating2 { * @return new Rating2 instance or {@code null} for error */ public static Rating2 fromBundle(@NonNull Context context, @Nullable Bundle bundle) { - return ApiLoader.getProvider(context).fromBundle_Rating2(context, bundle); + return ApiLoader.getProvider().fromBundle_Rating2(context, bundle); } /** @@ -154,7 +154,7 @@ public final class Rating2 { */ public static @Nullable Rating2 newUnratedRating(@NonNull Context context, @Style int ratingStyle) { - return ApiLoader.getProvider(context).newUnratedRating_Rating2(context, ratingStyle); + return ApiLoader.getProvider().newUnratedRating_Rating2(context, ratingStyle); } /** @@ -166,7 +166,7 @@ public final class Rating2 { * @return a new Rating2 instance. */ public static @Nullable Rating2 newHeartRating(@NonNull Context context, boolean hasHeart) { - return ApiLoader.getProvider(context).newHeartRating_Rating2(context, hasHeart); + return ApiLoader.getProvider().newHeartRating_Rating2(context, hasHeart); } /** @@ -178,7 +178,7 @@ public final class Rating2 { * @return a new Rating2 instance. */ public static @Nullable Rating2 newThumbRating(@NonNull Context context, boolean thumbIsUp) { - return ApiLoader.getProvider(context).newThumbRating_Rating2(context, thumbIsUp); + return ApiLoader.getProvider().newThumbRating_Rating2(context, thumbIsUp); } /** @@ -196,8 +196,7 @@ public final class Rating2 { */ public static @Nullable Rating2 newStarRating(@NonNull Context context, @StarStyle int starRatingStyle, float starRating) { - return ApiLoader.getProvider(context).newStarRating_Rating2( - context, starRatingStyle, starRating); + return ApiLoader.getProvider().newStarRating_Rating2(context, starRatingStyle, starRating); } /** @@ -209,7 +208,7 @@ public final class Rating2 { * @return null if the rating is out of range, a new Rating2 instance otherwise. */ public static @Nullable Rating2 newPercentageRating(@NonNull Context context, float percent) { - return ApiLoader.getProvider(context).newPercentageRating_Rating2(context, percent); + return ApiLoader.getProvider().newPercentageRating_Rating2(context, percent); } /** diff --git a/media/java/android/media/SessionToken2.java b/media/java/android/media/SessionToken2.java index fdfa43abd178..68a5641bf415 100644 --- a/media/java/android/media/SessionToken2.java +++ b/media/java/android/media/SessionToken2.java @@ -80,7 +80,7 @@ public final class SessionToken2 { */ public SessionToken2(@NonNull Context context, @NonNull String packageName, @NonNull String serviceName, int uid) { - mProvider = ApiLoader.getProvider(context).createSessionToken2( + mProvider = ApiLoader.getProvider().createSessionToken2( context, this, packageName, serviceName, uid); } @@ -150,7 +150,7 @@ public final class SessionToken2 { * @return */ public static SessionToken2 fromBundle(@NonNull Context context, @NonNull Bundle bundle) { - return ApiLoader.getProvider(context).fromBundle_SessionToken2(context, bundle); + return ApiLoader.getProvider().fromBundle_SessionToken2(context, bundle); } /** diff --git a/media/java/android/media/VolumeProvider2.java b/media/java/android/media/VolumeProvider2.java index 711f51f81013..8501924cb77a 100644 --- a/media/java/android/media/VolumeProvider2.java +++ b/media/java/android/media/VolumeProvider2.java @@ -76,7 +76,7 @@ public abstract class VolumeProvider2 { */ public VolumeProvider2(@NonNull Context context, @ControlType int controlType, int maxVolume, int currentVolume) { - mProvider = ApiLoader.getProvider(context).createVolumeProvider2( + mProvider = ApiLoader.getProvider().createVolumeProvider2( context, this, controlType, maxVolume, currentVolume); } diff --git a/media/java/android/media/update/ApiLoader.java b/media/java/android/media/update/ApiLoader.java index cf18bddbb57f..6f82f68304c9 100644 --- a/media/java/android/media/update/ApiLoader.java +++ b/media/java/android/media/update/ApiLoader.java @@ -46,11 +46,6 @@ public final class ApiLoader { private ApiLoader() { } - @Deprecated - public static StaticProvider getProvider(Context context) { - return getProvider(); - } - public static StaticProvider getProvider() { if (sMediaUpdatable != null) return sMediaUpdatable; @@ -79,7 +74,7 @@ public final class ApiLoader { ActivityManager.getService().addPackageDependency(ai.packageName); } - PathClassLoader classLoader = new PathClassLoader(ai.sourceDir, + ClassLoader classLoader = new PathClassLoader(ai.sourceDir, ai.nativeLibraryDir + File.pathSeparator + System.getProperty("java.library.path"), ClassLoader.getSystemClassLoader().getParent()); return sMediaUpdatable = (StaticProvider) classLoader.loadClass(UPDATE_CLASS) diff --git a/media/jni/android_mtp_MtpDatabase.cpp b/media/jni/android_mtp_MtpDatabase.cpp index 23ef84f6ad90..12d7440e3762 100644 --- a/media/jni/android_mtp_MtpDatabase.cpp +++ b/media/jni/android_mtp_MtpDatabase.cpp @@ -39,6 +39,7 @@ extern "C" { #include <android_runtime/AndroidRuntime.h> #include <android_runtime/Log.h> #include <jni.h> +#include <media/stagefright/NuMediaExtractor.h> #include <nativehelper/JNIHelp.h> #include <nativehelper/ScopedLocalRef.h> @@ -788,6 +789,41 @@ static long getLongFromExifEntry(ExifEntry *e) { return exif_get_long(e->data, o); } +static ExifData *getExifFromExtractor(const char *path) { + std::unique_ptr<uint8_t[]> exifBuf; + ExifData *exifdata = NULL; + + FILE *fp = fopen (path, "rb"); + if (!fp) { + ALOGE("failed to open file"); + return NULL; + } + + sp<NuMediaExtractor> extractor = new NuMediaExtractor(); + fseek(fp, 0L, SEEK_END); + if (extractor->setDataSource(fileno(fp), 0, ftell(fp)) != OK) { + ALOGE("failed to setDataSource"); + fclose(fp); + return NULL; + } + + off64_t offset; + size_t size; + if (extractor->getExifOffsetSize(&offset, &size) != OK) { + fclose(fp); + return NULL; + } + + exifBuf.reset(new uint8_t[size]); + fseek(fp, offset, SEEK_SET); + if (fread(exifBuf.get(), 1, size, fp) == size) { + exifdata = exif_data_new_from_data(exifBuf.get(), size); + } + + fclose(fp); + return exifdata; +} + MtpResponseCode MtpDatabase::getObjectInfo(MtpObjectHandle handle, MtpObjectInfo& info) { MtpString path; @@ -834,7 +870,12 @@ MtpResponseCode MtpDatabase::getObjectInfo(MtpObjectHandle handle, case MTP_FORMAT_EXIF_JPEG: case MTP_FORMAT_HEIF: case MTP_FORMAT_JFIF: { - ExifData *exifdata = exif_data_new_from_file(path); + ExifData *exifdata; + if (info.mFormat == MTP_FORMAT_HEIF) { + exifdata = getExifFromExtractor(path); + } else { + exifdata = exif_data_new_from_file(path); + } if (exifdata) { if ((false)) { exif_data_foreach_content(exifdata, foreachcontent, NULL); @@ -892,7 +933,12 @@ void* MtpDatabase::getThumbnail(MtpObjectHandle handle, size_t& outThumbSize) { case MTP_FORMAT_EXIF_JPEG: case MTP_FORMAT_HEIF: case MTP_FORMAT_JFIF: { - ExifData *exifdata = exif_data_new_from_file(path); + ExifData *exifdata; + if (format == MTP_FORMAT_HEIF) { + exifdata = getExifFromExtractor(path); + } else { + exifdata = exif_data_new_from_file(path); + } if (exifdata) { if (exifdata->data) { result = malloc(exifdata->size); diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java index 34aae4953d9d..797b4f9fa9d5 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java @@ -1158,8 +1158,8 @@ class SettingsProtoDumpUtil { Global.CHAINED_BATTERY_ATTRIBUTION_ENABLED, GlobalSettingsProto.CHAINED_BATTERY_ATTRIBUTION_ENABLED); dumpSetting(s, p, - Settings.Global.AUTOFILL_COMPAT_ALLOWED_PACKAGES, - GlobalSettingsProto.AUTOFILL_COMPAT_ALLOWED_PACKAGES); + Settings.Global.AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES, + GlobalSettingsProto.AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES); dumpSetting(s, p, Global.HIDDEN_API_BLACKLIST_EXEMPTIONS, GlobalSettingsProto.HIDDEN_API_BLACKLIST_EXEMPTIONS); diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 3c8a69510f45..375c31a9ba09 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -669,7 +669,7 @@ <string name="ethernet_label">Ethernet</string> <!-- QuickSettings: Onboarding text that introduces users to long press on an option in order to view the option's menu in Settings [CHAR LIMIT=NONE] --> - <string name="quick_settings_header_onboarding_text">Press & hold on the icons for more options</string> + <string name="quick_settings_header_onboarding_text">Touch & hold icons for more options</string> <!-- QuickSettings: Do not disturb [CHAR LIMIT=NONE] --> <string name="quick_settings_dnd_label">Do not disturb</string> <!-- QuickSettings: Do not disturb - Priority only [CHAR LIMIT=NONE] --> diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java index 40b8d78073cf..834feb7781ea 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java @@ -85,6 +85,7 @@ public abstract class QSTileImpl<TState extends State> implements QSTile { private String mTileSpec; private EnforcedAdmin mEnforcedAdmin; private boolean mShowingDetail; + private int mIsFullQs; public abstract TState newTileState(); @@ -110,18 +111,7 @@ public abstract class QSTileImpl<TState extends State> implements QSTile { * listening client it will go into the listening state. */ public void setListening(Object listener, boolean listening) { - if (listening) { - if (mListeners.add(listener) && mListeners.size() == 1) { - if (DEBUG) Log.d(TAG, "setListening " + true); - mHandler.obtainMessage(H.SET_LISTENING, 1, 0).sendToTarget(); - refreshState(); // Ensure we get at least one refresh after listening. - } - } else { - if (mListeners.remove(listener) && mListeners.size() == 0) { - if (DEBUG) Log.d(TAG, "setListening " + false); - mHandler.obtainMessage(H.SET_LISTENING, 0, 0).sendToTarget(); - } - } + mHandler.obtainMessage(H.SET_LISTENING, listening ? 1 : 0, 0, listener).sendToTarget(); } protected long getStaleTimeout() { @@ -205,19 +195,10 @@ public abstract class QSTileImpl<TState extends State> implements QSTile { logMaker.addTaggedData(FIELD_QS_VALUE, ((BooleanState) mState).value ? 1 : 0); } return logMaker.setSubtype(getMetricsCategory()) - .addTaggedData(FIELD_CONTEXT, isFullQs()) + .addTaggedData(FIELD_CONTEXT, mIsFullQs) .addTaggedData(FIELD_QS_POSITION, mHost.indexOf(mTileSpec)); } - private int isFullQs() { - for (Object listener : mListeners) { - if (TilePage.class.equals(listener.getClass())) { - return 1; - } - } - return 0; - } - public void showDetail(boolean show) { mHandler.obtainMessage(H.SHOW_DETAIL, show ? 1 : 0, 0).sendToTarget(); } @@ -352,6 +333,32 @@ public abstract class QSTileImpl<TState extends State> implements QSTile { handleRefreshState(null); } + private void handleSetListeningInternal(Object listener, boolean listening) { + if (listening) { + if (mListeners.add(listener) && mListeners.size() == 1) { + if (DEBUG) Log.d(TAG, "handleSetListening true"); + handleSetListening(listening); + refreshState(); // Ensure we get at least one refresh after listening. + } + } else { + if (mListeners.remove(listener) && mListeners.size() == 0) { + if (DEBUG) Log.d(TAG, "handleSetListening false"); + handleSetListening(listening); + } + } + updateIsFullQs(); + } + + private void updateIsFullQs() { + for (Object listener : mListeners) { + if (TilePage.class.equals(listener.getClass())) { + mIsFullQs = 1; + return; + } + } + mIsFullQs = 0; + } + protected abstract void handleSetListening(boolean listening); protected void handleDestroy() { @@ -464,8 +471,8 @@ public abstract class QSTileImpl<TState extends State> implements QSTile { name = "handleClearState"; handleClearState(); } else if (msg.what == SET_LISTENING) { - name = "handleSetListening"; - handleSetListening(msg.arg1 != 0); + name = "handleSetListeningInternal"; + handleSetListeningInternal(msg.obj, msg.arg1 != 0); } else if (msg.what == STALE) { name = "handleStale"; handleStale(); diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto index 5d2e241e2071..9417f04bbf50 100644 --- a/proto/src/metrics_constants.proto +++ b/proto/src/metrics_constants.proto @@ -3964,7 +3964,8 @@ message MetricsEvent { // Type TYPE_FAILURE: The request failed // Package: Package of app that is autofilled // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request - // Tag FIELD_AUTOFILL_NUM_DATASETS: The number of datasets returned (only in success case) + // Tag FIELD_AUTOFILL_NUM_DATASETS: The number of datasets returned in the response, or -1 if + // the service returned a null response. // NOTE: starting on OS P, it also added: // Type TYPE_CLOSE: Service returned a null response. // Tag FIELD_AUTOFILL_NUM_FIELD_CLASSIFICATION_IDS: if service requested field classification, diff --git a/services/art-profile b/services/art-profile index d2cde029b490..93e580af759a 100644 --- a/services/art-profile +++ b/services/art-profile @@ -10677,7 +10677,6 @@ PLcom/android/server/location/ContextHubService;->sendMessage(IILandroid/hardwar PLcom/android/server/location/CountryDetectorBase;-><init>(Landroid/content/Context;)V PLcom/android/server/location/CountryDetectorBase;->notifyListener(Landroid/location/Country;)V PLcom/android/server/location/CountryDetectorBase;->setCountryListener(Landroid/location/CountryListener;)V -PLcom/android/server/location/FlpHardwareProvider;->isSupported()Z PLcom/android/server/location/GeocoderProxy;-><init>(Landroid/content/Context;IIILandroid/os/Handler;)V PLcom/android/server/location/GeocoderProxy;->bind()Z PLcom/android/server/location/GeocoderProxy;->createAndBind(Landroid/content/Context;IIILandroid/os/Handler;)Lcom/android/server/location/GeocoderProxy; diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java index a5339e0e6549..7409ec210039 100644 --- a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java +++ b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java @@ -575,7 +575,7 @@ public final class AutofillManagerService extends SystemService { private String getWhitelistedCompatModePackagesFromSettings() { return Settings.Global.getString( mContext.getContentResolver(), - Settings.Global.AUTOFILL_COMPAT_ALLOWED_PACKAGES); + Settings.Global.AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES); } @Nullable @@ -1179,7 +1179,7 @@ public final class AutofillManagerService extends SystemService { resolver.registerContentObserver(Settings.Secure.getUriFor( Settings.Secure.USER_SETUP_COMPLETE), false, this, UserHandle.USER_ALL); resolver.registerContentObserver(Settings.Global.getUriFor( - Settings.Global.AUTOFILL_COMPAT_ALLOWED_PACKAGES), false, this, + Settings.Global.AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES), false, this, UserHandle.USER_ALL); } diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index 7f5761516302..55c0372dc3a0 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -596,6 +596,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } if (response == null) { processNullResponseLocked(requestFlags); + mMetricsLogger.write(newLogMaker(MetricsEvent.AUTOFILL_REQUEST, servicePackageName) + .setType(MetricsEvent.TYPE_SUCCESS) + .addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUM_DATASETS, -1)); return; } diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java index 4cac70721128..d6f6c6cf1fc3 100644 --- a/services/backup/java/com/android/server/backup/BackupManagerService.java +++ b/services/backup/java/com/android/server/backup/BackupManagerService.java @@ -215,6 +215,13 @@ public class BackupManagerService implements BackupManagerServiceInterface { // Timeout interval for deciding that a bind or clear-data has taken too long private static final long TIMEOUT_INTERVAL = 10 * 1000; + // Timeout intervals for agent backup & restore operations + public static final long TIMEOUT_BACKUP_INTERVAL = 30 * 1000; + public static final long TIMEOUT_FULL_BACKUP_INTERVAL = 5 * 60 * 1000; + public static final long TIMEOUT_SHARED_BACKUP_INTERVAL = 30 * 60 * 1000; + public static final long TIMEOUT_RESTORE_INTERVAL = 60 * 1000; + public static final long TIMEOUT_RESTORE_FINISHED_INTERVAL = 30 * 1000; + // User confirmation timeout for a full backup/restore operation. It's this long in // order to give them time to enter the backup password. private static final long TIMEOUT_FULL_CONFIRMATION = 60 * 1000; @@ -225,7 +232,6 @@ public class BackupManagerService implements BackupManagerServiceInterface { private static final int BUSY_BACKOFF_FUZZ = 1000 * 60 * 60 * 2; // two hours private BackupManagerConstants mConstants; - private BackupAgentTimeoutParameters mAgentTimeoutParameters; private Context mContext; private PackageManager mPackageManager; private IPackageManager mPackageManagerBinder; @@ -309,10 +315,6 @@ public class BackupManagerService implements BackupManagerServiceInterface { return mConstants; } - public BackupAgentTimeoutParameters getAgentTimeoutParameters() { - return mAgentTimeoutParameters; - } - public Context getContext() { return mContext; } @@ -854,10 +856,6 @@ public class BackupManagerService implements BackupManagerServiceInterface { // require frequent starting and stopping. mConstants.start(); - mAgentTimeoutParameters = new - BackupAgentTimeoutParameters(mBackupHandler, mContext.getContentResolver()); - mAgentTimeoutParameters.start(); - // Set up the various sorts of package tracking we do mFullBackupScheduleFile = new File(mBaseStateDir, "fb-schedule"); initPackageTracking(); @@ -3409,7 +3407,7 @@ public class BackupManagerService implements BackupManagerServiceInterface { } mActiveRestoreSession = new ActiveRestoreSession(this, packageName, transport); mBackupHandler.sendEmptyMessageDelayed(MSG_RESTORE_SESSION_TIMEOUT, - mAgentTimeoutParameters.getRestoreAgentTimeoutMillis()); + TIMEOUT_RESTORE_INTERVAL); } return mActiveRestoreSession; } diff --git a/services/backup/java/com/android/server/backup/BackupManagerServiceInterface.java b/services/backup/java/com/android/server/backup/BackupManagerServiceInterface.java index aabe7f611845..7b021c64eaf8 100644 --- a/services/backup/java/com/android/server/backup/BackupManagerServiceInterface.java +++ b/services/backup/java/com/android/server/backup/BackupManagerServiceInterface.java @@ -191,7 +191,4 @@ public interface BackupManagerServiceInterface { void dump(FileDescriptor fd, PrintWriter pw, String[] args); IBackupManager getBackupManagerBinder(); - - // Gets access to the backup/restore agent timeout parameters. - BackupAgentTimeoutParameters getAgentTimeoutParameters(); } diff --git a/services/backup/java/com/android/server/backup/KeyValueAdbBackupEngine.java b/services/backup/java/com/android/server/backup/KeyValueAdbBackupEngine.java index f08c65597a4b..47558775d19e 100644 --- a/services/backup/java/com/android/server/backup/KeyValueAdbBackupEngine.java +++ b/services/backup/java/com/android/server/backup/KeyValueAdbBackupEngine.java @@ -4,8 +4,8 @@ import static android.os.ParcelFileDescriptor.MODE_CREATE; import static android.os.ParcelFileDescriptor.MODE_READ_ONLY; import static android.os.ParcelFileDescriptor.MODE_READ_WRITE; import static android.os.ParcelFileDescriptor.MODE_TRUNCATE; - import static com.android.server.backup.BackupManagerService.OP_TYPE_BACKUP_WAIT; +import static com.android.server.backup.BackupManagerService.TIMEOUT_BACKUP_INTERVAL; import android.app.ApplicationThreadConstants; import android.app.IBackupAgent; @@ -59,7 +59,6 @@ public class KeyValueAdbBackupEngine { private ParcelFileDescriptor mSavedState; private ParcelFileDescriptor mBackupData; private ParcelFileDescriptor mNewState; - private final BackupAgentTimeoutParameters mAgentTimeoutParameters; public KeyValueAdbBackupEngine(OutputStream output, PackageInfo packageInfo, BackupManagerServiceInterface backupManagerService, PackageManager packageManager, @@ -82,7 +81,6 @@ public class KeyValueAdbBackupEngine { pkg + BACKUP_KEY_VALUE_NEW_STATE_FILENAME_SUFFIX); mManifestFile = new File(mDataDir, BackupManagerService.BACKUP_MANIFEST_FILENAME); - mAgentTimeoutParameters = backupManagerService.getAgentTimeoutParameters(); } public void backupOnePackage() throws IOException { @@ -150,9 +148,8 @@ public class KeyValueAdbBackupEngine { // Return true on backup success, false otherwise private boolean invokeAgentForAdbBackup(String packageName, IBackupAgent agent) { int token = mBackupManagerService.generateRandomIntegerToken(); - long kvBackupAgentTimeoutMillis = mAgentTimeoutParameters.getKvBackupAgentTimeoutMillis(); try { - mBackupManagerService.prepareOperationTimeout(token, kvBackupAgentTimeoutMillis, null, + mBackupManagerService.prepareOperationTimeout(token, TIMEOUT_BACKUP_INTERVAL, null, OP_TYPE_BACKUP_WAIT); // Start backup and wait for BackupManagerService to get callback for success or timeout @@ -234,14 +231,14 @@ public class KeyValueAdbBackupEngine { } private void writeBackupData() throws IOException { + int token = mBackupManagerService.generateRandomIntegerToken(); - long kvBackupAgentTimeoutMillis = mAgentTimeoutParameters.getKvBackupAgentTimeoutMillis(); ParcelFileDescriptor[] pipes = null; try { pipes = ParcelFileDescriptor.createPipe(); - mBackupManagerService.prepareOperationTimeout(token, kvBackupAgentTimeoutMillis, null, + mBackupManagerService.prepareOperationTimeout(token, TIMEOUT_BACKUP_INTERVAL, null, OP_TYPE_BACKUP_WAIT); // We will have to create a runnable that will read the manifest and backup data we diff --git a/services/backup/java/com/android/server/backup/fullbackup/FullBackupEngine.java b/services/backup/java/com/android/server/backup/fullbackup/FullBackupEngine.java index 597da21c7204..0582abac91d4 100644 --- a/services/backup/java/com/android/server/backup/fullbackup/FullBackupEngine.java +++ b/services/backup/java/com/android/server/backup/fullbackup/FullBackupEngine.java @@ -25,6 +25,9 @@ import static com.android.server.backup.BackupManagerService.MORE_DEBUG; import static com.android.server.backup.BackupManagerService.OP_TYPE_BACKUP_WAIT; import static com.android.server.backup.BackupManagerService.SHARED_BACKUP_AGENT_PACKAGE; import static com.android.server.backup.BackupManagerService.TAG; +import static com.android.server.backup.BackupManagerService.TIMEOUT_FULL_BACKUP_INTERVAL; +import static com.android.server.backup.BackupManagerService + .TIMEOUT_SHARED_BACKUP_INTERVAL; import android.app.ApplicationThreadConstants; import android.app.IBackupAgent; @@ -42,9 +45,8 @@ import android.util.Slog; import android.util.StringBuilderPrinter; import com.android.server.AppWidgetBackupBridge; -import com.android.server.backup.BackupAgentTimeoutParameters; -import com.android.server.backup.BackupManagerService; import com.android.server.backup.BackupRestoreTask; +import com.android.server.backup.BackupManagerService; import com.android.server.backup.utils.FullBackupUtils; import java.io.BufferedOutputStream; @@ -73,7 +75,6 @@ public class FullBackupEngine { private final long mQuota; private final int mOpToken; private final int mTransportFlags; - private final BackupAgentTimeoutParameters mAgentTimeoutParameters; class FullBackupRunner implements Runnable { @@ -136,8 +137,8 @@ public class FullBackupEngine { final boolean isSharedStorage = mPackage.packageName.equals(SHARED_BACKUP_AGENT_PACKAGE); final long timeout = isSharedStorage ? - mAgentTimeoutParameters.getSharedBackupAgentTimeoutMillis() : - mAgentTimeoutParameters.getFullBackupAgentTimeoutMillis(); + TIMEOUT_SHARED_BACKUP_INTERVAL : + TIMEOUT_FULL_BACKUP_INTERVAL; if (DEBUG) { Slog.d(TAG, "Calling doFullBackup() on " + mPackage.packageName); @@ -179,7 +180,6 @@ public class FullBackupEngine { mQuota = quota; mOpToken = opToken; mTransportFlags = transportFlags; - mAgentTimeoutParameters = backupManagerService.getAgentTimeoutParameters(); } public int preflightCheck() throws RemoteException { diff --git a/services/backup/java/com/android/server/backup/fullbackup/FullBackupObbConnection.java b/services/backup/java/com/android/server/backup/fullbackup/FullBackupObbConnection.java index d441cf6a78e1..40b6967a729a 100644 --- a/services/backup/java/com/android/server/backup/fullbackup/FullBackupObbConnection.java +++ b/services/backup/java/com/android/server/backup/fullbackup/FullBackupObbConnection.java @@ -19,6 +19,7 @@ package com.android.server.backup.fullbackup; import static com.android.server.backup.BackupManagerService.MORE_DEBUG; import static com.android.server.backup.BackupManagerService.OP_TYPE_BACKUP_WAIT; import static com.android.server.backup.BackupManagerService.TAG; +import static com.android.server.backup.BackupManagerService.TIMEOUT_FULL_BACKUP_INTERVAL; import android.app.backup.IBackupManager; import android.content.ComponentName; @@ -32,7 +33,6 @@ import android.os.UserHandle; import android.util.Slog; import com.android.internal.backup.IObbBackupService; -import com.android.server.backup.BackupAgentTimeoutParameters; import com.android.server.backup.BackupManagerService; import com.android.server.backup.utils.FullBackupUtils; @@ -46,12 +46,10 @@ public class FullBackupObbConnection implements ServiceConnection { private BackupManagerService backupManagerService; volatile IObbBackupService mService; - private final BackupAgentTimeoutParameters mAgentTimeoutParameters; public FullBackupObbConnection(BackupManagerService backupManagerService) { this.backupManagerService = backupManagerService; mService = null; - mAgentTimeoutParameters = backupManagerService.getAgentTimeoutParameters(); } public void establish() { @@ -77,10 +75,8 @@ public class FullBackupObbConnection implements ServiceConnection { try { pipes = ParcelFileDescriptor.createPipe(); int token = backupManagerService.generateRandomIntegerToken(); - long fullBackupAgentTimeoutMillis = - mAgentTimeoutParameters.getFullBackupAgentTimeoutMillis(); backupManagerService.prepareOperationTimeout( - token, fullBackupAgentTimeoutMillis, null, OP_TYPE_BACKUP_WAIT); + token, TIMEOUT_FULL_BACKUP_INTERVAL, null, OP_TYPE_BACKUP_WAIT); mService.backupObbs(pkg.packageName, pipes[1], token, backupManagerService.getBackupManagerBinder()); FullBackupUtils.routeSocketDataToOutput(pipes[0], out); diff --git a/services/backup/java/com/android/server/backup/fullbackup/PerformFullTransportBackupTask.java b/services/backup/java/com/android/server/backup/fullbackup/PerformFullTransportBackupTask.java index 1ea3eb5fc2e8..2c2dd8528cb1 100644 --- a/services/backup/java/com/android/server/backup/fullbackup/PerformFullTransportBackupTask.java +++ b/services/backup/java/com/android/server/backup/fullbackup/PerformFullTransportBackupTask.java @@ -22,6 +22,7 @@ import static com.android.server.backup.BackupManagerService.MORE_DEBUG; import static com.android.server.backup.BackupManagerService.OP_PENDING; import static com.android.server.backup.BackupManagerService.OP_TYPE_BACKUP; import static com.android.server.backup.BackupManagerService.OP_TYPE_BACKUP_WAIT; +import static com.android.server.backup.BackupManagerService.TIMEOUT_FULL_BACKUP_INTERVAL; import android.annotation.Nullable; import android.app.IBackupAgent; @@ -43,7 +44,6 @@ import android.util.Slog; import com.android.internal.backup.IBackupTransport; import com.android.server.EventLogTags; -import com.android.server.backup.BackupAgentTimeoutParameters; import com.android.server.backup.BackupRestoreTask; import com.android.server.backup.FullBackupJob; import com.android.server.backup.BackupManagerService; @@ -146,7 +146,6 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba private volatile boolean mIsDoingBackup; private volatile boolean mCancelAll; private final int mCurrentOpToken; - private final BackupAgentTimeoutParameters mAgentTimeoutParameters; public PerformFullTransportBackupTask(BackupManagerService backupManagerService, TransportClient transportClient, @@ -168,7 +167,6 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba mUserInitiated = userInitiated; mCurrentOpToken = backupManagerService.generateRandomIntegerToken(); mBackupRunnerOpToken = backupManagerService.generateRandomIntegerToken(); - mAgentTimeoutParameters = backupManagerService.getAgentTimeoutParameters(); if (backupManagerService.isBackupOperationInProgress()) { if (DEBUG) { @@ -700,11 +698,9 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba @Override public int preflightFullBackup(PackageInfo pkg, IBackupAgent agent) { int result; - long fullBackupAgentTimeoutMillis = - mAgentTimeoutParameters.getFullBackupAgentTimeoutMillis(); try { backupManagerService.prepareOperationTimeout( - mCurrentOpToken, fullBackupAgentTimeoutMillis, this, OP_TYPE_BACKUP_WAIT); + mCurrentOpToken, TIMEOUT_FULL_BACKUP_INTERVAL, this, OP_TYPE_BACKUP_WAIT); backupManagerService.addBackupTrace("preflighting"); if (MORE_DEBUG) { Slog.d(TAG, "Preflighting full payload of " + pkg.packageName); @@ -717,7 +713,7 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba // timeout had been produced. In case of a real backstop timeout, mResult // will still contain the value it was constructed with, AGENT_ERROR, which // intentionaly falls into the "just report failure" code. - mLatch.await(fullBackupAgentTimeoutMillis, TimeUnit.MILLISECONDS); + mLatch.await(TIMEOUT_FULL_BACKUP_INTERVAL, TimeUnit.MILLISECONDS); long totalSize = mResult.get(); // If preflight timed out, mResult will contain error code as int. @@ -773,10 +769,8 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba @Override public long getExpectedSizeOrErrorCode() { - long fullBackupAgentTimeoutMillis = - mAgentTimeoutParameters.getFullBackupAgentTimeoutMillis(); try { - mLatch.await(fullBackupAgentTimeoutMillis, TimeUnit.MILLISECONDS); + mLatch.await(TIMEOUT_FULL_BACKUP_INTERVAL, TimeUnit.MILLISECONDS); return mResult.get(); } catch (InterruptedException e) { return BackupTransport.NO_MORE_DATA; @@ -869,10 +863,8 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba // If preflight succeeded, returns positive number - preflight size, // otherwise return negative error code. long getPreflightResultBlocking() { - long fullBackupAgentTimeoutMillis = - mAgentTimeoutParameters.getFullBackupAgentTimeoutMillis(); try { - mPreflightLatch.await(fullBackupAgentTimeoutMillis, TimeUnit.MILLISECONDS); + mPreflightLatch.await(TIMEOUT_FULL_BACKUP_INTERVAL, TimeUnit.MILLISECONDS); if (mIsCancelled) { return BackupManager.ERROR_BACKUP_CANCELLED; } @@ -887,10 +879,8 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba } int getBackupResultBlocking() { - long fullBackupAgentTimeoutMillis = - mAgentTimeoutParameters.getFullBackupAgentTimeoutMillis(); try { - mBackupLatch.await(fullBackupAgentTimeoutMillis, TimeUnit.MILLISECONDS); + mBackupLatch.await(TIMEOUT_FULL_BACKUP_INTERVAL, TimeUnit.MILLISECONDS); if (mIsCancelled) { return BackupManager.ERROR_BACKUP_CANCELLED; } diff --git a/services/backup/java/com/android/server/backup/internal/BackupHandler.java b/services/backup/java/com/android/server/backup/internal/BackupHandler.java index 58868627ee2b..136fada43b1f 100644 --- a/services/backup/java/com/android/server/backup/internal/BackupHandler.java +++ b/services/backup/java/com/android/server/backup/internal/BackupHandler.java @@ -19,6 +19,7 @@ package com.android.server.backup.internal; import static com.android.server.backup.BackupManagerService.DEBUG; import static com.android.server.backup.BackupManagerService.MORE_DEBUG; import static com.android.server.backup.BackupManagerService.TAG; +import static com.android.server.backup.BackupManagerService.TIMEOUT_RESTORE_INTERVAL; import android.app.backup.RestoreSet; import android.content.Intent; @@ -33,7 +34,6 @@ import android.util.Slog; import com.android.internal.backup.IBackupTransport; import com.android.server.EventLogTags; -import com.android.server.backup.BackupAgentTimeoutParameters; import com.android.server.backup.BackupManagerService; import com.android.server.backup.BackupRestoreTask; import com.android.server.backup.DataChangedJournal; @@ -81,12 +81,10 @@ public class BackupHandler extends Handler { public static final int MSG_OP_COMPLETE = 21; private final BackupManagerService backupManagerService; - private final BackupAgentTimeoutParameters mAgentTimeoutParameters; public BackupHandler(BackupManagerService backupManagerService, Looper looper) { super(looper); this.backupManagerService = backupManagerService; - mAgentTimeoutParameters = backupManagerService.getAgentTimeoutParameters(); } public void handleMessage(Message msg) { @@ -324,8 +322,7 @@ public class BackupHandler extends Handler { // Done: reset the session timeout clock removeMessages(MSG_RESTORE_SESSION_TIMEOUT); - sendEmptyMessageDelayed(MSG_RESTORE_SESSION_TIMEOUT, - mAgentTimeoutParameters.getRestoreAgentTimeoutMillis()); + sendEmptyMessageDelayed(MSG_RESTORE_SESSION_TIMEOUT, TIMEOUT_RESTORE_INTERVAL); params.listener.onFinished(callerLogString); } diff --git a/services/backup/java/com/android/server/backup/internal/PerformBackupTask.java b/services/backup/java/com/android/server/backup/internal/PerformBackupTask.java index 0313066656d8..11394e66a0f0 100644 --- a/services/backup/java/com/android/server/backup/internal/PerformBackupTask.java +++ b/services/backup/java/com/android/server/backup/internal/PerformBackupTask.java @@ -24,6 +24,7 @@ import static com.android.server.backup.BackupManagerService.OP_PENDING; import static com.android.server.backup.BackupManagerService.OP_TYPE_BACKUP; import static com.android.server.backup.BackupManagerService.OP_TYPE_BACKUP_WAIT; import static com.android.server.backup.BackupManagerService.PACKAGE_MANAGER_SENTINEL; +import static com.android.server.backup.BackupManagerService.TIMEOUT_BACKUP_INTERVAL; import static com.android.server.backup.internal.BackupHandler.MSG_BACKUP_OPERATION_TIMEOUT; import static com.android.server.backup.internal.BackupHandler.MSG_BACKUP_RESTORE_STEP; @@ -56,7 +57,6 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.backup.IBackupTransport; import com.android.server.AppWidgetBackupBridge; import com.android.server.EventLogTags; -import com.android.server.backup.BackupAgentTimeoutParameters; import com.android.server.backup.BackupRestoreTask; import com.android.server.backup.DataChangedJournal; import com.android.server.backup.KeyValueBackupJob; @@ -142,7 +142,6 @@ public class PerformBackupTask implements BackupRestoreTask { private boolean mFinished; private final boolean mUserInitiated; private final boolean mNonIncremental; - private final BackupAgentTimeoutParameters mAgentTimeoutParameters; private volatile boolean mCancelAll; @@ -163,7 +162,6 @@ public class PerformBackupTask implements BackupRestoreTask { mPendingFullBackups = pendingFullBackups; mUserInitiated = userInitiated; mNonIncremental = nonIncremental; - mAgentTimeoutParameters = backupManagerService.getAgentTimeoutParameters(); mStateDir = new File(backupManagerService.getBaseStateDir(), dirName); mCurrentOpToken = backupManagerService.generateRandomIntegerToken(); @@ -713,10 +711,8 @@ public class PerformBackupTask implements BackupRestoreTask { // Initiate the target's backup pass backupManagerService.addBackupTrace("setting timeout"); - long kvBackupAgentTimeoutMillis = - mAgentTimeoutParameters.getKvBackupAgentTimeoutMillis(); backupManagerService.prepareOperationTimeout( - mEphemeralOpToken, kvBackupAgentTimeoutMillis, this, OP_TYPE_BACKUP_WAIT); + mEphemeralOpToken, TIMEOUT_BACKUP_INTERVAL, this, OP_TYPE_BACKUP_WAIT); backupManagerService.addBackupTrace("calling agent doBackup()"); agent.doBackup( diff --git a/services/backup/java/com/android/server/backup/restore/AdbRestoreFinishedLatch.java b/services/backup/java/com/android/server/backup/restore/AdbRestoreFinishedLatch.java index 6175629d7451..e4f3a9d5cd0a 100644 --- a/services/backup/java/com/android/server/backup/restore/AdbRestoreFinishedLatch.java +++ b/services/backup/java/com/android/server/backup/restore/AdbRestoreFinishedLatch.java @@ -18,10 +18,10 @@ package com.android.server.backup.restore; import static com.android.server.backup.BackupManagerService.DEBUG; import static com.android.server.backup.BackupManagerService.MORE_DEBUG; +import static com.android.server.backup.BackupManagerService.TIMEOUT_FULL_BACKUP_INTERVAL; import android.util.Slog; -import com.android.server.backup.BackupAgentTimeoutParameters; import com.android.server.backup.BackupManagerService; import com.android.server.backup.BackupRestoreTask; @@ -37,22 +37,18 @@ public class AdbRestoreFinishedLatch implements BackupRestoreTask { private BackupManagerService backupManagerService; final CountDownLatch mLatch; private final int mCurrentOpToken; - private final BackupAgentTimeoutParameters mAgentTimeoutParameters; public AdbRestoreFinishedLatch(BackupManagerService backupManagerService, int currentOpToken) { this.backupManagerService = backupManagerService; mLatch = new CountDownLatch(1); mCurrentOpToken = currentOpToken; - mAgentTimeoutParameters = backupManagerService.getAgentTimeoutParameters(); } void await() { boolean latched = false; - long fullBackupAgentTimeoutMillis = - mAgentTimeoutParameters.getFullBackupAgentTimeoutMillis(); try { - latched = mLatch.await(fullBackupAgentTimeoutMillis, TimeUnit.MILLISECONDS); + latched = mLatch.await(TIMEOUT_FULL_BACKUP_INTERVAL, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Slog.w(TAG, "Interrupted!"); } diff --git a/services/backup/java/com/android/server/backup/restore/FullRestoreEngine.java b/services/backup/java/com/android/server/backup/restore/FullRestoreEngine.java index f168afed55ea..c1a1c1dc10e7 100644 --- a/services/backup/java/com/android/server/backup/restore/FullRestoreEngine.java +++ b/services/backup/java/com/android/server/backup/restore/FullRestoreEngine.java @@ -23,6 +23,9 @@ import static com.android.server.backup.BackupManagerService.MORE_DEBUG; import static com.android.server.backup.BackupManagerService.OP_TYPE_RESTORE_WAIT; import static com.android.server.backup.BackupManagerService.SHARED_BACKUP_AGENT_PACKAGE; import static com.android.server.backup.BackupManagerService.TAG; +import static com.android.server.backup.BackupManagerService.TIMEOUT_RESTORE_INTERVAL; +import static com.android.server.backup.BackupManagerService + .TIMEOUT_SHARED_BACKUP_INTERVAL; import static com.android.server.backup.internal.BackupHandler.MSG_RESTORE_OPERATION_TIMEOUT; import android.app.ApplicationThreadConstants; @@ -40,11 +43,10 @@ import android.os.RemoteException; import android.util.Slog; import com.android.server.LocalServices; -import com.android.server.backup.BackupAgentTimeoutParameters; -import com.android.server.backup.BackupManagerService; import com.android.server.backup.BackupRestoreTask; import com.android.server.backup.FileMetadata; import com.android.server.backup.KeyValueAdbRestoreEngine; +import com.android.server.backup.BackupManagerService; import com.android.server.backup.fullbackup.FullBackupObbConnection; import com.android.server.backup.utils.BytesReadListener; import com.android.server.backup.utils.FullBackupRestoreObserverUtils; @@ -119,8 +121,6 @@ public class FullRestoreEngine extends RestoreEngine { final int mEphemeralOpToken; - private final BackupAgentTimeoutParameters mAgentTimeoutParameters; - public FullRestoreEngine(BackupManagerService backupManagerService, BackupRestoreTask monitorTask, IFullBackupRestoreObserver observer, IBackupManagerMonitor monitor, PackageInfo onlyPackage, boolean allowApks, @@ -135,7 +135,6 @@ public class FullRestoreEngine extends RestoreEngine { mAllowObbs = allowObbs; mBuffer = new byte[32 * 1024]; mBytes = 0; - mAgentTimeoutParameters = backupManagerService.getAgentTimeoutParameters(); } public IBackupAgent getAgent() { @@ -382,8 +381,8 @@ public class FullRestoreEngine extends RestoreEngine { long toCopy = info.size; final boolean isSharedStorage = pkg.equals(SHARED_BACKUP_AGENT_PACKAGE); final long timeout = isSharedStorage ? - mAgentTimeoutParameters.getSharedBackupAgentTimeoutMillis() : - mAgentTimeoutParameters.getRestoreAgentTimeoutMillis(); + TIMEOUT_SHARED_BACKUP_INTERVAL : + TIMEOUT_RESTORE_INTERVAL; try { mBackupManagerService.prepareOperationTimeout(token, timeout, diff --git a/services/backup/java/com/android/server/backup/restore/PerformAdbRestoreTask.java b/services/backup/java/com/android/server/backup/restore/PerformAdbRestoreTask.java index 221637cae191..dacde0b9af68 100644 --- a/services/backup/java/com/android/server/backup/restore/PerformAdbRestoreTask.java +++ b/services/backup/java/com/android/server/backup/restore/PerformAdbRestoreTask.java @@ -16,6 +16,8 @@ package com.android.server.backup.restore; +import static com.android.server.backup.BackupPasswordManager.PBKDF_CURRENT; +import static com.android.server.backup.BackupPasswordManager.PBKDF_FALLBACK; import static com.android.server.backup.BackupManagerService.BACKUP_FILE_HEADER_MAGIC; import static com.android.server.backup.BackupManagerService.BACKUP_FILE_VERSION; import static com.android.server.backup.BackupManagerService.BACKUP_MANIFEST_FILENAME; @@ -26,8 +28,8 @@ import static com.android.server.backup.BackupManagerService.OP_TYPE_RESTORE_WAI import static com.android.server.backup.BackupManagerService.SETTINGS_PACKAGE; import static com.android.server.backup.BackupManagerService.SHARED_BACKUP_AGENT_PACKAGE; import static com.android.server.backup.BackupManagerService.TAG; -import static com.android.server.backup.BackupPasswordManager.PBKDF_CURRENT; -import static com.android.server.backup.BackupPasswordManager.PBKDF_FALLBACK; +import static com.android.server.backup.BackupManagerService.TIMEOUT_FULL_BACKUP_INTERVAL; +import static com.android.server.backup.BackupManagerService.TIMEOUT_RESTORE_INTERVAL; import static com.android.server.backup.internal.BackupHandler.MSG_RESTORE_OPERATION_TIMEOUT; import android.app.ApplicationThreadConstants; @@ -47,7 +49,6 @@ import android.util.Slog; import com.android.internal.annotations.VisibleForTesting; import com.android.server.LocalServices; -import com.android.server.backup.BackupAgentTimeoutParameters; import com.android.server.backup.BackupManagerService; import com.android.server.backup.FileMetadata; import com.android.server.backup.KeyValueAdbRestoreEngine; @@ -100,7 +101,6 @@ public class PerformAdbRestoreTask implements Runnable { private byte[] mWidgetData = null; private long mBytes; - private final BackupAgentTimeoutParameters mAgentTimeoutParameters; // Runner that can be placed on a separate thread to do in-process invocation // of the "restore finished" API asynchronously. Used by adb restore. @@ -155,7 +155,6 @@ public class PerformAdbRestoreTask implements Runnable { mAgentPackage = null; mTargetApp = null; mObbConnection = new FullBackupObbConnection(backupManagerService); - mAgentTimeoutParameters = backupManagerService.getAgentTimeoutParameters(); // Which packages we've already wiped data on. We prepopulate this // with a whitelist of packages known to be unclearable. @@ -644,11 +643,9 @@ public class PerformAdbRestoreTask implements Runnable { if (okay) { boolean agentSuccess = true; long toCopy = info.size; - long restoreAgentTimeoutMillis = - mAgentTimeoutParameters.getRestoreAgentTimeoutMillis(); try { mBackupManagerService.prepareOperationTimeout( - token, restoreAgentTimeoutMillis, null, OP_TYPE_RESTORE_WAIT); + token, TIMEOUT_RESTORE_INTERVAL, null, OP_TYPE_RESTORE_WAIT); if (FullBackup.OBB_TREE_TOKEN.equals(info.domain)) { if (DEBUG) { @@ -823,12 +820,10 @@ public class PerformAdbRestoreTask implements Runnable { // In the adb restore case, we do restore-finished here if (doRestoreFinished) { final int token = mBackupManagerService.generateRandomIntegerToken(); - long fullBackupAgentTimeoutMillis = - mAgentTimeoutParameters.getFullBackupAgentTimeoutMillis(); final AdbRestoreFinishedLatch latch = new AdbRestoreFinishedLatch( mBackupManagerService, token); mBackupManagerService.prepareOperationTimeout( - token, fullBackupAgentTimeoutMillis, latch, OP_TYPE_RESTORE_WAIT); + token, TIMEOUT_FULL_BACKUP_INTERVAL, latch, OP_TYPE_RESTORE_WAIT); if (mTargetApp.processName.equals("system")) { if (MORE_DEBUG) { Slog.d(TAG, "system agent - restoreFinished on thread"); diff --git a/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java b/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java index 069e3b6c8247..4b467e5a0399 100644 --- a/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java +++ b/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java @@ -23,6 +23,9 @@ import static com.android.server.backup.BackupManagerService.OP_TYPE_RESTORE_WAI import static com.android.server.backup.BackupManagerService.PACKAGE_MANAGER_SENTINEL; import static com.android.server.backup.BackupManagerService.SETTINGS_PACKAGE; import static com.android.server.backup.BackupManagerService.TAG; +import static com.android.server.backup.BackupManagerService + .TIMEOUT_RESTORE_FINISHED_INTERVAL; +import static com.android.server.backup.BackupManagerService.TIMEOUT_RESTORE_INTERVAL; import static com.android.server.backup.internal.BackupHandler.MSG_BACKUP_RESTORE_STEP; import static com.android.server.backup.internal.BackupHandler.MSG_RESTORE_OPERATION_TIMEOUT; import static com.android.server.backup.internal.BackupHandler.MSG_RESTORE_SESSION_TIMEOUT; @@ -56,7 +59,6 @@ import com.android.internal.backup.IBackupTransport; import com.android.server.AppWidgetBackupBridge; import com.android.server.EventLogTags; import com.android.server.LocalServices; -import com.android.server.backup.BackupAgentTimeoutParameters; import com.android.server.backup.BackupRestoreTask; import com.android.server.backup.BackupUtils; import com.android.server.backup.PackageManagerBackupAgent; @@ -158,7 +160,6 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { ParcelFileDescriptor mNewState; private final int mEphemeralOpToken; - private final BackupAgentTimeoutParameters mAgentTimeoutParameters; // This task can assume that the wakelock is properly held for it and doesn't have to worry // about releasing it. @@ -189,7 +190,6 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { mFinished = false; mDidLaunch = false; mListener = listener; - mAgentTimeoutParameters = backupManagerService.getAgentTimeoutParameters(); if (targetPackage != null) { // Single package restore @@ -760,9 +760,8 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { // Kick off the restore, checking for hung agents. The timeout or // the operationComplete() callback will schedule the next step, // so we do not do that here. - long restoreAgentTimeoutMillis = mAgentTimeoutParameters.getRestoreAgentTimeoutMillis(); backupManagerService.prepareOperationTimeout( - mEphemeralOpToken, restoreAgentTimeoutMillis, this, OP_TYPE_RESTORE_WAIT); + mEphemeralOpToken, TIMEOUT_RESTORE_INTERVAL, this, OP_TYPE_RESTORE_WAIT); mAgent.doRestore(mBackupData, appVersionCode, mNewState, mEphemeralOpToken, backupManagerService.getBackupManagerBinder()); } catch (Exception e) { @@ -814,11 +813,9 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { Slog.d(TAG, "restoreFinished packageName=" + mCurrentPackage.packageName); } try { - long restoreAgentFinishedTimeoutMillis = - mAgentTimeoutParameters.getRestoreAgentFinishedTimeoutMillis(); backupManagerService .prepareOperationTimeout(mEphemeralOpToken, - restoreAgentFinishedTimeoutMillis, this, + TIMEOUT_RESTORE_FINISHED_INTERVAL, this, OP_TYPE_RESTORE_WAIT); mAgent.doRestoreFinished(mEphemeralOpToken, backupManagerService.getBackupManagerBinder()); @@ -1112,10 +1109,9 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { } else { // We were invoked via an active restore session, not by the Package // Manager, so start up the session timeout again. - long restoreAgentTimeoutMillis = mAgentTimeoutParameters.getRestoreAgentTimeoutMillis(); backupManagerService.getBackupHandler().sendEmptyMessageDelayed( MSG_RESTORE_SESSION_TIMEOUT, - restoreAgentTimeoutMillis); + TIMEOUT_RESTORE_INTERVAL); } // Kick off any work that may be needed regarding app widget restores diff --git a/services/core/java/com/android/server/BinderCallsStatsService.java b/services/core/java/com/android/server/BinderCallsStatsService.java new file mode 100644 index 000000000000..2ed451610354 --- /dev/null +++ b/services/core/java/com/android/server/BinderCallsStatsService.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.server; + +import android.os.Binder; +import android.os.ServiceManager; +import android.os.SystemProperties; +import android.util.Slog; + +import com.android.internal.os.BinderCallsStats; + +import java.io.FileDescriptor; +import java.io.PrintWriter; + +public class BinderCallsStatsService extends Binder { + + private static final String TAG = "BinderCallsStatsService"; + + private static final String PERSIST_SYS_BINDER_CPU_STATS_TRACKING + = "persist.sys.binder_cpu_stats_tracking"; + + public static void start() { + BinderCallsStatsService service = new BinderCallsStatsService(); + ServiceManager.addService("binder_calls_stats", service); + // TODO Enable by default on eng/userdebug builds + boolean trackingEnabledDefault = false; + boolean trackingEnabled = SystemProperties.getBoolean(PERSIST_SYS_BINDER_CPU_STATS_TRACKING, + trackingEnabledDefault); + + if (trackingEnabled) { + Slog.i(TAG, "Enabled CPU usage tracking for binder calls. Controlled by " + + PERSIST_SYS_BINDER_CPU_STATS_TRACKING); + BinderCallsStats.getInstance().setTrackingEnabled(true); + } + } + + @Override + protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + BinderCallsStats.getInstance().dump(pw); + } +} diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index 5b57c14c1115..f6ff359d8c19 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -3663,16 +3663,21 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } + boolean reenableMinimumNonAuxSystemImes = false; // TODO: The following code should find better place to live. if (!resetDefaultEnabledIme) { boolean enabledImeFound = false; + boolean enabledNonAuxImeFound = false; final List<InputMethodInfo> enabledImes = mSettings.getEnabledInputMethodListLocked(); final int N = enabledImes.size(); for (int i = 0; i < N; ++i) { final InputMethodInfo imi = enabledImes.get(i); if (mMethodList.contains(imi)) { enabledImeFound = true; - break; + if (!imi.isAuxiliaryIme()) { + enabledNonAuxImeFound = true; + break; + } } } if (!enabledImeFound) { @@ -3681,12 +3686,18 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } resetDefaultEnabledIme = true; resetSelectedInputMethodAndSubtypeLocked(""); + } else if (!enabledNonAuxImeFound) { + if (DEBUG) { + Slog.i(TAG, "All the enabled non-Aux IMEs are gone. Do partial reset."); + } + reenableMinimumNonAuxSystemImes = true; } } - if (resetDefaultEnabledIme) { + if (resetDefaultEnabledIme || reenableMinimumNonAuxSystemImes) { final ArrayList<InputMethodInfo> defaultEnabledIme = - InputMethodUtils.getDefaultEnabledImes(mContext, mMethodList); + InputMethodUtils.getDefaultEnabledImes(mContext, mMethodList, + reenableMinimumNonAuxSystemImes); final int N = defaultEnabledIme.size(); for (int i = 0; i < N; ++i) { final InputMethodInfo imi = defaultEnabledIme.get(i); diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java index 65e90bad41a7..26b83f5ae0c3 100644 --- a/services/core/java/com/android/server/LocationManagerService.java +++ b/services/core/java/com/android/server/LocationManagerService.java @@ -19,6 +19,7 @@ package com.android.server; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import android.annotation.NonNull; +import android.annotation.Nullable; import android.app.ActivityManager; import android.app.AppOpsManager; import android.app.PendingIntent; @@ -82,8 +83,6 @@ import com.android.internal.os.BackgroundThread; import com.android.internal.util.ArrayUtils; import com.android.internal.util.DumpUtils; import com.android.server.location.ActivityRecognitionProxy; -import com.android.server.location.FlpHardwareProvider; -import com.android.server.location.FusedProxy; import com.android.server.location.GeocoderProxy; import com.android.server.location.GeofenceManager; import com.android.server.location.GeofenceProxy; @@ -491,13 +490,6 @@ public class LocationManagerService extends ILocationManager.Stub { if (gpsProvider != null && gpsProvider.isEnabled()) { gpsProvider.disable(); } - - // it is needed to check if FLP HW provider is supported before accessing the instance, this - // avoids an exception to be thrown by the singleton factory method - if (FlpHardwareProvider.isSupported()) { - FlpHardwareProvider flpHardwareProvider = FlpHardwareProvider.getInstance(mContext); - flpHardwareProvider.cleanup(); - } } /** @@ -686,27 +678,6 @@ public class LocationManagerService extends ILocationManager.Stub { Slog.e(TAG, "no geocoder provider found"); } - // bind to fused hardware provider if supported - // in devices without support, requesting an instance of FlpHardwareProvider will raise an - // exception, so make sure we only do that when supported - FlpHardwareProvider flpHardwareProvider; - if (FlpHardwareProvider.isSupported()) { - flpHardwareProvider = FlpHardwareProvider.getInstance(mContext); - FusedProxy fusedProxy = FusedProxy.createAndBind( - mContext, - mLocationHandler, - flpHardwareProvider.getLocationHardware(), - com.android.internal.R.bool.config_enableHardwareFlpOverlay, - com.android.internal.R.string.config_hardwareFlpPackageName, - com.android.internal.R.array.config_locationProviderPackageNames); - if (fusedProxy == null) { - Slog.d(TAG, "Unable to bind FusedProxy."); - } - } else { - flpHardwareProvider = null; - Slog.d(TAG, "FLP HAL not supported"); - } - // bind to geofence provider GeofenceProxy provider = GeofenceProxy.createAndBind( mContext, com.android.internal.R.bool.config_enableGeofenceOverlay, @@ -714,7 +685,7 @@ public class LocationManagerService extends ILocationManager.Stub { com.android.internal.R.array.config_locationProviderPackageNames, mLocationHandler, mGpsGeofenceProxy, - flpHardwareProvider != null ? flpHardwareProvider.getGeofenceHardware() : null); + null); if (provider == null) { Slog.d(TAG, "Unable to bind FLP Geofence proxy."); } @@ -1161,11 +1132,12 @@ public class LocationManagerService extends ILocationManager.Stub { * Returns the model name of the GNSS hardware. */ @Override + @Nullable public String getGnssHardwareModelName() { if (mGnssSystemInfoProvider != null) { return mGnssSystemInfoProvider.getGnssHardwareModelName(); } else { - return LocationManager.GNSS_HARDWARE_MODEL_NAME_UNKNOWN; + return null; } } diff --git a/services/core/java/com/android/server/am/GlobalSettingsToPropertiesMapper.java b/services/core/java/com/android/server/am/GlobalSettingsToPropertiesMapper.java index 5bf5020c99ee..328426da159f 100644 --- a/services/core/java/com/android/server/am/GlobalSettingsToPropertiesMapper.java +++ b/services/core/java/com/android/server/am/GlobalSettingsToPropertiesMapper.java @@ -36,9 +36,11 @@ class GlobalSettingsToPropertiesMapper { private static final String TAG = "GlobalSettingsToPropertiesMapper"; + // List mapping entries in the following format: + // {Settings.Global.SETTING_NAME, "system_property_name"} + // Important: Property being added should be whitelisted by SELinux policy or have one of the + // already whitelisted prefixes in system_server.te, e.g. sys. private static final String[][] sGlobalSettingsMapping = new String[][] { - // List mapping entries in the following format: - // {Settings.Global.SETTING_NAME, "system_property_name"}, {Settings.Global.SYS_VDSO, "sys.vdso"}, {Settings.Global.FPS_DEVISOR, ThreadedRenderer.DEBUG_FPS_DIVISOR}, {Settings.Global.DISPLAY_PANEL_LPM, "sys.display_panel_lpm"}, diff --git a/services/core/java/com/android/server/am/OWNERS b/services/core/java/com/android/server/am/OWNERS new file mode 100644 index 000000000000..99640530a49b --- /dev/null +++ b/services/core/java/com/android/server/am/OWNERS @@ -0,0 +1,4 @@ +per-file GlobalSettingsToPropertiesMapper.java=fkupolov@google.com +per-file GlobalSettingsToPropertiesMapper.java=omakoto@google.com +per-file GlobalSettingsToPropertiesMapper.java=svetoslavganov@google.com +per-file GlobalSettingsToPropertiesMapper.java=yamasani@google.com
\ No newline at end of file diff --git a/services/core/java/com/android/server/display/BrightnessTracker.java b/services/core/java/com/android/server/display/BrightnessTracker.java index 171f40ed37cd..88df195e8051 100644 --- a/services/core/java/com/android/server/display/BrightnessTracker.java +++ b/services/core/java/com/android/server/display/BrightnessTracker.java @@ -25,12 +25,14 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ParceledListSlice; +import android.database.ContentObserver; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.hardware.display.AmbientBrightnessDayStats; import android.hardware.display.BrightnessChangeEvent; +import android.net.Uri; import android.os.BatteryManager; import android.os.Environment; import android.os.Handler; @@ -110,6 +112,8 @@ public class BrightnessTracker { private static final int MSG_BACKGROUND_START = 0; private static final int MSG_BRIGHTNESS_CHANGED = 1; + private static final int MSG_STOP_SENSOR_LISTENER = 2; + private static final int MSG_START_SENSOR_LISTENER = 3; // Lock held while accessing mEvents, is held while writing events to flash. private final Object mEventsLock = new Object(); @@ -127,9 +131,14 @@ public class BrightnessTracker { private final Context mContext; private final ContentResolver mContentResolver; private Handler mBgHandler; - // mBroadcastReceiver and mSensorListener should only be used on the mBgHandler thread. + + // mBroadcastReceiver, mSensorListener, mSettingsObserver and mSensorRegistered + // should only be used on the mBgHandler thread. private BroadcastReceiver mBroadcastReceiver; private SensorListener mSensorListener; + private SettingsObserver mSettingsObserver; + private boolean mSensorRegistered; + private @UserIdInt int mCurrentUserId = UserHandle.USER_NULL; // Lock held while collecting data related to brightness changes. @@ -178,10 +187,9 @@ public class BrightnessTracker { mSensorListener = new SensorListener(); - - if (mInjector.isInteractive(mContext)) { - mInjector.registerSensorListener(mContext, mSensorListener, mBgHandler); - } + mSettingsObserver = new SettingsObserver(mBgHandler); + mInjector.registerBrightnessModeObserver(mContentResolver, mSettingsObserver); + startSensorListener(); final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_SHUTDOWN); @@ -205,10 +213,11 @@ public class BrightnessTracker { Slog.d(TAG, "Stop"); } mBgHandler.removeMessages(MSG_BACKGROUND_START); + stopSensorListener(); mInjector.unregisterSensorListener(mContext, mSensorListener); + mInjector.unregisterBrightnessModeObserver(mContext, mSettingsObserver); mInjector.unregisterReceiver(mContext, mBroadcastReceiver); mInjector.cancelIdleJob(mContext); - mAmbientBrightnessStatsTracker.stop(); synchronized (mDataCollectionLock) { mStarted = false; @@ -366,6 +375,25 @@ public class BrightnessTracker { } } + private void startSensorListener() { + if (!mSensorRegistered + && mInjector.isInteractive(mContext) + && mInjector.isBrightnessModeAutomatic(mContentResolver)) { + mAmbientBrightnessStatsTracker.start(); + mSensorRegistered = true; + mInjector.registerSensorListener(mContext, mSensorListener, + mInjector.getBackgroundHandler()); + } + } + + private void stopSensorListener() { + if (mSensorRegistered) { + mAmbientBrightnessStatsTracker.stop(); + mInjector.unregisterSensorListener(mContext, mSensorListener); + mSensorRegistered = false; + } + } + private void scheduleWriteBrightnessTrackerState() { if (!mWriteBrightnessTrackerStateScheduled) { mBgHandler.post(() -> { @@ -724,6 +752,24 @@ public class BrightnessTracker { } } + private final class SettingsObserver extends ContentObserver { + public SettingsObserver(Handler handler) { + super(handler); + } + + @Override + public void onChange(boolean selfChange, Uri uri) { + if (DEBUG) { + Slog.v(TAG, "settings change " + uri); + } + if (mInjector.isBrightnessModeAutomatic(mContentResolver)) { + mBgHandler.obtainMessage(MSG_START_SENSOR_LISTENER).sendToTarget(); + } else { + mBgHandler.obtainMessage(MSG_STOP_SENSOR_LISTENER).sendToTarget(); + } + } + } + private final class Receiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { @@ -741,12 +787,9 @@ public class BrightnessTracker { batteryLevelChanged(level, scale); } } else if (Intent.ACTION_SCREEN_OFF.equals(action)) { - mAmbientBrightnessStatsTracker.stop(); - mInjector.unregisterSensorListener(mContext, mSensorListener); + mBgHandler.obtainMessage(MSG_STOP_SENSOR_LISTENER).sendToTarget(); } else if (Intent.ACTION_SCREEN_ON.equals(action)) { - mAmbientBrightnessStatsTracker.start(); - mInjector.registerSensorListener(mContext, mSensorListener, - mInjector.getBackgroundHandler()); + mBgHandler.obtainMessage(MSG_START_SENSOR_LISTENER).sendToTarget(); } } } @@ -767,6 +810,12 @@ public class BrightnessTracker { values.powerBrightnessFactor, values.isUserSetBrightness, values.isDefaultBrightnessConfig); break; + case MSG_START_SENSOR_LISTENER: + startSensorListener(); + break; + case MSG_STOP_SENSOR_LISTENER: + stopSensorListener(); + break; } } } @@ -801,6 +850,18 @@ public class BrightnessTracker { sensorManager.unregisterListener(sensorListener); } + public void registerBrightnessModeObserver(ContentResolver resolver, + ContentObserver settingsObserver) { + resolver.registerContentObserver(Settings.System.getUriFor( + Settings.System.SCREEN_BRIGHTNESS_MODE), + false, settingsObserver, UserHandle.USER_ALL); + } + + public void unregisterBrightnessModeObserver(Context context, + ContentObserver settingsObserver) { + context.getContentResolver().unregisterContentObserver(settingsObserver); + } + public void registerReceiver(Context context, BroadcastReceiver receiver, IntentFilter filter) { context.registerReceiver(receiver, filter); @@ -815,6 +876,12 @@ public class BrightnessTracker { return BackgroundThread.getHandler(); } + public boolean isBrightnessModeAutomatic(ContentResolver resolver) { + return Settings.System.getIntForUser(resolver, Settings.System.SCREEN_BRIGHTNESS_MODE, + Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, UserHandle.USER_CURRENT) + == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; + } + public int getSecureIntForUser(ContentResolver resolver, String setting, int defaultValue, int userId) { return Settings.Secure.getIntForUser(resolver, setting, defaultValue, userId); diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java index 0b1f9a65868c..66817fad4e5b 100644 --- a/services/core/java/com/android/server/job/JobSchedulerService.java +++ b/services/core/java/com/android/server/job/JobSchedulerService.java @@ -29,6 +29,7 @@ import android.app.IUidObserver; import android.app.job.IJobScheduler; import android.app.job.JobInfo; import android.app.job.JobParameters; +import android.app.job.JobProtoEnums; import android.app.job.JobScheduler; import android.app.job.JobService; import android.app.job.JobWorkItem; @@ -880,7 +881,8 @@ public final class JobSchedulerService extends com.android.server.SystemService startTrackingJobLocked(jobStatus, toCancel); StatsLog.write_non_chained(StatsLog.SCHEDULED_JOB_STATE_CHANGED, uId, null, jobStatus.getBatteryName(), - StatsLog.SCHEDULED_JOB_STATE_CHANGED__STATE__SCHEDULED); + StatsLog.SCHEDULED_JOB_STATE_CHANGED__STATE__SCHEDULED, + JobProtoEnums.STOP_REASON_CANCELLED); // If the job is immediately ready to run, then we can just immediately // put it in the pending list and try to schedule it. This is especially diff --git a/services/core/java/com/android/server/location/FlpHardwareProvider.java b/services/core/java/com/android/server/location/FlpHardwareProvider.java deleted file mode 100644 index 5c9b0eaa29cc..000000000000 --- a/services/core/java/com/android/server/location/FlpHardwareProvider.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.server.location; - -import android.content.Context; -import android.hardware.location.IFusedLocationHardware; -import android.location.IFusedGeofenceHardware; -import android.util.Log; - -/** - * This class was an interop layer for JVM types and the JNI code that interacted - * with the FLP HAL implementation. - * - * Now, after Treble FLP & GNSS HAL simplification, it is a thin shell that acts like the - * pre-existing cases where there was no FLP Hardware support, to keep legacy users of this - * class operating. - * - * {@hide} - * {@Deprecated} - */ -public class FlpHardwareProvider { - private static FlpHardwareProvider sSingletonInstance = null; - - private final static String TAG = "FlpHardwareProvider"; - - private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); - - public static FlpHardwareProvider getInstance(Context context) { - if (sSingletonInstance == null) { - sSingletonInstance = new FlpHardwareProvider(); - if (DEBUG) Log.d(TAG, "getInstance() created empty provider"); - } - return sSingletonInstance; - } - - private FlpHardwareProvider() { - } - - public static boolean isSupported() { - if (DEBUG) Log.d(TAG, "isSupported() returning false"); - return false; - } - - /** - * Interface implementations for services built on top of this functionality. - */ - public static final String LOCATION = "Location"; - - public IFusedLocationHardware getLocationHardware() { - return null; - } - - public IFusedGeofenceHardware getGeofenceHardware() { - return null; - } - - public void cleanup() { - if (DEBUG) Log.d(TAG, "empty cleanup()"); - } -} diff --git a/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java b/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java deleted file mode 100644 index a08d3263be6c..000000000000 --- a/services/core/java/com/android/server/location/FusedLocationHardwareSecure.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.server.location; - -import android.content.Context; -import android.hardware.location.IFusedLocationHardware; -import android.hardware.location.IFusedLocationHardwareSink; -import android.location.FusedBatchOptions; -import android.os.RemoteException; - -/** - * FusedLocationHardware decorator that adds permission checking. - * @hide - */ -public class FusedLocationHardwareSecure extends IFusedLocationHardware.Stub { - private final IFusedLocationHardware mLocationHardware; - private final Context mContext; - private final String mPermissionId; - - public FusedLocationHardwareSecure( - IFusedLocationHardware locationHardware, - Context context, - String permissionId) { - mLocationHardware = locationHardware; - mContext = context; - mPermissionId = permissionId; - } - - private void checkPermissions() { - mContext.enforceCallingPermission( - mPermissionId, - String.format( - "Permission '%s' not granted to access FusedLocationHardware", - mPermissionId)); - } - - @Override - public void registerSink(IFusedLocationHardwareSink eventSink) throws RemoteException { - checkPermissions(); - mLocationHardware.registerSink(eventSink); - } - - @Override - public void unregisterSink(IFusedLocationHardwareSink eventSink) throws RemoteException { - checkPermissions(); - mLocationHardware.unregisterSink(eventSink); - } - - @Override - public int getSupportedBatchSize() throws RemoteException { - checkPermissions(); - return mLocationHardware.getSupportedBatchSize(); - } - - @Override - public void startBatching(int id, FusedBatchOptions batchOptions) throws RemoteException { - checkPermissions(); - mLocationHardware.startBatching(id, batchOptions); - } - - @Override - public void stopBatching(int id) throws RemoteException { - checkPermissions(); - mLocationHardware.stopBatching(id); - } - - @Override - public void updateBatchingOptions( - int id, - FusedBatchOptions batchoOptions - ) throws RemoteException { - checkPermissions(); - mLocationHardware.updateBatchingOptions(id, batchoOptions); - } - - @Override - public void requestBatchOfLocations(int batchSizeRequested) throws RemoteException { - checkPermissions(); - mLocationHardware.requestBatchOfLocations(batchSizeRequested); - } - - @Override - public boolean supportsDiagnosticDataInjection() throws RemoteException { - checkPermissions(); - return mLocationHardware.supportsDiagnosticDataInjection(); - } - - @Override - public void injectDiagnosticData(String data) throws RemoteException { - checkPermissions(); - mLocationHardware.injectDiagnosticData(data); - } - - @Override - public boolean supportsDeviceContextInjection() throws RemoteException { - checkPermissions(); - return mLocationHardware.supportsDeviceContextInjection(); - } - - @Override - public void injectDeviceContext(int deviceEnabledContext) throws RemoteException { - checkPermissions(); - mLocationHardware.injectDeviceContext(deviceEnabledContext); - } - - @Override - public void flushBatchedLocations() throws RemoteException { - checkPermissions(); - mLocationHardware.flushBatchedLocations(); - } - - @Override - public int getVersion() throws RemoteException { - checkPermissions(); - return mLocationHardware.getVersion(); - } -} diff --git a/services/core/java/com/android/server/location/FusedProxy.java b/services/core/java/com/android/server/location/FusedProxy.java deleted file mode 100644 index b90f037a5046..000000000000 --- a/services/core/java/com/android/server/location/FusedProxy.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (The "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.server.location; - -import com.android.server.ServiceWatcher; - -import android.Manifest; -import android.content.Context; -import android.hardware.location.IFusedLocationHardware; -import android.location.IFusedProvider; -import android.os.Handler; -import android.os.IBinder; -import android.os.RemoteException; -import android.util.Log; - -/** - * Proxy that helps bind GCore FusedProvider implementations to the Fused Hardware instances. - * - * @hide - */ -public final class FusedProxy { - private final String TAG = "FusedProxy"; - private final ServiceWatcher mServiceWatcher; - private final FusedLocationHardwareSecure mLocationHardware; - - /** - * Constructor of the class. - * This is private as the class follows a factory pattern for construction. - * - * @param context The context needed for construction. - * @param handler The handler needed for construction. - * @param locationHardware The instance of the Fused location hardware assigned to the proxy. - */ - private FusedProxy( - Context context, - Handler handler, - IFusedLocationHardware locationHardware, - int overlaySwitchResId, - int defaultServicePackageNameResId, - int initialPackageNameResId) { - mLocationHardware = new FusedLocationHardwareSecure( - locationHardware, - context, - Manifest.permission.LOCATION_HARDWARE); - Runnable newServiceWork = new Runnable() { - @Override - public void run() { - bindProvider(mLocationHardware); - } - }; - - // prepare the connection to the provider - mServiceWatcher = new ServiceWatcher( - context, - TAG, - "com.android.location.service.FusedProvider", - overlaySwitchResId, - defaultServicePackageNameResId, - initialPackageNameResId, - newServiceWork, - handler); - } - - /** - * Creates an instance of the proxy and binds it to the appropriate FusedProvider. - * - * @param context The context needed for construction. - * @param handler The handler needed for construction. - * @param locationHardware The instance of the Fused location hardware assigned to the proxy. - * - * @return An instance of the proxy if it could be bound, null otherwise. - */ - public static FusedProxy createAndBind( - Context context, - Handler handler, - IFusedLocationHardware locationHardware, - int overlaySwitchResId, - int defaultServicePackageNameResId, - int initialPackageNameResId) { - FusedProxy fusedProxy = new FusedProxy( - context, - handler, - locationHardware, - overlaySwitchResId, - defaultServicePackageNameResId, - initialPackageNameResId); - - // try to bind the Fused provider - if (!fusedProxy.mServiceWatcher.start()) { - return null; - } - - return fusedProxy; - } - - /** - * Helper function to bind the FusedLocationHardware to the appropriate FusedProvider instance. - * - * @param locationHardware The FusedLocationHardware instance to use for the binding operation. - */ - private void bindProvider(IFusedLocationHardware locationHardware) { - if (!mServiceWatcher.runOnBinder(new ServiceWatcher.BinderRunner() { - @Override - public void run(IBinder binder) { - IFusedProvider provider = IFusedProvider.Stub.asInterface(binder); - try { - provider.onFusedLocationHardwareChange(locationHardware); - } catch (RemoteException e) { - Log.e(TAG, e.toString()); - } - } - })) { - Log.e(TAG, "No instance of FusedProvider found on FusedLocationHardware connected."); - } - } -} diff --git a/services/core/java/com/android/server/location/GnssLocationProvider.java b/services/core/java/com/android/server/location/GnssLocationProvider.java index e02feecbc288..8f0e1dafc3d9 100644 --- a/services/core/java/com/android/server/location/GnssLocationProvider.java +++ b/services/core/java/com/android/server/location/GnssLocationProvider.java @@ -470,7 +470,7 @@ public class GnssLocationProvider implements LocationProviderInterface { // Volatile for simple inter-thread sync on these values. private volatile int mHardwareYear = 0; - private volatile String mHardwareModelName = LocationManager.GNSS_HARDWARE_MODEL_NAME_UNKNOWN; + private volatile String mHardwareModelName; // Set lower than the current ITAR limit of 600m/s to allow this to trigger even if GPS HAL // stops output right at 600m/s, depriving this of the information of a device that reaches diff --git a/services/core/java/com/android/server/locksettings/recoverablekeystore/KeySyncTask.java b/services/core/java/com/android/server/locksettings/recoverablekeystore/KeySyncTask.java index f46657c15b5a..a87adbde31e6 100644 --- a/services/core/java/com/android/server/locksettings/recoverablekeystore/KeySyncTask.java +++ b/services/core/java/com/android/server/locksettings/recoverablekeystore/KeySyncTask.java @@ -255,9 +255,6 @@ public class KeySyncTask implements Runnable { } } - // TODO: make sure the same counter id is used during recovery and remove temporary fix. - counterId = 1L; - byte[] vaultParams = KeySyncUtils.packVaultParams( publicKey, counterId, diff --git a/services/core/java/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManager.java b/services/core/java/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManager.java index 5b10add4ecfa..e03e86f1d455 100644 --- a/services/core/java/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManager.java +++ b/services/core/java/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManager.java @@ -416,8 +416,8 @@ public class RecoverableKeyStoreManager { * @param vaultChallenge Challenge issued by vault service. * @param secrets Lock-screen hashes. For now only a single secret is supported. * @return Encrypted bytes of recovery claim. This can then be issued to the vault service. - * @deprecated Use {@link #startRecoverySessionWithCertPath(String, RecoveryCertPath, byte[], - * byte[], List)} instead. + * @deprecated Use {@link #startRecoverySessionWithCertPath(String, String, RecoveryCertPath, + * byte[], byte[], List)} instead. * * @hide */ @@ -457,6 +457,7 @@ public class RecoverableKeyStoreManager { uid, new RecoverySessionStorage.Entry(sessionId, kfHash, keyClaimant, vaultParams)); + Log.i(TAG, "Received VaultParams for recovery: " + HexDump.toHexString(vaultParams)); try { byte[] thmKfHash = KeySyncUtils.calculateThmKfHash(kfHash); return KeySyncUtils.encryptRecoveryClaim( diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 54b4123e54ca..993556faee7d 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -859,10 +859,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // If the task has temp inset bounds set, we have to make sure all its windows uses // the temp inset frame. Otherwise different display frames get applied to the main // window and the child window, making them misaligned. - if (inFullscreenContainer || isLetterboxedAppWindow()) { - mInsetFrame.setEmpty(); - } else if (task != null && isInMultiWindowMode()) { + // Otherwise we need to clear the inset frame, to avoid using a stale frame after leaving + // multi window mode. + if (task != null && isInMultiWindowMode()) { task.getTempInsetBounds(mInsetFrame); + } else { + mInsetFrame.setEmpty(); } // Denotes the actual frame used to calculate the insets and to perform the layout. When diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index d165a45f0b01..6f50ee27d134 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -705,6 +705,11 @@ public final class SystemServer { mWebViewUpdateService = mSystemServiceManager.startService(WebViewUpdateService.class); traceEnd(); } + + // Tracks cpu time spent in binder calls + traceBeginAndSlog("StartBinderCallsStatsService"); + BinderCallsStatsService.start(); + traceEnd(); } /** diff --git a/services/robotests/src/com/android/server/backup/PerformBackupTaskTest.java b/services/robotests/src/com/android/server/backup/PerformBackupTaskTest.java index d0398ad539ac..f603a09baa37 100644 --- a/services/robotests/src/com/android/server/backup/PerformBackupTaskTest.java +++ b/services/robotests/src/com/android/server/backup/PerformBackupTaskTest.java @@ -148,22 +148,16 @@ public class PerformBackupTaskTest { Looper backupLooper = startBackupThreadAndGetLooper(); mShadowBackupLooper = shadowOf(backupLooper); mBackupHandler = new BackupHandler(mBackupManagerService, backupLooper); - Handler mainHandler = new Handler(Looper.getMainLooper()); mBackupManager = spy(FakeIBackupManager.class); - BackupAgentTimeoutParameters agentTimeoutParameters = - new BackupAgentTimeoutParameters(mainHandler, application.getContentResolver()); - agentTimeoutParameters.start(); - setUpBackupManagerServiceBasics( mBackupManagerService, application, mTransportManager, packageManager, mBackupHandler, - mWakeLock, - agentTimeoutParameters); + mWakeLock); when(mBackupManagerService.getBaseStateDir()).thenReturn(mBaseStateDir); when(mBackupManagerService.getDataDir()).thenReturn(dataDir); when(mBackupManagerService.getBackupManagerBinder()).thenReturn(mBackupManager); diff --git a/services/robotests/src/com/android/server/backup/restore/ActiveRestoreSessionTest.java b/services/robotests/src/com/android/server/backup/restore/ActiveRestoreSessionTest.java index 869c50b55fe8..03792b1d40ba 100644 --- a/services/robotests/src/com/android/server/backup/restore/ActiveRestoreSessionTest.java +++ b/services/robotests/src/com/android/server/backup/restore/ActiveRestoreSessionTest.java @@ -41,14 +41,12 @@ import android.app.backup.IRestoreSession; import android.app.backup.RestoreSet; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; -import android.os.Handler; import android.os.Looper; import android.os.PowerManager; import android.os.RemoteException; import android.platform.test.annotations.Presubmit; import com.android.server.EventLogTags; -import com.android.server.backup.BackupAgentTimeoutParameters; import com.android.server.backup.BackupManagerService; import com.android.server.backup.TransportManager; import com.android.server.backup.internal.BackupHandler; @@ -117,15 +115,6 @@ public class ActiveRestoreSessionTest { Looper backupLooper = startBackupThreadAndGetLooper(); mShadowBackupLooper = shadowOf(backupLooper); - - Handler mainHandler = new Handler(Looper.getMainLooper()); - BackupAgentTimeoutParameters agentTimeoutParameters = - new BackupAgentTimeoutParameters(mainHandler, application.getContentResolver()); - agentTimeoutParameters.start(); - - // We need to mock BMS timeout parameters before initializing the BackupHandler since - // the constructor of BackupHandler relies on the timeout parameters. - when(mBackupManagerService.getAgentTimeoutParameters()).thenReturn(agentTimeoutParameters); BackupHandler backupHandler = new BackupHandler(mBackupManagerService, backupLooper); mWakeLock = createBackupWakeLock(application); @@ -136,8 +125,7 @@ public class ActiveRestoreSessionTest { mTransportManager, application.getPackageManager(), backupHandler, - mWakeLock, - agentTimeoutParameters); + mWakeLock); when(mBackupManagerService.getPendingRestores()).thenReturn(new ArrayDeque<>()); } diff --git a/services/robotests/src/com/android/server/backup/testing/BackupManagerServiceTestUtils.java b/services/robotests/src/com/android/server/backup/testing/BackupManagerServiceTestUtils.java index 5a886e33622f..c210fdea6e89 100644 --- a/services/robotests/src/com/android/server/backup/testing/BackupManagerServiceTestUtils.java +++ b/services/robotests/src/com/android/server/backup/testing/BackupManagerServiceTestUtils.java @@ -28,7 +28,6 @@ import android.os.Looper; import android.os.PowerManager; import android.util.SparseArray; -import com.android.server.backup.BackupAgentTimeoutParameters; import com.android.server.backup.BackupManagerService; import com.android.server.backup.TransportManager; import com.android.server.backup.internal.BackupHandler; @@ -44,8 +43,7 @@ public class BackupManagerServiceTestUtils { TransportManager transportManager, PackageManager packageManager, BackupHandler backupHandler, - PowerManager.WakeLock wakeLock, - BackupAgentTimeoutParameters agentTimeoutParameters) { + PowerManager.WakeLock wakeLock) { when(backupManagerService.getContext()).thenReturn(context); when(backupManagerService.getTransportManager()).thenReturn(transportManager); when(backupManagerService.getPackageManager()).thenReturn(packageManager); @@ -55,7 +53,6 @@ public class BackupManagerServiceTestUtils { when(backupManagerService.getCurrentOperations()).thenReturn(new SparseArray<>()); when(backupManagerService.getActivityManager()).thenReturn(mock(IActivityManager.class)); when(backupManagerService.getWakelock()).thenReturn(wakeLock); - when(backupManagerService.getAgentTimeoutParameters()).thenReturn(agentTimeoutParameters); } public static PowerManager.WakeLock createBackupWakeLock(Application application) { diff --git a/services/tests/servicestests/src/com/android/server/display/BrightnessTrackerTest.java b/services/tests/servicestests/src/com/android/server/display/BrightnessTrackerTest.java index b4f84742301d..92cc537ada6d 100644 --- a/services/tests/servicestests/src/com/android/server/display/BrightnessTrackerTest.java +++ b/services/tests/servicestests/src/com/android/server/display/BrightnessTrackerTest.java @@ -30,6 +30,7 @@ import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.database.ContentObserver; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.display.BrightnessChangeEvent; @@ -101,20 +102,24 @@ public class BrightnessTrackerTest { assertNull(mInjector.mSensorListener); assertNotNull(mInjector.mBroadcastReceiver); assertTrue(mInjector.mIdleScheduled); - Intent onIntent = new Intent(); - onIntent.setAction(Intent.ACTION_SCREEN_ON); - mInjector.mBroadcastReceiver.onReceive(InstrumentationRegistry.getContext(), - onIntent); + mInjector.sendScreenChange(/*screen on */ true); assertNotNull(mInjector.mSensorListener); - Intent offIntent = new Intent(); - offIntent.setAction(Intent.ACTION_SCREEN_OFF); - mInjector.mBroadcastReceiver.onReceive(InstrumentationRegistry.getContext(), - offIntent); + mInjector.sendScreenChange(/*screen on */ false); assertNull(mInjector.mSensorListener); - mInjector.mBroadcastReceiver.onReceive(InstrumentationRegistry.getContext(), - onIntent); + // Turn screen on while brightness mode is manual + mInjector.setBrightnessMode(/* isBrightnessModeAutomatic */ false); + mInjector.sendScreenChange(/*screen on */ true); + assertNull(mInjector.mSensorListener); + + // Set brightness mode to automatic while screen is off. + mInjector.sendScreenChange(/*screen on */ false); + mInjector.setBrightnessMode(/* isBrightnessModeAutomatic */ true); + assertNull(mInjector.mSensorListener); + + // Turn on screen while brightness mode is automatic. + mInjector.sendScreenChange(/*screen on */ true); assertNotNull(mInjector.mSensorListener); mTracker.stop(); @@ -124,6 +129,37 @@ public class BrightnessTrackerTest { } @Test + public void testAdaptiveOnOff() { + mInjector.mInteractive = true; + mInjector.mIsBrightnessModeAutomatic = false; + startTracker(mTracker); + assertNull(mInjector.mSensorListener); + assertNotNull(mInjector.mBroadcastReceiver); + assertNotNull(mInjector.mContentObserver); + assertTrue(mInjector.mIdleScheduled); + + mInjector.setBrightnessMode(/*isBrightnessModeAutomatic*/ true); + assertNotNull(mInjector.mSensorListener); + + SensorEventListener listener = mInjector.mSensorListener; + mInjector.mSensorListener = null; + // Duplicate notification + mInjector.setBrightnessMode(/*isBrightnessModeAutomatic*/ true); + // Sensor shouldn't have been registered as it was already registered. + assertNull(mInjector.mSensorListener); + mInjector.mSensorListener = listener; + + mInjector.setBrightnessMode(/*isBrightnessModeAutomatic*/ false); + assertNull(mInjector.mSensorListener); + + mTracker.stop(); + assertNull(mInjector.mSensorListener); + assertNull(mInjector.mBroadcastReceiver); + assertNull(mInjector.mContentObserver); + assertFalse(mInjector.mIdleScheduled); + } + + @Test public void testBrightnessEvent() { final int brightness = 20; @@ -618,16 +654,39 @@ public class BrightnessTrackerTest { boolean mIdleScheduled; boolean mInteractive = true; int[] mProfiles; + ContentObserver mContentObserver; + boolean mIsBrightnessModeAutomatic = true; public TestInjector(Handler handler) { mHandler = handler; } - public void incrementTime(long timeMillis) { + void incrementTime(long timeMillis) { mCurrentTimeMillis += timeMillis; mElapsedRealtimeNanos += TimeUnit.MILLISECONDS.toNanos(timeMillis); } + void setBrightnessMode(boolean isBrightnessModeAutomatic) { + mIsBrightnessModeAutomatic = isBrightnessModeAutomatic; + mContentObserver.dispatchChange(false, null); + waitForHandler(); + } + + void sendScreenChange(boolean screenOn) { + mInteractive = screenOn; + Intent intent = new Intent(); + intent.setAction(screenOn ? Intent.ACTION_SCREEN_ON : Intent.ACTION_SCREEN_OFF); + mBroadcastReceiver.onReceive(InstrumentationRegistry.getContext(), intent); + waitForHandler(); + } + + void waitForHandler() { + Idle idle = new Idle(); + mHandler.getLooper().getQueue().addIdleHandler(idle); + mHandler.post(() -> {}); + idle.waitForIdle(); + } + @Override public void registerSensorListener(Context context, SensorEventListener sensorListener, Handler handler) { @@ -641,6 +700,18 @@ public class BrightnessTrackerTest { } @Override + public void registerBrightnessModeObserver(ContentResolver resolver, + ContentObserver settingsObserver) { + mContentObserver = settingsObserver; + } + + @Override + public void unregisterBrightnessModeObserver(Context context, + ContentObserver settingsObserver) { + mContentObserver = null; + } + + @Override public void registerReceiver(Context context, BroadcastReceiver shutdownReceiver, IntentFilter shutdownFilter) { mBroadcastReceiver = shutdownReceiver; @@ -658,11 +729,9 @@ public class BrightnessTrackerTest { return mHandler; } - public void waitForHandler() { - Idle idle = new Idle(); - mHandler.getLooper().getQueue().addIdleHandler(idle); - mHandler.post(() -> {}); - idle.waitForIdle(); + @Override + public boolean isBrightnessModeAutomatic(ContentResolver resolver) { + return mIsBrightnessModeAutomatic; } @Override diff --git a/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/KeySyncTaskTest.java b/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/KeySyncTaskTest.java index 69796b33c2eb..25747b801b80 100644 --- a/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/KeySyncTaskTest.java +++ b/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/KeySyncTaskTest.java @@ -296,7 +296,6 @@ public class KeySyncTaskTest { keyDerivationParams.getSalt(), TEST_CREDENTIAL); Long counterId = mRecoverableKeyStoreDb.getCounterId(TEST_USER_ID, TEST_RECOVERY_AGENT_UID); - counterId = 1L; // TODO: use value from the database. assertThat(counterId).isNotNull(); byte[] recoveryKey = decryptThmEncryptedKey( lockScreenHash, diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationTest.java index c4a688bb385d..0f2e56b83f75 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationTest.java @@ -367,6 +367,28 @@ public class NotificationTest extends UiServiceTestCase { } @Test + public void testActionsMoreOptionsThanChoices() { + PendingIntent intent1 = mock(PendingIntent.class); + PendingIntent intent2 = mock(PendingIntent.class); + Icon icon = mock(Icon.class); + + Notification n1 = new Notification.Builder(mContext, "test") + .addAction(new Notification.Action.Builder(icon, "TEXT 1", intent1).build()) + .addAction(new Notification.Action.Builder(icon, "TEXT 2", intent1) + .addRemoteInput(new RemoteInput.Builder("a") + .setChoices(new CharSequence[] {"i", "m"}) + .build()) + .build()) + .build(); + Notification n2 = new Notification.Builder(mContext, "test") + .addAction(new Notification.Action.Builder(icon, "TEXT 1", intent2).build()) + .addAction(new Notification.Action.Builder(icon, "TEXT 2", intent1).build()) + .build(); + + assertTrue(Notification.areActionsVisiblyDifferent(n1, n2)); + } + + @Test public void testActionsDifferentRemoteInputs() { PendingIntent intent = mock(PendingIntent.class); Icon icon = mock(Icon.class); |