diff options
23 files changed, 103 insertions, 92 deletions
diff --git a/PACKAGE_MANAGER_OWNERS b/PACKAGE_MANAGER_OWNERS new file mode 100644 index 000000000000..e4549b4de164 --- /dev/null +++ b/PACKAGE_MANAGER_OWNERS @@ -0,0 +1,3 @@ +chiuwinson@google.com +patb@google.com +schfan@google.com
\ No newline at end of file diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 9c6939e5aae5..db3cedd27a9b 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -1941,7 +1941,7 @@ package android.bluetooth { method public long getControllerIdleTimeMillis(); method public long getControllerRxTimeMillis(); method public long getControllerTxTimeMillis(); - method public long getTimeStamp(); + method public long getTimestampMillis(); method @NonNull public java.util.List<android.bluetooth.UidTraffic> getUidTraffic(); method public boolean isValid(); field public static final int BT_STACK_STATE_INVALID = 0; // 0x0 diff --git a/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java b/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java index f371c6d78221..c17a7b4b3dfd 100644 --- a/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java +++ b/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java @@ -16,6 +16,7 @@ package android.bluetooth; +import android.annotation.ElapsedRealtimeLong; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.SystemApi; @@ -167,7 +168,7 @@ public final class BluetoothActivityEnergyInfo implements Parcelable { /** * @return timestamp (real time elapsed in milliseconds since boot) of record creation */ - public long getTimeStamp() { + public @ElapsedRealtimeLong long getTimestampMillis() { return mTimestamp; } @@ -189,7 +190,7 @@ public final class BluetoothActivityEnergyInfo implements Parcelable { } /** - * @return true if the record is valid + * @return true if the record Tx time, Rx time, and Idle time are more than 0. */ public boolean isValid() { return ((mControllerTxTimeMs >= 0) && (mControllerRxTimeMs >= 0) diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java index 9caeb297ace3..c71fcc637cb9 100644 --- a/core/java/android/bluetooth/BluetoothDevice.java +++ b/core/java/android/bluetooth/BluetoothDevice.java @@ -1186,6 +1186,11 @@ public final class BluetoothDevice implements Parcelable, Attributable { mAttributionSource = attributionSource; } + /** {@hide} */ + public void prepareToEnterProcess(@NonNull AttributionSource attributionSource) { + setAttributionSource(attributionSource); + } + @Override public boolean equals(@Nullable Object o) { if (o instanceof BluetoothDevice) { diff --git a/core/java/android/bluetooth/BluetoothManager.java b/core/java/android/bluetooth/BluetoothManager.java index b5df4db2460d..20152f3d2471 100644 --- a/core/java/android/bluetooth/BluetoothManager.java +++ b/core/java/android/bluetooth/BluetoothManager.java @@ -62,15 +62,15 @@ public final class BluetoothManager { private static final String TAG = "BluetoothManager"; private static final boolean DBG = false; - private static AttributionSource sAttributionSource = null; + private final AttributionSource mAttributionSource; private final BluetoothAdapter mAdapter; /** * @hide */ public BluetoothManager(Context context) { - sAttributionSource = resolveAttributionSource(context); - mAdapter = BluetoothAdapter.createAdapter(sAttributionSource); + mAttributionSource = resolveAttributionSource(context); + mAdapter = BluetoothAdapter.createAdapter(mAttributionSource); } /** {@hide} */ @@ -79,9 +79,6 @@ public final class BluetoothManager { if (context != null) { res = context.getAttributionSource(); } - else if (sAttributionSource != null) { - return sAttributionSource; - } if (res == null) { res = ActivityThread.currentAttributionSource(); } @@ -201,8 +198,8 @@ public final class BluetoothManager { IBluetoothGatt iGatt = managerService.getBluetoothGatt(); if (iGatt == null) return devices; devices = Attributable.setAttributionSource( - iGatt.getDevicesMatchingConnectionStates(states, sAttributionSource), - sAttributionSource); + iGatt.getDevicesMatchingConnectionStates(states, mAttributionSource), + mAttributionSource); } catch (RemoteException e) { Log.e(TAG, "", e); } diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 2fd437db14a7..d811040b6bb2 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -31,6 +31,7 @@ import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.TestApi; import android.app.AppGlobals; +import android.bluetooth.BluetoothDevice; import android.compat.annotation.UnsupportedAppUsage; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; @@ -11461,6 +11462,16 @@ public class Intent implements Parcelable, Cloneable { if (fromProtectedComponent) { mLocalFlags |= LOCAL_FLAG_FROM_PROTECTED_COMPONENT; } + + // Special attribution fix-up logic for any BluetoothDevice extras + // passed via Bluetooth intents + if (mAction != null && mAction.startsWith("android.bluetooth.") + && hasExtra(BluetoothDevice.EXTRA_DEVICE)) { + final BluetoothDevice device = getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); + if (device != null) { + device.prepareToEnterProcess(source); + } + } } /** @hide */ diff --git a/core/java/android/content/OWNERS b/core/java/android/content/OWNERS index c7f92c9714f0..660368aeca14 100644 --- a/core/java/android/content/OWNERS +++ b/core/java/android/content/OWNERS @@ -2,11 +2,9 @@ per-file Context.java = * per-file ContextWrapper.java = * per-file Content* = file:/services/core/java/com/android/server/am/OWNERS -per-file IntentFilter.java = toddke@google.com -per-file IntentFilter.java = patb@google.com +per-file IntentFilter.java = file:/PACKAGE_MANAGER_OWNERS per-file IntentFilter.java = file:/services/core/java/com/android/server/am/OWNERS -per-file Intent.java = toddke@google.com -per-file Intent.java = patb@google.com +per-file Intent.java = file:/PACKAGE_MANAGER_OWNERS per-file Intent.java = file:/services/core/java/com/android/server/wm/OWNERS per-file Intent.java = file:/services/core/java/com/android/server/am/OWNERS per-file AutofillOptions* = file:/core/java/android/service/autofill/OWNERS diff --git a/core/java/android/net/NetworkIdentity.java b/core/java/android/net/NetworkIdentity.java index 1d07a0330bc5..eb8f43e3d073 100644 --- a/core/java/android/net/NetworkIdentity.java +++ b/core/java/android/net/NetworkIdentity.java @@ -220,8 +220,10 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> { String networkId = null; boolean roaming = !snapshot.getNetworkCapabilities().hasCapability( NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING); - boolean metered = !snapshot.getNetworkCapabilities().hasCapability( - NetworkCapabilities.NET_CAPABILITY_NOT_METERED); + boolean metered = !(snapshot.getNetworkCapabilities().hasCapability( + NetworkCapabilities.NET_CAPABILITY_NOT_METERED) + || snapshot.getNetworkCapabilities().hasCapability( + NetworkCapabilities.NET_CAPABILITY_TEMPORARILY_NOT_METERED)); final int oemManaged = getOemBitfield(snapshot.getNetworkCapabilities()); diff --git a/core/java/android/net/NetworkTemplate.java b/core/java/android/net/NetworkTemplate.java index 08f75df5d82d..74506dae329b 100644 --- a/core/java/android/net/NetworkTemplate.java +++ b/core/java/android/net/NetworkTemplate.java @@ -160,19 +160,19 @@ public class NetworkTemplate implements Parcelable { } /** - * Template to match cellular networks with the given IMSI and {@code ratType}. - * Use {@link #NETWORK_TYPE_ALL} to include all network types when filtering. - * See {@code TelephonyManager.NETWORK_TYPE_*}. + * Template to match cellular networks with the given IMSI, {@code ratType} and + * {@code metered}. Use {@link #NETWORK_TYPE_ALL} to include all network types when + * filtering. See {@code TelephonyManager.NETWORK_TYPE_*}. */ public static NetworkTemplate buildTemplateMobileWithRatType(@Nullable String subscriberId, - @NetworkType int ratType) { + @NetworkType int ratType, int metered) { if (TextUtils.isEmpty(subscriberId)) { return new NetworkTemplate(MATCH_MOBILE_WILDCARD, null, null, null, - METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, ratType, OEM_MANAGED_ALL, + metered, ROAMING_ALL, DEFAULT_NETWORK_ALL, ratType, OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT); } return new NetworkTemplate(MATCH_MOBILE, subscriberId, new String[]{subscriberId}, null, - METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, ratType, OEM_MANAGED_ALL, + metered, ROAMING_ALL, DEFAULT_NETWORK_ALL, ratType, OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT); } @@ -305,6 +305,7 @@ public class NetworkTemplate implements Parcelable { } } + // TODO: Deprecate this constructor, mark it @UnsupportedAppUsage(maxTargetSdk = S) @UnsupportedAppUsage public NetworkTemplate(int matchRule, String subscriberId, String networkId) { this(matchRule, subscriberId, new String[] { subscriberId }, networkId); @@ -312,9 +313,14 @@ public class NetworkTemplate implements Parcelable { public NetworkTemplate(int matchRule, String subscriberId, String[] matchSubscriberIds, String networkId) { - this(matchRule, subscriberId, matchSubscriberIds, networkId, METERED_ALL, ROAMING_ALL, - DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL, - SUBSCRIBER_ID_MATCH_RULE_EXACT); + // Older versions used to only match MATCH_MOBILE and MATCH_MOBILE_WILDCARD templates + // to metered networks. It is now possible to match mobile with any meteredness, but + // in order to preserve backward compatibility of @UnsupportedAppUsage methods, this + //constructor passes METERED_YES for these types. + this(matchRule, subscriberId, matchSubscriberIds, networkId, + (matchRule == MATCH_MOBILE || matchRule == MATCH_MOBILE_WILDCARD) ? METERED_YES + : METERED_ALL , ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, + OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT); } // TODO: Remove it after updating all of the caller. @@ -589,11 +595,7 @@ public class NetworkTemplate implements Parcelable { // TODO: consider matching against WiMAX subscriber identity return true; } else { - // Only metered mobile network would be matched regardless of metered filter. - // This is used to exclude non-metered APNs, e.g. IMS. See ag/908650. - // TODO: Respect metered filter and remove mMetered condition. - return (ident.mType == TYPE_MOBILE && ident.mMetered) - && !ArrayUtils.isEmpty(mMatchSubscriberIds) + return ident.mType == TYPE_MOBILE && !ArrayUtils.isEmpty(mMatchSubscriberIds) && ArrayUtils.contains(mMatchSubscriberIds, ident.mSubscriberId) && matchesCollapsedRatType(ident); } @@ -707,8 +709,7 @@ public class NetworkTemplate implements Parcelable { if (ident.mType == TYPE_WIMAX) { return true; } else { - return (ident.mType == TYPE_MOBILE && ident.mMetered) - && matchesCollapsedRatType(ident); + return ident.mType == TYPE_MOBILE && matchesCollapsedRatType(ident); } } diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java index 635f58182b34..b677b6900d5c 100644 --- a/core/java/android/os/Binder.java +++ b/core/java/android/os/Binder.java @@ -313,7 +313,7 @@ public class Binder implements IBinder { * @hide */ @CriticalNative - public static final native boolean isHandlingTransaction(); + public static final native boolean isDirectlyHandlingTransaction(); /** * Return the Linux uid assigned to the process that sent the transaction @@ -323,7 +323,7 @@ public class Binder implements IBinder { * executing an incoming transaction. */ public static final int getCallingUidOrThrow() { - if (!isHandlingTransaction()) { + if (!isDirectlyHandlingTransaction()) { throw new IllegalStateException( "Thread is not in a binder transcation"); } diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index 793b4eba788c..61b91ddaa2e7 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -959,8 +959,7 @@ static jint android_os_Binder_getCallingUid() return IPCThreadState::self()->getCallingUid(); } -static jboolean android_os_Binder_isHandlingTransaction() -{ +static jboolean android_os_Binder_isDirectlyHandlingTransaction() { return getCurrentServingCall() == BinderCallType::BINDER; } @@ -1056,6 +1055,7 @@ static void android_os_Binder_setExtension(JNIEnv* env, jobject obj, jobject ext // ---------------------------------------------------------------------------- +// clang-format off static const JNINativeMethod gBinderMethods[] = { /* name, signature, funcPtr */ // @CriticalNative @@ -1063,7 +1063,7 @@ static const JNINativeMethod gBinderMethods[] = { // @CriticalNative { "getCallingUid", "()I", (void*)android_os_Binder_getCallingUid }, // @CriticalNative - { "isHandlingTransaction", "()Z", (void*)android_os_Binder_isHandlingTransaction }, + { "isDirectlyHandlingTransaction", "()Z", (void*)android_os_Binder_isDirectlyHandlingTransaction }, // @CriticalNative { "clearCallingIdentity", "()J", (void*)android_os_Binder_clearCallingIdentity }, // @CriticalNative @@ -1088,6 +1088,7 @@ static const JNINativeMethod gBinderMethods[] = { { "getExtension", "()Landroid/os/IBinder;", (void*)android_os_Binder_getExtension }, { "setExtension", "(Landroid/os/IBinder;)V", (void*)android_os_Binder_setExtension }, }; +// clang-format on const char* const kBinderPathName = "android/os/Binder"; diff --git a/media/jni/Android.bp b/media/jni/Android.bp index bc73f6ad1ad2..c775b6f7afc2 100644 --- a/media/jni/Android.bp +++ b/media/jni/Android.bp @@ -183,8 +183,8 @@ cc_library_shared { "libmedia", "libnativehelper", "libutils", - "tv_tuner_aidl_interface-ndk_platform", - "tv_tuner_resource_manager_aidl_interface-ndk_platform", + "tv_tuner_aidl_interface-ndk", + "tv_tuner_resource_manager_aidl_interface-ndk", ], static_libs: [ diff --git a/packages/PackageInstaller/OWNERS b/packages/PackageInstaller/OWNERS index c6331133367a..27368705c6b0 100644 --- a/packages/PackageInstaller/OWNERS +++ b/packages/PackageInstaller/OWNERS @@ -1,7 +1,5 @@ svetoslavganov@google.com -toddke@google.com -patb@google.com -suprabh@google.com +include /PACKAGE_MANAGER_OWNERS # For automotive related changes rogerxue@google.com diff --git a/packages/SettingsProvider/OWNERS b/packages/SettingsProvider/OWNERS index 6c61d4b91d36..5ade9716c8cb 100644 --- a/packages/SettingsProvider/OWNERS +++ b/packages/SettingsProvider/OWNERS @@ -2,6 +2,4 @@ hackbod@android.com hackbod@google.com narayan@google.com svetoslavganov@google.com -schfan@google.com -toddke@google.com -patb@google.com +include /PACKAGE_MANAGER_OWNERS diff --git a/services/core/java/android/content/pm/OWNERS b/services/core/java/android/content/pm/OWNERS index 5eed0b509688..39931407ec1f 100644 --- a/services/core/java/android/content/pm/OWNERS +++ b/services/core/java/android/content/pm/OWNERS @@ -1 +1 @@ -include /core/java/android/content/pm/OWNERS
\ No newline at end of file +include /PACKAGE_MANAGER_OWNERS
\ No newline at end of file diff --git a/services/core/java/com/android/server/connectivity/MultipathPolicyTracker.java b/services/core/java/com/android/server/connectivity/MultipathPolicyTracker.java index 091e6c4adf4d..a56a8ea993f0 100644 --- a/services/core/java/com/android/server/connectivity/MultipathPolicyTracker.java +++ b/services/core/java/com/android/server/connectivity/MultipathPolicyTracker.java @@ -227,7 +227,7 @@ public class MultipathPolicyTracker { subscriberId = tele.getSubscriberId(); mNetworkTemplate = new NetworkTemplate( NetworkTemplate.MATCH_MOBILE, subscriberId, new String[] { subscriberId }, - null, NetworkStats.METERED_ALL, NetworkStats.ROAMING_ALL, + null, NetworkStats.METERED_YES, NetworkStats.ROAMING_ALL, NetworkStats.DEFAULT_NETWORK_NO, NETWORK_TYPE_ALL, OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT); mUsageCallback = new UsageCallback() { diff --git a/services/core/java/com/android/server/pm/OWNERS b/services/core/java/com/android/server/pm/OWNERS index 3233819b543f..babe21c87a86 100644 --- a/services/core/java/com/android/server/pm/OWNERS +++ b/services/core/java/com/android/server/pm/OWNERS @@ -3,11 +3,9 @@ hackbod@google.com jsharkey@android.com jsharkey@google.com narayan@google.com -patb@google.com svetoslavganov@android.com svetoslavganov@google.com -toddke@android.com -toddke@google.com +include /PACKAGE_MANAGER_OWNERS # apex support per-file ApexManager.java = dariofreni@google.com, ioffe@google.com, olilan@google.com diff --git a/services/core/java/com/android/server/soundtrigger_middleware/ConversionUtil.java b/services/core/java/com/android/server/soundtrigger_middleware/ConversionUtil.java index 6366280e1762..7ffff935128f 100644 --- a/services/core/java/com/android/server/soundtrigger_middleware/ConversionUtil.java +++ b/services/core/java/com/android/server/soundtrigger_middleware/ConversionUtil.java @@ -429,15 +429,7 @@ class ConversionUtil { private static @NonNull HidlMemory parcelFileDescriptorToHidlMemory(@Nullable ParcelFileDescriptor data, int dataSize) { if (dataSize > 0) { - // Extract a dup of the underlying FileDescriptor out of data. - FileDescriptor fd = new FileDescriptor(); - try { - ParcelFileDescriptor dup = data.dup(); - fd.setInt$(dup.detachFd()); - return HidlMemoryUtil.fileDescriptorToHidlMemory(fd, dataSize); - } catch (IOException e) { - throw new RuntimeException(e); - } + return HidlMemoryUtil.fileDescriptorToHidlMemory(data.getFileDescriptor(), dataSize); } else { return HidlMemoryUtil.fileDescriptorToHidlMemory(null, 0); } diff --git a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java index ba3123431b3c..68b760a1be34 100644 --- a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +++ b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java @@ -29,6 +29,7 @@ import static android.net.NetworkIdentity.OEM_PAID; import static android.net.NetworkIdentity.OEM_PRIVATE; import static android.net.NetworkStats.DEFAULT_NETWORK_ALL; import static android.net.NetworkStats.METERED_ALL; +import static android.net.NetworkStats.METERED_YES; import static android.net.NetworkStats.ROAMING_ALL; import static android.net.NetworkTemplate.MATCH_ETHERNET; import static android.net.NetworkTemplate.MATCH_MOBILE_WILDCARD; @@ -1340,7 +1341,7 @@ public class StatsPullAtomService extends SystemService { @Nullable private NetworkStats getUidNetworkStatsSnapshotForTransport(int transport) { final NetworkTemplate template = (transport == TRANSPORT_CELLULAR) ? NetworkTemplate.buildTemplateMobileWithRatType( - /*subscriptionId=*/null, NETWORK_TYPE_ALL) + /*subscriptionId=*/null, NETWORK_TYPE_ALL, METERED_YES) : NetworkTemplate.buildTemplateWifiWildcard(); return getUidNetworkStatsSnapshotForTemplate(template, /*includeTags=*/false); } @@ -1380,7 +1381,8 @@ public class StatsPullAtomService extends SystemService { final List<NetworkStatsExt> ret = new ArrayList<>(); for (final int ratType : getAllCollapsedRatTypes()) { final NetworkTemplate template = - buildTemplateMobileWithRatType(subInfo.subscriberId, ratType); + buildTemplateMobileWithRatType(subInfo.subscriberId, ratType, + METERED_YES); final NetworkStats stats = getUidNetworkStatsSnapshotForTemplate(template, /*includeTags=*/false); if (stats != null) { @@ -2059,7 +2061,7 @@ public class StatsPullAtomService extends SystemService { if (info == null) { return StatsManager.PULL_SKIP; } - pulledData.add(FrameworkStatsLog.buildStatsEvent(atomTag, info.getTimeStamp(), + pulledData.add(FrameworkStatsLog.buildStatsEvent(atomTag, info.getTimestampMillis(), info.getBluetoothStackState(), info.getControllerTxTimeMillis(), info.getControllerRxTimeMillis(), info.getControllerIdleTimeMillis(), info.getControllerEnergyUsed())); diff --git a/services/core/java/com/android/server/tv/TvInputHardwareManager.java b/services/core/java/com/android/server/tv/TvInputHardwareManager.java index 92e0845012de..f57a852fe8c5 100755 --- a/services/core/java/com/android/server/tv/TvInputHardwareManager.java +++ b/services/core/java/com/android/server/tv/TvInputHardwareManager.java @@ -1075,17 +1075,22 @@ class TvInputHardwareManager implements TvInputHal.Callback { } if (shouldRecreateAudioPatch) { mCommittedVolume = volume; - if (mAudioPatch != null) { - mAudioManager.releaseAudioPatch(mAudioPatch); - } - mAudioManager.createAudioPatch( + // only recreate if something was updated or audioPath is null + if (mAudioPatch == null || sinkUpdated ||sourceUpdated ) { + if (mAudioPatch != null) { + mAudioManager.releaseAudioPatch(mAudioPatch); + audioPatchArray[0] = null; + } + mAudioManager.createAudioPatch( audioPatchArray, new AudioPortConfig[] { sourceConfig }, sinkConfigs.toArray(new AudioPortConfig[sinkConfigs.size()])); - mAudioPatch = audioPatchArray[0]; - if (sourceGainConfig != null) { - mAudioManager.setAudioPortGain(mAudioSource, sourceGainConfig); + mAudioPatch = audioPatchArray[0]; } + } + + if (sourceGainConfig != null) { + mAudioManager.setAudioPortGain(mAudioSource, sourceGainConfig); } } diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp index 2722b8d04370..710a304545af 100644 --- a/services/core/jni/Android.bp +++ b/services/core/jni/Android.bp @@ -165,7 +165,7 @@ cc_defaults { "android.hardware.power@1.1", "android.hardware.power-V2-cpp", "android.hardware.power.stats@1.0", - "android.hardware.power.stats-V1-ndk_platform", + "android.hardware.power.stats-V1-ndk", "android.hardware.thermal@1.0", "android.hardware.tv.input@1.0", "android.hardware.vibrator-V2-cpp", @@ -178,7 +178,7 @@ cc_defaults { "android.frameworks.schedulerservice@1.0", "android.frameworks.sensorservice@1.0", "android.frameworks.stats@1.0", - "android.frameworks.stats-V1-ndk_platform", + "android.frameworks.stats-V1-ndk", "android.system.suspend.control-V1-cpp", "android.system.suspend.control.internal-cpp", "android.system.suspend-V1-ndk", diff --git a/services/tests/PackageManagerServiceTests/OWNERS b/services/tests/PackageManagerServiceTests/OWNERS index 182dfe8fca9e..86ae5818e91c 100644 --- a/services/tests/PackageManagerServiceTests/OWNERS +++ b/services/tests/PackageManagerServiceTests/OWNERS @@ -1,3 +1 @@ -chiuwinson@google.com -patb@google.com -toddke@google.com +include /PACKAGE_MANAGER_OWNERS diff --git a/telephony/java/android/telephony/TelephonyScanManager.java b/telephony/java/android/telephony/TelephonyScanManager.java index e890acb36b48..9572154ec773 100644 --- a/telephony/java/android/telephony/TelephonyScanManager.java +++ b/telephony/java/android/telephony/TelephonyScanManager.java @@ -36,6 +36,7 @@ import com.android.telephony.Rlog; import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.concurrent.Executor; /** @@ -152,16 +153,9 @@ public final class TelephonyScanManager { throw new RuntimeException( "Failed to find NetworkScanInfo with id " + message.arg2); } - NetworkScanCallback callback = nsi.mCallback; - Executor executor = nsi.mExecutor; - if (callback == null) { - throw new RuntimeException( - "Failed to find NetworkScanCallback with id " + message.arg2); - } - if (executor == null) { - throw new RuntimeException( - "Failed to find Executor with id " + message.arg2); - } + + final NetworkScanCallback callback = nsi.mCallback; + final Executor executor = nsi.mExecutor; switch (message.what) { case CALLBACK_RESTRICTED_SCAN_RESULTS: @@ -246,17 +240,24 @@ public final class TelephonyScanManager { NetworkScanRequest request, Executor executor, NetworkScanCallback callback, String callingPackage, @Nullable String callingFeatureId) { try { + Objects.requireNonNull(request, "Request was null"); + Objects.requireNonNull(callback, "Callback was null"); + Objects.requireNonNull(executor, "Executor was null"); final ITelephony telephony = getITelephony(); if (telephony == null) return null; - int scanId = telephony.requestNetworkScan( - subId, request, mMessenger, new Binder(), callingPackage, - callingFeatureId); - if (scanId == INVALID_SCAN_ID) { - Rlog.e(TAG, "Failed to initiate network scan"); - return null; - } + // The lock must be taken before calling requestNetworkScan because the resulting + // scanId can be invoked asynchronously on another thread at any time after + // requestNetworkScan invoked, leaving a critical section between that call and adding + // the record to the ScanInfo cache. synchronized (mScanInfo) { + int scanId = telephony.requestNetworkScan( + subId, request, mMessenger, new Binder(), callingPackage, + callingFeatureId); + if (scanId == INVALID_SCAN_ID) { + Rlog.e(TAG, "Failed to initiate network scan"); + return null; + } // We link to death whenever a scan is started to ensure that we are linked // at the point that phone process death might matter. // We never unlink because: |