Merge "Support scanDirectories with JNI callback function"
diff --git a/Android.bp b/Android.bp
index 1f4c59a..c03530e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -12,6 +12,611 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+// Build the master framework library.
+
+// READ ME: ########################################################
+//
+// When updating this list of aidl files, consider if that aidl is
+// part of the SDK API.  If it is, also add it to the list in Android.mk
+// that is preprocessed and distributed with the SDK.  This list should
+// not contain any aidl files for parcelables, but the one below should
+// if you intend for 3rd parties to be able to send those objects
+// across process boundaries.
+//
+// READ ME: ########################################################
+
+java_library {
+    name: "framework",
+
+    srcs: [
+        // From build/make/core/pathmap.mk FRAMEWORK_BASE_SUBDIRS
+        "core/java/**/*.java",
+        "graphics/java/**/*.java",
+        "location/java/**/*.java",
+        "media/java/**/*.java",
+        "media/mca/effect/java/**/*.java",
+        "media/mca/filterfw/java/**/*.java",
+        "media/mca/filterpacks/java/**/*.java",
+        "drm/java/**/*.java",
+        "opengl/java/**/*.java",
+        "sax/java/**/*.java",
+        "telecomm/java/**/*.java",
+        "telephony/java/**/*.java",
+        "wifi/java/**/*.java",
+        "keystore/java/**/*.java",
+        "rs/java/**/*.java",
+
+        ":framework-javastream-protos",
+
+        "core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl",
+        "core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl",
+        "core/java/android/accounts/IAccountManager.aidl",
+        "core/java/android/accounts/IAccountManagerResponse.aidl",
+        "core/java/android/accounts/IAccountAuthenticator.aidl",
+        "core/java/android/accounts/IAccountAuthenticatorResponse.aidl",
+        "core/java/android/app/IActivityContainer.aidl",
+        "core/java/android/app/IActivityContainerCallback.aidl",
+        "core/java/android/app/IActivityController.aidl",
+        "core/java/android/app/IActivityManager.aidl",
+        "core/java/android/app/IActivityPendingResult.aidl",
+        "core/java/android/app/IAlarmCompleteListener.aidl",
+        "core/java/android/app/IAlarmListener.aidl",
+        "core/java/android/app/IAlarmManager.aidl",
+        "core/java/android/app/IAppTask.aidl",
+        "core/java/android/app/IApplicationThread.aidl",
+        "core/java/android/app/ITaskStackListener.aidl",
+        "core/java/android/app/IBackupAgent.aidl",
+        "core/java/android/app/IEphemeralResolver.aidl",
+        "core/java/android/app/IInstantAppResolver.aidl",
+        "core/java/android/app/IInstrumentationWatcher.aidl",
+        "core/java/android/app/INotificationManager.aidl",
+        "core/java/android/app/IProcessObserver.aidl",
+        "core/java/android/app/ISearchManager.aidl",
+        "core/java/android/app/ISearchManagerCallback.aidl",
+        "core/java/android/app/IServiceConnection.aidl",
+        "core/java/android/app/IStopUserCallback.aidl",
+        "core/java/android/app/job/IJobCallback.aidl",
+        "core/java/android/app/job/IJobScheduler.aidl",
+        "core/java/android/app/job/IJobService.aidl",
+        "core/java/android/app/ITransientNotification.aidl",
+        "core/java/android/app/IUidObserver.aidl",
+        "core/java/android/app/IUiAutomationConnection.aidl",
+        "core/java/android/app/IUiModeManager.aidl",
+        "core/java/android/app/IUserSwitchObserver.aidl",
+        "core/java/android/app/IWallpaperManager.aidl",
+        "core/java/android/app/IWallpaperManagerCallback.aidl",
+        "core/java/android/app/admin/IDeviceAdminService.aidl",
+        "core/java/android/app/admin/IDevicePolicyManager.aidl",
+        "core/java/android/app/trust/IStrongAuthTracker.aidl",
+        "core/java/android/app/trust/ITrustManager.aidl",
+        "core/java/android/app/trust/ITrustListener.aidl",
+        "core/java/android/app/backup/IBackupManager.aidl",
+        "core/java/android/app/backup/IBackupObserver.aidl",
+        "core/java/android/app/backup/IBackupManagerMonitor.aidl",
+        "core/java/android/app/backup/IFullBackupRestoreObserver.aidl",
+        "core/java/android/app/backup/IRestoreObserver.aidl",
+        "core/java/android/app/backup/IRestoreSession.aidl",
+        "core/java/android/app/backup/ISelectBackupTransportCallback.aidl",
+        "core/java/android/app/timezone/ICallback.aidl",
+        "core/java/android/app/timezone/IRulesManager.aidl",
+        "core/java/android/app/usage/ICacheQuotaService.aidl",
+        "core/java/android/app/usage/IStorageStatsManager.aidl",
+        "core/java/android/app/usage/IUsageStatsManager.aidl",
+        ":libbluetooth-binder-aidl",
+        "core/java/android/content/IClipboard.aidl",
+        "core/java/android/content/IContentService.aidl",
+        "core/java/android/content/IIntentReceiver.aidl",
+        "core/java/android/content/IIntentSender.aidl",
+        "core/java/android/content/IOnPrimaryClipChangedListener.aidl",
+        "core/java/android/content/IRestrictionsManager.aidl",
+        "core/java/android/content/ISyncAdapter.aidl",
+        "core/java/android/content/ISyncContext.aidl",
+        "core/java/android/content/ISyncServiceAdapter.aidl",
+        "core/java/android/content/ISyncStatusObserver.aidl",
+        "core/java/android/content/om/IOverlayManager.aidl",
+        "core/java/android/content/pm/IDexModuleRegisterCallback.aidl",
+        "core/java/android/content/pm/ILauncherApps.aidl",
+        "core/java/android/content/pm/IOnAppsChangedListener.aidl",
+        "core/java/android/content/pm/IOnPermissionsChangeListener.aidl",
+        "core/java/android/content/pm/IOtaDexopt.aidl",
+        "core/java/android/content/pm/IPackageDataObserver.aidl",
+        "core/java/android/content/pm/IPackageDeleteObserver.aidl",
+        "core/java/android/content/pm/IPackageDeleteObserver2.aidl",
+        "core/java/android/content/pm/IPackageInstallObserver.aidl",
+        "core/java/android/content/pm/IPackageInstallObserver2.aidl",
+        "core/java/android/content/pm/IPackageInstaller.aidl",
+        "core/java/android/content/pm/IPackageInstallerCallback.aidl",
+        "core/java/android/content/pm/IPackageInstallerSession.aidl",
+        "core/java/android/content/pm/IPackageManager.aidl",
+        "core/java/android/content/pm/IPackageMoveObserver.aidl",
+        "core/java/android/content/pm/IPackageStatsObserver.aidl",
+        "core/java/android/content/pm/IPinItemRequest.aidl",
+        "core/java/android/content/pm/IShortcutService.aidl",
+        "core/java/android/content/pm/permission/IRuntimePermissionPresenter.aidl",
+        "core/java/android/database/IContentObserver.aidl",
+        ":libcamera_client_aidl",
+        ":libcamera_client_framework_aidl",
+        "core/java/android/hardware/IConsumerIrService.aidl",
+        "core/java/android/hardware/ISerialManager.aidl",
+        "core/java/android/hardware/display/IDisplayManager.aidl",
+        "core/java/android/hardware/display/IDisplayManagerCallback.aidl",
+        "core/java/android/hardware/display/IVirtualDisplayCallback.aidl",
+        "core/java/android/hardware/fingerprint/IFingerprintService.aidl",
+        "core/java/android/hardware/fingerprint/IFingerprintServiceLockoutResetCallback.aidl",
+        "core/java/android/hardware/fingerprint/IFingerprintClientActiveCallback.aidl",
+        "core/java/android/hardware/fingerprint/IFingerprintServiceReceiver.aidl",
+        "core/java/android/hardware/hdmi/IHdmiControlCallback.aidl",
+        "core/java/android/hardware/hdmi/IHdmiControlService.aidl",
+        "core/java/android/hardware/hdmi/IHdmiDeviceEventListener.aidl",
+        "core/java/android/hardware/hdmi/IHdmiHotplugEventListener.aidl",
+        "core/java/android/hardware/hdmi/IHdmiInputChangeListener.aidl",
+        "core/java/android/hardware/hdmi/IHdmiMhlVendorCommandListener.aidl",
+        "core/java/android/hardware/hdmi/IHdmiRecordListener.aidl",
+        "core/java/android/hardware/hdmi/IHdmiSystemAudioModeChangeListener.aidl",
+        "core/java/android/hardware/hdmi/IHdmiVendorCommandListener.aidl",
+        "core/java/android/hardware/input/IInputManager.aidl",
+        "core/java/android/hardware/input/IInputDevicesChangedListener.aidl",
+        "core/java/android/hardware/input/ITabletModeChangedListener.aidl",
+        "core/java/android/hardware/location/IActivityRecognitionHardware.aidl",
+        "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",
+        "core/java/android/hardware/location/IContextHubCallback.aidl",
+        "core/java/android/hardware/location/IContextHubService.aidl",
+        "core/java/android/hardware/radio/IRadioService.aidl",
+        "core/java/android/hardware/radio/ITuner.aidl",
+        "core/java/android/hardware/radio/ITunerCallback.aidl",
+        "core/java/android/hardware/soundtrigger/IRecognitionStatusCallback.aidl",
+        "core/java/android/hardware/usb/IUsbManager.aidl",
+        "core/java/android/net/ICaptivePortal.aidl",
+        "core/java/android/net/IConnectivityManager.aidl",
+        "core/java/android/net/IIpConnectivityMetrics.aidl",
+        "core/java/android/net/IEthernetManager.aidl",
+        "core/java/android/net/IEthernetServiceListener.aidl",
+        "core/java/android/net/INetdEventCallback.aidl",
+        "core/java/android/net/IIpSecService.aidl",
+        "core/java/android/net/INetworkManagementEventObserver.aidl",
+        "core/java/android/net/INetworkPolicyListener.aidl",
+        "core/java/android/net/INetworkPolicyManager.aidl",
+        "core/java/android/net/INetworkRecommendationProvider.aidl",
+        "core/java/android/net/INetworkScoreCache.aidl",
+        "core/java/android/net/INetworkScoreService.aidl",
+        "core/java/android/net/INetworkStatsService.aidl",
+        "core/java/android/net/INetworkStatsSession.aidl",
+        "core/java/android/net/ITetheringStatsProvider.aidl",
+        "core/java/android/net/nsd/INsdManager.aidl",
+        "core/java/android/nfc/IAppCallback.aidl",
+        "core/java/android/nfc/INfcAdapter.aidl",
+        "core/java/android/nfc/INfcAdapterExtras.aidl",
+        "core/java/android/nfc/INfcTag.aidl",
+        "core/java/android/nfc/INfcCardEmulation.aidl",
+        "core/java/android/nfc/INfcFCardEmulation.aidl",
+        "core/java/android/nfc/INfcUnlockHandler.aidl",
+        "core/java/android/nfc/INfcDta.aidl",
+        "core/java/android/nfc/ITagRemovedCallback.aidl",
+        "core/java/android/os/IBatteryPropertiesListener.aidl",
+        "core/java/android/os/IBatteryPropertiesRegistrar.aidl",
+        "core/java/android/os/ICancellationSignal.aidl",
+        "core/java/android/os/IDeviceIdentifiersPolicyService.aidl",
+        "core/java/android/os/IDeviceIdleController.aidl",
+        "core/java/android/os/IHardwarePropertiesManager.aidl",
+        "core/java/android/os/IIncidentManager.aidl",
+        "core/java/android/os/IIncidentReportCompletedListener.aidl",
+        "core/java/android/os/IIncidentReportStatusListener.aidl",
+        "core/java/android/os/IMaintenanceActivityListener.aidl",
+        "core/java/android/os/IMessenger.aidl",
+        "core/java/android/os/INetworkActivityListener.aidl",
+        "core/java/android/os/INetworkManagementService.aidl",
+        "core/java/android/os/IPermissionController.aidl",
+        "core/java/android/os/IProcessInfoService.aidl",
+        "core/java/android/os/IProgressListener.aidl",
+        "core/java/android/os/IPowerManager.aidl",
+        "core/java/android/os/IRecoverySystem.aidl",
+        "core/java/android/os/IRecoverySystemProgressListener.aidl",
+        "core/java/android/os/IRemoteCallback.aidl",
+        "core/java/android/os/ISchedulingPolicyService.aidl",
+        "core/java/android/os/IUpdateLock.aidl",
+        "core/java/android/os/IUserManager.aidl",
+        "core/java/android/os/IVibratorService.aidl",
+        "core/java/android/os/storage/IStorageManager.aidl",
+        "core/java/android/os/storage/IStorageEventListener.aidl",
+        "core/java/android/os/storage/IStorageShutdownObserver.aidl",
+        "core/java/android/os/storage/IObbActionListener.aidl",
+        "core/java/android/security/IKeystoreService.aidl",
+        "core/java/android/security/keymaster/IKeyAttestationApplicationIdProvider.aidl",
+        "core/java/android/service/autofill/IAutoFillService.aidl",
+        "core/java/android/service/autofill/IFillCallback.aidl",
+        "core/java/android/service/autofill/ISaveCallback.aidl",
+        "core/java/android/service/carrier/ICarrierService.aidl",
+        "core/java/android/service/carrier/ICarrierMessagingCallback.aidl",
+        "core/java/android/service/carrier/ICarrierMessagingService.aidl",
+        "core/java/android/service/euicc/IDeleteSubscriptionCallback.aidl",
+        "core/java/android/service/euicc/IDownloadSubscriptionCallback.aidl",
+        "core/java/android/service/euicc/IEraseSubscriptionsCallback.aidl",
+        "core/java/android/service/euicc/IEuiccService.aidl",
+        "core/java/android/service/euicc/IGetDefaultDownloadableSubscriptionListCallback.aidl",
+        "core/java/android/service/euicc/IGetDownloadableSubscriptionMetadataCallback.aidl",
+        "core/java/android/service/euicc/IGetEidCallback.aidl",
+        "core/java/android/service/euicc/IGetEuiccInfoCallback.aidl",
+        "core/java/android/service/euicc/IGetEuiccProfileInfoListCallback.aidl",
+        "core/java/android/service/euicc/IRetainSubscriptionsForFactoryResetCallback.aidl",
+        "core/java/android/service/euicc/ISwitchToSubscriptionCallback.aidl",
+        "core/java/android/service/euicc/IUpdateSubscriptionNicknameCallback.aidl",
+        "core/java/android/service/gatekeeper/IGateKeeperService.aidl",
+        "core/java/android/service/notification/INotificationListener.aidl",
+        "core/java/android/service/notification/IStatusBarNotificationHolder.aidl",
+        "core/java/android/service/notification/IConditionListener.aidl",
+        "core/java/android/service/notification/IConditionProvider.aidl",
+        "core/java/android/service/vr/IPersistentVrStateCallbacks.aidl",
+        "core/java/android/service/vr/IVrListener.aidl",
+        "core/java/android/service/vr/IVrManager.aidl",
+        "core/java/android/service/vr/IVrStateCallbacks.aidl",
+        "core/java/android/print/ILayoutResultCallback.aidl",
+        "core/java/android/print/IPrinterDiscoveryObserver.aidl",
+        "core/java/android/print/IPrintDocumentAdapter.aidl",
+        "core/java/android/print/IPrintDocumentAdapterObserver.aidl",
+        "core/java/android/print/IPrintJobStateChangeListener.aidl",
+        "core/java/android/print/IPrintServicesChangeListener.aidl",
+        "core/java/android/printservice/recommendation/IRecommendationsChangeListener.aidl",
+        "core/java/android/print/IPrintManager.aidl",
+        "core/java/android/print/IPrintSpooler.aidl",
+        "core/java/android/print/IPrintSpoolerCallbacks.aidl",
+        "core/java/android/print/IPrintSpoolerClient.aidl",
+        "core/java/android/printservice/recommendation/IRecommendationServiceCallbacks.aidl",
+        "core/java/android/printservice/recommendation/IRecommendationService.aidl",
+        "core/java/android/print/IWriteResultCallback.aidl",
+        "core/java/android/printservice/IPrintService.aidl",
+        "core/java/android/printservice/IPrintServiceClient.aidl",
+        "core/java/android/companion/ICompanionDeviceManager.aidl",
+        "core/java/android/companion/ICompanionDeviceDiscoveryService.aidl",
+        "core/java/android/companion/ICompanionDeviceDiscoveryServiceCallback.aidl",
+        "core/java/android/companion/IFindDeviceCallback.aidl",
+        "core/java/android/service/dreams/IDreamManager.aidl",
+        "core/java/android/service/dreams/IDreamService.aidl",
+        "core/java/android/service/oemlock/IOemLockService.aidl",
+        "core/java/android/service/persistentdata/IPersistentDataBlockService.aidl",
+        "core/java/android/service/trust/ITrustAgentService.aidl",
+        "core/java/android/service/trust/ITrustAgentServiceCallback.aidl",
+        "core/java/android/service/voice/IVoiceInteractionService.aidl",
+        "core/java/android/service/voice/IVoiceInteractionSession.aidl",
+        "core/java/android/service/voice/IVoiceInteractionSessionService.aidl",
+        "core/java/android/service/wallpaper/IWallpaperConnection.aidl",
+        "core/java/android/service/wallpaper/IWallpaperEngine.aidl",
+        "core/java/android/service/wallpaper/IWallpaperService.aidl",
+        "core/java/android/service/chooser/IChooserTargetService.aidl",
+        "core/java/android/service/chooser/IChooserTargetResult.aidl",
+        "core/java/android/service/resolver/IResolverRankerService.aidl",
+        "core/java/android/service/resolver/IResolverRankerResult.aidl",
+        "core/java/android/view/accessibility/IAccessibilityInteractionConnection.aidl",
+        "core/java/android/view/accessibility/IAccessibilityInteractionConnectionCallback.aidl",
+        "core/java/android/view/accessibility/IAccessibilityManager.aidl",
+        "core/java/android/view/accessibility/IAccessibilityManagerClient.aidl",
+        "core/java/android/view/autofill/IAutoFillManager.aidl",
+        "core/java/android/view/autofill/IAutoFillManagerClient.aidl",
+        "core/java/android/view/autofill/IAutofillWindowPresenter.aidl",
+        "core/java/android/view/IApplicationToken.aidl",
+        "core/java/android/view/IAppTransitionAnimationSpecsFuture.aidl",
+        "core/java/android/view/IDockedStackListener.aidl",
+        "core/java/android/view/IGraphicsStats.aidl",
+        "core/java/android/view/IGraphicsStatsCallback.aidl",
+        "core/java/android/view/IInputFilter.aidl",
+        "core/java/android/view/IInputFilterHost.aidl",
+        "core/java/android/view/IOnKeyguardExitResult.aidl",
+        "core/java/android/view/IPinnedStackController.aidl",
+        "core/java/android/view/IPinnedStackListener.aidl",
+        "core/java/android/view/IRotationWatcher.aidl",
+        "core/java/android/view/IWallpaperVisibilityListener.aidl",
+        "core/java/android/view/IWindow.aidl",
+        "core/java/android/view/IWindowFocusObserver.aidl",
+        "core/java/android/view/IWindowId.aidl",
+        "core/java/android/view/IWindowManager.aidl",
+        "core/java/android/view/IWindowSession.aidl",
+        "core/java/android/view/IWindowSessionCallback.aidl",
+        "core/java/android/webkit/IWebViewUpdateService.aidl",
+        "core/java/android/speech/IRecognitionListener.aidl",
+        "core/java/android/speech/IRecognitionService.aidl",
+        "core/java/android/speech/tts/ITextToSpeechCallback.aidl",
+        "core/java/android/speech/tts/ITextToSpeechService.aidl",
+        "core/java/com/android/internal/app/IAppOpsCallback.aidl",
+        "core/java/com/android/internal/app/IAppOpsService.aidl",
+        "core/java/com/android/internal/app/IAssistScreenshotReceiver.aidl",
+        "core/java/com/android/internal/app/IBatteryStats.aidl",
+        "core/java/com/android/internal/app/ISoundTriggerService.aidl",
+        "core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl",
+        "core/java/com/android/internal/app/IVoiceInteractionSessionListener.aidl",
+        "core/java/com/android/internal/app/IVoiceInteractionSessionShowCallback.aidl",
+        "core/java/com/android/internal/app/IVoiceInteractor.aidl",
+        "core/java/com/android/internal/app/IVoiceInteractorCallback.aidl",
+        "core/java/com/android/internal/app/IVoiceInteractorRequest.aidl",
+        "core/java/com/android/internal/app/IMediaContainerService.aidl",
+        "core/java/com/android/internal/app/procstats/IProcessStats.aidl",
+        "core/java/com/android/internal/appwidget/IAppWidgetService.aidl",
+        "core/java/com/android/internal/appwidget/IAppWidgetHost.aidl",
+        "core/java/com/android/internal/backup/IBackupTransport.aidl",
+        "core/java/com/android/internal/backup/IObbBackupService.aidl",
+        "core/java/com/android/internal/car/ICarServiceHelper.aidl",
+        "core/java/com/android/internal/inputmethod/IInputContentUriToken.aidl",
+        "core/java/com/android/internal/policy/IKeyguardDrawnCallback.aidl",
+        "core/java/com/android/internal/policy/IKeyguardDismissCallback.aidl",
+        "core/java/com/android/internal/policy/IKeyguardExitCallback.aidl",
+        "core/java/com/android/internal/policy/IKeyguardService.aidl",
+        "core/java/com/android/internal/policy/IKeyguardStateCallback.aidl",
+        "core/java/com/android/internal/policy/IShortcutService.aidl",
+        "core/java/com/android/internal/os/IDropBoxManagerService.aidl",
+        "core/java/com/android/internal/os/IParcelFileDescriptorFactory.aidl",
+        "core/java/com/android/internal/os/IResultReceiver.aidl",
+        "core/java/com/android/internal/os/IShellCallback.aidl",
+        "core/java/com/android/internal/statusbar/IStatusBar.aidl",
+        "core/java/com/android/internal/statusbar/IStatusBarService.aidl",
+        "core/java/com/android/internal/textservice/ISpellCheckerService.aidl",
+        "core/java/com/android/internal/textservice/ISpellCheckerServiceCallback.aidl",
+        "core/java/com/android/internal/textservice/ISpellCheckerSession.aidl",
+        "core/java/com/android/internal/textservice/ISpellCheckerSessionListener.aidl",
+        "core/java/com/android/internal/textservice/ITextServicesManager.aidl",
+        "core/java/com/android/internal/textservice/ITextServicesSessionListener.aidl",
+        "core/java/com/android/internal/view/IDragAndDropPermissions.aidl",
+        "core/java/com/android/internal/view/IInputContext.aidl",
+        "core/java/com/android/internal/view/IInputContextCallback.aidl",
+        "core/java/com/android/internal/view/IInputMethod.aidl",
+        "core/java/com/android/internal/view/IInputMethodClient.aidl",
+        "core/java/com/android/internal/view/IInputMethodManager.aidl",
+        "core/java/com/android/internal/view/IInputMethodSession.aidl",
+        "core/java/com/android/internal/view/IInputSessionCallback.aidl",
+        "core/java/com/android/internal/widget/ICheckCredentialProgressCallback.aidl",
+        "core/java/com/android/internal/widget/ILockSettings.aidl",
+        "core/java/com/android/internal/widget/IRemoteViewsFactory.aidl",
+        "core/java/com/android/internal/widget/IRemoteViewsAdapterConnection.aidl",
+        "keystore/java/android/security/IKeyChainAliasCallback.aidl",
+        "keystore/java/android/security/IKeyChainService.aidl",
+        "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",
+        "location/java/android/location/IGnssStatusProvider.aidl",
+        "location/java/android/location/IGnssMeasurementsListener.aidl",
+        "location/java/android/location/IGnssNavigationMessageListener.aidl",
+        "location/java/android/location/ILocationListener.aidl",
+        "location/java/android/location/ILocationManager.aidl",
+        "location/java/android/location/IFusedGeofenceHardware.aidl",
+        "location/java/android/location/IGpsGeofenceHardware.aidl",
+        "location/java/android/location/INetInitiatedListener.aidl",
+        "location/java/com/android/internal/location/ILocationProvider.aidl",
+        "media/java/android/media/IAudioService.aidl",
+        ":libmediadrm_aidl",
+        "media/java/android/media/IAudioFocusDispatcher.aidl",
+        "media/java/android/media/IAudioRoutesObserver.aidl",
+        "media/java/android/media/IMediaHTTPConnection.aidl",
+        "media/java/android/media/IMediaHTTPService.aidl",
+        "media/java/android/media/IMediaResourceMonitor.aidl",
+        "media/java/android/media/IMediaRouterClient.aidl",
+        "media/java/android/media/IMediaRouterService.aidl",
+        "media/java/android/media/IMediaScannerListener.aidl",
+        "media/java/android/media/IMediaScannerService.aidl",
+        "media/java/android/media/IPlaybackConfigDispatcher.aidl",
+        "media/java/android/media/IPlayer.aidl",
+        "media/java/android/media/IRecordingConfigDispatcher.aidl",
+        "media/java/android/media/IRemoteDisplayCallback.aidl",
+        "media/java/android/media/IRemoteDisplayProvider.aidl",
+        "media/java/android/media/IRemoteVolumeController.aidl",
+        "media/java/android/media/IRemoteVolumeObserver.aidl",
+        "media/java/android/media/IRingtonePlayer.aidl",
+        "media/java/android/media/IVolumeController.aidl",
+        "media/java/android/media/audiopolicy/IAudioPolicyCallback.aidl",
+        "media/java/android/media/midi/IBluetoothMidiService.aidl",
+        "media/java/android/media/midi/IMidiDeviceListener.aidl",
+        "media/java/android/media/midi/IMidiDeviceOpenCallback.aidl",
+        "media/java/android/media/midi/IMidiDeviceServer.aidl",
+        "media/java/android/media/midi/IMidiManager.aidl",
+        "media/java/android/media/projection/IMediaProjection.aidl",
+        "media/java/android/media/projection/IMediaProjectionCallback.aidl",
+        "media/java/android/media/projection/IMediaProjectionManager.aidl",
+        "media/java/android/media/projection/IMediaProjectionWatcherCallback.aidl",
+        "media/java/android/media/session/IActiveSessionsListener.aidl",
+        "media/java/android/media/session/ICallback.aidl",
+        "media/java/android/media/session/IOnMediaKeyListener.aidl",
+        "media/java/android/media/session/IOnVolumeKeyLongPressListener.aidl",
+        "media/java/android/media/session/ISession.aidl",
+        "media/java/android/media/session/ISessionCallback.aidl",
+        "media/java/android/media/session/ISessionController.aidl",
+        "media/java/android/media/session/ISessionControllerCallback.aidl",
+        "media/java/android/media/session/ISessionManager.aidl",
+        "media/java/android/media/tv/ITvInputClient.aidl",
+        "media/java/android/media/tv/ITvInputHardware.aidl",
+        "media/java/android/media/tv/ITvInputHardwareCallback.aidl",
+        "media/java/android/media/tv/ITvInputManager.aidl",
+        "media/java/android/media/tv/ITvInputManagerCallback.aidl",
+        "media/java/android/media/tv/ITvInputService.aidl",
+        "media/java/android/media/tv/ITvInputServiceCallback.aidl",
+        "media/java/android/media/tv/ITvInputSession.aidl",
+        "media/java/android/media/tv/ITvInputSessionCallback.aidl",
+        "media/java/android/media/tv/ITvRemoteProvider.aidl",
+        "media/java/android/media/tv/ITvRemoteServiceInput.aidl",
+        "media/java/android/service/media/IMediaBrowserService.aidl",
+        "media/java/android/service/media/IMediaBrowserServiceCallbacks.aidl",
+        "telecomm/java/com/android/internal/telecom/ICallScreeningAdapter.aidl",
+        "telecomm/java/com/android/internal/telecom/ICallScreeningService.aidl",
+        "telecomm/java/com/android/internal/telecom/IVideoCallback.aidl",
+        "telecomm/java/com/android/internal/telecom/IVideoProvider.aidl",
+        "telecomm/java/com/android/internal/telecom/IConnectionService.aidl",
+        "telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl",
+        "telecomm/java/com/android/internal/telecom/IInCallAdapter.aidl",
+        "telecomm/java/com/android/internal/telecom/IInCallService.aidl",
+        "telecomm/java/com/android/internal/telecom/ITelecomService.aidl",
+        "telecomm/java/com/android/internal/telecom/RemoteServiceCallback.aidl",
+        "telephony/java/android/telephony/mbms/IMbmsDownloadSessionCallback.aidl",
+        "telephony/java/android/telephony/mbms/IMbmsStreamingSessionCallback.aidl",
+        "telephony/java/android/telephony/mbms/IDownloadStateCallback.aidl",
+        "telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl",
+        "telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl",
+        "telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl",
+        "telephony/java/com/android/ims/internal/IImsCallSession.aidl",
+        "telephony/java/com/android/ims/internal/IImsCallSessionListener.aidl",
+        "telephony/java/com/android/ims/internal/IImsConfig.aidl",
+        "telephony/java/com/android/ims/internal/IImsRegistrationListener.aidl",
+        "telephony/java/com/android/ims/internal/IImsEcbm.aidl",
+        "telephony/java/com/android/ims/internal/IImsEcbmListener.aidl",
+        "telephony/java/com/android/ims/internal/IImsExternalCallStateListener.aidl",
+        "telephony/java/com/android/ims/internal/IImsFeatureStatusCallback.aidl",
+        "telephony/java/com/android/ims/internal/IImsMMTelFeature.aidl",
+        "telephony/java/com/android/ims/internal/IImsMultiEndpoint.aidl",
+        "telephony/java/com/android/ims/internal/IImsRcsFeature.aidl",
+        "telephony/java/com/android/ims/internal/IImsService.aidl",
+        "telephony/java/com/android/ims/internal/IImsServiceController.aidl",
+        "telephony/java/com/android/ims/internal/IImsServiceFeatureCallback.aidl",
+        "telephony/java/com/android/ims/internal/IImsSmsFeature.aidl",
+        "telephony/java/com/android/ims/internal/IImsStreamMediaSession.aidl",
+        "telephony/java/com/android/ims/internal/IImsUt.aidl",
+        "telephony/java/com/android/ims/internal/IImsUtListener.aidl",
+        "telephony/java/com/android/ims/internal/IImsVideoCallCallback.aidl",
+        "telephony/java/com/android/ims/internal/IImsVideoCallProvider.aidl",
+        "telephony/java/com/android/ims/internal/ISmsListener.aidl",
+        "telephony/java/com/android/ims/internal/uce/uceservice/IUceService.aidl",
+        "telephony/java/com/android/ims/internal/uce/uceservice/IUceListener.aidl",
+        "telephony/java/com/android/ims/internal/uce/options/IOptionsService.aidl",
+        "telephony/java/com/android/ims/internal/uce/options/IOptionsListener.aidl",
+        "telephony/java/com/android/ims/internal/uce/presence/IPresenceService.aidl",
+        "telephony/java/com/android/ims/internal/uce/presence/IPresenceListener.aidl",
+        "telephony/java/com/android/ims/ImsConfigListener.aidl",
+        "telephony/java/com/android/internal/telephony/IApnSourceService.aidl",
+        "telephony/java/com/android/internal/telephony/ICarrierConfigLoader.aidl",
+        "telephony/java/com/android/internal/telephony/IMms.aidl",
+        "telephony/java/com/android/internal/telephony/IOnSubscriptionsChangedListener.aidl",
+        "telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl",
+        "telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl",
+        "telephony/java/com/android/internal/telephony/ISms.aidl",
+        "telephony/java/com/android/internal/telephony/ISub.aidl",
+        "telephony/java/com/android/internal/telephony/ITelephony.aidl",
+        "telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl",
+        "telephony/java/com/android/internal/telephony/IWapPushManager.aidl",
+        "telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl",
+        "wifi/java/android/net/wifi/IWifiManager.aidl",
+        "wifi/java/android/net/wifi/aware/IWifiAwareEventCallback.aidl",
+        "wifi/java/android/net/wifi/aware/IWifiAwareManager.aidl",
+        "wifi/java/android/net/wifi/aware/IWifiAwareDiscoverySessionCallback.aidl",
+        "wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl",
+        "wifi/java/android/net/wifi/IWifiScanner.aidl",
+        "wifi/java/android/net/wifi/IRttManager.aidl",
+        "packages/services/PacProcessor/com/android/net/IProxyService.aidl",
+        "packages/services/Proxy/com/android/net/IProxyCallback.aidl",
+        "packages/services/Proxy/com/android/net/IProxyPortListener.aidl",
+        "core/java/android/service/quicksettings/IQSService.aidl",
+        "core/java/android/service/quicksettings/IQSTileService.aidl",
+
+        ":libupdate_engine_aidl",
+
+        ":netd_aidl",
+        ":installd_aidl",
+
+        "core/java/android/app/admin/SecurityLogTags.logtags",
+        "core/java/android/content/EventLogTags.logtags",
+        "core/java/android/speech/tts/EventLogTags.logtags",
+        "core/java/android/net/EventLogTags.logtags",
+        "core/java/android/webkit/EventLogTags.logtags",
+        "core/java/com/android/internal/logging/EventLogTags.logtags",
+    ],
+    logtags: [
+        "core/java/android/app/admin/SecurityLogTags.logtags",
+        "core/java/android/content/EventLogTags.logtags",
+        "core/java/android/speech/tts/EventLogTags.logtags",
+        "core/java/android/net/EventLogTags.logtags",
+        "core/java/android/webkit/EventLogTags.logtags",
+        "core/java/com/android/internal/logging/EventLogTags.logtags",
+    ],
+
+    aidl: {
+        local_include_dirs: [
+            // From build/make/core/pathmap.mk FRAMEWORK_BASE_SUBDIRS
+            "core/java",
+            "graphics/java",
+            "location/java",
+            "media/java",
+            "media/mca/effect/java",
+            "media/mca/filterfw/java",
+            "media/mca/filterpacks/java",
+            "drm/java",
+            "opengl/java",
+            "sax/java",
+            "telecomm/java",
+            "telephony/java",
+            "wifi/java",
+            "keystore/java",
+            "rs/java",
+        ],
+
+        include_dirs: [
+            "system/update_engine/binder_bindings",
+            "frameworks/native/aidl/binder",
+            "frameworks/av/camera/aidl",
+            "frameworks/av/drm/libmediadrm/aidl",
+            "frameworks/native/aidl/gui",
+            "system/netd/server/binder",
+            "system/bt/binder",
+        ],
+    },
+
+    no_framework_libs: true,
+    libs: [
+        "conscrypt",
+        "okhttp",
+        "bouncycastle",
+        "ext",
+    ],
+
+    static_libs: [
+        "framework-protos",
+        "android.hardware.health-V1.0-java-constants",
+        "android.hardware.thermal-V1.0-java-constants",
+        "android.hardware.tv.input-V1.0-java-constants",
+        "android.hardware.usb-V1.0-java-constants",
+        "android.hardware.usb-V1.1-java-constants",
+        "android.hardware.vibrator-V1.0-java-constants",
+        "android.hardware.vibrator-V1.1-java-constants",
+        "android.hardware.wifi-V1.0-java-constants",
+    ],
+
+    // Loaded with System.loadLibrary by android.view.textclassifier
+    required: ["libtextclassifier"],
+
+    javac_shard_size: 150,
+
+    dxflags: [
+        "--core-library",
+        "--multi-dex",
+    ],
+}
+
+gensrcs {
+    name: "framework-javastream-protos",
+    depfile: true,
+
+    tools: [
+        "aprotoc",
+        "protoc-gen-javastream",
+        "soong_zip",
+    ],
+
+    cmd: "mkdir -p $(genDir)/$(in) " +
+        "&& $(location aprotoc) " +
+        "  --plugin=$(location protoc-gen-javastream) " +
+        "  --dependency_out=$(depfile) " +
+        "  --javastream_out=$(genDir)/$(in) " +
+        "  -Iexternal/protobuf/src " +
+        "  -I . " +
+        "  $(in) " +
+        "&& $(location soong_zip) -jar -o $(out) -C $(genDir)/$(in) -D $(genDir)/$(in)",
+
+    srcs: ["core/proto/**/*.proto"],
+    output_extension: "srcjar",
+}
+
 // Build ext.jar
 // ============================================================
 java_library {
diff --git a/Android.mk b/Android.mk
index dd53793..b745db0 100644
--- a/Android.mk
+++ b/Android.mk
@@ -15,16 +15,8 @@
 #
 LOCAL_PATH := $(call my-dir)
 
-# We have a special case here where we build the library's resources
-# independently from its code, so we need to find where the resource
-# class source got placed in the course of building the resources.
-# Thus, the magic here.
-# Also, this module cannot depend directly on the R.java file; if it
-# did, the PRIVATE_* vars for R.java wouldn't be guaranteed to be correct.
-# Instead, it depends on the R.stamp file, which lists the corresponding
-# R.java file as a prerequisite.
-# TODO: find a more appropriate way to do this.
-framework_res_source_path := APPS/framework-res_intermediates/src
+# Load framework-specific path mappings used later in the build.
+include $(LOCAL_PATH)/pathmap.mk
 
 # Build the master framework library.
 # The framework contains too many method references (>64K) for poor old DEX.
@@ -35,607 +27,6 @@
 # embedded builds use nothing in frameworks/base
 ifneq ($(ANDROID_BUILD_EMBEDDED),true)
 
-include $(CLEAR_VARS)
-
-# Load framework-specific path mappings used later in the build.
-include $(LOCAL_PATH)/pathmap.mk
-
-# FRAMEWORKS_BASE_SUBDIRS comes from build/core/pathmap.mk
-LOCAL_SRC_FILES := \
-        $(call find-other-java-files,$(FRAMEWORKS_BASE_SUBDIRS)) \
-        $(call all-proto-files-under, core/proto)
-
-# EventLogTags files.
-LOCAL_SRC_FILES += \
-       core/java/android/app/admin/SecurityLogTags.logtags \
-       core/java/android/content/EventLogTags.logtags \
-       core/java/android/speech/tts/EventLogTags.logtags \
-       core/java/android/net/EventLogTags.logtags \
-       core/java/android/webkit/EventLogTags.logtags \
-       core/java/com/android/internal/logging/EventLogTags.logtags \
-
-## READ ME: ########################################################
-##
-## When updating this list of aidl files, consider if that aidl is
-## part of the SDK API.  If it is, also add it to the list below that
-## is preprocessed and distributed with the SDK.  This list should
-## not contain any aidl files for parcelables, but the one below should
-## if you intend for 3rd parties to be able to send those objects
-## across process boundaries.
-##
-## READ ME: ########################################################
-LOCAL_SRC_FILES += \
-	core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl \
-	core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl \
-	core/java/android/accounts/IAccountManager.aidl \
-	core/java/android/accounts/IAccountManagerResponse.aidl \
-	core/java/android/accounts/IAccountAuthenticator.aidl \
-	core/java/android/accounts/IAccountAuthenticatorResponse.aidl \
-	core/java/android/app/IActivityContainer.aidl \
-	core/java/android/app/IActivityContainerCallback.aidl \
-	core/java/android/app/IActivityController.aidl \
-	core/java/android/app/IActivityManager.aidl \
-	core/java/android/app/IActivityPendingResult.aidl \
-	core/java/android/app/IAlarmCompleteListener.aidl \
-	core/java/android/app/IAlarmListener.aidl \
-	core/java/android/app/IAlarmManager.aidl \
-	core/java/android/app/IAppTask.aidl \
-	core/java/android/app/IApplicationThread.aidl \
-	core/java/android/app/ITaskStackListener.aidl \
-	core/java/android/app/IBackupAgent.aidl \
-	core/java/android/app/IEphemeralResolver.aidl \
-	core/java/android/app/IInstantAppResolver.aidl \
-	core/java/android/app/IInstrumentationWatcher.aidl \
-	core/java/android/app/INotificationManager.aidl \
-	core/java/android/app/IProcessObserver.aidl \
-	core/java/android/app/ISearchManager.aidl \
-	core/java/android/app/ISearchManagerCallback.aidl \
-	core/java/android/app/IServiceConnection.aidl \
-	core/java/android/app/IStopUserCallback.aidl \
-	core/java/android/app/job/IJobCallback.aidl \
-	core/java/android/app/job/IJobScheduler.aidl \
-	core/java/android/app/job/IJobService.aidl \
-	core/java/android/app/ITransientNotification.aidl \
-	core/java/android/app/IUidObserver.aidl \
-	core/java/android/app/IUiAutomationConnection.aidl \
-	core/java/android/app/IUiModeManager.aidl \
-	core/java/android/app/IUserSwitchObserver.aidl \
-	core/java/android/app/IWallpaperManager.aidl \
-	core/java/android/app/IWallpaperManagerCallback.aidl \
-	core/java/android/app/admin/IDeviceAdminService.aidl \
-	core/java/android/app/admin/IDevicePolicyManager.aidl \
-	core/java/android/app/trust/IStrongAuthTracker.aidl \
-	core/java/android/app/trust/ITrustManager.aidl \
-	core/java/android/app/trust/ITrustListener.aidl \
-	core/java/android/app/backup/IBackupManager.aidl \
-	core/java/android/app/backup/IBackupObserver.aidl \
-	core/java/android/app/backup/IBackupManagerMonitor.aidl \
-	core/java/android/app/backup/IFullBackupRestoreObserver.aidl \
-	core/java/android/app/backup/IRestoreObserver.aidl \
-	core/java/android/app/backup/IRestoreSession.aidl \
-	core/java/android/app/backup/ISelectBackupTransportCallback.aidl \
-	core/java/android/app/timezone/ICallback.aidl \
-	core/java/android/app/timezone/IRulesManager.aidl \
-	core/java/android/app/usage/ICacheQuotaService.aidl \
-	core/java/android/app/usage/IStorageStatsManager.aidl \
-	core/java/android/app/usage/IUsageStatsManager.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetooth.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothA2dp.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothA2dpSink.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothAvrcpController.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothCallback.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothProfileServiceConnection.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothHeadset.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothHeadsetPhone.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothHealth.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothHealthCallback.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothHidHost.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothPan.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothManager.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothManagerCallback.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothMap.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothMapClient.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothPbap.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothPbapClient.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothSap.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothSocketManager.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothStateChangeCallback.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothHeadsetClient.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothHidDevice.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothHidDeviceCallback.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothGatt.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothGattCallback.aidl \
-	../../system/bt/binder/android/bluetooth/IBluetoothGattServerCallback.aidl \
-	../../system/bt/binder/android/bluetooth/le/IAdvertisingSetCallback.aidl \
-	../../system/bt/binder/android/bluetooth/le/IPeriodicAdvertisingCallback.aidl \
-	../../system/bt/binder/android/bluetooth/le/IScannerCallback.aidl \
-	core/java/android/content/IClipboard.aidl \
-	core/java/android/content/IContentService.aidl \
-	core/java/android/content/IIntentReceiver.aidl \
-	core/java/android/content/IIntentSender.aidl \
-	core/java/android/content/IOnPrimaryClipChangedListener.aidl \
-	core/java/android/content/IRestrictionsManager.aidl \
-	core/java/android/content/ISyncAdapter.aidl \
-	core/java/android/content/ISyncContext.aidl \
-	core/java/android/content/ISyncServiceAdapter.aidl \
-	core/java/android/content/ISyncStatusObserver.aidl \
-	core/java/android/content/om/IOverlayManager.aidl \
-	core/java/android/content/pm/IDexModuleRegisterCallback.aidl \
-	core/java/android/content/pm/ILauncherApps.aidl \
-	core/java/android/content/pm/IOnAppsChangedListener.aidl \
-	core/java/android/content/pm/IOnPermissionsChangeListener.aidl \
-	core/java/android/content/pm/IOtaDexopt.aidl \
-	core/java/android/content/pm/IPackageDataObserver.aidl \
-	core/java/android/content/pm/IPackageDeleteObserver.aidl \
-	core/java/android/content/pm/IPackageDeleteObserver2.aidl \
-	core/java/android/content/pm/IPackageInstallObserver.aidl \
-	core/java/android/content/pm/IPackageInstallObserver2.aidl \
-	core/java/android/content/pm/IPackageInstaller.aidl \
-	core/java/android/content/pm/IPackageInstallerCallback.aidl \
-	core/java/android/content/pm/IPackageInstallerSession.aidl \
-	core/java/android/content/pm/IPackageManager.aidl \
-	core/java/android/content/pm/IPackageMoveObserver.aidl \
-	core/java/android/content/pm/IPackageStatsObserver.aidl \
-	core/java/android/content/pm/IPinItemRequest.aidl \
-	core/java/android/content/pm/IShortcutService.aidl \
-	core/java/android/content/pm/permission/IRuntimePermissionPresenter.aidl \
-	core/java/android/database/IContentObserver.aidl \
-	../av/camera/aidl/android/hardware/ICameraService.aidl \
-	../av/camera/aidl/android/hardware/ICameraServiceListener.aidl \
-	../av/camera/aidl/android/hardware/ICameraServiceProxy.aidl \
-	../av/camera/aidl/android/hardware/ICamera.aidl \
-	../av/camera/aidl/android/hardware/ICameraClient.aidl \
-	../av/camera/aidl/android/hardware/camera2/ICameraDeviceUser.aidl \
-	../av/camera/aidl/android/hardware/camera2/ICameraDeviceCallbacks.aidl \
-	core/java/android/hardware/IConsumerIrService.aidl \
-	core/java/android/hardware/ISerialManager.aidl \
-	core/java/android/hardware/display/IDisplayManager.aidl \
-	core/java/android/hardware/display/IDisplayManagerCallback.aidl \
-	core/java/android/hardware/display/IVirtualDisplayCallback.aidl \
-	core/java/android/hardware/fingerprint/IFingerprintService.aidl \
-	core/java/android/hardware/fingerprint/IFingerprintServiceLockoutResetCallback.aidl \
-	core/java/android/hardware/fingerprint/IFingerprintClientActiveCallback.aidl \
-	core/java/android/hardware/fingerprint/IFingerprintServiceReceiver.aidl \
-	core/java/android/hardware/hdmi/IHdmiControlCallback.aidl \
-	core/java/android/hardware/hdmi/IHdmiControlService.aidl \
-	core/java/android/hardware/hdmi/IHdmiDeviceEventListener.aidl \
-	core/java/android/hardware/hdmi/IHdmiHotplugEventListener.aidl \
-	core/java/android/hardware/hdmi/IHdmiInputChangeListener.aidl \
-	core/java/android/hardware/hdmi/IHdmiMhlVendorCommandListener.aidl \
-	core/java/android/hardware/hdmi/IHdmiRecordListener.aidl \
-	core/java/android/hardware/hdmi/IHdmiSystemAudioModeChangeListener.aidl \
-	core/java/android/hardware/hdmi/IHdmiVendorCommandListener.aidl \
-	core/java/android/hardware/input/IInputManager.aidl \
-	core/java/android/hardware/input/IInputDevicesChangedListener.aidl \
-	core/java/android/hardware/input/ITabletModeChangedListener.aidl \
-	core/java/android/hardware/location/IActivityRecognitionHardware.aidl \
-	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 \
-	core/java/android/hardware/location/IContextHubCallback.aidl \
-	core/java/android/hardware/location/IContextHubService.aidl \
-	core/java/android/hardware/radio/IRadioService.aidl \
-	core/java/android/hardware/radio/ITuner.aidl \
-	core/java/android/hardware/radio/ITunerCallback.aidl \
-	core/java/android/hardware/soundtrigger/IRecognitionStatusCallback.aidl \
-	core/java/android/hardware/usb/IUsbManager.aidl \
-	core/java/android/net/ICaptivePortal.aidl \
-	core/java/android/net/IConnectivityManager.aidl \
-	core/java/android/net/IIpConnectivityMetrics.aidl \
-	core/java/android/net/IEthernetManager.aidl \
-	core/java/android/net/IEthernetServiceListener.aidl \
-	core/java/android/net/INetdEventCallback.aidl \
-	core/java/android/net/IIpSecService.aidl \
-	core/java/android/net/INetworkManagementEventObserver.aidl \
-	core/java/android/net/INetworkPolicyListener.aidl \
-	core/java/android/net/INetworkPolicyManager.aidl \
-	core/java/android/net/INetworkRecommendationProvider.aidl \
-	core/java/android/net/INetworkScoreCache.aidl \
-	core/java/android/net/INetworkScoreService.aidl \
-	core/java/android/net/INetworkStatsService.aidl \
-	core/java/android/net/INetworkStatsSession.aidl \
-	core/java/android/net/ITetheringStatsProvider.aidl \
-	core/java/android/net/nsd/INsdManager.aidl \
-	core/java/android/nfc/IAppCallback.aidl \
-	core/java/android/nfc/INfcAdapter.aidl \
-	core/java/android/nfc/INfcAdapterExtras.aidl \
-	core/java/android/nfc/INfcTag.aidl \
-	core/java/android/nfc/INfcCardEmulation.aidl \
-	core/java/android/nfc/INfcFCardEmulation.aidl \
-	core/java/android/nfc/INfcUnlockHandler.aidl \
-	core/java/android/nfc/INfcDta.aidl \
-	core/java/android/nfc/ITagRemovedCallback.aidl \
-	core/java/android/os/IBatteryPropertiesListener.aidl \
-	core/java/android/os/IBatteryPropertiesRegistrar.aidl \
-	core/java/android/os/ICancellationSignal.aidl \
-	core/java/android/os/IDeviceIdentifiersPolicyService.aidl \
-	core/java/android/os/IDeviceIdleController.aidl \
-	core/java/android/os/IHardwarePropertiesManager.aidl \
-	core/java/android/os/IIncidentManager.aidl \
-	core/java/android/os/IIncidentReportCompletedListener.aidl \
-	core/java/android/os/IIncidentReportStatusListener.aidl \
-	core/java/android/os/IMaintenanceActivityListener.aidl \
-	core/java/android/os/IMessenger.aidl \
-	core/java/android/os/INetworkActivityListener.aidl \
-	core/java/android/os/INetworkManagementService.aidl \
-	core/java/android/os/IPermissionController.aidl \
-	core/java/android/os/IProcessInfoService.aidl \
-	core/java/android/os/IProgressListener.aidl \
-	core/java/android/os/IPowerManager.aidl \
-	core/java/android/os/IRecoverySystem.aidl \
-	core/java/android/os/IRecoverySystemProgressListener.aidl \
-	core/java/android/os/IRemoteCallback.aidl \
-	core/java/android/os/ISchedulingPolicyService.aidl \
-	core/java/android/os/IUpdateLock.aidl \
-	core/java/android/os/IUserManager.aidl \
-	core/java/android/os/IVibratorService.aidl \
-	core/java/android/os/storage/IStorageManager.aidl \
-	core/java/android/os/storage/IStorageEventListener.aidl \
-	core/java/android/os/storage/IStorageShutdownObserver.aidl \
-	core/java/android/os/storage/IObbActionListener.aidl \
-	core/java/android/security/IKeystoreService.aidl \
-	core/java/android/security/keymaster/IKeyAttestationApplicationIdProvider.aidl \
-	core/java/android/service/autofill/IAutoFillService.aidl \
-	core/java/android/service/autofill/IFillCallback.aidl \
-	core/java/android/service/autofill/ISaveCallback.aidl \
-	core/java/android/service/carrier/ICarrierService.aidl \
-	core/java/android/service/carrier/ICarrierMessagingCallback.aidl \
-	core/java/android/service/carrier/ICarrierMessagingService.aidl \
-	core/java/android/service/euicc/IDeleteSubscriptionCallback.aidl \
-	core/java/android/service/euicc/IDownloadSubscriptionCallback.aidl \
-	core/java/android/service/euicc/IEraseSubscriptionsCallback.aidl \
-	core/java/android/service/euicc/IEuiccService.aidl \
-	core/java/android/service/euicc/IGetDefaultDownloadableSubscriptionListCallback.aidl \
-	core/java/android/service/euicc/IGetDownloadableSubscriptionMetadataCallback.aidl \
-	core/java/android/service/euicc/IGetEidCallback.aidl \
-	core/java/android/service/euicc/IGetEuiccInfoCallback.aidl \
-	core/java/android/service/euicc/IGetEuiccProfileInfoListCallback.aidl \
-	core/java/android/service/euicc/IRetainSubscriptionsForFactoryResetCallback.aidl \
-	core/java/android/service/euicc/ISwitchToSubscriptionCallback.aidl \
-	core/java/android/service/euicc/IUpdateSubscriptionNicknameCallback.aidl \
-	core/java/android/service/gatekeeper/IGateKeeperService.aidl \
-	core/java/android/service/notification/INotificationListener.aidl \
-	core/java/android/service/notification/IStatusBarNotificationHolder.aidl \
-	core/java/android/service/notification/IConditionListener.aidl \
-	core/java/android/service/notification/IConditionProvider.aidl \
-	core/java/android/service/vr/IPersistentVrStateCallbacks.aidl \
-	core/java/android/service/vr/IVrListener.aidl \
-	core/java/android/service/vr/IVrManager.aidl \
-	core/java/android/service/vr/IVrStateCallbacks.aidl \
-	core/java/android/print/ILayoutResultCallback.aidl \
-	core/java/android/print/IPrinterDiscoveryObserver.aidl \
-	core/java/android/print/IPrintDocumentAdapter.aidl \
-	core/java/android/print/IPrintDocumentAdapterObserver.aidl \
-	core/java/android/print/IPrintJobStateChangeListener.aidl \
-	core/java/android/print/IPrintServicesChangeListener.aidl \
-	core/java/android/printservice/recommendation/IRecommendationsChangeListener.aidl \
-	core/java/android/print/IPrintManager.aidl \
-	core/java/android/print/IPrintSpooler.aidl \
-	core/java/android/print/IPrintSpoolerCallbacks.aidl \
-	core/java/android/print/IPrintSpoolerClient.aidl \
-	core/java/android/printservice/recommendation/IRecommendationServiceCallbacks.aidl \
-	core/java/android/printservice/recommendation/IRecommendationService.aidl \
-	core/java/android/print/IWriteResultCallback.aidl \
-	core/java/android/printservice/IPrintService.aidl \
-	core/java/android/printservice/IPrintServiceClient.aidl \
-	core/java/android/companion/ICompanionDeviceManager.aidl \
-	core/java/android/companion/ICompanionDeviceDiscoveryService.aidl \
-	core/java/android/companion/ICompanionDeviceDiscoveryServiceCallback.aidl \
-	core/java/android/companion/IFindDeviceCallback.aidl \
-	core/java/android/service/dreams/IDreamManager.aidl \
-	core/java/android/service/dreams/IDreamService.aidl \
-	core/java/android/service/oemlock/IOemLockService.aidl \
-	core/java/android/service/persistentdata/IPersistentDataBlockService.aidl \
-	core/java/android/service/trust/ITrustAgentService.aidl \
-	core/java/android/service/trust/ITrustAgentServiceCallback.aidl \
-	core/java/android/service/voice/IVoiceInteractionService.aidl \
-	core/java/android/service/voice/IVoiceInteractionSession.aidl \
-	core/java/android/service/voice/IVoiceInteractionSessionService.aidl \
-	core/java/android/service/wallpaper/IWallpaperConnection.aidl \
-	core/java/android/service/wallpaper/IWallpaperEngine.aidl \
-	core/java/android/service/wallpaper/IWallpaperService.aidl \
-	core/java/android/service/chooser/IChooserTargetService.aidl \
-	core/java/android/service/chooser/IChooserTargetResult.aidl \
-	core/java/android/service/resolver/IResolverRankerService.aidl \
-	core/java/android/service/resolver/IResolverRankerResult.aidl \
-	core/java/android/view/accessibility/IAccessibilityInteractionConnection.aidl\
-	core/java/android/view/accessibility/IAccessibilityInteractionConnectionCallback.aidl\
-	core/java/android/view/accessibility/IAccessibilityManager.aidl \
-	core/java/android/view/accessibility/IAccessibilityManagerClient.aidl \
-	core/java/android/view/autofill/IAutoFillManager.aidl \
-	core/java/android/view/autofill/IAutoFillManagerClient.aidl \
-	core/java/android/view/autofill/IAutofillWindowPresenter.aidl \
-	core/java/android/view/IApplicationToken.aidl \
-	core/java/android/view/IAppTransitionAnimationSpecsFuture.aidl \
-	core/java/android/view/IDockedStackListener.aidl \
-	core/java/android/view/IGraphicsStats.aidl \
-	core/java/android/view/IGraphicsStatsCallback.aidl \
-	core/java/android/view/IInputFilter.aidl \
-	core/java/android/view/IInputFilterHost.aidl \
-	core/java/android/view/IOnKeyguardExitResult.aidl \
-	core/java/android/view/IPinnedStackController.aidl \
-	core/java/android/view/IPinnedStackListener.aidl \
-	core/java/android/view/IRotationWatcher.aidl \
-	core/java/android/view/IWallpaperVisibilityListener.aidl \
-	core/java/android/view/IWindow.aidl \
-	core/java/android/view/IWindowFocusObserver.aidl \
-	core/java/android/view/IWindowId.aidl \
-	core/java/android/view/IWindowManager.aidl \
-	core/java/android/view/IWindowSession.aidl \
-	core/java/android/view/IWindowSessionCallback.aidl \
-	core/java/android/webkit/IWebViewUpdateService.aidl \
-	core/java/android/speech/IRecognitionListener.aidl \
-	core/java/android/speech/IRecognitionService.aidl \
-	core/java/android/speech/tts/ITextToSpeechCallback.aidl \
-	core/java/android/speech/tts/ITextToSpeechService.aidl \
-	core/java/com/android/internal/app/IAppOpsCallback.aidl \
-	core/java/com/android/internal/app/IAppOpsService.aidl \
-	core/java/com/android/internal/app/IAssistScreenshotReceiver.aidl \
-	core/java/com/android/internal/app/IBatteryStats.aidl \
-	core/java/com/android/internal/app/ISoundTriggerService.aidl \
-	core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl \
-	core/java/com/android/internal/app/IVoiceInteractionSessionListener.aidl \
-	core/java/com/android/internal/app/IVoiceInteractionSessionShowCallback.aidl \
-	core/java/com/android/internal/app/IVoiceInteractor.aidl \
-	core/java/com/android/internal/app/IVoiceInteractorCallback.aidl \
-	core/java/com/android/internal/app/IVoiceInteractorRequest.aidl \
-	core/java/com/android/internal/app/IMediaContainerService.aidl \
-	core/java/com/android/internal/app/procstats/IProcessStats.aidl \
-	core/java/com/android/internal/appwidget/IAppWidgetService.aidl \
-	core/java/com/android/internal/appwidget/IAppWidgetHost.aidl \
-	core/java/com/android/internal/backup/IBackupTransport.aidl \
-	core/java/com/android/internal/backup/IObbBackupService.aidl \
-	core/java/com/android/internal/car/ICarServiceHelper.aidl \
-	core/java/com/android/internal/inputmethod/IInputContentUriToken.aidl \
-	core/java/com/android/internal/policy/IKeyguardDrawnCallback.aidl \
-	core/java/com/android/internal/policy/IKeyguardDismissCallback.aidl \
-	core/java/com/android/internal/policy/IKeyguardExitCallback.aidl \
-	core/java/com/android/internal/policy/IKeyguardService.aidl \
-	core/java/com/android/internal/policy/IKeyguardStateCallback.aidl \
-	core/java/com/android/internal/policy/IShortcutService.aidl \
-	core/java/com/android/internal/os/IDropBoxManagerService.aidl \
-	core/java/com/android/internal/os/IParcelFileDescriptorFactory.aidl \
-	core/java/com/android/internal/os/IResultReceiver.aidl \
-	core/java/com/android/internal/os/IShellCallback.aidl \
-	core/java/com/android/internal/statusbar/IStatusBar.aidl \
-	core/java/com/android/internal/statusbar/IStatusBarService.aidl \
-	core/java/com/android/internal/textservice/ISpellCheckerService.aidl \
-	core/java/com/android/internal/textservice/ISpellCheckerServiceCallback.aidl \
-	core/java/com/android/internal/textservice/ISpellCheckerSession.aidl \
-	core/java/com/android/internal/textservice/ISpellCheckerSessionListener.aidl \
-	core/java/com/android/internal/textservice/ITextServicesManager.aidl \
-	core/java/com/android/internal/textservice/ITextServicesSessionListener.aidl \
-	core/java/com/android/internal/view/IDragAndDropPermissions.aidl \
-	core/java/com/android/internal/view/IInputContext.aidl \
-	core/java/com/android/internal/view/IInputContextCallback.aidl \
-	core/java/com/android/internal/view/IInputMethod.aidl \
-	core/java/com/android/internal/view/IInputMethodClient.aidl \
-	core/java/com/android/internal/view/IInputMethodManager.aidl \
-	core/java/com/android/internal/view/IInputMethodSession.aidl \
-	core/java/com/android/internal/view/IInputSessionCallback.aidl \
-	core/java/com/android/internal/widget/ICheckCredentialProgressCallback.aidl \
-	core/java/com/android/internal/widget/ILockSettings.aidl \
-	core/java/com/android/internal/widget/IRemoteViewsFactory.aidl \
-	core/java/com/android/internal/widget/IRemoteViewsAdapterConnection.aidl \
-	keystore/java/android/security/IKeyChainAliasCallback.aidl \
-	keystore/java/android/security/IKeyChainService.aidl \
-	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 \
-	location/java/android/location/IGnssStatusProvider.aidl \
-	location/java/android/location/IGnssMeasurementsListener.aidl \
-	location/java/android/location/IGnssNavigationMessageListener.aidl \
-	location/java/android/location/ILocationListener.aidl \
-	location/java/android/location/ILocationManager.aidl \
-	location/java/android/location/IFusedGeofenceHardware.aidl \
-	location/java/android/location/IGpsGeofenceHardware.aidl \
-	location/java/android/location/INetInitiatedListener.aidl \
-	location/java/com/android/internal/location/ILocationProvider.aidl \
-	media/java/android/media/IAudioService.aidl \
-	../av/drm/libmediadrm/aidl/android/media/ICas.aidl \
-	../av/drm/libmediadrm/aidl/android/media/ICasListener.aidl \
-	../av/drm/libmediadrm/aidl/android/media/IDescrambler.aidl \
-	../av/drm/libmediadrm/aidl/android/media/IMediaCasService.aidl \
-	media/java/android/media/IAudioFocusDispatcher.aidl \
-	media/java/android/media/IAudioRoutesObserver.aidl \
-	media/java/android/media/IMediaHTTPConnection.aidl \
-	media/java/android/media/IMediaHTTPService.aidl \
-	media/java/android/media/IMediaResourceMonitor.aidl \
-	media/java/android/media/IMediaRouterClient.aidl \
-	media/java/android/media/IMediaRouterService.aidl \
-	media/java/android/media/IMediaScannerListener.aidl \
-	media/java/android/media/IMediaScannerService.aidl \
-	media/java/android/media/IPlaybackConfigDispatcher.aidl \
-	media/java/android/media/IPlayer.aidl \
-	media/java/android/media/IRecordingConfigDispatcher.aidl \
-	media/java/android/media/IRemoteDisplayCallback.aidl \
-	media/java/android/media/IRemoteDisplayProvider.aidl \
-	media/java/android/media/IRemoteVolumeController.aidl \
-	media/java/android/media/IRemoteVolumeObserver.aidl \
-	media/java/android/media/IRingtonePlayer.aidl \
-	media/java/android/media/IVolumeController.aidl \
-	media/java/android/media/audiopolicy/IAudioPolicyCallback.aidl \
-	media/java/android/media/midi/IBluetoothMidiService.aidl \
-	media/java/android/media/midi/IMidiDeviceListener.aidl \
-	media/java/android/media/midi/IMidiDeviceOpenCallback.aidl \
-	media/java/android/media/midi/IMidiDeviceServer.aidl \
-	media/java/android/media/midi/IMidiManager.aidl \
-	media/java/android/media/projection/IMediaProjection.aidl \
-	media/java/android/media/projection/IMediaProjectionCallback.aidl \
-	media/java/android/media/projection/IMediaProjectionManager.aidl \
-	media/java/android/media/projection/IMediaProjectionWatcherCallback.aidl \
-	media/java/android/media/session/IActiveSessionsListener.aidl \
-	media/java/android/media/session/ICallback.aidl \
-	media/java/android/media/session/IOnMediaKeyListener.aidl \
-	media/java/android/media/session/IOnVolumeKeyLongPressListener.aidl \
-	media/java/android/media/session/ISession.aidl \
-	media/java/android/media/session/ISessionCallback.aidl \
-	media/java/android/media/session/ISessionController.aidl \
-	media/java/android/media/session/ISessionControllerCallback.aidl \
-	media/java/android/media/session/ISessionManager.aidl \
-	media/java/android/media/tv/ITvInputClient.aidl \
-	media/java/android/media/tv/ITvInputHardware.aidl \
-	media/java/android/media/tv/ITvInputHardwareCallback.aidl \
-	media/java/android/media/tv/ITvInputManager.aidl \
-	media/java/android/media/tv/ITvInputManagerCallback.aidl \
-	media/java/android/media/tv/ITvInputService.aidl \
-	media/java/android/media/tv/ITvInputServiceCallback.aidl \
-	media/java/android/media/tv/ITvInputSession.aidl \
-	media/java/android/media/tv/ITvInputSessionCallback.aidl \
-	media/java/android/media/tv/ITvRemoteProvider.aidl \
-	media/java/android/media/tv/ITvRemoteServiceInput.aidl \
-	media/java/android/service/media/IMediaBrowserService.aidl \
-	media/java/android/service/media/IMediaBrowserServiceCallbacks.aidl \
-	telecomm/java/com/android/internal/telecom/ICallScreeningAdapter.aidl \
-	telecomm/java/com/android/internal/telecom/ICallScreeningService.aidl \
-	telecomm/java/com/android/internal/telecom/IVideoCallback.aidl \
-	telecomm/java/com/android/internal/telecom/IVideoProvider.aidl \
-	telecomm/java/com/android/internal/telecom/IConnectionService.aidl \
-	telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl \
-	telecomm/java/com/android/internal/telecom/IInCallAdapter.aidl \
-	telecomm/java/com/android/internal/telecom/IInCallService.aidl \
-	telecomm/java/com/android/internal/telecom/ITelecomService.aidl \
-	telecomm/java/com/android/internal/telecom/RemoteServiceCallback.aidl \
-	telephony/java/android/telephony/mbms/IMbmsDownloadSessionCallback.aidl \
-	telephony/java/android/telephony/mbms/IMbmsStreamingSessionCallback.aidl \
-	telephony/java/android/telephony/mbms/IDownloadStateCallback.aidl \
-        telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl \
-	telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl \
-	telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl \
-	telephony/java/com/android/ims/internal/IImsCallSession.aidl \
-	telephony/java/com/android/ims/internal/IImsCallSessionListener.aidl \
-	telephony/java/com/android/ims/internal/IImsConfig.aidl \
-	telephony/java/com/android/ims/internal/IImsRegistrationListener.aidl \
-	telephony/java/com/android/ims/internal/IImsEcbm.aidl \
-	telephony/java/com/android/ims/internal/IImsEcbmListener.aidl \
-        telephony/java/com/android/ims/internal/IImsExternalCallStateListener.aidl \
-        telephony/java/com/android/ims/internal/IImsFeatureStatusCallback.aidl \
-        telephony/java/com/android/ims/internal/IImsMultiEndpoint.aidl \
-	telephony/java/com/android/ims/internal/IImsService.aidl \
-	telephony/java/com/android/ims/internal/IImsServiceController.aidl \
-	telephony/java/com/android/ims/internal/IImsServiceFeatureListener.aidl \
-	telephony/java/com/android/ims/internal/IImsStreamMediaSession.aidl \
-	telephony/java/com/android/ims/internal/IImsUt.aidl \
-	telephony/java/com/android/ims/internal/IImsUtListener.aidl \
-	telephony/java/com/android/ims/internal/IImsVideoCallCallback.aidl \
-	telephony/java/com/android/ims/internal/IImsVideoCallProvider.aidl \
-        telephony/java/com/android/ims/internal/uce/uceservice/IUceService.aidl \
-        telephony/java/com/android/ims/internal/uce/uceservice/IUceListener.aidl \
-        telephony/java/com/android/ims/internal/uce/options/IOptionsService.aidl \
-        telephony/java/com/android/ims/internal/uce/options/IOptionsListener.aidl \
-        telephony/java/com/android/ims/internal/uce/presence/IPresenceService.aidl \
-        telephony/java/com/android/ims/internal/uce/presence/IPresenceListener.aidl \
-	telephony/java/com/android/ims/ImsConfigListener.aidl \
-	telephony/java/com/android/internal/telephony/IApnSourceService.aidl \
-	telephony/java/com/android/internal/telephony/ICarrierConfigLoader.aidl \
-	telephony/java/com/android/internal/telephony/IMms.aidl \
-	telephony/java/com/android/internal/telephony/IOnSubscriptionsChangedListener.aidl \
-	telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \
-	telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \
-	telephony/java/com/android/internal/telephony/ISms.aidl \
-	telephony/java/com/android/internal/telephony/ISub.aidl \
-	telephony/java/com/android/internal/telephony/ITelephony.aidl \
-	telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \
-	telephony/java/com/android/internal/telephony/IWapPushManager.aidl \
-	telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl \
-	wifi/java/android/net/wifi/IWifiManager.aidl \
-	wifi/java/android/net/wifi/aware/IWifiAwareEventCallback.aidl \
-	wifi/java/android/net/wifi/aware/IWifiAwareManager.aidl \
-	wifi/java/android/net/wifi/aware/IWifiAwareDiscoverySessionCallback.aidl \
-	wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl \
-	wifi/java/android/net/wifi/IWifiScanner.aidl \
-	wifi/java/android/net/wifi/IRttManager.aidl \
-	packages/services/PacProcessor/com/android/net/IProxyService.aidl \
-	packages/services/Proxy/com/android/net/IProxyCallback.aidl \
-	packages/services/Proxy/com/android/net/IProxyPortListener.aidl \
-	core/java/android/service/quicksettings/IQSService.aidl \
-	core/java/android/service/quicksettings/IQSTileService.aidl \
-
-# The following are native binders that need to go with the native component
-# at system/update_engine/binder_bindings/. Use relative path to refer to them.
-LOCAL_SRC_FILES += \
-	../../system/update_engine/binder_bindings/android/os/IUpdateEngine.aidl \
-	../../system/update_engine/binder_bindings/android/os/IUpdateEngineCallback.aidl \
-
-LOCAL_SRC_FILES += \
-	../../system/netd/server/binder/android/net/INetd.aidl \
-	../native/cmds/installd/binder/android/os/IInstalld.aidl \
-
-LOCAL_AIDL_INCLUDES += system/update_engine/binder_bindings
-
-# FRAMEWORKS_BASE_JAVA_SRC_DIRS comes from build/core/pathmap.mk
-LOCAL_AIDL_INCLUDES += \
-      $(FRAMEWORKS_BASE_JAVA_SRC_DIRS) \
-      frameworks/native/aidl/binder
-
-LOCAL_AIDL_INCLUDES += \
-	frameworks/av/camera/aidl \
-	frameworks/av/drm/libmediadrm/aidl \
-	frameworks/native/aidl/gui \
-	system/netd/server/binder \
-	system/bt/binder
-
-LOCAL_INTERMEDIATE_SOURCES := \
-			$(framework_res_source_path)/android/R.java \
-			$(framework_res_source_path)/android/Manifest.java \
-			$(framework_res_source_path)/com/android/internal/R.java
-
-# Make sure that R.java and Manifest.java are built before we build
-# the source for this library.
-framework_res_R_stamp := \
-	$(call intermediates-dir-for,APPS,framework-res,,COMMON)/src/R.stamp
-LOCAL_ADDITIONAL_DEPENDENCIES := $(framework_res_R_stamp)
-
-LOCAL_NO_STANDARD_LIBRARIES := true
-LOCAL_JAVA_LIBRARIES := core-oj core-libart conscrypt okhttp bouncycastle ext
-
-LOCAL_STATIC_JAVA_LIBRARIES :=                          \
-    framework-protos                                    \
-    android.hardware.health-V1.0-java-constants          \
-    android.hardware.thermal-V1.0-java-constants         \
-    android.hardware.tv.input-V1.0-java-constants        \
-    android.hardware.usb-V1.0-java-constants             \
-    android.hardware.usb-V1.1-java-constants             \
-    android.hardware.vibrator-V1.0-java-constants        \
-    android.hardware.vibrator-V1.1-java-constants        \
-    android.hardware.wifi-V1.0-java-constants            \
-
-# Loaded with System.loadLibrary by android.view.textclassifier
-LOCAL_REQUIRED_MODULES += libtextclassifier
-
-LOCAL_PROTOC_OPTIMIZE_TYPE := stream
-LOCAL_PROTOC_FLAGS := \
-    -Iexternal/protobuf/src
-
-LOCAL_MODULE := framework
-
-LOCAL_JAVAC_SHARD_SIZE := 150
-
-LOCAL_DX_FLAGS := --core-library --multi-dex
-LOCAL_JACK_FLAGS := --multi-dex native
-
-LOCAL_RMTYPEDEFS := true
-
-ifeq ($(EMMA_INSTRUMENT_FRAMEWORK),true)
-LOCAL_EMMA_INSTRUMENT := true
-endif
-
-include $(BUILD_JAVA_LIBRARY)
-
-framework_module := $(LOCAL_INSTALLED_MODULE)
-$(framework_module): | $(dir $(framework_module))framework-res.apk
-
-framework_built := $(call java-lib-deps,framework)
-
 # Copy AIDL files to be preprocessed and included in the SDK,
 # specified relative to the root of the build tree.
 # ============================================================
@@ -655,6 +46,7 @@
 	frameworks/base/telephony/java/android/telephony/NeighboringCellInfo.aidl \
 	frameworks/base/telephony/java/android/telephony/ModemActivityInfo.aidl \
 	frameworks/base/telephony/java/android/telephony/UiccAccessRule.aidl \
+	frameworks/base/telephony/java/android/telephony/data/DataProfile.aidl \
 	frameworks/base/telephony/java/android/telephony/euicc/DownloadableSubscription.aidl \
 	frameworks/base/telephony/java/android/telephony/euicc/EuiccInfo.aidl \
 	frameworks/base/location/java/android/location/Location.aidl \
@@ -860,77 +252,69 @@
 
 # TODO: deal with com/google/android/googleapps
 packages_to_document := \
-	android \
-	javax/microedition/khronos \
-	org/apache/http/conn \
-	org/apache/http/params
-
-
-# Search through the base framework dirs for these packages.
-# The result will be relative to frameworks/base.
-fwbase_dirs_to_document := \
-	legacy-test/src \
-	test-runner/src \
-	$(patsubst $(LOCAL_PATH)/%,%, \
-	  $(wildcard \
-	    $(foreach dir, $(FRAMEWORKS_BASE_JAVA_SRC_DIRS), \
-	      $(addprefix $(dir)/, $(packages_to_document)) \
-	     ) \
-	   ) \
-	 )
+  android \
+  javax/microedition/khronos \
+  org/apache/http/conn \
+  org/apache/http/params \
 
 # include definition of libcore_to_document
 include libcore/Docs.mk
 
 non_base_dirs := \
-	../opt/telephony/src/java/android/telephony \
-	../opt/telephony/src/java/android/telephony/gsm \
-	../opt/net/voip/src/java/android/net/rtp \
-	../opt/net/voip/src/java/android/net/sip
+  ../opt/telephony/src/java/android/telephony \
+  ../opt/telephony/src/java/android/telephony/gsm \
+  ../opt/net/voip/src/java/android/net/rtp \
+  ../opt/net/voip/src/java/android/net/sip \
 
-# These are relative to frameworks/base
-dirs_to_check_apis := \
-  $(fwbase_dirs_to_document) \
-	$(non_base_dirs)
+# Find all files in specific directories (relative to frameworks/base)
+# to document and check apis
+files_to_check_apis := \
+  $(call find-other-java-files, \
+    legacy-test/src \
+    test-runner/src \
+    $(non_base_dirs) \
+  )
 
-###########################################################
-## Return all directories that have a 'NO_DOCS' file in
-## them, appending a '%' to them to form a pattern to
-## filter out files under those directories.
-## $(1): A list of base directories to look at.
-###########################################################
-define find-no-docs-pattern
-$(addsuffix %, $(dir $(foreach dir, $(1), $(shell cd $(LOCAL_PATH); find $(dir) -name NO_DOCS))))
-endef
+# Find all files in specific packages that were used to compile
+# framework.jar to document and check apis
+files_to_check_apis += \
+  $(addprefix ../../,\
+    $(filter \
+      $(foreach dir,$(FRAMEWORKS_BASE_JAVA_SRC_DIRS),\
+        $(foreach package,$(packages_to_document),\
+          $(dir)/$(package)/%.java)),\
+      $(SOONG_FRAMEWORK_SRCS)))
+
+# Find all generated files that were used to compile framework.jar
+files_to_check_apis_generated := \
+  $(filter $(OUT_DIR)/%,\
+    $(SOONG_FRAMEWORK_SRCS))
 
 # These are relative to frameworks/base
 # FRAMEWORKS_BASE_SUBDIRS comes from build/core/pathmap.mk
-dirs_to_document := \
-	$(dirs_to_check_apis) \
-	$(addprefix ../../, $(FRAMEWORKS_DATA_BINDING_JAVA_SRC_DIRS))
-
-patterns_to_not_document := \
-	$(call find-no-docs-pattern, $(dirs_to_document))
+files_to_document := \
+  $(files_to_check_apis) \
+  $(call find-other-java-files,$(addprefix ../../, $(FRAMEWORKS_DATA_BINDING_JAVA_SRC_DIRS)))
 
 # These are relative to frameworks/base
 html_dirs := \
 	$(FRAMEWORKS_BASE_SUBDIRS) \
-	$(non_base_dirs)
+	$(non_base_dirs) \
 
 # Common sources for doc check and api check
 common_src_files := \
 	$(call find-other-html-files, $(html_dirs)) \
-	$(addprefix ../../, $(libcore_to_document))
+	$(addprefix ../../, $(libcore_to_document)) \
 
 # These are relative to frameworks/base
 framework_docs_LOCAL_SRC_FILES := \
-	$(filter-out $(patterns_to_not_document), $(call find-other-java-files, $(dirs_to_document))) \
-	$(common_src_files)
+  $(files_to_document) \
+  $(common_src_files) \
 
 # These are relative to frameworks/base
 framework_docs_LOCAL_API_CHECK_SRC_FILES := \
-	$(call find-other-java-files, $(dirs_to_check_apis)) \
-	$(common_src_files)
+  $(files_to_check_apis) \
+  $(common_src_files) \
 
 # This is used by ide.mk as the list of source files that are
 # always included.
@@ -939,11 +323,11 @@
 framework_docs_LOCAL_DROIDDOC_SOURCE_PATH := \
 	$(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
 
-framework_docs_LOCAL_INTERMEDIATE_SOURCES := \
-	$(framework_res_source_path)/android/R.java \
-	$(framework_res_source_path)/android/Manifest.java \
-	$(framework_res_source_path)/com/android/internal/R.java \
-	$(patsubst $(TARGET_OUT_COMMON_INTERMEDIATES)/%,%,$(libcore_to_document_generated))
+framework_docs_LOCAL_SRCJARS := $(SOONG_FRAMEWORK_SRCJARS)
+
+framework_docs_LOCAL_GENERATED_SOURCES := \
+  $(libcore_to_document_generated) \
+  $(files_to_check_apis_generated) \
 
 framework_docs_LOCAL_API_CHECK_JAVA_LIBRARIES := \
 	core-oj \
@@ -1060,7 +444,8 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:=$(framework_docs_LOCAL_API_CHECK_SRC_FILES)
-LOCAL_INTERMEDIATE_SOURCES:=$(framework_docs_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_GENERATED_SOURCES:=$(framework_docs_LOCAL_GENERATED_SOURCES)
+LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
 LOCAL_JAVA_LIBRARIES:=$(framework_docs_LOCAL_API_CHECK_JAVA_LIBRARIES)
 LOCAL_MODULE_CLASS:=$(framework_docs_LOCAL_MODULE_CLASS)
 LOCAL_DROIDDOC_SOURCE_PATH:=$(framework_docs_LOCAL_DROIDDOC_SOURCE_PATH)
@@ -1086,7 +471,7 @@
 include $(BUILD_DROIDDOC)
 
 # $(gen), i.e. framework.aidl, is also needed while building against the current stub.
-$(full_target): $(framework_built) $(gen)
+$(full_target): $(gen)
 $(INTERNAL_PLATFORM_API_FILE): $(full_target)
 $(call dist-for-goals,sdk,$(INTERNAL_PLATFORM_API_FILE))
 
@@ -1094,7 +479,8 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:=$(framework_docs_LOCAL_API_CHECK_SRC_FILES)
-LOCAL_INTERMEDIATE_SOURCES:=$(framework_docs_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_GENERATED_SOURCES:=$(framework_docs_LOCAL_GENERATED_SOURCES)
+LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
 LOCAL_JAVA_LIBRARIES:=$(framework_docs_LOCAL_API_CHECK_JAVA_LIBRARIES)
 LOCAL_MODULE_CLASS:=$(framework_docs_LOCAL_MODULE_CLASS)
 LOCAL_DROIDDOC_SOURCE_PATH:=$(framework_docs_LOCAL_DROIDDOC_SOURCE_PATH)
@@ -1122,7 +508,7 @@
 include $(BUILD_DROIDDOC)
 
 # $(gen), i.e. framework.aidl, is also needed while building against the current stub.
-$(full_target): $(framework_built) $(gen)
+$(full_target): $(gen)
 $(INTERNAL_PLATFORM_SYSTEM_API_FILE): $(full_target)
 $(call dist-for-goals,sdk,$(INTERNAL_PLATFORM_SYSTEM_API_FILE))
 
@@ -1130,7 +516,8 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:=$(framework_docs_LOCAL_API_CHECK_SRC_FILES)
-LOCAL_INTERMEDIATE_SOURCES:=$(framework_docs_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_GENERATED_SOURCES:=$(framework_docs_LOCAL_GENERATED_SOURCES)
+LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
 LOCAL_JAVA_LIBRARIES:=$(framework_docs_LOCAL_API_CHECK_JAVA_LIBRARIES)
 LOCAL_MODULE_CLASS:=$(framework_docs_LOCAL_MODULE_CLASS)
 LOCAL_DROIDDOC_SOURCE_PATH:=$(framework_docs_LOCAL_DROIDDOC_SOURCE_PATH)
@@ -1159,7 +546,7 @@
 include $(BUILD_DROIDDOC)
 
 # $(gen), i.e. framework.aidl, is also needed while building against the current stub.
-$(full_target): $(framework_built) $(gen)
+$(full_target): $(gen)
 $(INTERNAL_PLATFORM_TEST_API_FILE): $(full_target)
 $(call dist-for-goals,sdk,$(INTERNAL_PLATFORM_TEST_API_FILE))
 
@@ -1167,7 +554,8 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:=$(framework_docs_LOCAL_SRC_FILES)
-LOCAL_INTERMEDIATE_SOURCES:=$(framework_docs_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_GENERATED_SOURCES:=$(framework_docs_LOCAL_GENERATED_SOURCES)
+LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
 LOCAL_JAVA_LIBRARIES:=$(framework_docs_LOCAL_JAVA_LIBRARIES)
 LOCAL_MODULE_CLASS:=$(framework_docs_LOCAL_MODULE_CLASS)
 LOCAL_DROIDDOC_SOURCE_PATH:=$(framework_docs_LOCAL_DROIDDOC_SOURCE_PATH)
@@ -1189,7 +577,7 @@
 include $(BUILD_DROIDDOC)
 
 # $(gen), i.e. framework.aidl, is also needed while building against the current stub.
-$(full_target): $(framework_built) $(gen)
+$(full_target): $(gen)
 
 # Run this for checkbuild
 checkbuild: doc-comment-check-docs
@@ -1200,7 +588,8 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:=$(framework_docs_LOCAL_SRC_FILES)
-LOCAL_INTERMEDIATE_SOURCES:=$(framework_docs_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_GENERATED_SOURCES:=$(framework_docs_LOCAL_GENERATED_SOURCES)
+LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
 LOCAL_JAVA_LIBRARIES:=$(framework_docs_LOCAL_JAVA_LIBRARIES)
 LOCAL_MODULE_CLASS:=$(framework_docs_LOCAL_MODULE_CLASS)
 LOCAL_DROIDDOC_SOURCE_PATH:=$(framework_docs_LOCAL_DROIDDOC_SOURCE_PATH)
@@ -1229,14 +618,14 @@
 	$(hide) $(ACP) $< $@
 
 $(full_target): $(static_doc_index_redirect)
-$(full_target): $(framework_built)
 
 
 # ====  static html in the sdk ==================================
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:=$(framework_docs_LOCAL_SRC_FILES)
-LOCAL_INTERMEDIATE_SOURCES:=$(framework_docs_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_GENERATED_SOURCES:=$(framework_docs_LOCAL_GENERATED_SOURCES)
+LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
 LOCAL_JAVA_LIBRARIES:=$(framework_docs_LOCAL_JAVA_LIBRARIES)
 LOCAL_MODULE_CLASS:=$(framework_docs_LOCAL_MODULE_CLASS)
 LOCAL_DROIDDOC_SOURCE_PATH:=$(framework_docs_LOCAL_DROIDDOC_SOURCE_PATH)
@@ -1271,14 +660,14 @@
 
 $(full_target): $(static_doc_index_redirect)
 $(full_target): $(static_doc_properties)
-$(full_target): $(framework_built)
 
 
 # ==== docs for the web (on the androiddevdocs app engine server) =======================
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:=$(framework_docs_LOCAL_SRC_FILES)
-LOCAL_INTERMEDIATE_SOURCES:=$(framework_docs_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_GENERATED_SOURCES:=$(framework_docs_LOCAL_GENERATED_SOURCES)
+LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
 LOCAL_STATIC_JAVA_LIBRARIES:=$(framework_docs_LOCAL_STATIC_JAVA_LIBRARIES)
 LOCAL_JAVA_LIBRARIES:=$(framework_docs_LOCAL_JAVA_LIBRARIES)
 LOCAL_MODULE_CLASS:=$(framework_docs_LOCAL_MODULE_CLASS)
@@ -1306,7 +695,8 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:=$(framework_docs_LOCAL_SRC_FILES)
-LOCAL_INTERMEDIATE_SOURCES:=$(framework_docs_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_GENERATED_SOURCES:=$(framework_docs_LOCAL_GENERATED_SOURCES)
+LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
 LOCAL_STATIC_JAVA_LIBRARIES:=$(framework_docs_LOCAL_STATIC_JAVA_LIBRARIES)
 LOCAL_JAVA_LIBRARIES:=$(framework_docs_LOCAL_JAVA_LIBRARIES)
 LOCAL_MODULE_CLASS:=$(framework_docs_LOCAL_MODULE_CLASS)
@@ -1341,7 +731,8 @@
 # ==== docs for the web (on the devsite app engine server) =======================
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES:=$(framework_docs_LOCAL_SRC_FILES)
-LOCAL_INTERMEDIATE_SOURCES:=$(framework_docs_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_GENERATED_SOURCES:=$(framework_docs_LOCAL_GENERATED_SOURCES)
+LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
 LOCAL_STATIC_JAVA_LIBRARIES:=$(framework_docs_LOCAL_STATIC_JAVA_LIBRARIES)
 LOCAL_JAVA_LIBRARIES:=$(framework_docs_LOCAL_JAVA_LIBRARIES)
 LOCAL_MODULE_CLASS:=$(framework_docs_LOCAL_MODULE_CLASS)
@@ -1370,7 +761,8 @@
 # ==== docs for the web (on the devsite app engine server) =======================
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES:=$(framework_docs_LOCAL_SRC_FILES)
-LOCAL_INTERMEDIATE_SOURCES:=$(framework_docs_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_GENERATED_SOURCES:=$(framework_docs_LOCAL_GENERATED_SOURCES)
+LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
 LOCAL_STATIC_JAVA_LIBRARIES:=$(framework_docs_LOCAL_STATIC_JAVA_LIBRARIES)
 LOCAL_JAVA_LIBRARIES:=$(framework_docs_LOCAL_JAVA_LIBRARIES)
 LOCAL_MODULE_CLASS:=$(framework_docs_LOCAL_MODULE_CLASS)
@@ -1399,7 +791,8 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:=$(framework_docs_LOCAL_SRC_FILES)
-LOCAL_INTERMEDIATE_SOURCES:=$(framework_docs_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_GENERATED_SOURCES:=$(framework_docs_LOCAL_GENERATED_SOURCES)
+LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
 LOCAL_STATIC_JAVA_LIBRARIES:=$(framework_docs_LOCAL_STATIC_JAVA_LIBRARIES)
 LOCAL_JAVA_LIBRARIES:=$(framework_docs_LOCAL_JAVA_LIBRARIES)
 LOCAL_MODULE_CLASS:=$(framework_docs_LOCAL_MODULE_CLASS)
@@ -1424,7 +817,8 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:=$(framework_docs_LOCAL_SRC_FILES)
-LOCAL_INTERMEDIATE_SOURCES:=$(framework_docs_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_GENERATED_SOURCES:=$(framework_docs_LOCAL_GENERATED_SOURCES)
+LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
 LOCAL_STATIC_JAVA_LIBRARIES:=$(framework_docs_LOCAL_STATIC_JAVA_LIBRARIES)
 LOCAL_JAVA_LIBRARIES:=$(framework_docs_LOCAL_JAVA_LIBRARIES)
 LOCAL_MODULE_CLASS:=$(framework_docs_LOCAL_MODULE_CLASS)
@@ -1452,7 +846,8 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:=$(framework_docs_LOCAL_SRC_FILES)
-LOCAL_INTERMEDIATE_SOURCES:=$(framework_docs_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_GENERATED_SOURCES:=$(framework_docs_LOCAL_GENERATED_SOURCES)
+LOCAL_SRCJARS:=$(framework_docs_LOCAL_SRCJARS)
 LOCAL_JAVA_LIBRARIES:=$(framework_docs_LOCAL_JAVA_LIBRARIES)
 LOCAL_MODULE_CLASS:=$(framework_docs_LOCAL_MODULE_CLASS)
 LOCAL_DROIDDOC_SOURCE_PATH:=$(framework_docs_LOCAL_DROIDDOC_SOURCE_PATH)
diff --git a/api/system-current.txt b/api/system-current.txt
index a859bcd..1620e65 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -43904,6 +43904,39 @@
 
 }
 
+package android.telephony.data {
+
+  public final class DataProfile implements android.os.Parcelable {
+    ctor public DataProfile(int, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, int, int, int, int, boolean, int, java.lang.String, int, int, java.lang.String, java.lang.String, boolean);
+    ctor public DataProfile(android.os.Parcel);
+    method public int describeContents();
+    method public java.lang.String getApn();
+    method public int getAuthType();
+    method public int getBearerBitmap();
+    method public int getMaxConns();
+    method public int getMaxConnsTime();
+    method public int getMtu();
+    method public java.lang.String getMvnoMatchData();
+    method public java.lang.String getMvnoType();
+    method public java.lang.String getPassword();
+    method public int getProfileId();
+    method public java.lang.String getProtocol();
+    method public java.lang.String getRoamingProtocol();
+    method public int getSupportedApnTypesBitmap();
+    method public int getType();
+    method public java.lang.String getUserName();
+    method public int getWaitTime();
+    method public boolean isEnabled();
+    method public boolean isModemCognitive();
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.telephony.data.DataProfile> CREATOR;
+    field public static final int TYPE_3GPP = 1; // 0x1
+    field public static final int TYPE_3GPP2 = 2; // 0x2
+    field public static final int TYPE_COMMON = 0; // 0x0
+  }
+
+}
+
 package android.telephony.gsm {
 
   public class GsmCellLocation extends android.telephony.CellLocation {
diff --git a/config/compiled-classes-phone b/config/compiled-classes-phone
index 17156e8..384540a 100644
--- a/config/compiled-classes-phone
+++ b/config/compiled-classes-phone
@@ -5194,7 +5194,7 @@
 com.android.ims.internal.IImsService
 com.android.ims.internal.IImsService$Stub
 com.android.ims.internal.IImsServiceController
-com.android.ims.internal.IImsServiceFeatureListener
+com.android.ims.internal.IImsServiceFeatureCallback
 com.android.ims.internal.IImsUt
 com.android.ims.internal.IImsUt$Stub
 com.android.ims.internal.IImsUtListener
diff --git a/core/java/android/app/SharedPreferencesImpl.java b/core/java/android/app/SharedPreferencesImpl.java
index aab7d77..e245bb5 100644
--- a/core/java/android/app/SharedPreferencesImpl.java
+++ b/core/java/android/app/SharedPreferencesImpl.java
@@ -34,8 +34,6 @@
 
 import libcore.io.IoUtils;
 
-import com.google.android.collect.Maps;
-
 import org.xmlpull.v1.XmlPullParserException;
 
 import java.io.BufferedInputStream;
@@ -52,6 +50,11 @@
 import java.util.Set;
 import java.util.WeakHashMap;
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 final class SharedPreferencesImpl implements SharedPreferences {
     private static final String TAG = "SharedPreferencesImpl";
@@ -71,16 +74,12 @@
     private final Object mLock = new Object();
     private final Object mWritingToDiskLock = new Object();
 
-    @GuardedBy("mLock")
-    private Map<String, Object> mMap;
+    private Future<Map<String, Object>> mMap;
 
     @GuardedBy("mLock")
     private int mDiskWritesInFlight = 0;
 
     @GuardedBy("mLock")
-    private boolean mLoaded = false;
-
-    @GuardedBy("mLock")
     private StructTimespec mStatTimestamp;
 
     @GuardedBy("mLock")
@@ -107,27 +106,18 @@
         mFile = file;
         mBackupFile = makeBackupFile(file);
         mMode = mode;
-        mLoaded = false;
         mMap = null;
         startLoadFromDisk();
     }
 
     private void startLoadFromDisk() {
-        synchronized (mLock) {
-            mLoaded = false;
-        }
-        new Thread("SharedPreferencesImpl-load") {
-            public void run() {
-                loadFromDisk();
-            }
-        }.start();
+        FutureTask<Map<String, Object>> futureTask = new FutureTask<>(() -> loadFromDisk());
+        mMap = futureTask;
+        new Thread(futureTask, "SharedPreferencesImpl-load").start();
     }
 
-    private void loadFromDisk() {
+    private Map<String, Object> loadFromDisk() {
         synchronized (mLock) {
-            if (mLoaded) {
-                return;
-            }
             if (mBackupFile.exists()) {
                 mFile.delete();
                 mBackupFile.renameTo(mFile);
@@ -139,7 +129,7 @@
             Log.w(TAG, "Attempt to read preferences file " + mFile + " without permission");
         }
 
-        Map map = null;
+        Map<String, Object> map = null;
         StructStat stat = null;
         try {
             stat = Os.stat(mFile.getPath());
@@ -148,7 +138,7 @@
                 try {
                     str = new BufferedInputStream(
                             new FileInputStream(mFile), 16*1024);
-                    map = XmlUtils.readMapXml(str);
+                    map = (Map<String, Object>) XmlUtils.readMapXml(str);
                 } catch (Exception e) {
                     Log.w(TAG, "Cannot read " + mFile.getAbsolutePath(), e);
                 } finally {
@@ -160,16 +150,14 @@
         }
 
         synchronized (mLock) {
-            mLoaded = true;
             if (map != null) {
-                mMap = map;
                 mStatTimestamp = stat.st_mtim;
                 mStatSize = stat.st_size;
             } else {
-                mMap = new HashMap<>();
+                map = new HashMap<>();
             }
-            mLock.notifyAll();
         }
+        return map;
     }
 
     static File makeBackupFile(File prefsFile) {
@@ -214,106 +202,122 @@
         }
     }
 
+    @Override
     public void registerOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener) {
         synchronized(mLock) {
             mListeners.put(listener, CONTENT);
         }
     }
 
+    @Override
     public void unregisterOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener) {
         synchronized(mLock) {
             mListeners.remove(listener);
         }
     }
 
-    private void awaitLoadedLocked() {
-        if (!mLoaded) {
+    private @GuardedBy("mLock") Map<String, Object> getLoaded() {
+        // For backwards compatibility, we need to ignore any interrupts. b/70122540.
+        for (;;) {
+            try {
+                return mMap.get();
+            } catch (ExecutionException e) {
+                throw new IllegalStateException(e);
+            } catch (InterruptedException e) {
+                // Ignore and try again.
+            }
+        }
+    }
+    private @GuardedBy("mLock") Map<String, Object> getLoadedWithBlockGuard() {
+        if (!mMap.isDone()) {
             // Raise an explicit StrictMode onReadFromDisk for this
             // thread, since the real read will be in a different
             // thread and otherwise ignored by StrictMode.
             BlockGuard.getThreadPolicy().onReadFromDisk();
         }
-        while (!mLoaded) {
-            try {
-                mLock.wait();
-            } catch (InterruptedException unused) {
-            }
-        }
+        return getLoaded();
     }
 
+    @Override
     public Map<String, ?> getAll() {
+        Map<String, Object> map = getLoadedWithBlockGuard();
         synchronized (mLock) {
-            awaitLoadedLocked();
-            //noinspection unchecked
-            return new HashMap<String, Object>(mMap);
+            return new HashMap<String, Object>(map);
         }
     }
 
+    @Override
     @Nullable
     public String getString(String key, @Nullable String defValue) {
+        Map<String, Object> map = getLoadedWithBlockGuard();
         synchronized (mLock) {
-            awaitLoadedLocked();
-            String v = (String)mMap.get(key);
+            String v = (String) map.get(key);
             return v != null ? v : defValue;
         }
     }
 
+    @Override
     @Nullable
     public Set<String> getStringSet(String key, @Nullable Set<String> defValues) {
+        Map<String, Object> map = getLoadedWithBlockGuard();
         synchronized (mLock) {
-            awaitLoadedLocked();
-            Set<String> v = (Set<String>) mMap.get(key);
+            @SuppressWarnings("unchecked")
+            Set<String> v = (Set<String>) map.get(key);
             return v != null ? v : defValues;
         }
     }
 
+    @Override
     public int getInt(String key, int defValue) {
+        Map<String, Object> map = getLoadedWithBlockGuard();
         synchronized (mLock) {
-            awaitLoadedLocked();
-            Integer v = (Integer)mMap.get(key);
+            Integer v = (Integer) map.get(key);
             return v != null ? v : defValue;
         }
     }
+    @Override
     public long getLong(String key, long defValue) {
+        Map<String, Object> map = getLoadedWithBlockGuard();
         synchronized (mLock) {
-            awaitLoadedLocked();
-            Long v = (Long)mMap.get(key);
+            Long v = (Long) map.get(key);
             return v != null ? v : defValue;
         }
     }
+    @Override
     public float getFloat(String key, float defValue) {
+        Map<String, Object> map = getLoadedWithBlockGuard();
         synchronized (mLock) {
-            awaitLoadedLocked();
-            Float v = (Float)mMap.get(key);
+            Float v = (Float) map.get(key);
             return v != null ? v : defValue;
         }
     }
+    @Override
     public boolean getBoolean(String key, boolean defValue) {
+        Map<String, Object> map = getLoadedWithBlockGuard();
         synchronized (mLock) {
-            awaitLoadedLocked();
-            Boolean v = (Boolean)mMap.get(key);
+            Boolean v = (Boolean) map.get(key);
             return v != null ? v : defValue;
         }
     }
 
+    @Override
     public boolean contains(String key) {
+        Map<String, Object> map = getLoadedWithBlockGuard();
         synchronized (mLock) {
-            awaitLoadedLocked();
-            return mMap.containsKey(key);
+            return map.containsKey(key);
         }
     }
 
+    @Override
     public Editor edit() {
-        // TODO: remove the need to call awaitLoadedLocked() when
+        // TODO: remove the need to call getLoaded() when
         // requesting an editor.  will require some work on the
         // Editor, but then we should be able to do:
         //
         //      context.getSharedPreferences(..).edit().putString(..).apply()
         //
         // ... all without blocking.
-        synchronized (mLock) {
-            awaitLoadedLocked();
-        }
+        getLoadedWithBlockGuard();
 
         return new EditorImpl();
     }
@@ -347,71 +351,81 @@
     }
 
     public final class EditorImpl implements Editor {
-        private final Object mLock = new Object();
+        private final Object mEditorLock = new Object();
 
-        @GuardedBy("mLock")
-        private final Map<String, Object> mModified = Maps.newHashMap();
+        @GuardedBy("mEditorLock")
+        private final Map<String, Object> mModified = new HashMap<>();
 
-        @GuardedBy("mLock")
+        @GuardedBy("mEditorLock")
         private boolean mClear = false;
 
+        @Override
         public Editor putString(String key, @Nullable String value) {
-            synchronized (mLock) {
+            synchronized (mEditorLock) {
                 mModified.put(key, value);
                 return this;
             }
         }
+        @Override
         public Editor putStringSet(String key, @Nullable Set<String> values) {
-            synchronized (mLock) {
+            synchronized (mEditorLock) {
                 mModified.put(key,
                         (values == null) ? null : new HashSet<String>(values));
                 return this;
             }
         }
+        @Override
         public Editor putInt(String key, int value) {
-            synchronized (mLock) {
+            synchronized (mEditorLock) {
                 mModified.put(key, value);
                 return this;
             }
         }
+        @Override
         public Editor putLong(String key, long value) {
-            synchronized (mLock) {
+            synchronized (mEditorLock) {
                 mModified.put(key, value);
                 return this;
             }
         }
+        @Override
         public Editor putFloat(String key, float value) {
-            synchronized (mLock) {
+            synchronized (mEditorLock) {
                 mModified.put(key, value);
                 return this;
             }
         }
+        @Override
         public Editor putBoolean(String key, boolean value) {
-            synchronized (mLock) {
+            synchronized (mEditorLock) {
                 mModified.put(key, value);
                 return this;
             }
         }
 
+        @Override
         public Editor remove(String key) {
-            synchronized (mLock) {
+            synchronized (mEditorLock) {
                 mModified.put(key, this);
                 return this;
             }
         }
 
+        @Override
         public Editor clear() {
-            synchronized (mLock) {
+            synchronized (mEditorLock) {
                 mClear = true;
                 return this;
             }
         }
 
+        @Override
         public void apply() {
             final long startTime = System.currentTimeMillis();
 
             final MemoryCommitResult mcr = commitToMemory();
             final Runnable awaitCommit = new Runnable() {
+                    @Override
                     public void run() {
                         try {
                             mcr.writtenToDiskLatch.await();
@@ -429,6 +443,7 @@
             QueuedWork.addFinisher(awaitCommit);
 
             Runnable postWriteRunnable = new Runnable() {
+                    @Override
                     public void run() {
                         awaitCommit.run();
                         QueuedWork.removeFinisher(awaitCommit);
@@ -456,13 +471,43 @@
                 // a memory commit comes in when we're already
                 // writing to disk.
                 if (mDiskWritesInFlight > 0) {
-                    // We can't modify our mMap as a currently
+                    // We can't modify our map as a currently
                     // in-flight write owns it.  Clone it before
                     // modifying it.
                     // noinspection unchecked
-                    mMap = new HashMap<String, Object>(mMap);
+                    mMap = new Future<Map<String, Object>>() {
+                        private Map<String, Object> mCopiedMap =
+                                new HashMap<String, Object>(getLoaded());
+
+                        @Override
+                        public boolean cancel(boolean mayInterruptIfRunning) {
+                            return false;
+                        }
+
+                        @Override
+                        public boolean isCancelled() {
+                            return false;
+                        }
+
+                        @Override
+                        public boolean isDone() {
+                            return true;
+                        }
+
+                        @Override
+                        public Map<String, Object> get()
+                                throws InterruptedException, ExecutionException {
+                            return mCopiedMap;
+                        }
+
+                        @Override
+                        public Map<String, Object> get(long timeout, TimeUnit unit)
+                                throws InterruptedException, ExecutionException, TimeoutException {
+                            return mCopiedMap;
+                        }
+                    };
                 }
-                mapToWriteToDisk = mMap;
+                mapToWriteToDisk = getLoaded();
                 mDiskWritesInFlight++;
 
                 boolean hasListeners = mListeners.size() > 0;
@@ -471,13 +516,13 @@
                     listeners = new HashSet<OnSharedPreferenceChangeListener>(mListeners.keySet());
                 }
 
-                synchronized (mLock) {
+                synchronized (mEditorLock) {
                     boolean changesMade = false;
 
                     if (mClear) {
-                        if (!mMap.isEmpty()) {
+                        if (!mapToWriteToDisk.isEmpty()) {
                             changesMade = true;
-                            mMap.clear();
+                            mapToWriteToDisk.clear();
                         }
                         mClear = false;
                     }
@@ -489,18 +534,18 @@
                         // setting a value to "null" for a given key is specified to be
                         // equivalent to calling remove on that key.
                         if (v == this || v == null) {
-                            if (!mMap.containsKey(k)) {
+                            if (!mapToWriteToDisk.containsKey(k)) {
                                 continue;
                             }
-                            mMap.remove(k);
+                            mapToWriteToDisk.remove(k);
                         } else {
-                            if (mMap.containsKey(k)) {
-                                Object existingValue = mMap.get(k);
+                            if (mapToWriteToDisk.containsKey(k)) {
+                                Object existingValue = mapToWriteToDisk.get(k);
                                 if (existingValue != null && existingValue.equals(v)) {
                                     continue;
                                 }
                             }
-                            mMap.put(k, v);
+                            mapToWriteToDisk.put(k, v);
                         }
 
                         changesMade = true;
@@ -522,6 +567,7 @@
                     mapToWriteToDisk);
         }
 
+        @Override
         public boolean commit() {
             long startTime = 0;
 
@@ -564,11 +610,7 @@
                 }
             } else {
                 // Run this function on the main thread.
-                ActivityThread.sMainThreadHandler.post(new Runnable() {
-                        public void run() {
-                            notifyListeners(mcr);
-                        }
-                    });
+                ActivityThread.sMainThreadHandler.post(() -> notifyListeners(mcr));
             }
         }
     }
@@ -594,6 +636,7 @@
         final boolean isFromSyncCommit = (postWriteRunnable == null);
 
         final Runnable writeToDiskRunnable = new Runnable() {
+                @Override
                 public void run() {
                     synchronized (mWritingToDiskLock) {
                         writeToFile(mcr, isFromSyncCommit);
@@ -646,7 +689,7 @@
         return str;
     }
 
-    // Note: must hold mWritingToDiskLock
+    @GuardedBy("mWritingToDiskLock")
     private void writeToFile(MemoryCommitResult mcr, boolean isFromSyncCommit) {
         long startTime = 0;
         long existsTime = 0;
diff --git a/core/java/android/net/IpSecAlgorithm.java b/core/java/android/net/IpSecAlgorithm.java
index d6e62cf..f82627b 100644
--- a/core/java/android/net/IpSecAlgorithm.java
+++ b/core/java/android/net/IpSecAlgorithm.java
@@ -21,6 +21,7 @@
 import android.os.Parcel;
 import android.os.Parcelable;
 
+import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.util.HexDump;
 
 import java.lang.annotation.Retention;
@@ -34,6 +35,8 @@
  * Internet Protocol</a>
  */
 public final class IpSecAlgorithm implements Parcelable {
+    private static final String TAG = "IpSecAlgorithm";
+
     /**
      * AES-CBC Encryption/Ciphering Algorithm.
      *
@@ -45,6 +48,7 @@
      * MD5 HMAC Authentication/Integrity Algorithm. <b>This algorithm is not recommended for use in
      * new applications and is provided for legacy compatibility with 3gpp infrastructure.</b>
      *
+     * <p>Keys for this algorithm must be 128 bits in length.
      * <p>Valid truncation lengths are multiples of 8 bits from 96 to (default) 128.
      */
     public static final String AUTH_HMAC_MD5 = "hmac(md5)";
@@ -53,6 +57,7 @@
      * SHA1 HMAC Authentication/Integrity Algorithm. <b>This algorithm is not recommended for use in
      * new applications and is provided for legacy compatibility with 3gpp infrastructure.</b>
      *
+     * <p>Keys for this algorithm must be 160 bits in length.
      * <p>Valid truncation lengths are multiples of 8 bits from 96 to (default) 160.
      */
     public static final String AUTH_HMAC_SHA1 = "hmac(sha1)";
@@ -60,6 +65,7 @@
     /**
      * SHA256 HMAC Authentication/Integrity Algorithm.
      *
+     * <p>Keys for this algorithm must be 256 bits in length.
      * <p>Valid truncation lengths are multiples of 8 bits from 96 to (default) 256.
      */
     public static final String AUTH_HMAC_SHA256 = "hmac(sha256)";
@@ -67,6 +73,7 @@
     /**
      * SHA384 HMAC Authentication/Integrity Algorithm.
      *
+     * <p>Keys for this algorithm must be 384 bits in length.
      * <p>Valid truncation lengths are multiples of 8 bits from 192 to (default) 384.
      */
     public static final String AUTH_HMAC_SHA384 = "hmac(sha384)";
@@ -74,6 +81,7 @@
     /**
      * SHA512 HMAC Authentication/Integrity Algorithm.
      *
+     * <p>Keys for this algorithm must be 512 bits in length.
      * <p>Valid truncation lengths are multiples of 8 bits from 256 to (default) 512.
      */
     public static final String AUTH_HMAC_SHA512 = "hmac(sha512)";
@@ -130,12 +138,10 @@
      * @param truncLenBits number of bits of output hash to use.
      */
     public IpSecAlgorithm(@AlgorithmName String algorithm, @NonNull byte[] key, int truncLenBits) {
-        if (!isTruncationLengthValid(algorithm, truncLenBits)) {
-            throw new IllegalArgumentException("Unknown algorithm or invalid length");
-        }
         mName = algorithm;
         mKey = key.clone();
-        mTruncLenBits = Math.min(truncLenBits, key.length * 8);
+        mTruncLenBits = truncLenBits;
+        checkValidOrThrow(mName, mKey.length * 8, mTruncLenBits);
     }
 
     /** Get the algorithm name */
@@ -169,7 +175,11 @@
     public static final Parcelable.Creator<IpSecAlgorithm> CREATOR =
             new Parcelable.Creator<IpSecAlgorithm>() {
                 public IpSecAlgorithm createFromParcel(Parcel in) {
-                    return new IpSecAlgorithm(in);
+                    final String name = in.readString();
+                    final byte[] key = in.createByteArray();
+                    final int truncLenBits = in.readInt();
+
+                    return new IpSecAlgorithm(name, key, truncLenBits);
                 }
 
                 public IpSecAlgorithm[] newArray(int size) {
@@ -177,30 +187,47 @@
                 }
             };
 
-    private IpSecAlgorithm(Parcel in) {
-        mName = in.readString();
-        mKey = in.createByteArray();
-        mTruncLenBits = in.readInt();
-    }
+    private static void checkValidOrThrow(String name, int keyLen, int truncLen) {
+        boolean isValidLen = true;
+        boolean isValidTruncLen = true;
 
-    private static boolean isTruncationLengthValid(String algo, int truncLenBits) {
-        switch (algo) {
+        switch(name) {
             case CRYPT_AES_CBC:
-                return (truncLenBits == 128 || truncLenBits == 192 || truncLenBits == 256);
+                isValidLen = keyLen == 128 || keyLen == 192 || keyLen == 256;
+                break;
             case AUTH_HMAC_MD5:
-                return (truncLenBits >= 96 && truncLenBits <= 128);
+                isValidLen = keyLen == 128;
+                isValidTruncLen = truncLen >= 96 && truncLen <= 128;
+                break;
             case AUTH_HMAC_SHA1:
-                return (truncLenBits >= 96 && truncLenBits <= 160);
+                isValidLen = keyLen == 160;
+                isValidTruncLen = truncLen >= 96 && truncLen <= 160;
+                break;
             case AUTH_HMAC_SHA256:
-                return (truncLenBits >= 96 && truncLenBits <= 256);
+                isValidLen = keyLen == 256;
+                isValidTruncLen = truncLen >= 96 && truncLen <= 256;
+                break;
             case AUTH_HMAC_SHA384:
-                return (truncLenBits >= 192 && truncLenBits <= 384);
+                isValidLen = keyLen == 384;
+                isValidTruncLen = truncLen >= 192 && truncLen <= 384;
+                break;
             case AUTH_HMAC_SHA512:
-                return (truncLenBits >= 256 && truncLenBits <= 512);
+                isValidLen = keyLen == 512;
+                isValidTruncLen = truncLen >= 256 && truncLen <= 512;
+                break;
             case AUTH_CRYPT_AES_GCM:
-                return (truncLenBits == 64 || truncLenBits == 96 || truncLenBits == 128);
+                // The keying material for GCM is a key plus a 32-bit salt
+                isValidLen = keyLen == 128 + 32 || keyLen == 192 + 32 || keyLen == 256 + 32;
+                break;
             default:
-                return false;
+                throw new IllegalArgumentException("Couldn't find an algorithm: " + name);
+        }
+
+        if (!isValidLen) {
+            throw new IllegalArgumentException("Invalid key material keyLength: " + keyLen);
+        }
+        if (!isValidTruncLen) {
+            throw new IllegalArgumentException("Invalid truncation keyLength: " + truncLen);
         }
     }
 
@@ -217,8 +244,9 @@
                 .toString();
     }
 
-    /** package */
-    static boolean equals(IpSecAlgorithm lhs, IpSecAlgorithm rhs) {
+    /** @hide */
+    @VisibleForTesting
+    public static boolean equals(IpSecAlgorithm lhs, IpSecAlgorithm rhs) {
         if (lhs == null || rhs == null) return (lhs == rhs);
         return (lhs.mName.equals(rhs.mName)
                 && Arrays.equals(lhs.mKey, rhs.mKey)
diff --git a/core/java/android/net/MacAddress.java b/core/java/android/net/MacAddress.java
index f6a69ba..5620a62 100644
--- a/core/java/android/net/MacAddress.java
+++ b/core/java/android/net/MacAddress.java
@@ -16,17 +16,23 @@
 
 package android.net;
 
+import android.annotation.IntDef;
 import android.os.Parcel;
 import android.os.Parcelable;
 
 import com.android.internal.util.BitUtils;
+import com.android.internal.util.Preconditions;
 
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
 import java.util.Arrays;
 import java.util.Random;
-import java.util.StringJoiner;
 
 /**
- * Represents a mac address.
+ * Representation of a MAC address.
+ *
+ * This class only supports 48 bits long addresses and does not support 64 bits long addresses.
+ * Instances of this class are immutable.
  *
  * @hide
  */
@@ -35,76 +41,102 @@
     private static final int ETHER_ADDR_LEN = 6;
     private static final byte[] ETHER_ADDR_BROADCAST = addr(0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
 
-    /** The broadcast mac address.  */
-    public static final MacAddress BROADCAST_ADDRESS = new MacAddress(ETHER_ADDR_BROADCAST);
+    /**
+     * The MacAddress representing the unique broadcast MAC address.
+     */
+    public static final MacAddress BROADCAST_ADDRESS = MacAddress.fromBytes(ETHER_ADDR_BROADCAST);
 
-    /** The zero mac address. */
+    /**
+     * The MacAddress zero MAC address.
+     * @hide
+     */
     public static final MacAddress ALL_ZEROS_ADDRESS = new MacAddress(0);
 
-    /** Represents categories of mac addresses. */
-    public enum MacAddressType {
-        UNICAST,
-        MULTICAST,
-        BROADCAST;
-    }
+    /** @hide */
+    @Retention(RetentionPolicy.SOURCE)
+    @IntDef(prefix = { "TYPE_" }, value = {
+            TYPE_UNKNOWN,
+            TYPE_UNICAST,
+            TYPE_MULTICAST,
+            TYPE_BROADCAST,
+    })
+    public @interface MacAddressType { }
 
-    private static final long VALID_LONG_MASK = BROADCAST_ADDRESS.mAddr;
-    private static final long LOCALLY_ASSIGNED_MASK = new MacAddress("2:0:0:0:0:0").mAddr;
-    private static final long MULTICAST_MASK = new MacAddress("1:0:0:0:0:0").mAddr;
-    private static final long OUI_MASK = new MacAddress("ff:ff:ff:0:0:0").mAddr;
-    private static final long NIC_MASK = new MacAddress("0:0:0:ff:ff:ff").mAddr;
-    private static final MacAddress BASE_ANDROID_MAC = new MacAddress("da:a1:19:0:0:0");
+    /** Indicates a MAC address of unknown type. */
+    public static final int TYPE_UNKNOWN = 0;
+    /** Indicates a MAC address is a unicast address. */
+    public static final int TYPE_UNICAST = 1;
+    /** Indicates a MAC address is a multicast address. */
+    public static final int TYPE_MULTICAST = 2;
+    /** Indicates a MAC address is the broadcast address. */
+    public static final int TYPE_BROADCAST = 3;
 
-    // Internal representation of the mac address as a single 8 byte long.
+    private static final long VALID_LONG_MASK = (1L << 48) - 1;
+    private static final long LOCALLY_ASSIGNED_MASK = MacAddress.fromString("2:0:0:0:0:0").mAddr;
+    private static final long MULTICAST_MASK = MacAddress.fromString("1:0:0:0:0:0").mAddr;
+    private static final long OUI_MASK = MacAddress.fromString("ff:ff:ff:0:0:0").mAddr;
+    private static final long NIC_MASK = MacAddress.fromString("0:0:0:ff:ff:ff").mAddr;
+    private static final MacAddress BASE_GOOGLE_MAC = MacAddress.fromString("da:a1:19:0:0:0");
+
+    // Internal representation of the MAC address as a single 8 byte long.
     // The encoding scheme sets the two most significant bytes to 0. The 6 bytes of the
-    // mac address are encoded in the 6 least significant bytes of the long, where the first
+    // MAC address are encoded in the 6 least significant bytes of the long, where the first
     // byte of the array is mapped to the 3rd highest logical byte of the long, the second
     // byte of the array is mapped to the 4th highest logical byte of the long, and so on.
     private final long mAddr;
 
     private MacAddress(long addr) {
-        mAddr = addr;
+        mAddr = (VALID_LONG_MASK & addr);
     }
 
-    /** Creates a MacAddress for the given byte representation. */
-    public MacAddress(byte[] addr) {
-        this(longAddrFromByteAddr(addr));
-    }
-
-    /** Creates a MacAddress for the given string representation. */
-    public MacAddress(String addr) {
-        this(longAddrFromByteAddr(byteAddrFromStringAddr(addr)));
-    }
-
-    /** Returns the MacAddressType of this MacAddress. */
-    public MacAddressType addressType() {
+    /**
+     * Returns the type of this address.
+     *
+     * @return the int constant representing the MAC address type of this MacAddress.
+     */
+    public @MacAddressType int addressType() {
         if (equals(BROADCAST_ADDRESS)) {
-            return MacAddressType.BROADCAST;
+            return TYPE_BROADCAST;
         }
         if (isMulticastAddress()) {
-            return MacAddressType.MULTICAST;
+            return TYPE_MULTICAST;
         }
-        return MacAddressType.UNICAST;
+        return TYPE_UNICAST;
     }
 
-    /** Returns true if this MacAddress corresponds to a multicast address. */
+    /**
+     * @return true if this MacAddress is a multicast address.
+     * @hide
+     */
     public boolean isMulticastAddress() {
         return (mAddr & MULTICAST_MASK) != 0;
     }
 
-    /** Returns true if this MacAddress corresponds to a locally assigned address. */
+    /**
+     * @return true if this MacAddress is a locally assigned address.
+     */
     public boolean isLocallyAssigned() {
         return (mAddr & LOCALLY_ASSIGNED_MASK) != 0;
     }
 
-    /** Returns a byte array representation of this MacAddress. */
+    /**
+     * @return a byte array representation of this MacAddress.
+     */
     public byte[] toByteArray() {
         return byteAddrFromLongAddr(mAddr);
     }
 
     @Override
     public String toString() {
-        return stringAddrFromByteAddr(byteAddrFromLongAddr(mAddr));
+        return stringAddrFromLongAddr(mAddr);
+    }
+
+    /**
+     * @return a String representation of the OUI part of this MacAddres,
+     * with the lower 3 bytes constituting the NIC part replaced with 0.
+     */
+    public String toSafeString() {
+        return stringAddrFromLongAddr(mAddr & OUI_MASK);
     }
 
     @Override
@@ -138,27 +170,50 @@
                 }
             };
 
-    /** Return true if the given byte array is not null and has the length of a mac address. */
+    /**
+     * Returns true if the given byte array is an valid MAC address.
+     * A valid byte array representation for a MacAddress is a non-null array of length 6.
+     *
+     * @param addr a byte array.
+     * @return true if the given byte array is not null and has the length of a MAC address.
+     *
+     * @hide
+     */
     public static boolean isMacAddress(byte[] addr) {
         return addr != null && addr.length == ETHER_ADDR_LEN;
     }
 
     /**
-     * Return the MacAddressType of the mac address represented by the given byte array,
-     * or null if the given byte array does not represent an mac address.
+     * Returns the MAC address type of the MAC address represented by the given byte array,
+     * or null if the given byte array does not represent a MAC address.
+     * A valid byte array representation for a MacAddress is a non-null array of length 6.
+     *
+     * @param addr a byte array representing a MAC address.
+     * @return the int constant representing the MAC address type of the MAC address represented
+     * by the given byte array, or type UNKNOWN if the byte array is not a valid MAC address.
+     *
+     * @hide
      */
-    public static MacAddressType macAddressType(byte[] addr) {
+    public static int macAddressType(byte[] addr) {
         if (!isMacAddress(addr)) {
-            return null;
+            return TYPE_UNKNOWN;
         }
-        return new MacAddress(addr).addressType();
+        return MacAddress.fromBytes(addr).addressType();
     }
 
-    /** DOCME */
+    /**
+     * Converts a String representation of a MAC address to a byte array representation.
+     * A valid String representation for a MacAddress is a series of 6 values in the
+     * range [0,ff] printed in hexadecimal and joined by ':' characters.
+     *
+     * @param addr a String representation of a MAC address.
+     * @return the byte representation of the MAC address.
+     * @throws IllegalArgumentException if the given String is not a valid representation.
+     *
+     * @hide
+     */
     public static byte[] byteAddrFromStringAddr(String addr) {
-        if (addr == null) {
-            throw new IllegalArgumentException("cannot convert the null String");
-        }
+        Preconditions.checkNotNull(addr);
         String[] parts = addr.split(":");
         if (parts.length != ETHER_ADDR_LEN) {
             throw new IllegalArgumentException(addr + " was not a valid MAC address");
@@ -174,20 +229,26 @@
         return bytes;
     }
 
-    /** DOCME */
+    /**
+     * Converts a byte array representation of a MAC address to a String representation made
+     * of 6 hexadecimal numbers in [0,ff] joined by ':' characters.
+     * A valid byte array representation for a MacAddress is a non-null array of length 6.
+     *
+     * @param addr a byte array representation of a MAC address.
+     * @return the String representation of the MAC address.
+     * @throws IllegalArgumentException if the given byte array is not a valid representation.
+     *
+     * @hide
+     */
     public static String stringAddrFromByteAddr(byte[] addr) {
         if (!isMacAddress(addr)) {
             return null;
         }
-        StringJoiner j = new StringJoiner(":");
-        for (byte b : addr) {
-            j.add(Integer.toHexString(BitUtils.uint8(b)));
-        }
-        return j.toString();
+        return String.format("%02x:%02x:%02x:%02x:%02x:%02x",
+                addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
     }
 
-    /** @hide */
-    public static byte[] byteAddrFromLongAddr(long addr) {
+    private static byte[] byteAddrFromLongAddr(long addr) {
         byte[] bytes = new byte[ETHER_ADDR_LEN];
         int index = ETHER_ADDR_LEN;
         while (index-- > 0) {
@@ -197,8 +258,8 @@
         return bytes;
     }
 
-    /** @hide */
-    public static long longAddrFromByteAddr(byte[] addr) {
+    private static long longAddrFromByteAddr(byte[] addr) {
+        Preconditions.checkNotNull(addr);
         if (!isMacAddress(addr)) {
             throw new IllegalArgumentException(
                     Arrays.toString(addr) + " was not a valid MAC address");
@@ -210,19 +271,17 @@
         return longAddr;
     }
 
-    /** @hide */
-    public static long longAddrFromStringAddr(String addr) {
-        if (addr == null) {
-            throw new IllegalArgumentException("cannot convert the null String");
-        }
+    // Internal conversion function equivalent to longAddrFromByteAddr(byteAddrFromStringAddr(addr))
+    // that avoids the allocation of an intermediary byte[].
+    private static long longAddrFromStringAddr(String addr) {
+        Preconditions.checkNotNull(addr);
         String[] parts = addr.split(":");
         if (parts.length != ETHER_ADDR_LEN) {
             throw new IllegalArgumentException(addr + " was not a valid MAC address");
         }
         long longAddr = 0;
-        int index = ETHER_ADDR_LEN;
-        while (index-- > 0) {
-            int x = Integer.valueOf(parts[index], 16);
+        for (int i = 0; i < parts.length; i++) {
+            int x = Integer.valueOf(parts[i], 16);
             if (x < 0 || 0xff < x) {
                 throw new IllegalArgumentException(addr + "was not a valid MAC address");
             }
@@ -231,32 +290,74 @@
         return longAddr;
     }
 
-    /** @hide */
-    public static String stringAddrFromLongAddr(long addr) {
-        addr = Long.reverseBytes(addr) >> 16;
-        StringJoiner j = new StringJoiner(":");
-        for (int i = 0; i < ETHER_ADDR_LEN; i++) {
-            j.add(Integer.toHexString((byte) addr));
-            addr = addr >> 8;
-        }
-        return j.toString();
+    // Internal conversion function equivalent to stringAddrFromByteAddr(byteAddrFromLongAddr(addr))
+    // that avoids the allocation of an intermediary byte[].
+    private static String stringAddrFromLongAddr(long addr) {
+        return String.format("%02x:%02x:%02x:%02x:%02x:%02x",
+                (addr >> 40) & 0xff,
+                (addr >> 32) & 0xff,
+                (addr >> 24) & 0xff,
+                (addr >> 16) & 0xff,
+                (addr >> 8) & 0xff,
+                addr & 0xff);
     }
 
     /**
-     * Returns a randomely generated mac address with the Android OUI value "DA-A1-19".
-     * The locally assigned bit is always set to 1.
+     * Creates a MacAddress from the given String representation. A valid String representation
+     * for a MacAddress is a series of 6 values in the range [0,ff] printed in hexadecimal
+     * and joined by ':' characters.
+     *
+     * @param addr a String representation of a MAC address.
+     * @return the MacAddress corresponding to the given String representation.
+     * @throws IllegalArgumentException if the given String is not a valid representation.
      */
-    public static MacAddress getRandomAddress() {
-        return getRandomAddress(BASE_ANDROID_MAC, new Random());
+    public static MacAddress fromString(String addr) {
+        return new MacAddress(longAddrFromStringAddr(addr));
     }
 
     /**
-     * Returns a randomely generated mac address using the given Random object and the same
-     * OUI values as the given MacAddress. The locally assigned bit is always set to 1.
+     * Creates a MacAddress from the given byte array representation.
+     * A valid byte array representation for a MacAddress is a non-null array of length 6.
+     *
+     * @param addr a byte array representation of a MAC address.
+     * @return the MacAddress corresponding to the given byte array representation.
+     * @throws IllegalArgumentException if the given byte array is not a valid representation.
      */
-    public static MacAddress getRandomAddress(MacAddress base, Random r) {
-        long longAddr = (base.mAddr & OUI_MASK) | (NIC_MASK & r.nextLong()) | LOCALLY_ASSIGNED_MASK;
-        return new MacAddress(longAddr);
+    public static MacAddress fromBytes(byte[] addr) {
+        return new MacAddress(longAddrFromByteAddr(addr));
+    }
+
+    /**
+     * Returns a generated MAC address whose 24 least significant bits constituting the
+     * NIC part of the address are randomly selected.
+     *
+     * The locally assigned bit is always set to 1. The multicast bit is always set to 0.
+     *
+     * @return a random locally assigned MacAddress.
+     *
+     * @hide
+     */
+    public static MacAddress createRandomUnicastAddress() {
+        return createRandomUnicastAddress(BASE_GOOGLE_MAC, new Random());
+    }
+
+    /**
+     * Returns a randomly generated MAC address using the given Random object and the same
+     * OUI values as the given MacAddress.
+     *
+     * The locally assigned bit is always set to 1. The multicast bit is always set to 0.
+     *
+     * @param base a base MacAddress whose OUI is used for generating the random address.
+     * @param r a standard Java Random object used for generating the random address.
+     * @return a random locally assigned MacAddress.
+     *
+     * @hide
+     */
+    public static MacAddress createRandomUnicastAddress(MacAddress base, Random r) {
+        long addr = (base.mAddr & OUI_MASK) | (NIC_MASK & r.nextLong());
+        addr = addr | LOCALLY_ASSIGNED_MASK;
+        addr = addr & ~MULTICAST_MASK;
+        return new MacAddress(addr);
     }
 
     // Convenience function for working around the lack of byte literals.
diff --git a/core/java/android/net/NetworkCapabilities.java b/core/java/android/net/NetworkCapabilities.java
index ee75fd4..f468e5d 100644
--- a/core/java/android/net/NetworkCapabilities.java
+++ b/core/java/android/net/NetworkCapabilities.java
@@ -31,16 +31,10 @@
 import java.util.StringJoiner;
 
 /**
- * Representation of the capabilities of a network. This object serves two
- * purposes:
- * <ul>
- * <li>An expression of the current capabilities of an active network, typically
- * expressed through
+ * Representation of the capabilities of an active network. Instances are
+ * typically obtained through
  * {@link NetworkCallback#onCapabilitiesChanged(Network, NetworkCapabilities)}
  * or {@link ConnectivityManager#getNetworkCapabilities(Network)}.
- * <li>An expression of the future capabilities of a desired network, typically
- * expressed through {@link NetworkRequest}.
- * </ul>
  * <p>
  * This replaces the old {@link ConnectivityManager#TYPE_MOBILE} method of
  * network selection. Rather than indicate a need for Wi-Fi because an
@@ -79,7 +73,7 @@
      */
     public void clearAll() {
         mNetworkCapabilities = mTransportTypes = 0;
-        mLinkUpBandwidthKbps = mLinkDownBandwidthKbps = 0;
+        mLinkUpBandwidthKbps = mLinkDownBandwidthKbps = LINK_BANDWIDTH_UNSPECIFIED;
         mNetworkSpecifier = null;
         mSignalStrength = SIGNAL_STRENGTH_UNSPECIFIED;
     }
@@ -359,6 +353,7 @@
 
     /**
      * Sets all the capabilities set on this {@code NetworkCapability} instance.
+     * This overwrites any existing capabilities.
      *
      * @hide
      */
@@ -582,6 +577,7 @@
 
     /**
      * Sets all the transports set on this {@code NetworkCapability} instance.
+     * This overwrites any existing transports.
      *
      * @hide
      */
@@ -780,7 +776,7 @@
      * Signal strength. This is a signed integer, and higher values indicate better signal.
      * The exact units are bearer-dependent. For example, Wi-Fi uses RSSI.
      */
-    private int mSignalStrength;
+    private int mSignalStrength = SIGNAL_STRENGTH_UNSPECIFIED;
 
     /**
      * Sets the signal strength. This is a signed integer, with higher values indicating a stronger
diff --git a/core/java/android/net/NetworkRequest.java b/core/java/android/net/NetworkRequest.java
index 25b1705..97ded2d 100644
--- a/core/java/android/net/NetworkRequest.java
+++ b/core/java/android/net/NetworkRequest.java
@@ -16,6 +16,7 @@
 
 package android.net;
 
+import android.annotation.NonNull;
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.text.TextUtils;
@@ -32,7 +33,7 @@
      * The {@link NetworkCapabilities} that define this request.
      * @hide
      */
-    public final NetworkCapabilities networkCapabilities;
+    public final @NonNull NetworkCapabilities networkCapabilities;
 
     /**
      * Identifies the request.  NetworkRequests should only be constructed by
@@ -307,7 +308,7 @@
         return 0;
     }
     public void writeToParcel(Parcel dest, int flags) {
-        dest.writeParcelable(networkCapabilities, flags);
+        networkCapabilities.writeToParcel(dest, flags);
         dest.writeInt(legacyType);
         dest.writeInt(requestId);
         dest.writeString(type.name());
@@ -315,7 +316,7 @@
     public static final Creator<NetworkRequest> CREATOR =
         new Creator<NetworkRequest>() {
             public NetworkRequest createFromParcel(Parcel in) {
-                NetworkCapabilities nc = (NetworkCapabilities)in.readParcelable(null);
+                NetworkCapabilities nc = NetworkCapabilities.CREATOR.createFromParcel(in);
                 int legacyType = in.readInt();
                 int requestId = in.readInt();
                 Type type = Type.valueOf(in.readString());  // IllegalArgumentException if invalid.
diff --git a/core/java/android/net/NetworkState.java b/core/java/android/net/NetworkState.java
index 95e3802..b00cb48 100644
--- a/core/java/android/net/NetworkState.java
+++ b/core/java/android/net/NetworkState.java
@@ -18,6 +18,7 @@
 
 import android.os.Parcel;
 import android.os.Parcelable;
+import android.util.Slog;
 
 /**
  * Snapshot of network state.
@@ -43,6 +44,16 @@
         this.network = network;
         this.subscriberId = subscriberId;
         this.networkId = networkId;
+
+        // This object is an atomic view of a network, so the various components
+        // should always agree on roaming state.
+        if (networkInfo != null && networkCapabilities != null) {
+            if (networkInfo.isRoaming() == networkCapabilities
+                    .hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING)) {
+                Slog.wtf("NetworkState", "Roaming state disagreement between " + networkInfo
+                        + " and " + networkCapabilities);
+            }
+        }
     }
 
     public NetworkState(Parcel in) {
diff --git a/core/java/android/net/metrics/WakeupStats.java b/core/java/android/net/metrics/WakeupStats.java
index 23c1f20..7277ba3 100644
--- a/core/java/android/net/metrics/WakeupStats.java
+++ b/core/java/android/net/metrics/WakeupStats.java
@@ -16,6 +16,7 @@
 
 package android.net.metrics;
 
+import android.net.MacAddress;
 import android.os.Process;
 import android.os.SystemClock;
 import android.util.SparseIntArray;
@@ -80,13 +81,13 @@
         }
 
         switch (ev.dstHwAddr.addressType()) {
-            case UNICAST:
+            case MacAddress.TYPE_UNICAST:
                 l2UnicastCount++;
                 break;
-            case MULTICAST:
+            case MacAddress.TYPE_MULTICAST:
                 l2MulticastCount++;
                 break;
-            case BROADCAST:
+            case MacAddress.TYPE_BROADCAST:
                 l2BroadcastCount++;
                 break;
             default:
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index 3c1d83c..86e5829 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -767,6 +767,8 @@
         private static final int LOG_MAIN_INDEX_SIZE = 8;
         private static final int MAIN_INDEX_SIZE = 1 <<  LOG_MAIN_INDEX_SIZE;
         private static final int MAIN_INDEX_MASK = MAIN_INDEX_SIZE - 1;
+        // Debuggable builds will throw an AssertionError if the number of map entries exceeds:
+        private static final int CRASH_AT_SIZE = 5_000;
 
         /**
          * We next warn when we exceed this bucket size.
@@ -888,9 +890,14 @@
                 keyArray[size] = key;
             }
             if (size >= mWarnBucketSize) {
+                final int total_size = size();
                 Log.v(Binder.TAG, "BinderProxy map growth! bucket size = " + size
-                        + " total = " + size());
+                        + " total = " + total_size);
                 mWarnBucketSize += WARN_INCREMENT;
+                if (Build.IS_DEBUGGABLE && total_size > CRASH_AT_SIZE) {
+                    throw new AssertionError("Binder ProxyMap has too many entries. "
+                            + "BinderProxy leak?");
+                }
             }
         }
 
diff --git a/core/java/android/os/HidlSupport.java b/core/java/android/os/HidlSupport.java
index 3544ea1..a080c8d 100644
--- a/core/java/android/os/HidlSupport.java
+++ b/core/java/android/os/HidlSupport.java
@@ -179,4 +179,9 @@
         }
         return Objects.equals(lft.asBinder(), ((IHwInterface) rgt).asBinder());
     }
+
+    /**
+     * Return PID of process if sharable to clients.
+     */
+    public static native int getPidIfSharable();
 }
diff --git a/core/java/android/print/IPrintClient.aidl b/core/java/android/print/IPrintClient.aidl
deleted file mode 100644
index 3f39d08..0000000
--- a/core/java/android/print/IPrintClient.aidl
+++ /dev/null
@@ -1,30 +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.print;
-
-import android.content.IntentSender;
-
-/**
- * Interface for communication with a printing app.
- *
- * @see android.print.IPrintClientCallback
- *
- * @hide
- */
-oneway interface IPrintClient {
-    void startPrintJobConfigActivity(in IntentSender intent);
-}
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index df944fd..6560a8f 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -9224,6 +9224,9 @@
         /** {@hide} */
         public static final String
                 BLUETOOTH_PAN_PRIORITY_PREFIX = "bluetooth_pan_priority_";
+        /** {@hide} */
+        public static final String
+                BLUETOOTH_HEARING_AID_PRIORITY_PREFIX = "bluetooth_hearing_aid_priority_";
 
         /**
          * Activity manager specific settings.
@@ -9545,6 +9548,14 @@
         }
 
         /**
+         * Get the key that retrieves a bluetooth hearing aid priority.
+         * @hide
+         */
+        public static final String getBluetoothHearingAidPriorityKey(String address) {
+            return BLUETOOTH_HEARING_AID_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
+        }
+
+        /**
          * Get the key that retrieves a bluetooth map priority.
          * @hide
          */
diff --git a/core/java/android/service/autofill/IAuthenticationCallback.aidl b/core/java/android/service/autofill/IAuthenticationCallback.aidl
deleted file mode 100644
index 36b989d..0000000
--- a/core/java/android/service/autofill/IAuthenticationCallback.aidl
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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 android.view.autofill;
-
-import android.view.autofill.Dataset;
-import android.service.autofill.FillResponse;
-
-/**
- * Callback for delivering authentication result.
- *
- * {@hide}
- */
-interface IAutoFillAuthCallback {
-    void onSuccessForDataset(in Dataset dataset);
-    void onSuccessForFillResponse(in FillResponse response);
-    void onFailure(CharSequence message);
-}
diff --git a/core/java/android/service/carrier/CarrierService.java b/core/java/android/service/carrier/CarrierService.java
index 813acc2..2707f14 100644
--- a/core/java/android/service/carrier/CarrierService.java
+++ b/core/java/android/service/carrier/CarrierService.java
@@ -17,10 +17,13 @@
 import android.annotation.CallSuper;
 import android.app.Service;
 import android.content.Intent;
+import android.os.Bundle;
 import android.os.IBinder;
 import android.os.PersistableBundle;
 import android.os.RemoteException;
+import android.os.ResultReceiver;
 import android.os.ServiceManager;
+import android.util.Log;
 
 import com.android.internal.telephony.ITelephonyRegistry;
 
@@ -48,6 +51,8 @@
  */
 public abstract class CarrierService extends Service {
 
+    private static final String LOG_TAG = "CarrierService";
+
     public static final String CARRIER_SERVICE_INTERFACE = "android.service.carrier.CarrierService";
 
     private static ITelephonyRegistry sRegistry;
@@ -133,11 +138,26 @@
     /**
      * A wrapper around ICarrierService that forwards calls to implementations of
      * {@link CarrierService}.
+     * @hide
      */
-    private class ICarrierServiceWrapper extends ICarrierService.Stub {
+    public class ICarrierServiceWrapper extends ICarrierService.Stub {
+        /** @hide */
+        public static final int RESULT_OK = 0;
+        /** @hide */
+        public static final int RESULT_ERROR = 1;
+        /** @hide */
+        public static final String KEY_CONFIG_BUNDLE = "config_bundle";
+
         @Override
-        public PersistableBundle getCarrierConfig(CarrierIdentifier id) {
-            return CarrierService.this.onLoadConfig(id);
+        public void getCarrierConfig(CarrierIdentifier id, ResultReceiver result) {
+            try {
+                Bundle data = new Bundle();
+                data.putParcelable(KEY_CONFIG_BUNDLE, CarrierService.this.onLoadConfig(id));
+                result.send(RESULT_OK, data);
+            } catch (Exception e) {
+                Log.e(LOG_TAG, "Error in onLoadConfig: " + e.getMessage(), e);
+                result.send(RESULT_ERROR, null);
+            }
         }
     }
 }
diff --git a/core/java/android/service/carrier/ICarrierService.aidl b/core/java/android/service/carrier/ICarrierService.aidl
index 4c87585..ac6f9614 100644
--- a/core/java/android/service/carrier/ICarrierService.aidl
+++ b/core/java/android/service/carrier/ICarrierService.aidl
@@ -17,6 +17,7 @@
 package android.service.carrier;
 
 import android.os.PersistableBundle;
+import android.os.ResultReceiver;
 import android.service.carrier.CarrierIdentifier;
 
 /**
@@ -28,5 +29,5 @@
 interface ICarrierService {
 
     /** @see android.service.carrier.CarrierService#onLoadConfig */
-    PersistableBundle getCarrierConfig(in CarrierIdentifier id);
+    oneway void getCarrierConfig(in CarrierIdentifier id, in ResultReceiver result);
 }
diff --git a/core/jni/Android.bp b/core/jni/Android.bp
index bc86ddd..ec51659 100644
--- a/core/jni/Android.bp
+++ b/core/jni/Android.bp
@@ -77,6 +77,7 @@
         "android_text_StaticLayout.cpp",
         "android_os_Debug.cpp",
         "android_os_GraphicsEnvironment.cpp",
+        "android_os_HidlSupport.cpp",
         "android_os_HwBinder.cpp",
         "android_os_HwBlob.cpp",
         "android_os_HwParcel.cpp",
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 8b6fc59..6bc6f63 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -154,6 +154,7 @@
 extern int register_android_nio_utils(JNIEnv* env);
 extern int register_android_os_Debug(JNIEnv* env);
 extern int register_android_os_GraphicsEnvironment(JNIEnv* env);
+extern int register_android_os_HidlSupport(JNIEnv* env);
 extern int register_android_os_HwBinder(JNIEnv *env);
 extern int register_android_os_HwBlob(JNIEnv *env);
 extern int register_android_os_HwParcel(JNIEnv *env);
@@ -1325,6 +1326,7 @@
     REG_JNI(register_android_os_SystemProperties),
     REG_JNI(register_android_os_Binder),
     REG_JNI(register_android_os_Parcel),
+    REG_JNI(register_android_os_HidlSupport),
     REG_JNI(register_android_os_HwBinder),
     REG_JNI(register_android_os_HwBlob),
     REG_JNI(register_android_os_HwParcel),
diff --git a/core/jni/android_os_HidlSupport.cpp b/core/jni/android_os_HidlSupport.cpp
new file mode 100644
index 0000000..e3602d8
--- /dev/null
+++ b/core/jni/android_os_HidlSupport.cpp
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+#include <hidl/HidlTransportSupport.h>
+#include <nativehelper/JNIHelp.h>
+
+#include "core_jni_helpers.h"
+
+namespace android {
+static jint android_os_HidlSupport_getPidIfSharable(JNIEnv*, jclass) {
+    return android::hardware::details::getPidIfSharable();
+}
+
+static const JNINativeMethod gHidlSupportMethods[] = {
+    {"getPidIfSharable", "()I", (void*)android_os_HidlSupport_getPidIfSharable},
+};
+
+const char* const kHidlSupportPathName = "android/os/HidlSupport";
+
+int register_android_os_HidlSupport(JNIEnv* env)
+{
+    return RegisterMethodsOrDie(env, kHidlSupportPathName, gHidlSupportMethods, NELEM(gHidlSupportMethods));
+}
+
+}  // namespace android
diff --git a/core/proto/android/providers/settings.proto b/core/proto/android/providers/settings.proto
index fa645f4..ef6eb09 100644
--- a/core/proto/android/providers/settings.proto
+++ b/core/proto/android/providers/settings.proto
@@ -254,6 +254,7 @@
     SettingProto bluetooth_pbap_client_priority_prefix = 209;
     SettingProto bluetooth_sap_priority_prefix = 210;
     SettingProto bluetooth_pan_priority_prefix = 211;
+    SettingProto bluetooth_hearing_aid_priority_prefix = 345;
     SettingProto device_idle_constants = 212;
     SettingProto device_idle_constants_watch = 213;
     SettingProto app_idle_constants = 214;
diff --git a/core/res/Android.bp b/core/res/Android.bp
new file mode 100644
index 0000000..6a3b012
--- /dev/null
+++ b/core/res/Android.bp
@@ -0,0 +1,38 @@
+//
+// Copyright (C) 2008 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.
+//
+
+android_app {
+    name: "framework-res",
+    no_framework_libs: true,
+    certificate: "platform",
+
+    // Soong special-cases framework-res to install this alongside
+    // the libraries at /system/framework/framework-res.apk.
+
+    // Generate private symbols into the com.android.internal.R class
+    // so they are not accessible to 3rd party apps.
+    aaptflags: [
+        "--private-symbols",
+        "com.android.internal",
+
+        // Framework doesn't need versioning since it IS the platform.
+        "--no-auto-version",
+    ],
+
+    // Create package-export.apk, which other packages can use to get
+    // PRODUCT-agnostic resource data like IDs and type definitions.
+    export_package_resources: true,
+}
diff --git a/core/res/Android.mk b/core/res/Android.mk
deleted file mode 100644
index b066929..0000000
--- a/core/res/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Copyright (C) 2008 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.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_USE_AAPT2 := true
-LOCAL_NO_STANDARD_LIBRARIES := true
-LOCAL_PACKAGE_NAME := framework-res
-LOCAL_CERTIFICATE := platform
-LOCAL_MODULE_TAGS := optional
-
-# Generate private symbols into the com.android.internal.R class
-# so they are not accessible to 3rd party apps.
-LOCAL_AAPT_FLAGS += --private-symbols com.android.internal
-
-# Framework doesn't need versioning since it IS the platform.
-LOCAL_AAPT_FLAGS += --no-auto-version
-
-# Install this alongside the libraries.
-LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)
-
-# Create package-export.apk, which other packages can use to get
-# PRODUCT-agnostic resource data like IDs and type definitions.
-LOCAL_EXPORT_PACKAGE_RESOURCES := true
-
-include $(BUILD_PACKAGE)
diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
index a979ac8..9edaffe 100644
--- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java
+++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
@@ -121,6 +121,7 @@
                     Settings.Global.BLUETOOTH_PAN_PRIORITY_PREFIX,
                     Settings.Global.BLUETOOTH_PBAP_CLIENT_PRIORITY_PREFIX,
                     Settings.Global.BLUETOOTH_SAP_PRIORITY_PREFIX,
+                    Settings.Global.BLUETOOTH_HEARING_AID_PRIORITY_PREFIX,
                     Settings.Global.BOOT_COUNT,
                     Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL,
                     Settings.Global.CAPTIVE_PORTAL_HTTPS_URL,
diff --git a/core/tests/coretests/src/android/view/PinchZoomAction.java b/core/tests/coretests/src/android/view/PinchZoomAction.java
index 78a4b31..97fe980 100644
--- a/core/tests/coretests/src/android/view/PinchZoomAction.java
+++ b/core/tests/coretests/src/android/view/PinchZoomAction.java
@@ -16,23 +16,23 @@
 
 package android.view;
 
-import static android.support.test.espresso.core.deps.guava.base.Preconditions.checkNotNull;
 import static android.support.test.espresso.matcher.ViewMatchers.isAssignableFrom;
 import static android.support.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import static org.hamcrest.Matchers.allOf;
 
 import android.os.SystemClock;
 import android.support.test.espresso.InjectEventSecurityException;
 import android.support.test.espresso.PerformException;
-import android.support.test.espresso.ViewAction;
-import android.support.test.espresso.action.MotionEvents;
-import android.support.test.espresso.action.Swiper;
 import android.support.test.espresso.UiController;
+import android.support.test.espresso.ViewAction;
+import android.support.test.espresso.action.Swiper;
 import android.support.test.espresso.util.HumanReadables;
 import android.view.MotionEvent;
 import android.view.View;
-import android.view.ViewConfiguration;
-import javax.annotation.Nullable;
+
 import org.hamcrest.Matcher;
 
 /**
diff --git a/core/tests/coretests/src/android/widget/espresso/MouseClickAction.java b/core/tests/coretests/src/android/widget/espresso/MouseClickAction.java
index bec4180..b50d6f4 100644
--- a/core/tests/coretests/src/android/widget/espresso/MouseClickAction.java
+++ b/core/tests/coretests/src/android/widget/espresso/MouseClickAction.java
@@ -16,8 +16,6 @@
 
 package android.widget.espresso;
 
-import org.hamcrest.Matcher;
-
 import android.support.test.espresso.UiController;
 import android.support.test.espresso.ViewAction;
 import android.support.test.espresso.action.CoordinatesProvider;
@@ -25,10 +23,13 @@
 import android.support.test.espresso.action.MotionEvents.DownResultHolder;
 import android.support.test.espresso.action.Press;
 import android.support.test.espresso.action.Tapper;
+import android.view.InputDevice;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewConfiguration;
 
+import org.hamcrest.Matcher;
+
 /**
  * ViewAction for performing an click on View by a mouse.
  */
@@ -41,8 +42,9 @@
         TRIPLE {
             @Override
             public Tapper.Status sendTap(UiController uiController, float[] coordinates,
-                    float[] precision) {
-                Tapper.Status stat = sendSingleTap(uiController, coordinates, precision);
+                    float[] precision, int inputDevice, int buttonState) {
+                Tapper.Status stat = sendSingleTap(uiController, coordinates, precision,
+                        inputDevice, buttonState);
                 boolean warning = false;
                 if (stat == Tapper.Status.FAILURE) {
                     return Tapper.Status.FAILURE;
@@ -55,7 +57,8 @@
                     if (0 < doubleTapMinimumTimeout) {
                         uiController.loopMainThreadForAtLeast(doubleTapMinimumTimeout);
                     }
-                    stat = sendSingleTap(uiController, coordinates, precision);
+                    stat = sendSingleTap(uiController, coordinates, precision, inputDevice,
+                            buttonState);
                     if (stat == Tapper.Status.FAILURE) {
                         return Tapper.Status.FAILURE;
                     } else if (stat == Tapper.Status.WARNING) {
@@ -69,11 +72,19 @@
                     return Tapper.Status.SUCCESS;
                 }
             }
+
+            @Override
+            public Tapper.Status sendTap(UiController uiController, float[] coordinates,
+                    float[] precision) {
+                return sendTap(uiController, coordinates, precision, InputDevice.SOURCE_UNKNOWN,
+                        MotionEvent.BUTTON_PRIMARY);
+            }
         };
 
         private static Tapper.Status sendSingleTap(UiController uiController,
-                float[] coordinates, float[] precision) {
-            DownResultHolder res = MotionEvents.sendDown(uiController, coordinates, precision);
+                float[] coordinates, float[] precision, int inputDevice, int buttonState) {
+            DownResultHolder res = MotionEvents.sendDown(uiController, coordinates, precision,
+                    inputDevice, buttonState);
             try {
                 if (!MotionEvents.sendUp(uiController, res.down)) {
                     MotionEvents.sendCancel(uiController, res.down);
diff --git a/core/tests/coretests/src/com/android/internal/widget/MessagingLinearLayoutTest.java b/core/tests/coretests/src/com/android/internal/widget/MessagingLinearLayoutTest.java
index 20fd4d3..dfe8511 100644
--- a/core/tests/coretests/src/com/android/internal/widget/MessagingLinearLayoutTest.java
+++ b/core/tests/coretests/src/com/android/internal/widget/MessagingLinearLayoutTest.java
@@ -22,12 +22,12 @@
 
 import android.content.Context;
 import android.support.test.InstrumentationRegistry;
-import android.support.test.espresso.core.deps.guava.base.Function;
 import android.support.test.filters.SmallTest;
 import android.view.LayoutInflater;
 import android.view.View.MeasureSpec;
 
 import com.android.frameworks.coretests.R;
+import com.google.common.base.Function;
 
 import org.junit.Before;
 import org.junit.Test;
diff --git a/core/tests/overlaytests/Android.mk b/core/tests/overlaytests/Android.mk
index bf69442..b798d87 100644
--- a/core/tests/overlaytests/Android.mk
+++ b/core/tests/overlaytests/Android.mk
@@ -1,4 +1,15 @@
-# Dummy makefile to halt recursive directory traversal.
+# 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.
 
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
+include $(call all-subdir-makefiles)
diff --git a/media/mca/filterfw/Android.mk b/media/mca/filterfw/Android.mk
index 334f4e2..37f1e13 100644
--- a/media/mca/filterfw/Android.mk
+++ b/media/mca/filterfw/Android.mk
@@ -26,6 +26,8 @@
 
 LOCAL_MODULE := libfilterfw
 
+LOCAL_CFLAGS := -Wall -Werror
+
 LOCAL_MODULE_TAGS := optional
 
 LOCAL_WHOLE_STATIC_LIBRARIES := libfilterfw_jni \
diff --git a/obex/javax/obex/ServerOperation.java b/obex/javax/obex/ServerOperation.java
index 56a675a..15ea367 100644
--- a/obex/javax/obex/ServerOperation.java
+++ b/obex/javax/obex/ServerOperation.java
@@ -195,7 +195,12 @@
             if(!handleObexPacket(packet)) {
                 return;
             }
-            if (!mHasBody) {
+            /* Don't Pre-Send continue when Remote requested for SRM
+             * Let the Application confirm.
+             */
+            if (V) Log.v(TAG, "Get App confirmation if SRM ENABLED case: " + mSrmEnabled
+                    + " not hasBody case: " + mHasBody);
+            if (!mHasBody && !mSrmEnabled) {
                 while ((!mGetOperation) && (!finalBitSet)) {
                     sendReply(ResponseCodes.OBEX_HTTP_CONTINUE);
                     if (mPrivateInput.available() > 0) {
@@ -204,8 +209,13 @@
                 }
             }
         }
-
-        while ((!mGetOperation) && (!finalBitSet) && (mPrivateInput.available() == 0)) {
+        /* Don't Pre-Send continue when Remote requested for SRM
+          * Let the Application confirm.
+          */
+        if (V) Log.v(TAG, "Get App confirmation if SRM ENABLED case: " + mSrmEnabled
+            + " not finalPacket: " + finalBitSet + " not GETOp Case: " + mGetOperation);
+        while ((!mSrmEnabled) && (!mGetOperation) && (!finalBitSet)
+                && (mPrivateInput.available() == 0)) {
             sendReply(ResponseCodes.OBEX_HTTP_CONTINUE);
             if (mPrivateInput.available() > 0) {
                 break;
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
index abd4e29..9217338 100755
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
@@ -118,7 +118,7 @@
     public synchronized void clearNonBondedDevices() {
         for (int i = mCachedDevices.size() - 1; i >= 0; i--) {
             CachedBluetoothDevice cachedDevice = mCachedDevices.get(i);
-            if (cachedDevice.getBondState() != BluetoothDevice.BOND_BONDED) {
+            if (cachedDevice.getBondState() == BluetoothDevice.BOND_NONE) {
                 mCachedDevices.remove(i);
             }
         }
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
index 819ee3e..d256b12 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
@@ -720,6 +720,9 @@
                 Settings.Global.BLUETOOTH_PAN_PRIORITY_PREFIX,
                 GlobalSettingsProto.BLUETOOTH_PAN_PRIORITY_PREFIX);
         dumpSetting(s, p,
+                Settings.Global.BLUETOOTH_HEARING_AID_PRIORITY_PREFIX,
+                GlobalSettingsProto.BLUETOOTH_HEARING_AID_PRIORITY_PREFIX);
+        dumpSetting(s, p,
                 Settings.Global.DEVICE_IDLE_CONSTANTS,
                 GlobalSettingsProto.DEVICE_IDLE_CONSTANTS);
         dumpSetting(s, p,
diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
index ca58080..e1371e8 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
@@ -600,9 +600,7 @@
         @Override
         public void onTaskStackChanged() {
             if (DEBUG) Log.d(TAG, "onTaskStackChanged()");
-            if (!checkCurrentUserId(mContext, DEBUG)) {
-                return;
-            }
+
             if (getState() != STATE_NO_PIP) {
                 boolean hasPip = false;
 
@@ -637,9 +635,7 @@
         @Override
         public void onActivityPinned(String packageName, int taskId) {
             if (DEBUG) Log.d(TAG, "onActivityPinned()");
-            if (!checkCurrentUserId(mContext, DEBUG)) {
-                return;
-            }
+
             StackInfo stackInfo = getPinnedStackInfo();
             if (stackInfo == null) {
                 Log.w(TAG, "Cannot find pinned stack");
@@ -664,9 +660,7 @@
         @Override
         public void onPinnedActivityRestartAttempt(boolean clearedTask) {
             if (DEBUG) Log.d(TAG, "onPinnedActivityRestartAttempt()");
-            if (!checkCurrentUserId(mContext, DEBUG)) {
-                return;
-            }
+
             // If PIPed activity is launched again by Launcher or intent, make it fullscreen.
             movePipToFullscreen();
         }
@@ -674,9 +668,7 @@
         @Override
         public void onPinnedStackAnimationEnded() {
             if (DEBUG) Log.d(TAG, "onPinnedStackAnimationEnded()");
-            if (!checkCurrentUserId(mContext, DEBUG)) {
-                return;
-            }
+
             switch (getState()) {
                 case STATE_PIP_MENU:
                     showPipMenu();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
index b93fb22..9d3cf82 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
@@ -300,7 +300,7 @@
                 && !mCurrentState.carrierNetworkChangeMode
                 && mCurrentState.activityOut;
         showDataIcon &= mCurrentState.isDefault || dataDisabled;
-        int typeIcon = showDataIcon ? icons.mDataType : 0;
+        int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.mDataType : 0;
         callback.setMobileDataIndicators(statusIcon, qsIcon, typeIcon, qsTypeIcon,
                 activityIn, activityOut, dataContentDescription, description, icons.mIsWide,
                 mSubscriptionInfo.getSubscriptionId(), mCurrentState.roaming);
@@ -460,7 +460,7 @@
         mCurrentState.roaming = isRoaming();
         if (isCarrierNetworkChangeActive()) {
             mCurrentState.iconGroup = TelephonyIcons.CARRIER_NETWORK_CHANGE;
-        } else if (isDataDisabled()) {
+        } else if (isDataDisabled() && !mConfig.alwaysShowDataRatIcon) {
             mCurrentState.iconGroup = TelephonyIcons.DATA_DISABLED;
         }
         if (isEmergencyOnly() != mCurrentState.isEmergency) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index c217bda..926dbc5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -29,7 +29,9 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Looper;
+import android.os.PersistableBundle;
 import android.provider.Settings;
+import android.telephony.CarrierConfigManager;
 import android.telephony.ServiceState;
 import android.telephony.SignalStrength;
 import android.telephony.SubscriptionInfo;
@@ -246,6 +248,7 @@
         filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
         filter.addAction(ConnectivityManager.INET_CONDITION_ACTION);
         filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
+        filter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
         mContext.registerReceiver(this, filter, null, mReceiverHandler);
         mListening = true;
 
@@ -434,6 +437,14 @@
                 // emergency state.
                 recalculateEmergency();
             }
+        } else if (action.equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) {
+            mConfig = Config.readConfig(mContext);
+            mReceiverHandler.post(new Runnable() {
+                @Override
+                public void run() {
+                    handleConfigurationChanged();
+                }
+            });
         } else {
             int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
                     SubscriptionManager.INVALID_SUBSCRIPTION_ID);
@@ -959,6 +970,7 @@
         boolean hideLtePlus = false;
         boolean hspaDataDistinguishable;
         boolean inflateSignalStrengths = false;
+        boolean alwaysShowDataRatIcon = false;
 
         static Config readConfig(Context context) {
             Config config = new Config();
@@ -972,6 +984,14 @@
                     res.getBoolean(R.bool.config_hspa_data_distinguishable);
             config.hideLtePlus = res.getBoolean(R.bool.config_hideLtePlus);
             config.inflateSignalStrengths = res.getBoolean(R.bool.config_inflateSignalStrength);
+
+            CarrierConfigManager configMgr = (CarrierConfigManager)
+                    context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
+            PersistableBundle b = configMgr.getConfig();
+            if (b != null) {
+                config.alwaysShowDataRatIcon = b.getBoolean(
+                        CarrierConfigManager.KEY_ALWAYS_SHOW_DATA_RAT_ICON_BOOL);
+            }
             return config;
         }
     }
diff --git a/packages/SystemUI/tests/src/com/android/AAAPlusPlusVerifySysuiRequiredTestPropertiesTest.java b/packages/SystemUI/tests/src/com/android/AAAPlusPlusVerifySysuiRequiredTestPropertiesTest.java
index b597868..fe23541 100644
--- a/packages/SystemUI/tests/src/com/android/AAAPlusPlusVerifySysuiRequiredTestPropertiesTest.java
+++ b/packages/SystemUI/tests/src/com/android/AAAPlusPlusVerifySysuiRequiredTestPropertiesTest.java
@@ -22,7 +22,6 @@
 import android.support.test.internal.runner.ClassPathScanner;
 import android.support.test.internal.runner.ClassPathScanner.ChainedClassNameFilter;
 import android.support.test.internal.runner.ClassPathScanner.ExternalClassNameFilter;
-import android.support.test.internal.runner.TestLoader;
 import android.testing.AndroidTestingRunner;
 import android.text.TextUtils;
 import android.util.Log;
@@ -32,8 +31,11 @@
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.junit.internal.builders.AllDefaultPossibilitiesBuilder;
 
 import java.io.IOException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -69,12 +71,11 @@
     };
 
     @Test
-    public void testAllClassInheritance() {
+    public void testAllClassInheritance() throws Throwable {
         boolean anyClassWrong = false;
-        TestLoader loader = new TestLoader();
         for (String className : getClassNamesFromClassPath()) {
-            Class<?> cls = loader.loadIfTest(className);
-            if (cls == null) continue;
+            Class<?> cls = Class.forName(className, false, this.getClass().getClassLoader());		
+            if (!isTestClass(cls)) continue;
 
             boolean hasParent = false;
             for (Class<?> parent : BASE_CLS_WHITELIST) {
@@ -125,4 +126,85 @@
         return TextUtils.join(",", Arrays.asList(BASE_CLS_WHITELIST)
                 .stream().map(cls -> cls.getSimpleName()).toArray());
     }
+
+    /**
+     * Determines if given class is a valid test class.
+     *
+     * @param loadedClass
+     * @return <code>true</code> if loadedClass is a test
+     */
+    private boolean isTestClass(Class<?> loadedClass) {
+        try {
+            if (Modifier.isAbstract(loadedClass.getModifiers())) {
+                logDebug(String.format("Skipping abstract class %s: not a test",
+                        loadedClass.getName()));
+                return false;
+            }
+            // TODO: try to find upstream junit calls to replace these checks
+            if (junit.framework.Test.class.isAssignableFrom(loadedClass)) {
+                // ensure that if a TestCase, it has at least one test method otherwise
+                // TestSuite will throw error
+                if (junit.framework.TestCase.class.isAssignableFrom(loadedClass)) {
+                    return hasJUnit3TestMethod(loadedClass);
+                }
+                return true;
+            }
+            // TODO: look for a 'suite' method?
+            if (loadedClass.isAnnotationPresent(org.junit.runner.RunWith.class)) {
+                return true;
+            }
+            for (Method testMethod : loadedClass.getMethods()) {
+                if (testMethod.isAnnotationPresent(org.junit.Test.class)) {
+                    return true;
+                }
+            }
+            logDebug(String.format("Skipping class %s: not a test", loadedClass.getName()));
+            return false;
+        } catch (Exception e) {
+            // Defensively catch exceptions - Will throw runtime exception if it cannot load methods.
+            // For earlier versions of Android (Pre-ICS), Dalvik might try to initialize a class
+            // during getMethods(), fail to do so, hide the error and throw a NoSuchMethodException.
+            // Since the java.lang.Class.getMethods does not declare such an exception, resort to a
+            // generic catch all.
+            // For ICS+, Dalvik will throw a NoClassDefFoundException.
+            Log.w(TAG, String.format("%s in isTestClass for %s", e.toString(),
+                    loadedClass.getName()));
+            return false;
+        } catch (Error e) {
+            // defensively catch Errors too
+            Log.w(TAG, String.format("%s in isTestClass for %s", e.toString(),
+                    loadedClass.getName()));
+            return false;
+        }
+    }
+
+    private boolean hasJUnit3TestMethod(Class<?> loadedClass) {
+        for (Method testMethod : loadedClass.getMethods()) {
+            if (isPublicTestMethod(testMethod)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    // copied from junit.framework.TestSuite
+    private boolean isPublicTestMethod(Method m) {
+        return isTestMethod(m) && Modifier.isPublic(m.getModifiers());
+    }
+
+    // copied from junit.framework.TestSuite
+    private boolean isTestMethod(Method m) {
+        return m.getParameterTypes().length == 0 && m.getName().startsWith("test")
+                && m.getReturnType().equals(Void.TYPE);
+    }
+
+    /**
+     * Utility method for logging debug messages. Only actually logs a message if TAG is marked
+     * as loggable to limit log spam during normal use.
+     */
+    private void logDebug(String msg) {
+        if (Log.isLoggable(TAG, Log.DEBUG)) {
+            Log.d(TAG, msg);
+        }
+    }
 }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
index 7708adb..47ddd2e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
@@ -144,6 +144,23 @@
 
     @Test
     @Ignore("Flaky")
+    public void testAlwaysShowDataRatIcon() {
+        setupDefaultSignal();
+        when(mMockTm.getDataEnabled(mSubId)).thenReturn(false);
+        updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED,
+                TelephonyManager.NETWORK_TYPE_GSM);
+
+        // Switch to showing data RAT icon when data is disconnected
+        // and re-initialize the NetworkController.
+        mConfig.alwaysShowDataRatIcon = true;
+        mNetworkController.handleConfigurationChanged();
+
+        verifyDataIndicators(TelephonyIcons.ICON_G,
+                TelephonyIcons.QS_DATA_G);
+    }
+
+    @Test
+    @Ignore("Flaky")
     public void test4gDataIconConfigChange() {
         setupDefaultSignal();
         updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java
index c34c30c..04279a3 100644
--- a/services/core/java/com/android/server/BluetoothManagerService.java
+++ b/services/core/java/com/android/server/BluetoothManagerService.java
@@ -2150,31 +2150,26 @@
                                           (int)((onDuration / (1000 * 60)) % 60),
                                           (int)((onDuration / 1000) % 60),
                                           (int)(onDuration % 1000));
-                writer.println("  time since enabled: " + onDurationString + "\n");
+                writer.println("  time since enabled: " + onDurationString);
             }
 
             if (mActiveLogs.size() == 0) {
-                writer.println("Bluetooth never enabled!");
+                writer.println("\nBluetooth never enabled!");
             } else {
-                writer.println("Enable log:");
+                writer.println("\nEnable log:");
                 for (ActiveLog log : mActiveLogs) {
                     writer.println("  " + log);
                 }
             }
 
-            writer.println("Bluetooth crashed " + mCrashes + " time" + (mCrashes == 1 ? "" : "s"));
+            writer.println("\nBluetooth crashed " + mCrashes + " time" + (mCrashes == 1 ? "" : "s"));
             if (mCrashes == CRASH_LOG_MAX_SIZE) writer.println("(last " + CRASH_LOG_MAX_SIZE + ")");
             for (Long time : mCrashTimestamps) {
               writer.println("  " + timeToLog(time.longValue()));
             }
 
-            String bleAppString = "No BLE Apps registered.";
-            if (mBleApps.size() == 1) {
-                bleAppString = "1 BLE App registered:";
-            } else if (mBleApps.size() > 1) {
-                bleAppString = mBleApps.size() + " BLE Apps registered:";
-            }
-            writer.println("\n" + bleAppString);
+            writer.println("\n" + mBleApps.size() + " BLE app" +
+                            (mBleApps.size() == 1 ? "" : "s") + "registered");
             for (ClientDeathRecipient app : mBleApps.values()) {
                 writer.println("  " + app.getPackageName());
             }
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index ce19a1c..e168dd8 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -951,7 +951,10 @@
                         getNetworkTypeName(networkType), "");
                 info.setDetailedState(NetworkInfo.DetailedState.DISCONNECTED, null, null);
                 info.setIsAvailable(true);
-                state = new NetworkState(info, new LinkProperties(), new NetworkCapabilities(),
+                final NetworkCapabilities capabilities = new NetworkCapabilities();
+                capabilities.setCapability(NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING,
+                        !info.isRoaming());
+                state = new NetworkState(info, new LinkProperties(), capabilities,
                         null, null, null);
             }
             filterNetworkStateForUid(state, uid, ignoreBlocked);
diff --git a/services/core/java/com/android/server/connectivity/NetdEventListenerService.java b/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
index 6f2d77f..25b52da 100644
--- a/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
+++ b/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
@@ -243,7 +243,7 @@
         event.timestampMs = timestampMs;
         event.uid = uid;
         event.ethertype = ethertype;
-        event.dstHwAddr = new MacAddress(dstHw);
+        event.dstHwAddr = MacAddress.fromBytes(dstHw);
         event.srcIp = srcIp;
         event.dstIp = dstIp;
         event.ipNextHeader = ipNextHeader;
diff --git a/services/core/java/com/android/server/pm/PackageDexOptimizer.java b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
index bf1c4c3..c6969ed 100644
--- a/services/core/java/com/android/server/pm/PackageDexOptimizer.java
+++ b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
@@ -128,6 +128,10 @@
     int performDexOpt(PackageParser.Package pkg, String[] sharedLibraries,
             String[] instructionSets, CompilerStats.PackageStats packageStats,
             PackageDexUsage.PackageUseInfo packageUseInfo, DexoptOptions options) {
+        if (pkg.applicationInfo.uid == -1) {
+            throw new IllegalArgumentException("Dexopt for " + pkg.packageName
+                    + " has invalid uid.");
+        }
         if (!canOptimizePackage(pkg)) {
             return DEX_OPT_SKIPPED;
         }
@@ -299,6 +303,9 @@
      */
     public int dexOptSecondaryDexPath(ApplicationInfo info, String path,
             PackageDexUsage.DexUseInfo dexUseInfo, DexoptOptions options) {
+        if (info.uid == -1) {
+            throw new IllegalArgumentException("Dexopt for path " + path + " has invalid uid.");
+        }
         synchronized (mInstallLock) {
             final long acquireTime = acquireWakeLockLI(info.uid);
             try {
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 93d8894..2195587 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -17225,6 +17225,15 @@
                 return;
             }
 
+            // check if the new package supports all of the abis which the old package supports
+            boolean oldPkgSupportMultiArch = oldPackage.applicationInfo.secondaryCpuAbi != null;
+            boolean newPkgSupportMultiArch = pkg.applicationInfo.secondaryCpuAbi != null;
+            if (isSystemApp(oldPackage) && oldPkgSupportMultiArch && !newPkgSupportMultiArch) {
+                res.setError(INSTALL_FAILED_UPDATE_INCOMPATIBLE,
+                        "Update to package " + pkgName + " doesn't support multi arch");
+                return;
+            }
+
             // In case of rollback, remember per-user/profile install state
             allUsers = sUserManager.getUserIds();
             installedUsers = ps.queryInstalledUsers(allUsers, true);
@@ -18271,52 +18280,14 @@
             return;
         }
 
-        // Verify if we need to dexopt the app.
-        //
-        // NOTE: it is *important* to call dexopt after doRename which will sync the
-        // package data from PackageParser.Package and its corresponding ApplicationInfo.
-        //
-        // We only need to dexopt if the package meets ALL of the following conditions:
-        //   1) it is not forward locked.
-        //   2) it is not on on an external ASEC container.
-        //   3) it is not an instant app or if it is then dexopt is enabled via gservices.
-        //
-        // Note that we do not dexopt instant apps by default. dexopt can take some time to
-        // complete, so we skip this step during installation. Instead, we'll take extra time
-        // the first time the instant app starts. It's preferred to do it this way to provide
-        // continuous progress to the useur instead of mysteriously blocking somewhere in the
-        // middle of running an instant app. The default behaviour can be overridden
-        // via gservices.
-        final boolean performDexopt = !forwardLocked
-            && !pkg.applicationInfo.isExternalAsec()
-            && (!instantApp || Global.getInt(mContext.getContentResolver(),
-                    Global.INSTANT_APP_DEXOPT_ENABLED, 0) != 0);
-
-        if (performDexopt) {
-            Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dexopt");
-            // Do not run PackageDexOptimizer through the local performDexOpt
-            // method because `pkg` may not be in `mPackages` yet.
-            //
-            // Also, don't fail application installs if the dexopt step fails.
-            DexoptOptions dexoptOptions = new DexoptOptions(pkg.packageName,
-                REASON_INSTALL,
-                DexoptOptions.DEXOPT_BOOT_COMPLETE);
-            mPackageDexOptimizer.performDexOpt(pkg, pkg.usesLibraryFiles,
-                null /* instructionSets */,
-                getOrCreateCompilerPackageStats(pkg),
-                mDexManager.getPackageUseInfoOrDefault(pkg.packageName),
-                dexoptOptions);
-            Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
+        if (!instantApp) {
+            startIntentFilterVerifications(args.user.getIdentifier(), replace, pkg);
+        } else {
+            if (DEBUG_DOMAIN_VERIFICATION) {
+                Slog.d(TAG, "Not verifying instant app install for app links: " + pkgName);
+            }
         }
 
-        // Notify BackgroundDexOptService that the package has been changed.
-        // If this is an update of a package which used to fail to compile,
-        // BackgroundDexOptService will remove it from its blacklist.
-        // TODO: Layering violation
-        BackgroundDexOptService.notifyPackageChanged(pkg.packageName);
-
-        startIntentFilterVerifications(args.user.getIdentifier(), replace, pkg);
-
         try (PackageFreezer freezer = freezePackageForInstall(pkgName, installFlags,
                 "installPackageLI")) {
             if (replace) {
@@ -18340,6 +18311,55 @@
             }
         }
 
+        // Check whether we need to dexopt the app.
+        //
+        // NOTE: it is IMPORTANT to call dexopt:
+        //   - after doRename which will sync the package data from PackageParser.Package and its
+        //     corresponding ApplicationInfo.
+        //   - after installNewPackageLIF or replacePackageLIF which will update result with the
+        //     uid of the application (pkg.applicationInfo.uid).
+        //     This update happens in place!
+        //
+        // We only need to dexopt if the package meets ALL of the following conditions:
+        //   1) it is not forward locked.
+        //   2) it is not on on an external ASEC container.
+        //   3) it is not an instant app or if it is then dexopt is enabled via gservices.
+        //
+        // Note that we do not dexopt instant apps by default. dexopt can take some time to
+        // complete, so we skip this step during installation. Instead, we'll take extra time
+        // the first time the instant app starts. It's preferred to do it this way to provide
+        // continuous progress to the useur instead of mysteriously blocking somewhere in the
+        // middle of running an instant app. The default behaviour can be overridden
+        // via gservices.
+        final boolean performDexopt = (res.returnCode == PackageManager.INSTALL_SUCCEEDED)
+                && !forwardLocked
+                && !pkg.applicationInfo.isExternalAsec()
+                && (!instantApp || Global.getInt(mContext.getContentResolver(),
+                Global.INSTANT_APP_DEXOPT_ENABLED, 0) != 0);
+
+        if (performDexopt) {
+            Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dexopt");
+            // Do not run PackageDexOptimizer through the local performDexOpt
+            // method because `pkg` may not be in `mPackages` yet.
+            //
+            // Also, don't fail application installs if the dexopt step fails.
+            DexoptOptions dexoptOptions = new DexoptOptions(pkg.packageName,
+                    REASON_INSTALL,
+                    DexoptOptions.DEXOPT_BOOT_COMPLETE);
+            mPackageDexOptimizer.performDexOpt(pkg, pkg.usesLibraryFiles,
+                    null /* instructionSets */,
+                    getOrCreateCompilerPackageStats(pkg),
+                    mDexManager.getPackageUseInfoOrDefault(pkg.packageName),
+                    dexoptOptions);
+            Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
+        }
+
+        // Notify BackgroundDexOptService that the package has been changed.
+        // If this is an update of a package which used to fail to compile,
+        // BackgroundDexOptService will remove it from its blacklist.
+        // TODO: Layering violation
+        BackgroundDexOptService.notifyPackageChanged(pkg.packageName);
+
         synchronized (mPackages) {
             final PackageSetting ps = mSettings.mPackages.get(pkgName);
             if (ps != null) {
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 1d08111..4d57dc2 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -710,6 +710,14 @@
     public static final String KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL = "show_iccid_in_sim_status_bool";
 
     /**
+     * Flag specifying whether signal strength is hidden in SIM Status screen,
+     * default to false.
+     * @hide
+     */
+    public static final String KEY_HIDE_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL =
+        "hide_signal_strength_in_sim_status_bool";
+
+    /**
      * Flag specifying whether an additional (client initiated) intent needs to be sent on System
      * update
      */
@@ -779,6 +787,14 @@
     public static final String KEY_IMS_CONFERENCE_SIZE_LIMIT_INT = "ims_conference_size_limit_int";
 
     /**
+     * Determines whether manage IMS conference calls is supported by a carrier.  When {@code true},
+     * manage IMS conference call is supported, {@code false otherwise}.
+     * @hide
+     */
+    public static final String KEY_SUPPORT_MANAGE_IMS_CONFERENCE_CALL_BOOL =
+            "support_manage_ims_conference_call_bool";
+
+    /**
      * Determines whether High Definition audio property is displayed in the dialer UI.
      * If {@code false}, remove the HD audio property from the connection so that HD audio related
      * UI is not displayed. If {@code true}, keep HD audio property as it is configured.
@@ -947,6 +963,12 @@
     public static final String KEY_STK_DISABLE_LAUNCH_BROWSER_BOOL =
             "stk_disable_launch_browser_bool";
 
+    /**
+     * Boolean indicating if show data RAT icon on status bar even when data is disabled
+     * @hide
+     */
+    public static final String KEY_ALWAYS_SHOW_DATA_RAT_ICON_BOOL =
+            "always_show_data_rat_icon_bool";
 
     // These variables are used by the MMS service and exposed through another API, {@link
     // SmsManager}. The variable names and string values are copied from there.
@@ -1729,6 +1751,7 @@
         sDefaults.putString(KEY_CARRIER_VVM_PACKAGE_NAME_STRING, "");
         sDefaults.putStringArray(KEY_CARRIER_VVM_PACKAGE_NAME_STRING_ARRAY, null);
         sDefaults.putBoolean(KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL, false);
+        sDefaults.putBoolean(KEY_HIDE_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL, false);
         sDefaults.putBoolean(KEY_CI_ACTION_ON_SYS_UPDATE_BOOL, false);
         sDefaults.putString(KEY_CI_ACTION_ON_SYS_UPDATE_INTENT_STRING, "");
         sDefaults.putString(KEY_CI_ACTION_ON_SYS_UPDATE_EXTRA_STRING, "");
@@ -1782,6 +1805,7 @@
         sDefaults.putInt(KEY_CDMA_3WAYCALL_FLASH_DELAY_INT , 0);
         sDefaults.putBoolean(KEY_SUPPORT_CONFERENCE_CALL_BOOL, true);
         sDefaults.putBoolean(KEY_SUPPORT_IMS_CONFERENCE_CALL_BOOL, true);
+        sDefaults.putBoolean(KEY_SUPPORT_MANAGE_IMS_CONFERENCE_CALL_BOOL, true);
         sDefaults.putBoolean(KEY_SUPPORT_VIDEO_CONFERENCE_CALL_BOOL, false);
         sDefaults.putBoolean(KEY_IS_IMS_CONFERENCE_SIZE_ENFORCED_BOOL, false);
         sDefaults.putInt(KEY_IMS_CONFERENCE_SIZE_LIMIT_INT, 5);
@@ -1925,6 +1949,7 @@
         sDefaults.putStringArray(KEY_FEATURE_ACCESS_CODES_STRING_ARRAY, null);
         sDefaults.putBoolean(KEY_IDENTIFY_HIGH_DEFINITION_CALLS_IN_CALL_LOG_BOOL, false);
         sDefaults.putBoolean(KEY_SPN_DISPLAY_RULE_USE_ROAMING_FROM_SERVICE_STATE_BOOL, false);
+        sDefaults.putBoolean(KEY_ALWAYS_SHOW_DATA_RAT_ICON_BOOL, false);
     }
 
     /**
diff --git a/telephony/java/android/telephony/CellIdentityGsm.java b/telephony/java/android/telephony/CellIdentityGsm.java
index c9684062..376e6aa 100644
--- a/telephony/java/android/telephony/CellIdentityGsm.java
+++ b/telephony/java/android/telephony/CellIdentityGsm.java
@@ -202,7 +202,7 @@
      * @return a 5 or 6 character string (MCC+MNC), null if any field is unknown
      */
     public String getMobileNetworkOperator() {
-        return (mMncStr == null || mMncStr == null) ? null : mMccStr + mMncStr;
+        return (mMccStr == null || mMncStr == null) ? null : mMccStr + mMncStr;
     }
 
     /**
diff --git a/telephony/java/android/telephony/CellIdentityLte.java b/telephony/java/android/telephony/CellIdentityLte.java
index 825dcc3..6ca5daf6 100644
--- a/telephony/java/android/telephony/CellIdentityLte.java
+++ b/telephony/java/android/telephony/CellIdentityLte.java
@@ -213,7 +213,7 @@
      * @return a 5 or 6 character string (MCC+MNC), null if any field is unknown
      */
     public String getMobileNetworkOperator() {
-        return (mMncStr == null || mMncStr == null) ? null : mMccStr + mMncStr;
+        return (mMccStr == null || mMncStr == null) ? null : mMccStr + mMncStr;
     }
 
     /**
diff --git a/telephony/java/android/telephony/CellIdentityWcdma.java b/telephony/java/android/telephony/CellIdentityWcdma.java
index e74b570..e4bb4f2 100644
--- a/telephony/java/android/telephony/CellIdentityWcdma.java
+++ b/telephony/java/android/telephony/CellIdentityWcdma.java
@@ -208,7 +208,7 @@
      * @return a 5 or 6 character string (MCC+MNC), null if any field is unknown
      */
     public String getMobileNetworkOperator() {
-        return (mMncStr == null || mMncStr == null) ? null : mMccStr + mMncStr;
+        return (mMccStr == null || mMncStr == null) ? null : mMccStr + mMncStr;
     }
 
     /**
diff --git a/telephony/java/android/telephony/MbmsDownloadSession.java b/telephony/java/android/telephony/MbmsDownloadSession.java
index f392570..a554c69 100644
--- a/telephony/java/android/telephony/MbmsDownloadSession.java
+++ b/telephony/java/android/telephony/MbmsDownloadSession.java
@@ -347,6 +347,7 @@
 
                     @Override
                     public void onServiceDisconnected(ComponentName name) {
+                        Log.w(LOG_TAG, "bindAndInitialize: Remote service disconnected");
                         sIsInitialized.set(false);
                         mService.set(null);
                     }
@@ -385,6 +386,7 @@
         } catch (RemoteException e) {
             Log.w(LOG_TAG, "Remote process died");
             mService.set(null);
+            sIsInitialized.set(false);
             sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
         }
     }
@@ -438,6 +440,7 @@
             }
         } catch (RemoteException e) {
             mService.set(null);
+            sIsInitialized.set(false);
             sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
             return;
         }
@@ -521,6 +524,7 @@
             downloadService.download(request);
         } catch (RemoteException e) {
             mService.set(null);
+            sIsInitialized.set(false);
             sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
         }
     }
@@ -542,6 +546,7 @@
             return downloadService.listPendingDownloads(mSubscriptionId);
         } catch (RemoteException e) {
             mService.set(null);
+            sIsInitialized.set(false);
             sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
             return Collections.emptyList();
         }
@@ -583,6 +588,7 @@
             }
         } catch (RemoteException e) {
             mService.set(null);
+            sIsInitialized.set(false);
             sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
             return;
         }
@@ -622,6 +628,7 @@
                 }
             } catch (RemoteException e) {
                 mService.set(null);
+                sIsInitialized.set(false);
                 sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
             }
         } finally {
@@ -658,6 +665,7 @@
             }
         } catch (RemoteException e) {
             mService.set(null);
+            sIsInitialized.set(false);
             sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
             return;
         }
@@ -686,6 +694,7 @@
             return downloadService.getDownloadStatus(downloadRequest, fileInfo);
         } catch (RemoteException e) {
             mService.set(null);
+            sIsInitialized.set(false);
             sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
             return STATUS_UNKNOWN;
         }
@@ -727,6 +736,7 @@
             }
         } catch (RemoteException e) {
             mService.set(null);
+            sIsInitialized.set(false);
             sendErrorToApp(MbmsErrors.ERROR_MIDDLEWARE_LOST, null);
         }
     }
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index f461910..6b26dbb 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -52,8 +52,9 @@
 import android.telephony.ims.feature.ImsFeature;
 import android.util.Log;
 
-import com.android.ims.internal.IImsServiceController;
-import com.android.ims.internal.IImsServiceFeatureListener;
+import com.android.ims.internal.IImsMMTelFeature;
+import com.android.ims.internal.IImsRcsFeature;
+import com.android.ims.internal.IImsServiceFeatureCallback;
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.telecom.ITelecomService;
 import com.android.internal.telephony.CellNetworkScanResult;
@@ -407,9 +408,12 @@
      * Open the voicemail settings activity to make changes to voicemail configuration.
      *
      * <p>
+     * The {@link #EXTRA_PHONE_ACCOUNT_HANDLE} extra indicates which {@link PhoneAccountHandle} to
+     * configure voicemail.
      * The {@link #EXTRA_HIDE_PUBLIC_SETTINGS} hides settings the dialer will modify through public
      * API if set.
      *
+     * @see #EXTRA_PHONE_ACCOUNT_HANDLE
      * @see #EXTRA_HIDE_PUBLIC_SETTINGS
      */
     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
@@ -771,8 +775,9 @@
             "android.telephony.action.SHOW_VOICEMAIL_NOTIFICATION";
 
     /**
-     * The extra used with an {@link #ACTION_SHOW_VOICEMAIL_NOTIFICATION} {@code Intent} to specify
-     * the {@link PhoneAccountHandle} the notification is for.
+     * The extra used with an {@link #ACTION_CONFIGURE_VOICEMAIL} and
+     * {@link #ACTION_SHOW_VOICEMAIL_NOTIFICATION} {@code Intent} to specify the
+     * {@link PhoneAccountHandle} the configuration or notification is for.
      * <p class="note">
      * Retrieve with {@link android.content.Intent#getParcelableExtra(String)}.
      */
@@ -4584,27 +4589,78 @@
     public @interface Feature {}
 
     /**
-     * Returns the {@link IImsServiceController} that corresponds to the given slot Id and IMS
-     * feature or {@link null} if the service is not available. If an ImsServiceController is
-     * available, the {@link IImsServiceFeatureListener} callback is registered as a listener for
-     * feature updates.
-     * @param slotIndex The SIM slot that we are requesting the {@link IImsServiceController} for.
-     * @param feature The IMS Feature we are requesting, corresponding to {@link ImsFeature}.
+     * Returns the {@link IImsMMTelFeature} that corresponds to the given slot Id and MMTel
+     * feature or {@link null} if the service is not available. If an MMTelFeature is available, the
+     * {@link IImsServiceFeatureCallback} callback is registered as a listener for feature updates.
+     * @param slotIndex The SIM slot that we are requesting the {@link IImsMMTelFeature} for.
      * @param callback Listener that will send updates to ImsManager when there are updates to
      * ImsServiceController.
-     * @return {@link IImsServiceController} interface for the feature specified or {@link null} if
+     * @return {@link IImsMMTelFeature} interface for the feature specified or {@code null} if
      * it is unavailable.
      * @hide
      */
-    public IImsServiceController getImsServiceControllerAndListen(int slotIndex, @Feature int feature,
-            IImsServiceFeatureListener callback) {
+    public @Nullable IImsMMTelFeature getImsMMTelFeatureAndListen(int slotIndex,
+            IImsServiceFeatureCallback callback) {
         try {
             ITelephony telephony = getITelephony();
             if (telephony != null) {
-                return telephony.getImsServiceControllerAndListen(slotIndex, feature, callback);
+                return telephony.getMMTelFeatureAndListen(slotIndex, callback);
             }
         } catch (RemoteException e) {
-            Rlog.e(TAG, "getImsServiceControllerAndListen, RemoteException: " + e.getMessage());
+            Rlog.e(TAG, "getImsMMTelFeatureAndListen, RemoteException: "
+                    + e.getMessage());
+        }
+        return null;
+    }
+
+    /**
+     * Returns the {@link IImsMMTelFeature} that corresponds to the given slot Id and MMTel
+     * feature for emergency calling or {@link null} if the service is not available. If an
+     * MMTelFeature is available, the {@link IImsServiceFeatureCallback} callback is registered as a
+     * listener for feature updates.
+     * @param slotIndex The SIM slot that we are requesting the {@link IImsMMTelFeature} for.
+     * @param callback Listener that will send updates to ImsManager when there are updates to
+     * ImsServiceController.
+     * @return {@link IImsMMTelFeature} interface for the feature specified or {@code null} if
+     * it is unavailable.
+     * @hide
+     */
+    public @Nullable IImsMMTelFeature getImsEmergencyMMTelFeatureAndListen(int slotIndex,
+            IImsServiceFeatureCallback callback) {
+        try {
+            ITelephony telephony = getITelephony();
+            if (telephony != null) {
+                return telephony.getEmergencyMMTelFeatureAndListen(slotIndex, callback);
+            }
+        } catch (RemoteException e) {
+            Rlog.e(TAG, "getImsEmergencyMMTelFeatureAndListen, RemoteException: "
+                    + e.getMessage());
+        }
+        return null;
+    }
+
+    /**
+     * Returns the {@link IImsRcsFeature} that corresponds to the given slot Id and RCS
+     * feature for emergency calling or {@link null} if the service is not available. If an
+     * RcsFeature is available, the {@link IImsServiceFeatureCallback} callback is registered as a
+     * listener for feature updates.
+     * @param slotIndex The SIM slot that we are requesting the {@link IImsRcsFeature} for.
+     * @param callback Listener that will send updates to ImsManager when there are updates to
+     * ImsServiceController.
+     * @return {@link IImsRcsFeature} interface for the feature specified or {@code null} if
+     * it is unavailable.
+     * @hide
+     */
+    public @Nullable IImsRcsFeature getImsRcsFeatureAndListen(int slotIndex,
+            IImsServiceFeatureCallback callback) {
+        try {
+            ITelephony telephony = getITelephony();
+            if (telephony != null) {
+                return telephony.getRcsFeatureAndListen(slotIndex, callback);
+            }
+        } catch (RemoteException e) {
+            Rlog.e(TAG, "getImsRcsFeatureAndListen, RemoteException: "
+                    + e.getMessage());
         }
         return null;
     }
diff --git a/telephony/java/com/android/internal/telephony/ISubscriptionListener.aidl b/telephony/java/android/telephony/data/DataProfile.aidl
similarity index 71%
copy from telephony/java/com/android/internal/telephony/ISubscriptionListener.aidl
copy to telephony/java/android/telephony/data/DataProfile.aidl
index 4ccdea5..65fdf91 100644
--- a/telephony/java/com/android/internal/telephony/ISubscriptionListener.aidl
+++ b/telephony/java/android/telephony/data/DataProfile.aidl
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 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.
@@ -14,11 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+/** @hide */
+package android.telephony.data;
 
-import android.telephony.SubscriptionInfo;
-
-oneway interface ISubscriptionListener {
-    void onSubscriptionInfoChanged();
-}
-
+parcelable DataProfile;
diff --git a/telephony/java/android/telephony/data/DataProfile.java b/telephony/java/android/telephony/data/DataProfile.java
new file mode 100644
index 0000000..41c1430
--- /dev/null
+++ b/telephony/java/android/telephony/data/DataProfile.java
@@ -0,0 +1,280 @@
+/*
+ * Copyright 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 android.telephony.data;
+
+import android.annotation.SystemApi;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.text.TextUtils;
+
+import com.android.internal.telephony.RILConstants;
+
+/**
+ * Description of a mobile data profile used for establishing
+ * data connections.
+ *
+ * @hide
+ */
+@SystemApi
+public final class DataProfile implements Parcelable {
+
+    // The types indicating the data profile is used on GSM (3GPP) or CDMA (3GPP2) network.
+    public static final int TYPE_COMMON = 0;
+    public static final int TYPE_3GPP = 1;
+    public static final int TYPE_3GPP2 = 2;
+
+    private final int mProfileId;
+
+    private final String mApn;
+
+    private final String mProtocol;
+
+    private final int mAuthType;
+
+    private final String mUserName;
+
+    private final String mPassword;
+
+    private final int mType;
+
+    private final int mMaxConnsTime;
+
+    private final int mMaxConns;
+
+    private final int mWaitTime;
+
+    private final boolean mEnabled;
+
+    private final int mSupportedApnTypesBitmap;
+
+    private final String mRoamingProtocol;
+
+    private final int mBearerBitmap;
+
+    private final int mMtu;
+
+    private final String mMvnoType;
+
+    private final String mMvnoMatchData;
+
+    private final boolean mModemCognitive;
+
+    public DataProfile(int profileId, String apn, String protocol, int authType,
+                String userName, String password, int type, int maxConnsTime, int maxConns,
+                int waitTime, boolean enabled, int supportedApnTypesBitmap, String roamingProtocol,
+                int bearerBitmap, int mtu, String mvnoType, String mvnoMatchData,
+                boolean modemCognitive) {
+
+        this.mProfileId = profileId;
+        this.mApn = apn;
+        this.mProtocol = protocol;
+        if (authType == -1) {
+            authType = TextUtils.isEmpty(userName) ? RILConstants.SETUP_DATA_AUTH_NONE
+                    : RILConstants.SETUP_DATA_AUTH_PAP_CHAP;
+        }
+        this.mAuthType = authType;
+        this.mUserName = userName;
+        this.mPassword = password;
+        this.mType = type;
+        this.mMaxConnsTime = maxConnsTime;
+        this.mMaxConns = maxConns;
+        this.mWaitTime = waitTime;
+        this.mEnabled = enabled;
+
+        this.mSupportedApnTypesBitmap = supportedApnTypesBitmap;
+        this.mRoamingProtocol = roamingProtocol;
+        this.mBearerBitmap = bearerBitmap;
+        this.mMtu = mtu;
+        this.mMvnoType = mvnoType;
+        this.mMvnoMatchData = mvnoMatchData;
+        this.mModemCognitive = modemCognitive;
+    }
+
+    public DataProfile(Parcel source) {
+        mProfileId = source.readInt();
+        mApn = source.readString();
+        mProtocol = source.readString();
+        mAuthType = source.readInt();
+        mUserName = source.readString();
+        mPassword = source.readString();
+        mType = source.readInt();
+        mMaxConnsTime = source.readInt();
+        mMaxConns = source.readInt();
+        mWaitTime = source.readInt();
+        mEnabled = source.readBoolean();
+        mSupportedApnTypesBitmap = source.readInt();
+        mRoamingProtocol = source.readString();
+        mBearerBitmap = source.readInt();
+        mMtu = source.readInt();
+        mMvnoType = source.readString();
+        mMvnoMatchData = source.readString();
+        mModemCognitive = source.readBoolean();
+    }
+
+    /**
+     * @return Id of the data profile.
+     */
+    public int getProfileId() { return mProfileId; }
+
+    /**
+     * @return The APN to establish data connection.
+     */
+    public String getApn() { return mApn; }
+
+    /**
+     * @return The connection protocol, should be one of the PDP_type values in TS 27.007 section
+     * 10.1.1. For example, "IP", "IPV6", "IPV4V6", or "PPP".
+     */
+    public String getProtocol() { return mProtocol; }
+
+    /**
+     * @return The authentication protocol used for this PDP context
+     * (None: 0, PAP: 1, CHAP: 2, PAP&CHAP: 3)
+     */
+    public int getAuthType() { return mAuthType; }
+
+    /**
+     * @return The username for APN. Can be null.
+     */
+    public String getUserName() { return mUserName; }
+
+    /**
+     * @return The password for APN. Can be null.
+     */
+    public String getPassword() { return mPassword; }
+
+    /**
+     * @return The profile type. Could be one of TYPE_COMMON, TYPE_3GPP, or TYPE_3GPP2.
+     */
+    public int getType() { return mType; }
+
+    /**
+     * @return The period in seconds to limit the maximum connections.
+     */
+    public int getMaxConnsTime() { return mMaxConnsTime; }
+
+    /**
+     * @return The maximum connections allowed.
+     */
+    public int getMaxConns() { return mMaxConns; }
+
+    /**
+     * @return The required wait time in seconds after a successful UE initiated disconnect of a
+     * given PDN connection before the device can send a new PDN connection request for that given
+     * PDN.
+     */
+    public int getWaitTime() { return mWaitTime; }
+
+    /**
+     * @return True if the profile is enabled.
+     */
+    public boolean isEnabled() { return mEnabled; }
+
+    /**
+     * @return The supported APN types bitmap. See RIL_ApnTypes for the value of each bit.
+     */
+    public int getSupportedApnTypesBitmap() { return mSupportedApnTypesBitmap; }
+
+    /**
+     * @return  The connection protocol on roaming network, should be one of the PDP_type values in
+     * TS 27.007 section 10.1.1. For example, "IP", "IPV6", "IPV4V6", or "PPP".
+     */
+    public String getRoamingProtocol() { return mRoamingProtocol; }
+
+    /**
+     * @return The bearer bitmap. See RIL_RadioAccessFamily for the value of each bit.
+     */
+    public int getBearerBitmap() { return mBearerBitmap; }
+
+    /**
+     * @return The maximum transmission unit (MTU) size in bytes.
+     */
+    public int getMtu() { return mMtu; }
+
+    /**
+     * @return The MVNO type: possible values are "imsi", "gid", "spn".
+     */
+    public String getMvnoType() { return mMvnoType; }
+
+    /**
+     * @return The MVNO match data. For example,
+     * SPN: A MOBILE, BEN NL, ...
+     * IMSI: 302720x94, 2060188, ...
+     * GID: 4E, 33, ...
+     */
+    public String getMvnoMatchData() { return mMvnoMatchData; }
+
+    /**
+     * @return True if the data profile was sent to the modem through setDataProfile earlier.
+     */
+    public boolean isModemCognitive() { return mModemCognitive; }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public String toString() {
+        return "DataProfile=" + mProfileId + "/" + mApn + "/" + mProtocol + "/" + mAuthType
+                + "/" + mUserName + "/" + mPassword + "/" + mType + "/" + mMaxConnsTime
+                + "/" + mMaxConns + "/" + mWaitTime + "/" + mEnabled + "/"
+                + mSupportedApnTypesBitmap + "/" + mRoamingProtocol + "/" + mBearerBitmap + "/"
+                + mMtu + "/" + mMvnoType + "/" + mMvnoMatchData + "/" + mModemCognitive;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o instanceof DataProfile == false) return false;
+        return (o == this || toString().equals(o.toString()));
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeInt(mProfileId);
+        dest.writeString(mApn);
+        dest.writeString(mProtocol);
+        dest.writeInt(mAuthType);
+        dest.writeString(mUserName);
+        dest.writeString(mPassword);
+        dest.writeInt(mType);
+        dest.writeInt(mMaxConnsTime);
+        dest.writeInt(mMaxConns);
+        dest.writeInt(mWaitTime);
+        dest.writeBoolean(mEnabled);
+        dest.writeInt(mSupportedApnTypesBitmap);
+        dest.writeString(mRoamingProtocol);
+        dest.writeInt(mBearerBitmap);
+        dest.writeInt(mMtu);
+        dest.writeString(mMvnoType);
+        dest.writeString(mMvnoMatchData);
+        dest.writeBoolean(mModemCognitive);
+    }
+
+    public static final Parcelable.Creator<DataProfile> CREATOR =
+            new Parcelable.Creator<DataProfile>() {
+        @Override
+        public DataProfile createFromParcel(Parcel source) {
+            return new DataProfile(source);
+        }
+
+        @Override
+        public DataProfile[] newArray(int size) {
+            return new DataProfile[size];
+        }
+    };
+}
diff --git a/telephony/java/android/telephony/ims/ImsService.java b/telephony/java/android/telephony/ims/ImsService.java
index 9d91cc3..8230eaf 100644
--- a/telephony/java/android/telephony/ims/ImsService.java
+++ b/telephony/java/android/telephony/ims/ImsService.java
@@ -16,13 +16,11 @@
 
 package android.telephony.ims;
 
+import android.annotation.Nullable;
 import android.annotation.SystemApi;
-import android.app.PendingIntent;
 import android.app.Service;
 import android.content.Intent;
-import android.content.pm.PackageManager;
 import android.os.IBinder;
-import android.os.Message;
 import android.os.RemoteException;
 import android.telephony.CarrierConfigManager;
 import android.telephony.ims.feature.ImsFeature;
@@ -31,22 +29,13 @@
 import android.util.Log;
 import android.util.SparseArray;
 
-import com.android.ims.ImsCallProfile;
-import com.android.ims.internal.IImsCallSession;
-import com.android.ims.internal.IImsCallSessionListener;
-import com.android.ims.internal.IImsConfig;
-import com.android.ims.internal.IImsEcbm;
 import com.android.ims.internal.IImsFeatureStatusCallback;
-import com.android.ims.internal.IImsMultiEndpoint;
-import com.android.ims.internal.IImsRegistrationListener;
+import com.android.ims.internal.IImsMMTelFeature;
+import com.android.ims.internal.IImsRcsFeature;
 import com.android.ims.internal.IImsServiceController;
-import com.android.ims.internal.IImsServiceFeatureListener;
-import com.android.ims.internal.IImsUt;
 import com.android.internal.annotations.VisibleForTesting;
 
 import static android.Manifest.permission.MODIFY_PHONE_STATE;
-import static android.Manifest.permission.READ_PHONE_STATE;
-import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE;
 
 /**
  * Main ImsService implementation, which binds via the Telephony ImsResolver. Services that extend
@@ -92,247 +81,38 @@
      */
     public static final String SERVICE_INTERFACE = "android.telephony.ims.ImsService";
 
-    // A map of slot Id -> Set of features corresponding to that slot.
-    private final SparseArray<SparseArray<ImsFeature>> mFeatures = new SparseArray<>();
+    // A map of slot Id -> map of features (indexed by ImsFeature feature id) corresponding to that
+    // slot.
+    // We keep track of this to facilitate cleanup of the IImsFeatureStatusCallback and
+    // call ImsFeature#onFeatureRemoved.
+    private final SparseArray<SparseArray<ImsFeature>> mFeaturesBySlot = new SparseArray<>();
 
     /**
      * @hide
      */
-    // Implements all supported features as a flat interface.
     protected final IBinder mImsServiceController = new IImsServiceController.Stub() {
 
         @Override
-        public void createImsFeature(int slotId, int feature, IImsFeatureStatusCallback c)
+        public IImsMMTelFeature createEmergencyMMTelFeature(int slotId,
+                IImsFeatureStatusCallback c) {
+            return createEmergencyMMTelFeatureInternal(slotId, c);
+        }
+
+        @Override
+        public IImsMMTelFeature createMMTelFeature(int slotId, IImsFeatureStatusCallback c) {
+            return createMMTelFeatureInternal(slotId, c);
+        }
+
+        @Override
+        public IImsRcsFeature createRcsFeature(int slotId, IImsFeatureStatusCallback c) {
+            return createRcsFeatureInternal(slotId, c);
+        }
+
+        @Override
+        public void removeImsFeature(int slotId, int featureType, IImsFeatureStatusCallback c)
                 throws RemoteException {
-            synchronized (mFeatures) {
-                enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "createImsFeature");
-                onCreateImsFeatureInternal(slotId, feature, c);
-            }
+            ImsService.this.removeImsFeature(slotId, featureType, c);
         }
-
-        @Override
-        public void removeImsFeature(int slotId, int feature,  IImsFeatureStatusCallback c)
-                throws RemoteException {
-            synchronized (mFeatures) {
-                enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "removeImsFeature");
-                onRemoveImsFeatureInternal(slotId, feature, c);
-            }
-        }
-
-        @Override
-        public int startSession(int slotId, int featureType, PendingIntent incomingCallIntent,
-                IImsRegistrationListener listener) throws RemoteException {
-            enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "startSession");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    return feature.startSession(incomingCallIntent, listener);
-                }
-            }
-            return 0;
-        }
-
-        @Override
-        public void endSession(int slotId, int featureType, int sessionId) throws RemoteException {
-            synchronized (mFeatures) {
-                enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "endSession");
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    feature.endSession(sessionId);
-                }
-            }
-        }
-
-        @Override
-        public boolean isConnected(int slotId, int featureType, int callSessionType, int callType)
-                throws RemoteException {
-            enforceReadPhoneStatePermission("isConnected");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    return feature.isConnected(callSessionType, callType);
-                }
-            }
-            return false;
-        }
-
-        @Override
-        public boolean isOpened(int slotId, int featureType) throws RemoteException {
-            enforceReadPhoneStatePermission("isOpened");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    return feature.isOpened();
-                }
-            }
-            return false;
-        }
-
-        @Override
-        public int getFeatureStatus(int slotId, int featureType) throws RemoteException {
-            enforceReadPhoneStatePermission("getFeatureStatus");
-            int status = ImsFeature.STATE_NOT_AVAILABLE;
-            synchronized (mFeatures) {
-                SparseArray<ImsFeature> featureMap = mFeatures.get(slotId);
-                if (featureMap != null) {
-                    ImsFeature feature = getImsFeatureFromType(featureMap, featureType);
-                    if (feature != null) {
-                        status = feature.getFeatureState();
-                    }
-                }
-            }
-            return status;
-        }
-
-        @Override
-        public void addRegistrationListener(int slotId, int featureType,
-                IImsRegistrationListener listener) throws RemoteException {
-            enforceReadPhoneStatePermission("addRegistrationListener");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    feature.addRegistrationListener(listener);
-                }
-            }
-        }
-
-        @Override
-        public void removeRegistrationListener(int slotId, int featureType,
-                IImsRegistrationListener listener) throws RemoteException {
-            enforceReadPhoneStatePermission("removeRegistrationListener");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    feature.removeRegistrationListener(listener);
-                }
-            }
-        }
-
-        @Override
-        public ImsCallProfile createCallProfile(int slotId, int featureType, int sessionId,
-                int callSessionType, int callType) throws RemoteException {
-            enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "createCallProfile");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    return feature.createCallProfile(sessionId, callSessionType,  callType);
-                }
-            }
-            return null;
-        }
-
-        @Override
-        public IImsCallSession createCallSession(int slotId, int featureType, int sessionId,
-                ImsCallProfile profile, IImsCallSessionListener listener) throws RemoteException {
-            enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "createCallSession");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    return feature.createCallSession(sessionId, profile, listener);
-                }
-            }
-            return null;
-        }
-
-        @Override
-        public IImsCallSession getPendingCallSession(int slotId, int featureType, int sessionId,
-                String callId) throws RemoteException {
-            enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "getPendingCallSession");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    return feature.getPendingCallSession(sessionId, callId);
-                }
-            }
-            return null;
-        }
-
-        @Override
-        public IImsUt getUtInterface(int slotId, int featureType)
-                throws RemoteException {
-            enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "getUtInterface");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    return feature.getUtInterface();
-                }
-            }
-            return null;
-        }
-
-        @Override
-        public IImsConfig getConfigInterface(int slotId, int featureType)
-                throws RemoteException {
-            enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "getConfigInterface");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    return feature.getConfigInterface();
-                }
-            }
-            return null;
-        }
-
-        @Override
-        public void turnOnIms(int slotId, int featureType) throws RemoteException {
-            enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "turnOnIms");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    feature.turnOnIms();
-                }
-            }
-        }
-
-        @Override
-        public void turnOffIms(int slotId, int featureType) throws RemoteException {
-            enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "turnOffIms");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    feature.turnOffIms();
-                }
-            }
-        }
-
-        @Override
-        public IImsEcbm getEcbmInterface(int slotId, int featureType)
-                throws RemoteException {
-            enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "getEcbmInterface");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    return feature.getEcbmInterface();
-                }
-            }
-            return null;
-        }
-
-        @Override
-        public void setUiTTYMode(int slotId, int featureType, int uiTtyMode, Message onComplete)
-                throws RemoteException {
-            enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "setUiTTYMode");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    feature.setUiTTYMode(uiTtyMode, onComplete);
-                }
-            }
-        }
-
-        @Override
-        public IImsMultiEndpoint getMultiEndpointInterface(int slotId, int featureType)
-                throws RemoteException {
-            enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "getMultiEndpointInterface");
-            synchronized (mFeatures) {
-                MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
-                if (feature != null) {
-                    return feature.getMultiEndpointInterface();
-                }
-            }
-            return null;
-        }
-
     };
 
     /**
@@ -341,127 +121,93 @@
     @Override
     public IBinder onBind(Intent intent) {
         if(SERVICE_INTERFACE.equals(intent.getAction())) {
+            Log.i(LOG_TAG, "ImsService Bound.");
             return mImsServiceController;
         }
         return null;
     }
 
     /**
-     * Called from the ImsResolver to create the requested ImsFeature, as defined by the slot and
-     * featureType
-     * @param slotId An integer representing which SIM slot the ImsFeature is assigned to.
-     * @param featureType An integer representing the type of ImsFeature being created. This is
-     * defined in {@link ImsFeature}.
+     * @hide
      */
-    // Be sure to lock on mFeatures before accessing this method
-    private void onCreateImsFeatureInternal(int slotId, int featureType,
+    @VisibleForTesting
+    public SparseArray<ImsFeature> getFeatures(int slotId) {
+        return mFeaturesBySlot.get(slotId);
+    }
+
+    private IImsMMTelFeature createEmergencyMMTelFeatureInternal(int slotId,
             IImsFeatureStatusCallback c) {
-        SparseArray<ImsFeature> featureMap = mFeatures.get(slotId);
-        if (featureMap == null) {
-            featureMap = new SparseArray<>();
-            mFeatures.put(slotId, featureMap);
-        }
-        ImsFeature f = makeImsFeature(slotId, featureType);
+        MMTelFeature f = onCreateEmergencyMMTelImsFeature(slotId);
         if (f != null) {
-            f.setContext(this);
-            f.setSlotId(slotId);
-            f.addImsFeatureStatusCallback(c);
-            featureMap.put(featureType, f);
-        }
-
-    }
-    /**
-     * Called from the ImsResolver to remove an existing ImsFeature, as defined by the slot and
-     * featureType.
-     * @param slotId An integer representing which SIM slot the ImsFeature is assigned to.
-     * @param featureType An integer representing the type of ImsFeature being removed. This is
-     * defined in {@link ImsFeature}.
-     */
-    // Be sure to lock on mFeatures before accessing this method
-    private void onRemoveImsFeatureInternal(int slotId, int featureType,
-            IImsFeatureStatusCallback c) {
-        SparseArray<ImsFeature> featureMap = mFeatures.get(slotId);
-        if (featureMap == null) {
-            return;
-        }
-
-        ImsFeature featureToRemove = getImsFeatureFromType(featureMap, featureType);
-        if (featureToRemove != null) {
-            featureMap.remove(featureType);
-            featureToRemove.notifyFeatureRemoved(slotId);
-            // Remove reference to Binder
-            featureToRemove.removeImsFeatureStatusCallback(c);
-        }
-    }
-
-    // Be sure to lock on mFeatures before accessing this method
-    private MMTelFeature resolveMMTelFeature(int slotId, int featureType) {
-        SparseArray<ImsFeature> features = getImsFeatureMap(slotId);
-        MMTelFeature feature = null;
-        if (features != null) {
-            feature = resolveImsFeature(features, featureType, MMTelFeature.class);
-        }
-        return feature;
-    }
-
-    // Be sure to lock on mFeatures before accessing this method
-    private <T extends ImsFeature> T resolveImsFeature(SparseArray<ImsFeature> set, int featureType,
-            Class<T> className) {
-        ImsFeature feature = getImsFeatureFromType(set, featureType);
-        if (feature == null) {
+            setupFeature(f, slotId, ImsFeature.EMERGENCY_MMTEL, c);
+            return f.getBinder();
+        } else {
             return null;
         }
-        try {
-            return className.cast(feature);
-        } catch (ClassCastException e)
-        {
-            Log.e(LOG_TAG, "Can not cast ImsFeature! Exception: " + e.getMessage());
+    }
+
+    private IImsMMTelFeature createMMTelFeatureInternal(int slotId,
+            IImsFeatureStatusCallback c) {
+        MMTelFeature f = onCreateMMTelImsFeature(slotId);
+        if (f != null) {
+            setupFeature(f, slotId, ImsFeature.MMTEL, c);
+            return f.getBinder();
+        } else {
+            return null;
         }
-        return null;
     }
 
-    /**
-     * @hide
-     */
-    @VisibleForTesting
-    // Be sure to lock on mFeatures before accessing this method
-    public SparseArray<ImsFeature> getImsFeatureMap(int slotId) {
-        return mFeatures.get(slotId);
-    }
-
-    /**
-     * @hide
-     */
-    @VisibleForTesting
-    // Be sure to lock on mFeatures before accessing this method
-    public ImsFeature getImsFeatureFromType(SparseArray<ImsFeature> set, int featureType) {
-        return set.get(featureType);
-    }
-
-    private ImsFeature makeImsFeature(int slotId, int feature) {
-        switch (feature) {
-            case ImsFeature.EMERGENCY_MMTEL: {
-                return onCreateEmergencyMMTelImsFeature(slotId);
-            }
-            case ImsFeature.MMTEL: {
-                return onCreateMMTelImsFeature(slotId);
-            }
-            case ImsFeature.RCS: {
-                return onCreateRcsFeature(slotId);
-            }
+    private IImsRcsFeature createRcsFeatureInternal(int slotId,
+            IImsFeatureStatusCallback c) {
+        RcsFeature f = onCreateRcsFeature(slotId);
+        if (f != null) {
+            setupFeature(f, slotId, ImsFeature.RCS, c);
+            return f.getBinder();
+        } else {
+            return null;
         }
-        // Tried to create feature that is not defined.
-        return null;
     }
 
-    /**
-     * Check for both READ_PHONE_STATE and READ_PRIVILEGED_PHONE_STATE. READ_PHONE_STATE is a
-     * public permission and READ_PRIVILEGED_PHONE_STATE is only granted to system apps.
-     */
-    private void enforceReadPhoneStatePermission(String fn) {
-        if (checkCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE)
-                != PackageManager.PERMISSION_GRANTED) {
-            enforceCallingOrSelfPermission(READ_PHONE_STATE, fn);
+    private void setupFeature(ImsFeature f, int slotId, int featureType,
+            IImsFeatureStatusCallback c) {
+        f.setContext(this);
+        f.setSlotId(slotId);
+        f.addImsFeatureStatusCallback(c);
+        addImsFeature(slotId, featureType, f);
+    }
+
+    private void addImsFeature(int slotId, int featureType, ImsFeature f) {
+        synchronized (mFeaturesBySlot) {
+            // Get SparseArray for Features, by querying slot Id
+            SparseArray<ImsFeature> features = mFeaturesBySlot.get(slotId);
+            if (features == null) {
+                // Populate new SparseArray of features if it doesn't exist for this slot yet.
+                features = new SparseArray<>();
+                mFeaturesBySlot.put(slotId, features);
+            }
+            features.put(featureType, f);
+        }
+    }
+
+    private void removeImsFeature(int slotId, int featureType,
+            IImsFeatureStatusCallback c) {
+        synchronized (mFeaturesBySlot) {
+            // get ImsFeature associated with the slot/feature
+            SparseArray<ImsFeature> features = mFeaturesBySlot.get(slotId);
+            if (features == null) {
+                Log.w(LOG_TAG, "Can not remove ImsFeature. No ImsFeatures exist on slot "
+                        + slotId);
+                return;
+            }
+            ImsFeature f = features.get(featureType);
+            if (f == null) {
+                Log.w(LOG_TAG, "Can not remove ImsFeature. No feature with type "
+                        + featureType + " exists on slot " + slotId);
+                return;
+            }
+            f.removeImsFeatureStatusCallback(c);
+            f.onFeatureRemoved();
+            features.remove(featureType);
         }
     }
 
@@ -470,7 +216,7 @@
      * functionality. Must be able to handle emergency calls at any time as well.
      * @hide
      */
-    public MMTelFeature onCreateEmergencyMMTelImsFeature(int slotId) {
+    public @Nullable MMTelFeature onCreateEmergencyMMTelImsFeature(int slotId) {
         return null;
     }
 
@@ -479,7 +225,7 @@
      * functionality.
      * @hide
      */
-    public MMTelFeature onCreateMMTelImsFeature(int slotId) {
+    public @Nullable MMTelFeature onCreateMMTelImsFeature(int slotId) {
         return null;
     }
 
@@ -487,7 +233,7 @@
      * @return An implementation of RcsFeature that will be used by the system for RCS.
      * @hide
      */
-    public RcsFeature onCreateRcsFeature(int slotId) {
+    public @Nullable RcsFeature onCreateRcsFeature(int slotId) {
         return null;
     }
 }
diff --git a/telephony/java/android/telephony/ims/feature/ImsFeature.java b/telephony/java/android/telephony/ims/feature/ImsFeature.java
index 9d880b7..ca4a210 100644
--- a/telephony/java/android/telephony/ims/feature/ImsFeature.java
+++ b/telephony/java/android/telephony/ims/feature/ImsFeature.java
@@ -19,6 +19,7 @@
 import android.annotation.IntDef;
 import android.content.Context;
 import android.content.Intent;
+import android.os.IInterface;
 import android.os.RemoteException;
 import android.telephony.SubscriptionManager;
 import android.util.Log;
@@ -91,17 +92,12 @@
     public static final int STATE_INITIALIZING = 1;
     public static final int STATE_READY = 2;
 
-    private List<INotifyFeatureRemoved> mRemovedListeners = new ArrayList<>();
     private final Set<IImsFeatureStatusCallback> mStatusCallbacks = Collections.newSetFromMap(
             new WeakHashMap<IImsFeatureStatusCallback, Boolean>());
     private @ImsState int mState = STATE_NOT_AVAILABLE;
     private int mSlotId = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
     private Context mContext;
 
-    public interface INotifyFeatureRemoved {
-        void onFeatureRemoved(int slotId);
-    }
-
     public void setContext(Context context) {
         mContext = context;
     }
@@ -110,26 +106,6 @@
         mSlotId = slotId;
     }
 
-    public void addFeatureRemovedListener(INotifyFeatureRemoved listener) {
-        synchronized (mRemovedListeners) {
-            mRemovedListeners.add(listener);
-        }
-    }
-
-    public void removeFeatureRemovedListener(INotifyFeatureRemoved listener) {
-        synchronized (mRemovedListeners) {
-            mRemovedListeners.remove(listener);
-        }
-    }
-
-    // Not final for testing.
-    public void notifyFeatureRemoved(int slotId) {
-        synchronized (mRemovedListeners) {
-            mRemovedListeners.forEach(l -> l.onFeatureRemoved(slotId));
-            onFeatureRemoved();
-        }
-    }
-
     public int getFeatureState() {
         return mState;
     }
@@ -212,7 +188,17 @@
     }
 
     /**
+     * Called when the feature is ready to use.
+     */
+    public abstract void onFeatureReady();
+
+    /**
      * Called when the feature is being removed and must be cleaned up.
      */
     public abstract void onFeatureRemoved();
+
+    /**
+     * @return Binder instance
+     */
+    public abstract IInterface getBinder();
 }
diff --git a/telephony/java/android/telephony/ims/feature/MMTelFeature.java b/telephony/java/android/telephony/ims/feature/MMTelFeature.java
index 758c379..4e095e3a 100644
--- a/telephony/java/android/telephony/ims/feature/MMTelFeature.java
+++ b/telephony/java/android/telephony/ims/feature/MMTelFeature.java
@@ -18,18 +18,18 @@
 
 import android.app.PendingIntent;
 import android.os.Message;
+import android.os.RemoteException;
 
 import com.android.ims.ImsCallProfile;
 import com.android.ims.internal.IImsCallSession;
 import com.android.ims.internal.IImsCallSessionListener;
 import com.android.ims.internal.IImsConfig;
 import com.android.ims.internal.IImsEcbm;
+import com.android.ims.internal.IImsMMTelFeature;
 import com.android.ims.internal.IImsMultiEndpoint;
 import com.android.ims.internal.IImsRegistrationListener;
 import com.android.ims.internal.IImsUt;
-
-import java.util.ArrayList;
-import java.util.List;
+import com.android.ims.internal.ImsCallSession;
 
 /**
  * Base implementation for MMTel.
@@ -41,6 +41,146 @@
 
 public class MMTelFeature extends ImsFeature {
 
+    // Lock for feature synchronization
+    private final Object mLock = new Object();
+
+    private final IImsMMTelFeature mImsMMTelBinder = new IImsMMTelFeature.Stub() {
+
+        @Override
+        public int startSession(PendingIntent incomingCallIntent,
+                IImsRegistrationListener listener) throws RemoteException {
+            synchronized (mLock) {
+                return MMTelFeature.this.startSession(incomingCallIntent, listener);
+            }
+        }
+
+        @Override
+        public void endSession(int sessionId) throws RemoteException {
+            synchronized (mLock) {
+                MMTelFeature.this.endSession(sessionId);
+            }
+        }
+
+        @Override
+        public boolean isConnected(int callSessionType, int callType)
+                throws RemoteException {
+            synchronized (mLock) {
+                return MMTelFeature.this.isConnected(callSessionType, callType);
+            }
+        }
+
+        @Override
+        public boolean isOpened() throws RemoteException {
+            synchronized (mLock) {
+                return MMTelFeature.this.isOpened();
+            }
+        }
+
+        @Override
+        public int getFeatureStatus() throws RemoteException {
+            synchronized (mLock) {
+                return MMTelFeature.this.getFeatureState();
+            }
+        }
+
+        @Override
+        public void addRegistrationListener(IImsRegistrationListener listener)
+                throws RemoteException {
+            synchronized (mLock) {
+                MMTelFeature.this.addRegistrationListener(listener);
+            }
+        }
+
+        @Override
+        public void removeRegistrationListener(IImsRegistrationListener listener)
+                throws RemoteException {
+            synchronized (mLock) {
+                MMTelFeature.this.removeRegistrationListener(listener);
+            }
+        }
+
+        @Override
+        public ImsCallProfile createCallProfile(int sessionId, int callSessionType, int callType)
+                throws RemoteException {
+            synchronized (mLock) {
+                return MMTelFeature.this.createCallProfile(sessionId, callSessionType,  callType);
+            }
+        }
+
+        @Override
+        public IImsCallSession createCallSession(int sessionId, ImsCallProfile profile,
+                IImsCallSessionListener listener) throws RemoteException {
+            synchronized (mLock) {
+                return MMTelFeature.this.createCallSession(sessionId, profile, listener);
+            }
+        }
+
+        @Override
+        public IImsCallSession getPendingCallSession(int sessionId, String callId)
+                throws RemoteException {
+            synchronized (mLock) {
+                return MMTelFeature.this.getPendingCallSession(sessionId, callId);
+            }
+        }
+
+        @Override
+        public IImsUt getUtInterface() throws RemoteException {
+            synchronized (mLock) {
+                return MMTelFeature.this.getUtInterface();
+            }
+        }
+
+        @Override
+        public IImsConfig getConfigInterface() throws RemoteException {
+            synchronized (mLock) {
+                return MMTelFeature.this.getConfigInterface();
+            }
+        }
+
+        @Override
+        public void turnOnIms() throws RemoteException {
+            synchronized (mLock) {
+                MMTelFeature.this.turnOnIms();
+            }
+        }
+
+        @Override
+        public void turnOffIms() throws RemoteException {
+            synchronized (mLock) {
+                MMTelFeature.this.turnOffIms();
+            }
+        }
+
+        @Override
+        public IImsEcbm getEcbmInterface() throws RemoteException {
+            synchronized (mLock) {
+                return MMTelFeature.this.getEcbmInterface();
+            }
+        }
+
+        @Override
+        public void setUiTTYMode(int uiTtyMode, Message onComplete) throws RemoteException {
+            synchronized (mLock) {
+                MMTelFeature.this.setUiTTYMode(uiTtyMode, onComplete);
+            }
+        }
+
+        @Override
+        public IImsMultiEndpoint getMultiEndpointInterface() throws RemoteException {
+            synchronized (mLock) {
+                return MMTelFeature.this.getMultiEndpointInterface();
+            }
+        }
+    };
+
+    /**
+     * @hide
+     */
+    @Override
+    public final IImsMMTelFeature getBinder() {
+        return mImsMMTelBinder;
+    }
+
     /**
      * Notifies the MMTel feature that you would like to start a session. This should always be
      * done before making/receiving IMS calls. The IMS service will register the device to the
@@ -135,7 +275,7 @@
     }
 
     /**
-     * Creates a {@link ImsCallSession} with the specified call profile.
+     * Creates an {@link ImsCallSession} with the specified call profile.
      * Use other methods, if applicable, instead of interacting with
      * {@link ImsCallSession} directly.
      *
@@ -206,6 +346,11 @@
         return null;
     }
 
+    @Override
+    public void onFeatureReady() {
+
+    }
+
     /**
      * {@inheritDoc}
      */
diff --git a/telephony/java/android/telephony/ims/feature/RcsFeature.java b/telephony/java/android/telephony/ims/feature/RcsFeature.java
index 332cca3..40c5181 100644
--- a/telephony/java/android/telephony/ims/feature/RcsFeature.java
+++ b/telephony/java/android/telephony/ims/feature/RcsFeature.java
@@ -16,6 +16,8 @@
 
 package android.telephony.ims.feature;
 
+import com.android.ims.internal.IImsRcsFeature;
+
 /**
  * Base implementation of the RcsFeature APIs. Any ImsService wishing to support RCS should extend
  * this class and provide implementations of the RcsFeature methods that they support.
@@ -24,12 +26,27 @@
 
 public class RcsFeature extends ImsFeature {
 
+    private final IImsRcsFeature mImsRcsBinder = new IImsRcsFeature.Stub() {
+        // Empty Default Implementation.
+    };
+
+
     public RcsFeature() {
         super();
     }
 
     @Override
+    public void onFeatureReady() {
+
+    }
+
+    @Override
     public void onFeatureRemoved() {
 
     }
+
+    @Override
+    public final IImsRcsFeature getBinder() {
+        return mImsRcsBinder;
+    }
 }
diff --git a/telephony/java/android/telephony/ims/feature/SmsFeature.java b/telephony/java/android/telephony/ims/feature/SmsFeature.java
new file mode 100644
index 0000000..c1366db
--- /dev/null
+++ b/telephony/java/android/telephony/ims/feature/SmsFeature.java
@@ -0,0 +1,237 @@
+/*
+ * 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 android.telephony.ims.feature;
+
+import android.annotation.SystemApi;
+import android.os.RemoteException;
+import com.android.ims.internal.IImsSmsFeature;
+import com.android.ims.internal.ISmsListener;
+
+/**
+ * Base implementation of SMS over IMS functionality.
+ *
+ * @hide
+ */
+public class SmsFeature extends ImsFeature {
+  /**
+   * SMS over IMS format is 3gpp.
+   */
+  public static final int IMS_SMS_FORMAT_3GPP = 1;
+
+  /**
+   * SMS over IMS format is 3gpp2.
+   */
+  public static final int IMS_SMS_FORMAT_3GPP2 = 2;
+
+  /**
+   * Message was sent successfully.
+   */
+  public static final int SEND_STATUS_OK = 1;
+
+  /**
+   * IMS provider failed to send the message and platform should not retry falling back to sending
+   * the message using the radio.
+   */
+  public static final int SEND_STATUS_ERROR = 2;
+
+  /**
+   * IMS provider failed to send the message and platform should retry again after setting TP-RD bit
+   * to high.
+   */
+  public static final int SEND_STATUS_ERROR_RETRY = 3;
+
+  /**
+   * IMS provider failed to send the message and platform should retry falling back to sending
+   * the message using the radio.
+   */
+  public static final int SEND_STATUS_ERROR_FALLBACK = 4;
+
+  /**
+   * Message was delivered successfully.
+   */
+  public static final int DELIVER_STATUS_OK = 1;
+
+  /**
+   * Message was not delivered.
+   */
+  public static final int DELIVER_STATUS_ERROR = 2;
+
+  // Lock for feature synchronization
+  private final Object mLock = new Object();
+  private ISmsListener mSmsListener;
+
+  private final IImsSmsFeature mIImsSmsBinder = new IImsSmsFeature.Stub() {
+    @Override
+    public void registerSmsListener(ISmsListener listener) {
+      synchronized (mLock) {
+        SmsFeature.this.registerSmsListener(listener);
+      }
+    }
+
+    @Override
+    public void sendSms(int format, int messageRef, boolean retry, byte[] pdu) {
+      synchronized (mLock) {
+        SmsFeature.this.sendSms(format, messageRef, retry, pdu);
+      }
+    }
+
+    @Override
+    public void acknowledgeSms(int messageRef, int result) {
+      synchronized (mLock) {
+        SmsFeature.this.acknowledgeSms(messageRef, result);
+      }
+    }
+
+    @Override
+    public int getSmsFormat() {
+      synchronized (mLock) {
+        return SmsFeature.this.getSmsFormat();
+      }
+    }
+  };
+
+  /**
+   * Registers a listener responsible for handling tasks like delivering messages.
+
+   * @param listener listener to register.
+   *
+   * @hide
+   */
+  @SystemApi
+  public final void registerSmsListener(ISmsListener listener) {
+    synchronized (mLock) {
+      mSmsListener = listener;
+    }
+  }
+
+  /**
+   * This method will be triggered by the platform when the user attempts to send an SMS. This
+   * method should be implemented by the IMS providers to provide implementation of sending an SMS
+   * over IMS.
+   *
+   * @param format the format of the message. One of {@link #IMS_SMS_FORMAT_3GPP} or
+   *                {@link #IMS_SMS_FORMAT_3GPP2}
+   * @param messageRef the message reference.
+   * @param retry whether it is a retry of an already attempted message or not.
+   * @param pdu PDUs representing the contents of the message.
+   */
+  public void sendSms(int format, int messageRef, boolean isRetry, byte[] pdu) {
+  }
+
+  /**
+   * This method will be triggered by the platform after {@link #deliverSms(int, byte[])} has been
+   * called to deliver the result to the IMS provider. It will also be triggered after
+   * {@link #setSentSmsResult(int, int)} has been called to provide the result of the operation.
+   *
+   * @param result Should be {@link #DELIVER_STATUS_OK} if the message was delivered successfully,
+   * {@link #DELIVER_STATUS_ERROR} otherwise.
+   * @param messageRef the message reference.
+   */
+  public void acknowledgeSms(int messageRef, int result) {
+
+  }
+
+  /**
+   * This method should be triggered by the IMS providers when there is an incoming message. The
+   * platform will deliver the message to the messages database and notify the IMS provider of the
+   * result by calling {@link #acknowledgeSms(int)}.
+   *
+   * This method must not be called before {@link #onFeatureReady()} is called.
+   *
+   * @param format the format of the message.One of {@link #IMS_SMS_FORMAT_3GPP} or
+   *                {@link #IMS_SMS_FORMAT_3GPP2}
+   * @param pdu PDUs representing the contents of the message.
+   * @throws IllegalStateException if called before {@link #onFeatureReady()}
+   */
+  public final void deliverSms(int format, byte[] pdu) throws IllegalStateException {
+    // TODO: Guard against NPE/ Check if feature is ready and thrown an exception
+    // otherwise.
+    try {
+      mSmsListener.deliverSms(format, pdu);
+    } catch (RemoteException e) {
+    }
+  }
+
+  /**
+   * This method should be triggered by the IMS providers to pass the result of the sent message
+   * to the platform.
+   *
+   * This method must not be called before {@link #onFeatureReady()} is called.
+   *
+   * @param messageRef the message reference.
+   * @param result One of {@link #SEND_STATUS_OK}, {@link #SEND_STATUS_ERROR},
+   *                {@link #SEND_STATUS_ERROR_RETRY}, {@link #SEND_STATUS_ERROR_FALLBACK}
+   * @throws IllegalStateException if called before {@link #onFeatureReady()}
+   */
+  public final void setSentSmsResult(int messageRef, int result) throws IllegalStateException {
+    // TODO: Guard against NPE/ Check if feature is ready and thrown an exception
+    // otherwise.
+    try {
+      mSmsListener.setSentSmsResult(messageRef, result);
+    } catch (RemoteException e) {
+    }
+  }
+
+  /**
+   * Sets the status report of the sent message.
+   *
+   * @param format Should be {@link #IMS_SMS_FORMAT_3GPP} or {@link #IMS_SMS_FORMAT_3GPP2}
+   * @param pdu PDUs representing the content of the status report.
+   * @throws IllegalStateException if called before {@link #onFeatureReady()}
+   */
+  public final void setSentSmsStatusReport(int format, byte[] pdu) {
+    // TODO: Guard against NPE/ Check if feature is ready and thrown an exception
+    // otherwise.
+    try {
+      mSmsListener.setSentSmsStatusReport(format, pdu);
+    } catch (RemoteException e) {
+    }
+  }
+
+  /**
+   * Returns the SMS format. Default is {@link #IMS_SMS_FORMAT_3GPP} unless overridden by IMS
+   * Provider.
+   *
+   * @return sms format.
+   */
+  public int getSmsFormat() {
+    return IMS_SMS_FORMAT_3GPP;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public void onFeatureReady() {
+
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public void onFeatureRemoved() {
+
+  }
+
+  /**
+   * @hide
+   */
+  @Override
+  public final IImsSmsFeature getBinder() {
+    return mIImsSmsBinder;
+  }
+}
\ No newline at end of file
diff --git a/telephony/java/android/telephony/ims/stub/ImsUtImplBase.java b/telephony/java/android/telephony/ims/stub/ImsUtImplBase.java
index dc74094..054a8b2 100644
--- a/telephony/java/android/telephony/ims/stub/ImsUtImplBase.java
+++ b/telephony/java/android/telephony/ims/stub/ImsUtImplBase.java
@@ -53,6 +53,15 @@
     }
 
     /**
+     * Retrieves the configuration of the call barring for specified service class.
+     */
+    @Override
+    public int queryCallBarringForServiceClass(int cbType, int serviceClass)
+            throws RemoteException {
+        return -1;
+    }
+
+    /**
      * Retrieves the configuration of the call forward.
      */
     @Override
@@ -117,6 +126,15 @@
     }
 
     /**
+     * Updates the configuration of the call barring for specified service class.
+     */
+    @Override
+    public int updateCallBarringForServiceClass(int cbType, int action, String[] barrList,
+            int serviceClass) throws RemoteException {
+        return -1;
+    }
+
+    /**
      * Updates the configuration of the call forward.
      */
     @Override
diff --git a/telephony/java/com/android/ims/ImsUtInterface.java b/telephony/java/com/android/ims/ImsUtInterface.java
index 5984e78..250371f 100644
--- a/telephony/java/com/android/ims/ImsUtInterface.java
+++ b/telephony/java/com/android/ims/ImsUtInterface.java
@@ -109,6 +109,12 @@
     public void queryCallBarring(int cbType, Message result);
 
     /**
+     * Retrieves the configuration of the call barring for specified service class.
+     * The return value of ((AsyncResult)result.obj) is an array of {@link ImsSsInfo}.
+     */
+    public void queryCallBarring(int cbType, Message result, int serviceClass);
+
+    /**
      * Retrieves the configuration of the call forward.
      * The return value of ((AsyncResult)result.obj) is an array of {@link ImsCallForwardInfo}.
      */
@@ -147,6 +153,12 @@
             Message result, String[] barrList);
 
     /**
+     * Modifies the configuration of the call barring for specified service class.
+     */
+    public void updateCallBarring(int cbType, int action, Message result,
+            String[] barrList, int serviceClass);
+
+    /**
      * Modifies the configuration of the call forward.
      */
     public void updateCallForward(int action, int condition, String number,
diff --git a/telephony/java/com/android/ims/internal/IImsMMTelFeature.aidl b/telephony/java/com/android/ims/internal/IImsMMTelFeature.aidl
new file mode 100644
index 0000000..52b3853
--- /dev/null
+++ b/telephony/java/com/android/ims/internal/IImsMMTelFeature.aidl
@@ -0,0 +1,56 @@
+/*
+ * 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.ims.internal;
+
+import android.app.PendingIntent;
+
+import com.android.ims.ImsCallProfile;
+import com.android.ims.internal.IImsCallSession;
+import com.android.ims.internal.IImsCallSessionListener;
+import com.android.ims.internal.IImsConfig;
+import com.android.ims.internal.IImsEcbm;
+import com.android.ims.internal.IImsMultiEndpoint;
+import com.android.ims.internal.IImsRegistrationListener;
+import com.android.ims.internal.IImsUt;
+
+import android.os.Message;
+
+/**
+ * See MMTelFeature for more information.
+ * {@hide}
+ */
+interface IImsMMTelFeature {
+    int startSession(in PendingIntent incomingCallIntent,
+            in IImsRegistrationListener listener);
+    void endSession(int sessionId);
+    boolean isConnected(int callSessionType, int callType);
+    boolean isOpened();
+    int getFeatureStatus();
+    void addRegistrationListener(in IImsRegistrationListener listener);
+    void removeRegistrationListener(in IImsRegistrationListener listener);
+    ImsCallProfile createCallProfile(int sessionId, int callSessionType, int callType);
+    IImsCallSession createCallSession(int sessionId, in ImsCallProfile profile,
+            IImsCallSessionListener listener);
+    IImsCallSession getPendingCallSession(int sessionId, String callId);
+    IImsUt getUtInterface();
+    IImsConfig getConfigInterface();
+    void turnOnIms();
+    void turnOffIms();
+    IImsEcbm getEcbmInterface();
+    void setUiTTYMode(int uiTtyMode, in Message onComplete);
+    IImsMultiEndpoint getMultiEndpointInterface();
+}
diff --git a/telephony/java/com/android/internal/telephony/ISubscriptionListener.aidl b/telephony/java/com/android/ims/internal/IImsRcsFeature.aidl
similarity index 71%
rename from telephony/java/com/android/internal/telephony/ISubscriptionListener.aidl
rename to telephony/java/com/android/ims/internal/IImsRcsFeature.aidl
index 4ccdea5..b1cb23b 100644
--- a/telephony/java/com/android/internal/telephony/ISubscriptionListener.aidl
+++ b/telephony/java/com/android/ims/internal/IImsRcsFeature.aidl
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 The Android Open Source Project
+ * 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.
@@ -14,11 +14,12 @@
  * limitations under the License.
  */
 
-package com.android.internal.telephony;
+package com.android.ims.internal;
 
-import android.telephony.SubscriptionInfo;
-
-oneway interface ISubscriptionListener {
-    void onSubscriptionInfoChanged();
-}
-
+/**
+ * See RcsFeature for more information.
+ * {@hide}
+ */
+interface IImsRcsFeature {
+    //Empty Default Implementation
+}
\ No newline at end of file
diff --git a/telephony/java/com/android/ims/internal/IImsServiceController.aidl b/telephony/java/com/android/ims/internal/IImsServiceController.aidl
index f1e2262..857089f 100644
--- a/telephony/java/com/android/ims/internal/IImsServiceController.aidl
+++ b/telephony/java/com/android/ims/internal/IImsServiceController.aidl
@@ -16,49 +16,17 @@
 
 package com.android.ims.internal;
 
-import android.app.PendingIntent;
-
-import com.android.ims.ImsCallProfile;
-import com.android.ims.internal.IImsCallSession;
-import com.android.ims.internal.IImsCallSessionListener;
-import com.android.ims.internal.IImsConfig;
-import com.android.ims.internal.IImsEcbm;
 import com.android.ims.internal.IImsFeatureStatusCallback;
-import com.android.ims.internal.IImsMultiEndpoint;
-import com.android.ims.internal.IImsRegistrationListener;
-import com.android.ims.internal.IImsUt;
-
-import android.os.Message;
+import com.android.ims.internal.IImsMMTelFeature;
+import com.android.ims.internal.IImsRcsFeature;
 
 /**
  * See ImsService and MMTelFeature for more information.
  * {@hide}
  */
 interface IImsServiceController {
-    // ImsService Control
-    void createImsFeature(int slotId, int feature, IImsFeatureStatusCallback c);
-    void removeImsFeature(int slotId, int feature, IImsFeatureStatusCallback c);
-    // MMTel Feature
-    int startSession(int slotId, int featureType, in PendingIntent incomingCallIntent,
-            in IImsRegistrationListener listener);
-    void endSession(int slotId, int featureType, int sessionId);
-    boolean isConnected(int slotId, int featureType, int callSessionType, int callType);
-    boolean isOpened(int slotId, int featureType);
-    int getFeatureStatus(int slotId, int featureType);
-    void addRegistrationListener(int slotId, int featureType, in IImsRegistrationListener listener);
-    void removeRegistrationListener(int slotId, int featureType,
-            in IImsRegistrationListener listener);
-    ImsCallProfile createCallProfile(int slotId, int featureType, int sessionId,
-            int callSessionType, int callType);
-    IImsCallSession createCallSession(int slotId, int featureType, int sessionId,
-            in ImsCallProfile profile, IImsCallSessionListener listener);
-    IImsCallSession getPendingCallSession(int slotId, int featureType, int sessionId,
-            String callId);
-    IImsUt getUtInterface(int slotId, int featureType);
-    IImsConfig getConfigInterface(int slotId, int featureType);
-    void turnOnIms(int slotId, int featureType);
-    void turnOffIms(int slotId, int featureType);
-    IImsEcbm getEcbmInterface(int slotId, int featureType);
-    void setUiTTYMode(int slotId, int featureType, int uiTtyMode, in Message onComplete);
-    IImsMultiEndpoint getMultiEndpointInterface(int slotId, int featureType);
+    IImsMMTelFeature createEmergencyMMTelFeature(int slotId, in IImsFeatureStatusCallback c);
+    IImsMMTelFeature createMMTelFeature(int slotId, in IImsFeatureStatusCallback c);
+    IImsRcsFeature createRcsFeature(int slotId, in IImsFeatureStatusCallback c);
+    void removeImsFeature(int slotId, int featureType, in IImsFeatureStatusCallback c);
 }
diff --git a/telephony/java/com/android/ims/internal/IImsServiceFeatureListener.aidl b/telephony/java/com/android/ims/internal/IImsServiceFeatureCallback.aidl
similarity index 95%
rename from telephony/java/com/android/ims/internal/IImsServiceFeatureListener.aidl
rename to telephony/java/com/android/ims/internal/IImsServiceFeatureCallback.aidl
index df10700..9a9cf53 100644
--- a/telephony/java/com/android/ims/internal/IImsServiceFeatureListener.aidl
+++ b/telephony/java/com/android/ims/internal/IImsServiceFeatureCallback.aidl
@@ -21,7 +21,7 @@
  * Callback to ImsManager when a feature changes in the ImsServiceController.
  * {@hide}
  */
-oneway interface IImsServiceFeatureListener {
+oneway interface IImsServiceFeatureCallback {
     void imsFeatureCreated(int slotId, int feature);
     void imsFeatureRemoved(int slotId, int feature);
     void imsStatusChanged(int slotId, int feature, int status);
diff --git a/telephony/java/com/android/ims/internal/IImsServiceFeatureListener.aidl b/telephony/java/com/android/ims/internal/IImsSmsFeature.aidl
similarity index 65%
copy from telephony/java/com/android/ims/internal/IImsServiceFeatureListener.aidl
copy to telephony/java/com/android/ims/internal/IImsSmsFeature.aidl
index df10700..5068128 100644
--- a/telephony/java/com/android/ims/internal/IImsServiceFeatureListener.aidl
+++ b/telephony/java/com/android/ims/internal/IImsSmsFeature.aidl
@@ -16,13 +16,16 @@
 
 package com.android.ims.internal;
 
+import com.android.ims.internal.ISmsListener;
+
 /**
- *  Interface from ImsResolver to ImsServiceProxy in ImsManager.
- * Callback to ImsManager when a feature changes in the ImsServiceController.
+ * See SmsFeature for more information.
+ *
  * {@hide}
  */
-oneway interface IImsServiceFeatureListener {
-    void imsFeatureCreated(int slotId, int feature);
-    void imsFeatureRemoved(int slotId, int feature);
-    void imsStatusChanged(int slotId, int feature, int status);
+interface IImsSmsFeature {
+    void registerSmsListener(in ISmsListener listener);
+    void sendSms(in int format, in int messageRef, in boolean retry, in byte[] pdu);
+    void acknowledgeSms(in int messageRef, in int result);
+    int getSmsFormat();
 }
\ No newline at end of file
diff --git a/telephony/java/com/android/ims/internal/IImsUt.aidl b/telephony/java/com/android/ims/internal/IImsUt.aidl
index 4ab5ee3..4f97cc5 100644
--- a/telephony/java/com/android/ims/internal/IImsUt.aidl
+++ b/telephony/java/com/android/ims/internal/IImsUt.aidl
@@ -111,4 +111,15 @@
      * Sets the listener.
      */
     void setListener(in IImsUtListener listener);
+
+    /**
+     * Retrieves the configuration of the call barring for specified service class.
+     */
+    int queryCallBarringForServiceClass(int cbType, int serviceClass);
+
+    /**
+     * Updates the configuration of the call barring for specified service class.
+     */
+    int updateCallBarringForServiceClass(int cbType, int action, in String[] barrList,
+            int serviceClass);
 }
diff --git a/telephony/java/com/android/ims/internal/IImsServiceFeatureListener.aidl b/telephony/java/com/android/ims/internal/ISmsListener.aidl
similarity index 65%
copy from telephony/java/com/android/ims/internal/IImsServiceFeatureListener.aidl
copy to telephony/java/com/android/ims/internal/ISmsListener.aidl
index df10700..1266f04 100644
--- a/telephony/java/com/android/ims/internal/IImsServiceFeatureListener.aidl
+++ b/telephony/java/com/android/ims/internal/ISmsListener.aidl
@@ -17,12 +17,11 @@
 package com.android.ims.internal;
 
 /**
- *  Interface from ImsResolver to ImsServiceProxy in ImsManager.
- * Callback to ImsManager when a feature changes in the ImsServiceController.
+ * See SmsFeature for more information.
  * {@hide}
  */
-oneway interface IImsServiceFeatureListener {
-    void imsFeatureCreated(int slotId, int feature);
-    void imsFeatureRemoved(int slotId, int feature);
-    void imsStatusChanged(int slotId, int feature, int status);
+interface ISmsListener {
+    void setSentSmsResult(in int messageRef, in int result);
+    void setSentSmsStatusReport(in int format, in byte[] pdu);
+    void deliverSms(in int format, in byte[] pdu);
 }
\ No newline at end of file
diff --git a/telephony/java/com/android/internal/telephony/ICallService.aidl b/telephony/java/com/android/internal/telephony/ICallService.aidl
deleted file mode 100644
index cb9b2e8..0000000
--- a/telephony/java/com/android/internal/telephony/ICallService.aidl
+++ /dev/null
@@ -1,61 +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.internal.telephony;
-
-import com.android.internal.telephony.ICallServiceAdapter;
-
-/**
- * Service interface for services which would like to provide calls to be
- * managed by the system in-call UI.
- *
- * This interface provides methods that the android framework can use to deliver commands
- * for calls provided by this call service including making new calls and disconnecting
- * existing ones. A binding to ICallService implementations exists for two conditions:
- * 1) There exists one or more live calls for that call service,
- * 2) Prior to an outbound call to test if this call service is compatible with the outgoing call.
- */
-oneway interface ICallService {
-
-    /**
-     * Determines if the CallService can make calls to the handle.
-     * TODO(santoscordon): Move this method into its own service interface long term.
-     * TODO(santoscordon): Add response callback parameter.
-     */
-    void isCompatibleWith(String handle);
-
-    /**
-     * Attempts to call the relevant party using the specified handle, be it a phone number,
-     * SIP address, or some other kind of user ID.  Note that the set of handle types is
-     * dynamically extensible since call providers should be able to implement arbitrary
-     * handle-calling systems.  See {@link #isCompatibleWith}.
-     * TODO(santoscordon): Should this have a response attached to it to ensure that the call
-     * service actually plans to make the call?
-     */
-    void call(String handle);
-
-    /**
-     * Disconnects the call identified by callId.
-     */
-    void disconnect(String callId);
-
-    /**
-     * Sets an implementation of ICallServiceAdapter which the call service can use to add new calls
-     * and communicate state changes of existing calls. This is the first method that is called
-     * after a the framework binds to the call service.
-     */
-    void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter);
-}
diff --git a/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl b/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl
deleted file mode 100644
index bc900f0..0000000
--- a/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl
+++ /dev/null
@@ -1,61 +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.internal.telephony;
-
-import com.android.internal.telephony.CallInfo;
-
-/**
- * Provides methods for ICallService implementations to interact with the system phone app.
- */
-oneway interface ICallServiceAdapter {
-
-    /**
-     * Retrieves a new unique call id for use with newOutgoingCall and newIncomingCall.
-     */
-    void getNextCallId(/* TODO(santoscordon): Needs response object */);
-
-    /**
-     * Tells CallsManager of a new incoming call.
-     */
-    void newIncomingCall(String callId, in CallInfo info);
-
-    /**
-     * Tells CallsManager of a new outgoing call.
-     */
-    void newOutgoingCall(String callId, in CallInfo info);
-
-    /**
-     * Sets a call's state to active (e.g., an ongoing call where two parties can actively
-     * communicate).
-     */
-    void setActive(String callId);
-
-    /**
-     * Sets a call's state to ringing (e.g., an inbound ringing call).
-     */
-    void setRinging(String callId);
-
-    /**
-     * Sets a call's state to dialing (e.g., dialing an outbound call).
-     */
-    void setDialing(String callId);
-
-    /**
-     * Sets a call's state to disconnected.
-     */
-    void setDisconnected(String callId);
-}
diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl
index 644ad49..5e015e0 100755
--- a/telephony/java/com/android/internal/telephony/ISub.aidl
+++ b/telephony/java/com/android/internal/telephony/ISub.aidl
@@ -18,7 +18,6 @@
 
 import android.app.PendingIntent;
 import android.telephony.SubscriptionInfo;
-import com.android.internal.telephony.ISubscriptionListener;
 
 interface ISub {
     /**
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 3cc9bde..fd6091a 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -38,8 +38,9 @@
 import android.telephony.SignalStrength;
 import android.telephony.TelephonyHistogram;
 import android.telephony.VisualVoicemailSmsFilterSettings;
-import com.android.ims.internal.IImsServiceController;
-import com.android.ims.internal.IImsServiceFeatureListener;
+import com.android.ims.internal.IImsMMTelFeature;
+import com.android.ims.internal.IImsRcsFeature;
+import com.android.ims.internal.IImsServiceFeatureCallback;
 import com.android.internal.telephony.CellNetworkScanResult;
 import com.android.internal.telephony.OperatorInfo;
 
@@ -784,12 +785,27 @@
     int getTetherApnRequired();
 
     /**
-     *  Get ImsServiceController binder from ImsResolver that corresponds to the subId and feature
-     *  requested as well as registering the ImsServiceController for callbacks using the
-     *  IImsServiceFeatureListener interface.
+     *  Get IImsMMTelFeature binder from ImsResolver that corresponds to the subId and MMTel feature
+     *  as well as registering the MMTelFeature for callbacks using the IImsServiceFeatureCallback
+     *  interface.
      */
-    IImsServiceController getImsServiceControllerAndListen(int slotIndex, int feature,
-                IImsServiceFeatureListener callback);
+    IImsMMTelFeature getMMTelFeatureAndListen(int slotId, in IImsServiceFeatureCallback callback);
+
+    /**
+     *  Get IImsMMTelFeature binder from ImsResolver that corresponds to the subId and MMTel feature
+     *  as well as registering the MMTelFeature for callbacks using the IImsServiceFeatureCallback
+     *  interface.
+     *  Used for emergency calling only.
+     */
+    IImsMMTelFeature getEmergencyMMTelFeatureAndListen(int slotId,
+            in IImsServiceFeatureCallback callback);
+
+    /**
+     *  Get IImsRcsFeature binder from ImsResolver that corresponds to the subId and RCS feature
+     *  as well as registering the RcsFeature for callbacks using the IImsServiceFeatureCallback
+     *  interface.
+     */
+    IImsRcsFeature getRcsFeatureAndListen(int slotId, in IImsServiceFeatureCallback callback);
 
     /**
      * Set the network selection mode to automatic.
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaSmsAddress.java b/telephony/java/com/android/internal/telephony/cdma/CdmaSmsAddress.java
index 5f2e561..d27a758 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaSmsAddress.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaSmsAddress.java
@@ -18,6 +18,7 @@
 
 import android.util.SparseBooleanArray;
 
+import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.telephony.SmsAddress;
 import com.android.internal.telephony.cdma.sms.UserData;
 import com.android.internal.util.HexDump;
@@ -113,8 +114,8 @@
      * share code and logic with GSM.  Also, gather all DTMF/BCD
      * processing code in one place.
      */
-
-    private static byte[] parseToDtmf(String address) {
+    @VisibleForTesting
+    public static byte[] parseToDtmf(String address) {
         int digits = address.length();
         byte[] result = new byte[digits];
         for (int i = 0; i < digits; i++) {
@@ -196,33 +197,46 @@
     public static CdmaSmsAddress parse(String address) {
         CdmaSmsAddress addr = new CdmaSmsAddress();
         addr.address = address;
-        addr.ton = CdmaSmsAddress.TON_UNKNOWN;
-        byte[] origBytes = null;
+        addr.ton = TON_UNKNOWN;
+        addr.digitMode = DIGIT_MODE_4BIT_DTMF;
+        addr.numberPlan = NUMBERING_PLAN_UNKNOWN;
+        addr.numberMode = NUMBER_MODE_NOT_DATA_NETWORK;
+
+        byte[] origBytes;
         String filteredAddr = filterNumericSugar(address);
-        if (filteredAddr != null) {
-            origBytes = parseToDtmf(filteredAddr);
-        }
-        if (origBytes != null) {
-            addr.digitMode = DIGIT_MODE_4BIT_DTMF;
-            addr.numberMode = NUMBER_MODE_NOT_DATA_NETWORK;
-            if (address.indexOf('+') != -1) {
-                addr.ton = TON_INTERNATIONAL_OR_IP;
-            }
-        } else {
-            filteredAddr = filterWhitespace(address);
-            origBytes = UserData.stringToAscii(filteredAddr);
-            if (origBytes == null) {
-                return null;
-            }
+        if (address.contains("+") || filteredAddr == null) {
+            // 3GPP2 C.S0015-B section 3.4.3.3 Address Parameters
+            // NUMBER_MODE should set to 1 for network address and email address.
             addr.digitMode = DIGIT_MODE_8BIT_CHAR;
             addr.numberMode = NUMBER_MODE_DATA_NETWORK;
-            if (address.indexOf('@') != -1) {
+            filteredAddr = filterWhitespace(address);
+
+            if (address.contains("@")) {
+                // This is an email address
                 addr.ton = TON_NATIONAL_OR_EMAIL;
+            } else if (address.contains("+") && filterNumericSugar(address) != null) {
+                // This is an international number
+                // 3GPP2 C.S0015-B section 3.4.3.3 Address Parameters
+                // digit mode is set to 1 and number mode is set to 0, type of number should set
+                // to the value correspond to the value in 3GPP2 C.S005-D, table2.7.1.3.2.4-2
+                addr.ton = TON_INTERNATIONAL_OR_IP;
+                addr.numberPlan = NUMBERING_PLAN_ISDN_TELEPHONY;
+                addr.numberMode = NUMBER_MODE_NOT_DATA_NETWORK;
+                filteredAddr = filterNumericSugar(address);
             }
+
+            origBytes = UserData.stringToAscii(filteredAddr);
+        } else {
+            // The address is not an international number and it only contains digit and *#
+            origBytes = parseToDtmf(filteredAddr);
         }
+
+        if (origBytes == null) {
+            return null;
+        }
+
         addr.origBytes = origBytes;
         addr.numberOfDigits = origBytes.length;
         return addr;
     }
-
 }
diff --git a/tests/backup/Android.mk b/tests/backup/Android.mk
index 88794c2..202a699 100644
--- a/tests/backup/Android.mk
+++ b/tests/backup/Android.mk
@@ -20,7 +20,8 @@
 
 LOCAL_SRC_FILES := \
     backup_helper_test.cpp
- 
+
+LOCAL_CFLAGS := -Wall -Werror
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := backup_helper_test
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
@@ -43,4 +44,3 @@
 LOCAL_PROGUARD_ENABLED := disabled
 
 include $(BUILD_PACKAGE)
-    
diff --git a/tests/backup/backup_helper_test.cpp b/tests/backup/backup_helper_test.cpp
index b5f6ff5..457dcc4 100644
--- a/tests/backup/backup_helper_test.cpp
+++ b/tests/backup/backup_helper_test.cpp
@@ -118,7 +118,7 @@
 
 #else
 int
-main(int argc, char** argv)
+main(int, char**)
 {
     printf ("test_backup_helper built without the tests\n");
     return 0;
diff --git a/tests/net/java/android/net/IpSecAlgorithmTest.java b/tests/net/java/android/net/IpSecAlgorithmTest.java
new file mode 100644
index 0000000..6bdfdc6
--- /dev/null
+++ b/tests/net/java/android/net/IpSecAlgorithmTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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 android.net;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import android.os.Parcel;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+import java.util.Arrays;
+import java.util.Random;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/** Unit tests for {@link IpSecAlgorithm}. */
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class IpSecAlgorithmTest {
+
+    private static final byte[] KEY_MATERIAL;
+
+    static {
+        KEY_MATERIAL = new byte[128];
+        new Random().nextBytes(KEY_MATERIAL);
+    };
+
+    @Test
+    public void testDefaultTruncLen() throws Exception {
+        IpSecAlgorithm explicit =
+                new IpSecAlgorithm(
+                        IpSecAlgorithm.AUTH_HMAC_SHA256, Arrays.copyOf(KEY_MATERIAL, 256 / 8), 256);
+        IpSecAlgorithm implicit =
+                new IpSecAlgorithm(
+                        IpSecAlgorithm.AUTH_HMAC_SHA256, Arrays.copyOf(KEY_MATERIAL, 256 / 8));
+        assertTrue(
+                "Default Truncation Length Incorrect, Explicit: "
+                        + explicit
+                        + "implicit: "
+                        + implicit,
+                IpSecAlgorithm.equals(explicit, implicit));
+    }
+
+    @Test
+    public void testTruncLenValidation() throws Exception {
+        for (int truncLen : new int[] {256, 512}) {
+            new IpSecAlgorithm(
+                    IpSecAlgorithm.AUTH_HMAC_SHA512,
+                    Arrays.copyOf(KEY_MATERIAL, 512 / 8),
+                    truncLen);
+        }
+
+        for (int truncLen : new int[] {255, 513}) {
+            try {
+                new IpSecAlgorithm(
+                        IpSecAlgorithm.AUTH_HMAC_SHA512,
+                        Arrays.copyOf(KEY_MATERIAL, 512 / 8),
+                        truncLen);
+                fail("Invalid truncation length not validated");
+            } catch (IllegalArgumentException pass) {
+            }
+        }
+    }
+
+    @Test
+    public void testLenValidation() throws Exception {
+        for (int len : new int[] {128, 192, 256}) {
+            new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, Arrays.copyOf(KEY_MATERIAL, len / 8));
+        }
+        try {
+            new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, Arrays.copyOf(KEY_MATERIAL, 384 / 8));
+            fail("Invalid key length not validated");
+        } catch (IllegalArgumentException pass) {
+        }
+    }
+
+    @Test
+    public void testAlgoNameValidation() throws Exception {
+        try {
+            new IpSecAlgorithm("rot13", Arrays.copyOf(KEY_MATERIAL, 128 / 8));
+            fail("Invalid algorithm name not validated");
+        } catch (IllegalArgumentException pass) {
+        }
+    }
+
+    @Test
+    public void testParcelUnparcel() throws Exception {
+        IpSecAlgorithm init =
+                new IpSecAlgorithm(
+                        IpSecAlgorithm.AUTH_HMAC_SHA512, Arrays.copyOf(KEY_MATERIAL, 512 / 8), 256);
+
+        Parcel p = Parcel.obtain();
+        p.setDataPosition(0);
+        init.writeToParcel(p, 0);
+
+        p.setDataPosition(0);
+        IpSecAlgorithm fin = IpSecAlgorithm.CREATOR.createFromParcel(p);
+        assertTrue("Parcel/Unparcel failed!", IpSecAlgorithm.equals(init, fin));
+        p.recycle();
+    }
+}
diff --git a/tests/net/java/android/net/IpSecConfigTest.java b/tests/net/java/android/net/IpSecConfigTest.java
index 1b4bef5..efc01f2a 100644
--- a/tests/net/java/android/net/IpSecConfigTest.java
+++ b/tests/net/java/android/net/IpSecConfigTest.java
@@ -71,7 +71,7 @@
         c.setAuthentication(
                 IpSecTransform.DIRECTION_OUT,
                 new IpSecAlgorithm(
-                        IpSecAlgorithm.AUTH_HMAC_SHA1,
+                        IpSecAlgorithm.AUTH_HMAC_MD5,
                         new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0}));
         c.setSpiResourceId(IpSecTransform.DIRECTION_OUT, 1984);
         c.setEncryption(
@@ -82,7 +82,7 @@
         c.setAuthentication(
                 IpSecTransform.DIRECTION_IN,
                 new IpSecAlgorithm(
-                        IpSecAlgorithm.AUTH_HMAC_SHA1,
+                        IpSecAlgorithm.AUTH_HMAC_MD5,
                         new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 1}));
         c.setSpiResourceId(IpSecTransform.DIRECTION_IN, 99);
         assertParcelingIsLossless(c);
diff --git a/tests/net/java/android/net/MacAddressTest.java b/tests/net/java/android/net/MacAddressTest.java
index fcbb9da..558dbb6 100644
--- a/tests/net/java/android/net/MacAddressTest.java
+++ b/tests/net/java/android/net/MacAddressTest.java
@@ -21,7 +21,6 @@
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.fail;
 
-import android.net.MacAddress.MacAddressType;
 import android.support.test.filters.SmallTest;
 import android.support.test.runner.AndroidJUnit4;
 
@@ -37,11 +36,11 @@
 
     static class AddrTypeTestCase {
         byte[] addr;
-        MacAddressType expected;
+        int expectedType;
 
-        static AddrTypeTestCase of(MacAddressType expected, int... addr) {
+        static AddrTypeTestCase of(int expectedType, int... addr) {
             AddrTypeTestCase t = new AddrTypeTestCase();
-            t.expected = expected;
+            t.expectedType = expectedType;
             t.addr = toByteArray(addr);
             return t;
         }
@@ -50,41 +49,73 @@
     @Test
     public void testMacAddrTypes() {
         AddrTypeTestCase[] testcases = {
-            AddrTypeTestCase.of(null),
-            AddrTypeTestCase.of(null, 0),
-            AddrTypeTestCase.of(null, 1, 2, 3, 4, 5),
-            AddrTypeTestCase.of(null, 1, 2, 3, 4, 5, 6, 7),
-            AddrTypeTestCase.of(MacAddressType.UNICAST, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0),
-            AddrTypeTestCase.of(MacAddressType.BROADCAST, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff),
-            AddrTypeTestCase.of(MacAddressType.MULTICAST, 1, 2, 3, 4, 5, 6),
-            AddrTypeTestCase.of(MacAddressType.MULTICAST, 11, 22, 33, 44, 55, 66),
-            AddrTypeTestCase.of(MacAddressType.MULTICAST, 33, 33, 0xaa, 0xbb, 0xcc, 0xdd)
+            AddrTypeTestCase.of(MacAddress.TYPE_UNKNOWN),
+            AddrTypeTestCase.of(MacAddress.TYPE_UNKNOWN, 0),
+            AddrTypeTestCase.of(MacAddress.TYPE_UNKNOWN, 1, 2, 3, 4, 5),
+            AddrTypeTestCase.of(MacAddress.TYPE_UNKNOWN, 1, 2, 3, 4, 5, 6, 7),
+            AddrTypeTestCase.of(MacAddress.TYPE_UNICAST, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0),
+            AddrTypeTestCase.of(MacAddress.TYPE_BROADCAST, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff),
+            AddrTypeTestCase.of(MacAddress.TYPE_MULTICAST, 1, 2, 3, 4, 5, 6),
+            AddrTypeTestCase.of(MacAddress.TYPE_MULTICAST, 11, 22, 33, 44, 55, 66),
+            AddrTypeTestCase.of(MacAddress.TYPE_MULTICAST, 33, 33, 0xaa, 0xbb, 0xcc, 0xdd)
         };
 
         for (AddrTypeTestCase t : testcases) {
-            MacAddressType got = MacAddress.macAddressType(t.addr);
+            int got = MacAddress.macAddressType(t.addr);
             String msg = String.format("expected type of %s to be %s, but got %s",
-                    Arrays.toString(t.addr), t.expected, got);
-            assertEquals(msg, t.expected, got);
+                    Arrays.toString(t.addr), t.expectedType, got);
+            assertEquals(msg, t.expectedType, got);
 
-            if (got != null) {
-                assertEquals(got, new MacAddress(t.addr).addressType());
+            if (got != MacAddress.TYPE_UNKNOWN) {
+                assertEquals(got, MacAddress.fromBytes(t.addr).addressType());
             }
         }
     }
 
     @Test
+    public void testToSafeString() {
+        String[][] macs = {
+            {"07:00:d3:56:8a:c4", "07:00:d3:00:00:00"},
+            {"33:33:aa:bb:cc:dd", "33:33:aa:00:00:00"},
+            {"06:00:00:00:00:00", "06:00:00:00:00:00"},
+            {"07:00:d3:56:8a:c4", "07:00:d3:00:00:00"}
+        };
+
+        for (String[] pair : macs) {
+            String mac = pair[0];
+            String expected = pair[1];
+            assertEquals(expected, MacAddress.fromString(mac).toSafeString());
+        }
+    }
+
+    @Test
+    public void testHexPaddingWhenPrinting() {
+        String[] macs = {
+            "07:00:d3:56:8a:c4",
+            "33:33:aa:bb:cc:dd",
+            "06:00:00:00:00:00",
+            "07:00:d3:56:8a:c4"
+        };
+
+        for (String mac : macs) {
+            assertEquals(mac, MacAddress.fromString(mac).toString());
+            assertEquals(mac,
+                    MacAddress.stringAddrFromByteAddr(MacAddress.byteAddrFromStringAddr(mac)));
+        }
+    }
+
+    @Test
     public void testIsMulticastAddress() {
         MacAddress[] multicastAddresses = {
             MacAddress.BROADCAST_ADDRESS,
-            new MacAddress("07:00:d3:56:8a:c4"),
-            new MacAddress("33:33:aa:bb:cc:dd"),
+            MacAddress.fromString("07:00:d3:56:8a:c4"),
+            MacAddress.fromString("33:33:aa:bb:cc:dd"),
         };
         MacAddress[] unicastAddresses = {
             MacAddress.ALL_ZEROS_ADDRESS,
-            new MacAddress("00:01:44:55:66:77"),
-            new MacAddress("08:00:22:33:44:55"),
-            new MacAddress("06:00:00:00:00:00"),
+            MacAddress.fromString("00:01:44:55:66:77"),
+            MacAddress.fromString("08:00:22:33:44:55"),
+            MacAddress.fromString("06:00:00:00:00:00"),
         };
 
         for (MacAddress mac : multicastAddresses) {
@@ -100,13 +131,13 @@
     @Test
     public void testIsLocallyAssignedAddress() {
         MacAddress[] localAddresses = {
-            new MacAddress("06:00:00:00:00:00"),
-            new MacAddress("07:00:d3:56:8a:c4"),
-            new MacAddress("33:33:aa:bb:cc:dd"),
+            MacAddress.fromString("06:00:00:00:00:00"),
+            MacAddress.fromString("07:00:d3:56:8a:c4"),
+            MacAddress.fromString("33:33:aa:bb:cc:dd"),
         };
         MacAddress[] universalAddresses = {
-            new MacAddress("00:01:44:55:66:77"),
-            new MacAddress("08:00:22:33:44:55"),
+            MacAddress.fromString("00:01:44:55:66:77"),
+            MacAddress.fromString("08:00:22:33:44:55"),
         };
 
         for (MacAddress mac : localAddresses) {
@@ -123,13 +154,16 @@
     public void testMacAddressConversions() {
         final int iterations = 10000;
         for (int i = 0; i < iterations; i++) {
-            MacAddress mac = MacAddress.getRandomAddress();
+            MacAddress mac = MacAddress.createRandomUnicastAddress();
 
             String stringRepr = mac.toString();
             byte[] bytesRepr = mac.toByteArray();
 
-            assertEquals(mac, new MacAddress(stringRepr));
-            assertEquals(mac, new MacAddress(bytesRepr));
+            assertEquals(mac, MacAddress.fromString(stringRepr));
+            assertEquals(mac, MacAddress.fromBytes(bytesRepr));
+
+            assertEquals(mac, MacAddress.fromString(MacAddress.stringAddrFromByteAddr(bytesRepr)));
+            assertEquals(mac, MacAddress.fromBytes(MacAddress.byteAddrFromStringAddr(stringRepr)));
         }
     }
 
@@ -138,7 +172,7 @@
         final int iterations = 1000;
         final String expectedAndroidOui = "da:a1:19";
         for (int i = 0; i < iterations; i++) {
-            MacAddress mac = MacAddress.getRandomAddress();
+            MacAddress mac = MacAddress.createRandomUnicastAddress();
             String stringRepr = mac.toString();
 
             assertTrue(stringRepr + " expected to be a locally assigned address",
@@ -150,13 +184,14 @@
         final Random r = new Random();
         final String anotherOui = "24:5f:78";
         final String expectedLocalOui = "26:5f:78";
-        final MacAddress base = new MacAddress(anotherOui + ":0:0:0");
+        final MacAddress base = MacAddress.fromString(anotherOui + ":0:0:0");
         for (int i = 0; i < iterations; i++) {
-            MacAddress mac = MacAddress.getRandomAddress(base, r);
+            MacAddress mac = MacAddress.createRandomUnicastAddress(base, r);
             String stringRepr = mac.toString();
 
             assertTrue(stringRepr + " expected to be a locally assigned address",
                     mac.isLocallyAssigned());
+            assertEquals(MacAddress.TYPE_UNICAST, mac.addressType());
             assertTrue(stringRepr + " expected to begin with " + expectedLocalOui,
                     stringRepr.startsWith(expectedLocalOui));
         }
@@ -165,7 +200,6 @@
     @Test
     public void testConstructorInputValidation() {
         String[] invalidStringAddresses = {
-            null,
             "",
             "abcd",
             "1:2:3:4:5",
@@ -175,14 +209,19 @@
 
         for (String s : invalidStringAddresses) {
             try {
-                MacAddress mac = new MacAddress(s);
-                fail("new MacAddress(" + s + ") should have failed, but returned " + mac);
+                MacAddress mac = MacAddress.fromString(s);
+                fail("MacAddress.fromString(" + s + ") should have failed, but returned " + mac);
             } catch (IllegalArgumentException excepted) {
             }
         }
 
+        try {
+            MacAddress mac = MacAddress.fromString(null);
+            fail("MacAddress.fromString(null) should have failed, but returned " + mac);
+        } catch (NullPointerException excepted) {
+        }
+
         byte[][] invalidBytesAddresses = {
-            null,
             {},
             {1,2,3,4,5},
             {1,2,3,4,5,6,7},
@@ -190,12 +229,18 @@
 
         for (byte[] b : invalidBytesAddresses) {
             try {
-                MacAddress mac = new MacAddress(b);
-                fail("new MacAddress(" + Arrays.toString(b)
+                MacAddress mac = MacAddress.fromBytes(b);
+                fail("MacAddress.fromBytes(" + Arrays.toString(b)
                         + ") should have failed, but returned " + mac);
             } catch (IllegalArgumentException excepted) {
             }
         }
+
+        try {
+            MacAddress mac = MacAddress.fromBytes(null);
+            fail("MacAddress.fromBytes(null) should have failed, but returned " + mac);
+        } catch (NullPointerException excepted) {
+        }
     }
 
     static byte[] toByteArray(int... in) {
diff --git a/tools/aapt2/link/ProductFilter_test.cpp b/tools/aapt2/link/ProductFilter_test.cpp
index 379ad26..86dd56a 100644
--- a/tools/aapt2/link/ProductFilter_test.cpp
+++ b/tools/aapt2/link/ProductFilter_test.cpp
@@ -73,7 +73,7 @@
       test::ValueBuilder<Id>().SetSource(Source("tablet.xml")).Build(),
       context->GetDiagnostics()));
 
-  ProductFilter filter({});
+  ProductFilter filter(std::unordered_set<std::string>{});
   ASSERT_TRUE(filter.Consume(context.get(), &table));
 
   EXPECT_NE(nullptr, test::GetValueForConfigAndProduct<Id>(
@@ -123,7 +123,7 @@
       test::ValueBuilder<Id>().SetSource(Source("default.xml")).Build(),
       context->GetDiagnostics()));
 
-  ProductFilter filter({});
+  ProductFilter filter(std::unordered_set<std::string>{});
   ASSERT_FALSE(filter.Consume(context.get(), &table));
 }