Dialer: Replace deprecated stuff

* getParcelable[...](String) is deprecated in favor of
  getParcelable[...](String, Class)
* resolveActivity(), getPackageInfo(), resolveContentProvider() and
  getApplicationInfo() all now have a new prototype to pass flags
* Handler() is deprecated in favor of Handler(Looper)
* KeyguardManager.inKeyguardRestrictedInputMode() ->
  KeyguardManager.isKeyguardLocked()
* MediaRecorder() -> MediaRecorder(Context)
* getPhoneCount() -> getActiveModemCount()
* Airplane mode flag has been moved to Settings.Global
* Imei and Meid have functions to read, getDeviceId() is deprecated
* LocationManager.requestSingleUpdate() should be getCurrentLocation()
* Html.fromHtml(String) should provide the mode
* Cursors shouldn't requery or deactivate
* AVAILABLE_PHONE_ACCOUNTS -> EXTRA_SUGGESTED_PHONE_ACCOUNTS

Change-Id: Ie089e9e25a3930af43435515a85ac1d241a01b01
diff --git a/java/com/android/contacts/common/dialog/CallSubjectDialog.java b/java/com/android/contacts/common/dialog/CallSubjectDialog.java
index 1e1ee0d..3ddf4da 100644
--- a/java/com/android/contacts/common/dialog/CallSubjectDialog.java
+++ b/java/com/android/contacts/common/dialog/CallSubjectDialog.java
@@ -329,14 +329,15 @@
       return;
     }
     mPhotoID = arguments.getLong(ARG_PHOTO_ID);
-    mPhotoUri = arguments.getParcelable(ARG_PHOTO_URI);
-    mContactUri = arguments.getParcelable(ARG_CONTACT_URI);
+    mPhotoUri = arguments.getParcelable(ARG_PHOTO_URI, Uri.class);
+    mContactUri = arguments.getParcelable(ARG_CONTACT_URI, Uri.class);
     mNameOrNumber = arguments.getString(ARG_NAME_OR_NUMBER);
     mNumber = arguments.getString(ARG_NUMBER);
     mDisplayNumber = arguments.getString(ARG_DISPLAY_NUMBER);
     mNumberLabel = arguments.getString(ARG_NUMBER_LABEL);
     mContactType = arguments.getInt(ARG_CONTACT_TYPE, LetterTileDrawable.TYPE_DEFAULT);
-    mPhoneAccountHandle = arguments.getParcelable(ARG_PHONE_ACCOUNT_HANDLE);
+    mPhoneAccountHandle = arguments.getParcelable(ARG_PHONE_ACCOUNT_HANDLE,
+            PhoneAccountHandle.class);
   }
 
   /**
diff --git a/java/com/android/contacts/common/model/AccountTypeManager.java b/java/com/android/contacts/common/model/AccountTypeManager.java
index 070c9a7..283863e 100644
--- a/java/com/android/contacts/common/model/AccountTypeManager.java
+++ b/java/com/android/contacts/common/model/AccountTypeManager.java
@@ -696,8 +696,8 @@
         result.remove(accountTypeWithDataSet);
         continue;
       }
-      ResolveInfo resolveInfo =
-          packageManager.resolveActivity(invitableIntent, PackageManager.MATCH_DEFAULT_ONLY);
+      ResolveInfo resolveInfo = packageManager.resolveActivity(invitableIntent,
+              PackageManager.ResolveInfoFlags.of(PackageManager.MATCH_DEFAULT_ONLY));
       if (resolveInfo == null) {
         // If we can't find an activity to start for this intent, then there's no point in
         // showing this option to the user.
diff --git a/java/com/android/contacts/common/model/RawContact.java b/java/com/android/contacts/common/model/RawContact.java
index 9efc8a8..37c5634 100644
--- a/java/com/android/contacts/common/model/RawContact.java
+++ b/java/com/android/contacts/common/model/RawContact.java
@@ -78,7 +78,7 @@
    * @param parcel The parcel to de-serialize from.
    */
   private RawContact(Parcel parcel) {
-    mValues = parcel.readParcelable(ContentValues.class.getClassLoader());
+    mValues = parcel.readParcelable(ContentValues.class.getClassLoader(), ContentValues.class);
     mDataItems = new ArrayList<>();
     parcel.readTypedList(mDataItems, NamedDataItem.CREATOR);
   }
@@ -314,8 +314,9 @@
     }
 
     public NamedDataItem(Parcel parcel) {
-      this.mUri = parcel.readParcelable(Uri.class.getClassLoader());
-      this.mContentValues = parcel.readParcelable(ContentValues.class.getClassLoader());
+      this.mUri = parcel.readParcelable(Uri.class.getClassLoader(), Uri.class);
+      this.mContentValues = parcel.readParcelable(ContentValues.class.getClassLoader(),
+              ContentValues.class);
     }
 
     @Override
diff --git a/java/com/android/contacts/common/model/account/ExternalAccountType.java b/java/com/android/contacts/common/model/account/ExternalAccountType.java
index a38f8f2..24cd6ed 100644
--- a/java/com/android/contacts/common/model/account/ExternalAccountType.java
+++ b/java/com/android/contacts/common/model/account/ExternalAccountType.java
@@ -30,9 +30,11 @@
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.util.Xml;
+
 import com.android.contacts.common.model.dataitem.DataKind;
+import com.android.dialer.R;
 import com.android.dialer.common.LogUtil;
-import com.android.dialer.contacts.resources.R;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
@@ -189,25 +191,23 @@
   public static XmlResourceParser loadContactsXml(Context context, String resPackageName) {
     final PackageManager pm = context.getPackageManager();
     final Intent intent = new Intent(SYNC_META_DATA).setPackage(resPackageName);
-    final List<ResolveInfo> intentServices =
-        pm.queryIntentServices(intent, PackageManager.GET_SERVICES | PackageManager.GET_META_DATA);
+    final List<ResolveInfo> intentServices = pm.queryIntentServices(intent,
+            PackageManager.ResolveInfoFlags.of(PackageManager.GET_META_DATA));
 
-    if (intentServices != null) {
-      for (final ResolveInfo resolveInfo : intentServices) {
-        final ServiceInfo serviceInfo = resolveInfo.serviceInfo;
-        if (serviceInfo == null) {
-          continue;
-        }
-        for (String metadataName : METADATA_CONTACTS_NAMES) {
-          final XmlResourceParser parser = serviceInfo.loadXmlMetaData(pm, metadataName);
-          if (parser != null) {
-            LogUtil.d(
-                TAG,
-                String.format(
-                    "Metadata loaded from: %s, %s, %s",
-                    serviceInfo.packageName, serviceInfo.name, metadataName));
-            return parser;
-          }
+    for (final ResolveInfo resolveInfo : intentServices) {
+      final ServiceInfo serviceInfo = resolveInfo.serviceInfo;
+      if (serviceInfo == null) {
+        continue;
+      }
+      for (String metadataName : METADATA_CONTACTS_NAMES) {
+        final XmlResourceParser parser = serviceInfo.loadXmlMetaData(pm, metadataName);
+        if (parser != null) {
+          LogUtil.d(
+              TAG,
+              String.format(
+                  "Metadata loaded from: %s, %s, %s",
+                  serviceInfo.packageName, serviceInfo.name, metadataName));
+          return parser;
         }
       }
     }
diff --git a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
index 0b3575b..2bb5f6a 100644
--- a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
+++ b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
@@ -23,6 +23,7 @@
 import android.content.DialogInterface;
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.Looper;
 import android.os.ResultReceiver;
 import android.telecom.PhoneAccount;
 import android.telecom.PhoneAccountHandle;
@@ -184,14 +185,14 @@
     static final String EXTRA_CALL_ID = "extra_call_id";
 
     protected SelectPhoneAccountListener() {
-      super(new Handler());
+      super(new Handler(Looper.getMainLooper()));
     }
 
     @Override
     protected void onReceiveResult(int resultCode, Bundle resultData) {
       if (resultCode == RESULT_SELECTED) {
         onPhoneAccountSelected(
-            resultData.getParcelable(EXTRA_SELECTED_ACCOUNT_HANDLE),
+            resultData.getParcelable(EXTRA_SELECTED_ACCOUNT_HANDLE, PhoneAccountHandle.class),
             resultData.getBoolean(EXTRA_SET_DEFAULT),
             resultData.getString(EXTRA_CALL_ID));
       } else if (resultCode == RESULT_DISMISSED) {
diff --git a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogOptionsUtil.java b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogOptionsUtil.java
index 1880d65..6106bc3 100644
--- a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogOptionsUtil.java
+++ b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogOptionsUtil.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,7 +40,7 @@
       byte[] marshalledUserHandle = entry.getUserHandle().toByteArray();
       parcel.unmarshall(marshalledUserHandle, 0, marshalledUserHandle.length);
       parcel.setDataPosition(0);
-      userHandle = parcel.readParcelable(UserHandle.class.getClassLoader());
+      userHandle = parcel.readParcelable(UserHandle.class.getClassLoader(), UserHandle.class);
     } catch (NullPointerException e) {
       userHandle = null;
     }
diff --git a/java/com/android/dialer/app/AccountSelectionActivity.java b/java/com/android/dialer/app/AccountSelectionActivity.java
index 3f037a8..b6ab6b7 100644
--- a/java/com/android/dialer/app/AccountSelectionActivity.java
+++ b/java/com/android/dialer/app/AccountSelectionActivity.java
@@ -88,7 +88,8 @@
     initiationType = CallInitiationType.Type.values()[getIntent().getIntExtra("type", 0)];
 
     if (getSupportFragmentManager().findFragmentByTag("dialog") == null) {
-      List<PhoneAccountHandle> handles = getIntent().getParcelableArrayListExtra("accountHandles");
+      List<PhoneAccountHandle> handles = getIntent().getParcelableArrayListExtra("accountHandles",
+              PhoneAccountHandle.class);
       SelectPhoneAccountDialogOptions options = SelectPhoneAccountDialogOptionsUtil
           .builderWithAccounts(handles)
           .setTitle(R.string.call_via_dialog_title)
diff --git a/java/com/android/dialer/app/calllog/CallLogFragment.java b/java/com/android/dialer/app/calllog/CallLogFragment.java
index 3442d73..04adc6c 100644
--- a/java/com/android/dialer/app/calllog/CallLogFragment.java
+++ b/java/com/android/dialer/app/calllog/CallLogFragment.java
@@ -98,7 +98,7 @@
   private static final int EVENT_UPDATE_DISPLAY = 1;
 
   private static final long MILLIS_IN_MINUTE = 60 * 1000;
-  private final Handler handler = new Handler();
+  private final Handler handler = new Handler(Looper.getMainLooper());
   // See issue 6363009
   private final ContentObserver callLogObserver = new CustomContentObserver();
   private final ContentObserver contactsObserver = new CustomContentObserver();
diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsService.java b/java/com/android/dialer/app/calllog/CallLogNotificationsService.java
index 947dd02..a9ab8c2 100644
--- a/java/com/android/dialer/app/calllog/CallLogNotificationsService.java
+++ b/java/com/android/dialer/app/calllog/CallLogNotificationsService.java
@@ -159,7 +159,9 @@
         break;
       case ACTION_LEGACY_VOICEMAIL_DISMISSED:
         LegacyVoicemailNotificationReceiver.setDismissed(
-            this, intent.getParcelableExtra(EXTRA_PHONE_ACCOUNT_HANDLE), true);
+                this,
+                intent.getParcelableExtra(EXTRA_PHONE_ACCOUNT_HANDLE, PhoneAccountHandle.class),
+                true);
         break;
       case ACTION_CANCEL_ALL_MISSED_CALLS:
         cancelAllMissedCalls(this);
diff --git a/java/com/android/dialer/app/calllog/GroupingListAdapter.java b/java/com/android/dialer/app/calllog/GroupingListAdapter.java
index e1a395e..01250ab 100644
--- a/java/com/android/dialer/app/calllog/GroupingListAdapter.java
+++ b/java/com/android/dialer/app/calllog/GroupingListAdapter.java
@@ -21,6 +21,7 @@
 import android.database.Cursor;
 import android.database.DataSetObserver;
 import android.os.Handler;
+import android.os.Looper;
 import android.util.SparseIntArray;
 
 import androidx.recyclerview.widget.RecyclerView;
@@ -35,7 +36,7 @@
 abstract class GroupingListAdapter extends RecyclerView.Adapter {
 
   protected final ContentObserver changeObserver =
-      new ContentObserver(new Handler()) {
+      new ContentObserver(new Handler(Looper.getMainLooper())) {
         @Override
         public boolean deliverSelfNotifications() {
           return true;
diff --git a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
index c92177e..47d97aa 100644
--- a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
+++ b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
@@ -174,7 +174,7 @@
   @NonNull
   private static String getNotificationTag(
       @NonNull Context context, @NonNull PhoneAccountHandle phoneAccountHandle) {
-    if (context.getSystemService(TelephonyManager.class).getPhoneCount() <= 1) {
+    if (context.getSystemService(TelephonyManager.class).getActiveModemCount() <= 1) {
       return NOTIFICATION_TAG;
     }
 
diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java
index 0e75aee..d9c848a 100644
--- a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java
+++ b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java
@@ -210,7 +210,7 @@
     if (getActivity() != null) {
       getActivity().setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
       // onNotVisible will be called in the lock screen when the call ends
-      if (!getActivity().getSystemService(KeyguardManager.class).inKeyguardRestrictedInputMode()) {
+      if (!getActivity().getSystemService(KeyguardManager.class).isKeyguardLocked()) {
         LogUtil.i("VisualVoicemailCallLogFragment.onNotVisible", "clearing all new voicemails");
         CallLogNotificationsService.markAllNewVoicemailsAsOld(getActivity());
       }
diff --git a/java/com/android/dialer/app/contactinfo/ContactInfoCache.java b/java/com/android/dialer/app/contactinfo/ContactInfoCache.java
index 702bacb..0121eeb 100644
--- a/java/com/android/dialer/app/contactinfo/ContactInfoCache.java
+++ b/java/com/android/dialer/app/contactinfo/ContactInfoCache.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,6 +18,7 @@
 package com.android.dialer.app.contactinfo;
 
 import android.os.Handler;
+import android.os.Looper;
 import android.os.Message;
 import android.os.SystemClock;
 import android.text.TextUtils;
@@ -66,6 +68,7 @@
     private final WeakReference<ContactInfoCache> contactInfoCacheWeakReference;
 
     public InnerHandler(WeakReference<ContactInfoCache> contactInfoCacheWeakReference) {
+      super(Looper.getMainLooper());
       this.contactInfoCacheWeakReference = contactInfoCacheWeakReference;
     }
 
diff --git a/java/com/android/dialer/app/settings/SoundSettingsFragment.java b/java/com/android/dialer/app/settings/SoundSettingsFragment.java
index b274339..8e12149 100644
--- a/java/com/android/dialer/app/settings/SoundSettingsFragment.java
+++ b/java/com/android/dialer/app/settings/SoundSettingsFragment.java
@@ -56,7 +56,7 @@
 
   private Preference ringtonePreference;
   private final Handler ringtoneLookupComplete =
-      new Handler() {
+      new Handler(Looper.getMainLooper()) {
         @Override
         public void handleMessage(Message msg) {
           switch (msg.what) {
diff --git a/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java b/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java
index 9f7c185..fb75ef1 100644
--- a/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java
+++ b/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java
@@ -55,7 +55,8 @@
     LogUtil.i(
         "LegacyVoicemailNotificationReceiver.onReceive", "received legacy voicemail notification");
     PhoneAccountHandle phoneAccountHandle =
-        Assert.isNotNull(intent.getParcelableExtra(TelephonyManager.EXTRA_PHONE_ACCOUNT_HANDLE));
+        Assert.isNotNull(intent.getParcelableExtra(TelephonyManager.EXTRA_PHONE_ACCOUNT_HANDLE,
+                PhoneAccountHandle.class));
     int count = intent.getIntExtra(TelephonyManager.EXTRA_NOTIFICATION_COUNT, -1);
 
     boolean isRefresh = intent.getBooleanExtra(TelephonyManagerCompat.EXTRA_IS_REFRESH, false);
@@ -98,9 +99,11 @@
 
     String voicemailNumber = intent.getStringExtra(TelephonyManager.EXTRA_VOICEMAIL_NUMBER);
     PendingIntent callVoicemailIntent =
-        intent.getParcelableExtra(TelephonyManager.EXTRA_CALL_VOICEMAIL_INTENT);
+        intent.getParcelableExtra(TelephonyManager.EXTRA_CALL_VOICEMAIL_INTENT,
+                PendingIntent.class);
     PendingIntent voicemailSettingIntent =
-        intent.getParcelableExtra(TelephonyManager.EXTRA_LAUNCH_VOICEMAIL_SETTINGS_INTENT);
+        intent.getParcelableExtra(TelephonyManager.EXTRA_LAUNCH_VOICEMAIL_SETTINGS_INTENT,
+                PendingIntent.class);
 
     LogUtil.i("LegacyVoicemailNotificationReceiver.onReceive", "sending notification");
     LegacyVoicemailNotifier.showNotification(
diff --git a/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java b/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java
index c469d3c..40d9e7b 100644
--- a/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java
+++ b/java/com/android/dialer/app/voicemail/VoicemailErrorManager.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +21,7 @@
 import android.database.ContentObserver;
 import android.database.Cursor;
 import android.os.Handler;
+import android.os.Looper;
 import android.telecom.PhoneAccountHandle;
 import android.telephony.PhoneStateListener;
 import android.telephony.ServiceState;
@@ -55,7 +57,7 @@
   private final Map<PhoneAccountHandle, ServiceStateListener> listeners = new ArrayMap<>();
 
   private final ContentObserver statusObserver =
-      new ContentObserver(new Handler()) {
+      new ContentObserver(new Handler(Looper.getMainLooper())) {
         @Override
         public void onChange(boolean selfChange) {
           super.onChange(selfChange);
diff --git a/java/com/android/dialer/callintent/CallIntent.java b/java/com/android/dialer/callintent/CallIntent.java
index ac722b3..dc875cc 100644
--- a/java/com/android/dialer/callintent/CallIntent.java
+++ b/java/com/android/dialer/callintent/CallIntent.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -210,7 +211,7 @@
         public CallIntent createFromParcel(Parcel source) {
           CallIntent.Builder callIntentBuilder = builder();
           ClassLoader classLoader = CallIntent.class.getClassLoader();
-          callIntentBuilder.setNumber(source.readParcelable(classLoader));
+          callIntentBuilder.setNumber(source.readParcelable(classLoader, Uri.class));
           CallSpecificAppData data;
           try {
             data = CallSpecificAppData.parseFrom(source.createByteArray());
@@ -219,7 +220,7 @@
           }
           callIntentBuilder
               .setCallSpecificAppData(data)
-              .setPhoneAccountHandle(source.readParcelable(classLoader))
+              .setPhoneAccountHandle(source.readParcelable(classLoader, PhoneAccountHandle.class))
               .setIsVideoCall(source.readInt() != 0)
               .setCallSubject(source.readString())
               .setAllowAssistedDial(source.readInt() != 0);
diff --git a/java/com/android/dialer/callintent/CallIntentBuilder.java b/java/com/android/dialer/callintent/CallIntentBuilder.java
index 4e93e30..8567cc3 100644
--- a/java/com/android/dialer/callintent/CallIntentBuilder.java
+++ b/java/com/android/dialer/callintent/CallIntentBuilder.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -75,7 +76,7 @@
 
   public CallIntentBuilder(@NonNull Parcel parcel) {
     ClassLoader classLoader = CallIntentBuilder.class.getClassLoader();
-    uri = parcel.readParcelable(classLoader);
+    uri = parcel.readParcelable(classLoader, Uri.class);
     CallSpecificAppData data;
     try {
       data = CallSpecificAppData.parseFrom(parcel.createByteArray());
@@ -83,7 +84,7 @@
       data = createCallSpecificAppData(Type.UNKNOWN_INITIATION);
     }
     callSpecificAppData = data;
-    phoneAccountHandle = parcel.readParcelable(classLoader);
+    phoneAccountHandle = parcel.readParcelable(classLoader, PhoneAccountHandle.class);
     isVideoCall = parcel.readInt() != 0;
     callSubject = parcel.readString();
     allowAssistedDial = parcel.readInt() != 0;
diff --git a/java/com/android/dialer/callrecord/impl/CallRecorderService.java b/java/com/android/dialer/callrecord/impl/CallRecorderService.java
index 5681925..9940956 100644
--- a/java/com/android/dialer/callrecord/impl/CallRecorderService.java
+++ b/java/com/android/dialer/callrecord/impl/CallRecorderService.java
@@ -123,7 +123,7 @@
 
     if (DBG) Log.d(TAG, "Starting recording");
 
-    mMediaRecorder = new MediaRecorder();
+    mMediaRecorder = new MediaRecorder(getApplicationContext());
     try {
       int audioSource = getAudioSource();
       int formatChoice = getAudioFormatChoice();
diff --git a/java/com/android/dialer/callstats/CallStatsDetailActivity.java b/java/com/android/dialer/callstats/CallStatsDetailActivity.java
index 4c36e81..5d18de8 100644
--- a/java/com/android/dialer/callstats/CallStatsDetailActivity.java
+++ b/java/com/android/dialer/callstats/CallStatsDetailActivity.java
@@ -167,8 +167,8 @@
         R.string.call_stats_outgoing, Calls.OUTGOING_TYPE);
 
     Intent launchIntent = getIntent();
-    mData = (CallStatsDetails) launchIntent.getParcelableExtra(EXTRA_DETAILS);
-    mTotalData = (CallStatsDetails) launchIntent.getParcelableExtra(EXTRA_TOTAL);
+    mData = launchIntent.getParcelableExtra(EXTRA_DETAILS, CallStatsDetails.class);
+    mTotalData = launchIntent.getParcelableExtra(EXTRA_TOTAL, CallStatsDetails.class);
     updateData();
 
     TextView dateFilterView = (TextView) findViewById(R.id.date_filter);
diff --git a/java/com/android/dialer/callstats/CallStatsFragment.java b/java/com/android/dialer/callstats/CallStatsFragment.java
index 4ce5f8f..95f7df4 100644
--- a/java/com/android/dialer/callstats/CallStatsFragment.java
+++ b/java/com/android/dialer/callstats/CallStatsFragment.java
@@ -26,6 +26,7 @@
 import android.database.ContentObserver;
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.Looper;
 import android.provider.CallLog;
 import android.provider.ContactsContract;
 import android.telecom.PhoneAccountHandle;
@@ -81,7 +82,8 @@
   private boolean mHasReadCallLogPermission = false;
 
   private boolean mRefreshDataRequired = true;
-  private final ContentObserver mObserver = new ContentObserver(new Handler()) {
+  private final ContentObserver mObserver = new ContentObserver(
+          new Handler(Looper.getMainLooper())) {
     @Override
     public void onChange(boolean selfChange) {
       mRefreshDataRequired = true;
diff --git a/java/com/android/dialer/common/PackageUtils.java b/java/com/android/dialer/common/PackageUtils.java
index 1944a85..fe32d36 100644
--- a/java/com/android/dialer/common/PackageUtils.java
+++ b/java/com/android/dialer/common/PackageUtils.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,8 +30,9 @@
     Assert.isNotNull(packageName);
     Assert.isNotNull(context);
     try {
-      PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0);
-      if (info != null && info.packageName != null) {
+      PackageInfo info = context.getPackageManager().getPackageInfo(packageName,
+              PackageManager.PackageInfoFlags.of(0));
+      if (info.packageName != null) {
         LogUtil.d("PackageUtils.isPackageInstalled", packageName + " is found");
         return true;
       }
diff --git a/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java b/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
index 4519ba1..d50febf 100644
--- a/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
+++ b/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
@@ -94,7 +94,7 @@
     if (telephonyManager == null) {
       return 1;
     }
-    return telephonyManager.getPhoneCount();
+    return telephonyManager.getActiveModemCount();
   }
 
   /**
diff --git a/java/com/android/dialer/contactphoto/ContactPhotoManagerImpl.java b/java/com/android/dialer/contactphoto/ContactPhotoManagerImpl.java
index eaf197d..7f2905e 100644
--- a/java/com/android/dialer/contactphoto/ContactPhotoManagerImpl.java
+++ b/java/com/android/dialer/contactphoto/ContactPhotoManagerImpl.java
@@ -38,6 +38,7 @@
 import android.os.Handler;
 import android.os.Handler.Callback;
 import android.os.HandlerThread;
+import android.os.Looper;
 import android.os.Message;
 import android.provider.ContactsContract;
 import android.provider.ContactsContract.Contacts;
@@ -133,7 +134,7 @@
   private final ConcurrentHashMap<ImageView, Request> pendingRequests =
       new ConcurrentHashMap<ImageView, Request>();
   /** Handler for messages sent to the UI thread. */
-  private final Handler mainThreadHandler = new Handler(this);
+  private final Handler mainThreadHandler = new Handler(Looper.getMainLooper(), this);
   /** For debug: How many times we had to reload cached photo for a stale entry */
   private final AtomicInteger staleCacheOverwrite = new AtomicInteger();
   /** For debug: How many times we had to reload cached photo for a fresh entry. Should be 0. */
diff --git a/java/com/android/dialer/dialpadview/DialpadFragment.java b/java/com/android/dialer/dialpadview/DialpadFragment.java
index 6fdbbdc..c3bd2bc 100644
--- a/java/com/android/dialer/dialpadview/DialpadFragment.java
+++ b/java/com/android/dialer/dialpadview/DialpadFragment.java
@@ -1071,10 +1071,8 @@
         } else if (getActivity() != null) {
           // Voicemail is unavailable maybe because Airplane mode is turned on.
           // Check the current status and show the most appropriate error message.
-          final boolean isAirplaneModeOn =
-              Settings.System.getInt(
-                      getActivity().getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0)
-                  != 0;
+          final boolean isAirplaneModeOn = Settings.Global.getInt(
+                  getActivity().getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
           if (isAirplaneModeOn) {
             DialogFragment dialogFragment =
                 ErrorDialogFragment.newInstance(R.string.dialog_voicemail_airplane_mode_message);
@@ -1389,7 +1387,8 @@
   public boolean onMenuItemClick(MenuItem item) {
     if (item.getGroupId() == Menu.FIRST) {
       Intent intent = item.getIntent();
-      selectedAccount = intent.getParcelableExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
+      selectedAccount = intent.getParcelableExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE,
+              PhoneAccountHandle.class);
       return true;
     }
     int resId = item.getItemId();
diff --git a/java/com/android/dialer/dialpadview/PseudoEmergencyAnimator.java b/java/com/android/dialer/dialpadview/PseudoEmergencyAnimator.java
index f3442e6..aaa65d0 100644
--- a/java/com/android/dialer/dialpadview/PseudoEmergencyAnimator.java
+++ b/java/com/android/dialer/dialpadview/PseudoEmergencyAnimator.java
@@ -25,6 +25,7 @@
 import android.graphics.ColorFilter;
 import android.graphics.LightingColorFilter;
 import android.os.Handler;
+import android.os.Looper;
 import android.os.Vibrator;
 import android.view.View;
 
@@ -92,7 +93,7 @@
                   viewProvider.getFab().getBackground().clearColorFilter();
                 }
 
-                new Handler()
+                new Handler(Looper.getMainLooper())
                     .postDelayed(
                         () -> {
                           try {
diff --git a/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java b/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java
index 157b1cf..616df5a 100644
--- a/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java
+++ b/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java
@@ -178,7 +178,7 @@
     // accessed from the emergency dialer.
     KeyguardManager keyguardManager =
         (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
-    if (keyguardManager.inKeyguardRestrictedInputMode()) {
+    if (keyguardManager.isKeyguardLocked()) {
       return false;
     }
 
@@ -321,14 +321,18 @@
       ViewGroup holder = customView.findViewById(R.id.deviceids_holder);
 
       if (TelephonyManagerCompat.getPhoneCount(telephonyManager) > 1) {
-        for (int slot = 0; slot < telephonyManager.getPhoneCount(); slot++) {
-          String deviceId = telephonyManager.getDeviceId(slot);
+        for (int slot = 0; slot < telephonyManager.getActiveModemCount(); slot++) {
+          String deviceId = telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM
+                  ? telephonyManager.getImei(slot)
+                  : telephonyManager.getMeid(slot);
           if (!TextUtils.isEmpty(deviceId)) {
             addDeviceIdRow(holder, deviceId);
           }
         }
       } else {
-        addDeviceIdRow(holder, telephonyManager.getDeviceId());
+        addDeviceIdRow(holder, telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM
+                ? telephonyManager.getImei()
+                : telephonyManager.getMeid());
       }
 
       new AlertDialog.Builder(context)
diff --git a/java/com/android/dialer/interactions/PhoneNumberInteraction.java b/java/com/android/dialer/interactions/PhoneNumberInteraction.java
index a38ba29..98c6864 100644
--- a/java/com/android/dialer/interactions/PhoneNumberInteraction.java
+++ b/java/com/android/dialer/interactions/PhoneNumberInteraction.java
@@ -523,7 +523,7 @@
       final Activity activity = getActivity();
       Assert.checkState(activity instanceof DisambigDialogDismissedListener);
 
-      phoneList = getArguments().getParcelableArrayList(ARG_PHONE_LIST);
+      phoneList = getArguments().getParcelableArrayList(ARG_PHONE_LIST, PhoneItem.class);
       interactionType = getArguments().getInt(ARG_INTERACTION_TYPE);
       isVideoCall = getArguments().getBoolean(ARG_IS_VIDEO_CALL);
       callSpecificAppData = CallIntentParser.getCallSpecificAppData(getArguments());
diff --git a/java/com/android/dialer/location/CountryDetector.java b/java/com/android/dialer/location/CountryDetector.java
index e198030..a50e232 100644
--- a/java/com/android/dialer/location/CountryDetector.java
+++ b/java/com/android/dialer/location/CountryDetector.java
@@ -209,7 +209,7 @@
       }
 
       final Location location =
-          (Location) intent.getExtras().get(LocationManager.KEY_LOCATION_CHANGED);
+              intent.getParcelableExtra(LocationManager.KEY_LOCATION_CHANGED, Location.class);
 
       // TODO: rething how we access the gecoder here, right now we have to set the static instance
       // of CountryDetector to make this work for tests which is weird
diff --git a/java/com/android/dialer/lookup/LookupProvider.java b/java/com/android/dialer/lookup/LookupProvider.java
index 3061b55..ba8c2b6 100644
--- a/java/com/android/dialer/lookup/LookupProvider.java
+++ b/java/com/android/dialer/lookup/LookupProvider.java
@@ -18,25 +18,18 @@
 package com.android.dialer.lookup;
 
 import android.content.ContentProvider;
-import android.content.ContentResolver;
 import android.content.ContentValues;
-import android.content.Context;
 import android.content.UriMatcher;
 import android.database.Cursor;
 import android.database.MatrixCursor;
-import android.location.Criteria;
 import android.location.Location;
-import android.location.LocationListener;
 import android.location.LocationManager;
 import android.net.Uri;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
+import android.os.CancellationSignal;
 import android.os.ParcelFileDescriptor;
 import android.provider.ContactsContract;
 import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
 import android.provider.ContactsContract.Contacts;
-import android.provider.Settings;
 import android.util.Log;
 
 import com.android.dialer.searchfragment.common.Projections;
@@ -55,6 +48,7 @@
 import java.util.concurrent.Callable;
 import java.util.concurrent.CancellationException;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
 import java.util.concurrent.FutureTask;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.TimeUnit;
@@ -233,15 +227,8 @@
    * @return Whether location services are enabled
    */
   private boolean isLocationEnabled() {
-    try {
-      int mode = Settings.Secure.getInt(getContext().getContentResolver(),
-          Settings.Secure.LOCATION_MODE);
-
-      return mode != Settings.Secure.LOCATION_MODE_OFF;
-    } catch (Settings.SettingNotFoundException e) {
-      Log.e(TAG, "Failed to get location mode", e);
-      return false;
-    }
+      LocationManager locationManager = requireContext().getSystemService(LocationManager.class);
+      return locationManager.isLocationEnabled();
   }
 
   /**
@@ -250,26 +237,11 @@
    * @return The last location
    */
   private Location getLastLocation() {
-    LocationManager locationManager = getContext().getSystemService(LocationManager.class);
+    LocationManager locationManager = requireContext().getSystemService(LocationManager.class);
 
     try {
-      locationManager.requestSingleUpdate(new Criteria(), new LocationListener() {
-        @Override
-        public void onLocationChanged(Location location) {
-        }
-
-        @Override
-        public void onProviderDisabled(String provider) {
-        }
-
-        @Override
-        public void onProviderEnabled(String provider) {
-        }
-
-        @Override
-        public void onStatusChanged(String provider, int status, Bundle extras) {
-        }
-      }, Looper.getMainLooper());
+      locationManager.getCurrentLocation(LocationManager.FUSED_PROVIDER, new CancellationSignal(),
+              Executors.newSingleThreadExecutor(), location -> {});
 
       return locationManager.getLastKnownLocation(LocationManager.FUSED_PROVIDER);
     } catch (IllegalArgumentException e) {
diff --git a/java/com/android/dialer/lookup/LookupUtils.java b/java/com/android/dialer/lookup/LookupUtils.java
index b6e4533..47271c6 100644
--- a/java/com/android/dialer/lookup/LookupUtils.java
+++ b/java/com/android/dialer/lookup/LookupUtils.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2014 The CyanogenMod Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -163,6 +164,6 @@
     if (input == null) {
       return null;
     }
-    return Html.fromHtml(input).toString().trim();
+    return Html.fromHtml(input, Html.FROM_HTML_MODE_LEGACY).toString().trim();
   }
 }
diff --git a/java/com/android/dialer/lookup/ReverseLookupService.java b/java/com/android/dialer/lookup/ReverseLookupService.java
index 02e873b..647ca5b 100644
--- a/java/com/android/dialer/lookup/ReverseLookupService.java
+++ b/java/com/android/dialer/lookup/ReverseLookupService.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2014 Xiao-Long Chen <chillermillerlong@hotmail.com>
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
 import android.net.Uri;
 import android.os.Handler;
 import android.os.HandlerThread;
+import android.os.Looper;
 import android.os.Message;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.TelephonyManager;
@@ -51,7 +53,7 @@
     backgroundThread.start();
 
     backgroundHandler = new Handler(backgroundThread.getLooper(), this);
-    handler = new Handler(this);
+    handler = new Handler(Looper.getMainLooper(), this);
   }
 
   @Override
diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java
index fc068d1..d27c4eb 100644
--- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java
+++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java
@@ -27,6 +27,7 @@
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.Looper;
 import android.provider.CallLog.Calls;
 import android.provider.ContactsContract.QuickContact;
 import android.provider.VoicemailContract;
@@ -733,7 +734,7 @@
     private boolean activityIsAlive;
 
     private final ContentObserver voicemailStatusObserver =
-        new ContentObserver(new Handler()) {
+        new ContentObserver(new Handler(Looper.getMainLooper())) {
           @Override
           public void onChange(boolean selfChange) {
             LogUtil.i(
diff --git a/java/com/android/dialer/notification/VoicemailChannelUtils.java b/java/com/android/dialer/notification/VoicemailChannelUtils.java
index 763da0c..ac41cf6 100644
--- a/java/com/android/dialer/notification/VoicemailChannelUtils.java
+++ b/java/com/android/dialer/notification/VoicemailChannelUtils.java
@@ -225,7 +225,7 @@
     if (!PermissionsUtil.hasReadPhoneStatePermissions(context)) {
       return true;
     }
-    return context.getSystemService(TelephonyManager.class).getPhoneCount() <= 1;
+    return context.getSystemService(TelephonyManager.class).getActiveModemCount() <= 1;
   }
 
   private VoicemailChannelUtils() {}
diff --git a/java/com/android/dialer/oem/CequintPackageUtils.java b/java/com/android/dialer/oem/CequintPackageUtils.java
index 5ff501d..010d54d 100644
--- a/java/com/android/dialer/oem/CequintPackageUtils.java
+++ b/java/com/android/dialer/oem/CequintPackageUtils.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -241,7 +242,8 @@
     }
 
     ProviderInfo providerInfo =
-        packageManager.resolveContentProvider(authority, PackageManager.GET_META_DATA);
+        packageManager.resolveContentProvider(authority,
+                PackageManager.ComponentInfoFlags.of(PackageManager.GET_META_DATA));
     if (providerInfo == null) {
       LogUtil.d(
           "CequintPackageUtils.isCallerIdInstalled",
@@ -262,9 +264,10 @@
 
     try {
       PackageInfo packageInfo =
-          packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
+          packageManager.getPackageInfo(packageName,
+                  PackageManager.PackageInfoFlags.of(PackageManager.GET_SIGNING_CERTIFICATES));
 
-      Signature[] signatures = packageInfo.signatures;
+      Signature[] signatures = packageInfo.signingInfo.getSigningCertificateHistory();
       if (signatures.length > 1) {
         LogUtil.w(
             "CequintPackageUtils.isCallerIdInstalled", "package has more than one signature.");
diff --git a/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java b/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java
index 508ad3d..2453a76 100644
--- a/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java
+++ b/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java
@@ -21,6 +21,7 @@
 import android.content.ActivityNotFoundException;
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import com.android.dialer.common.LogUtil;
 import java.util.ArrayList;
@@ -157,7 +158,8 @@
       intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
       intent.putExtra(EXTRA_HIDDEN_MENU_CODE, input);
 
-      ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, 0);
+      ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent,
+              PackageManager.ResolveInfoFlags.of(0));
 
       if (resolveInfo != null
           && resolveInfo.activityInfo != null
diff --git a/java/com/android/dialer/phonelookup/cequint/CequintPhoneLookup.java b/java/com/android/dialer/phonelookup/cequint/CequintPhoneLookup.java
index b045d03..4426eb8 100644
--- a/java/com/android/dialer/phonelookup/cequint/CequintPhoneLookup.java
+++ b/java/com/android/dialer/phonelookup/cequint/CequintPhoneLookup.java
@@ -70,7 +70,7 @@
                   TelecomCallUtil.getNumber(call), GeoUtil.getCurrentCountryIso(appContext));
             });
     String callerDisplayName = call.getDetails().getCallerDisplayName();
-    boolean isIncomingCall = (call.getState() == Call.STATE_RINGING);
+    boolean isIncomingCall = (call.getDetails().getState() == Call.STATE_RINGING);
 
     return Futures.transformAsync(
         dialerPhoneNumberFuture,
diff --git a/java/com/android/dialer/postcall/PostCallActivity.java b/java/com/android/dialer/postcall/PostCallActivity.java
index 0b76caf..000ee54 100644
--- a/java/com/android/dialer/postcall/PostCallActivity.java
+++ b/java/com/android/dialer/postcall/PostCallActivity.java
@@ -97,7 +97,7 @@
       finish();
     } else if (PermissionsUtil.hasPermission(this, permission.SEND_SMS)) {
       LogUtil.i("PostCallActivity.sendMessage", "Sending post call SMS.");
-      SmsManager smsManager = SmsManager.getDefault();
+      SmsManager smsManager = getSystemService(SmsManager.class);
       smsManager.sendMultipartTextMessage(
           number, null, smsManager.divideMessage(message), null, null);
       PostCall.onMessageSent(this, number);
diff --git a/java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java b/java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java
index 359bd81..4aed1a5 100644
--- a/java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java
+++ b/java/com/android/dialer/precall/externalreceiver/LaunchPreCallActivity.java
@@ -69,9 +69,11 @@
     Intent intent = getIntent();
     CallIntentBuilder builder = new CallIntentBuilder(intent.getData(), Type.EXTERNAL_INITIATION);
 
-    PhoneAccountHandle phoneAccountHandle = intent.getParcelableExtra(EXTRA_PHONE_ACCOUNT_HANDLE);
+    PhoneAccountHandle phoneAccountHandle = intent.getParcelableExtra(EXTRA_PHONE_ACCOUNT_HANDLE,
+            PhoneAccountHandle.class);
     if (phoneAccountHandle == null) {
-      phoneAccountHandle = intent.getParcelableExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
+      phoneAccountHandle = intent.getParcelableExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE,
+              PhoneAccountHandle.class);
     }
 
     builder
@@ -125,7 +127,8 @@
 
     if (intentExtras.containsKey(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE)) {
       builder.setPhoneAccountHandle(
-          intentExtras.getParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE));
+          intentExtras.getParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE,
+                  PhoneAccountHandle.class));
     }
 
     if (intentExtras.containsKey(TelecomManager.EXTRA_CALL_SUBJECT)) {
diff --git a/java/com/android/dialer/precall/impl/CallingAccountSelector.java b/java/com/android/dialer/precall/impl/CallingAccountSelector.java
index 4fd8f33..46cac7f 100644
--- a/java/com/android/dialer/precall/impl/CallingAccountSelector.java
+++ b/java/com/android/dialer/precall/impl/CallingAccountSelector.java
@@ -22,7 +22,7 @@
 import android.telecom.PhoneAccount;
 import android.telecom.PhoneAccountHandle;
 import android.telecom.TelecomManager;
-import android.telephony.PhoneNumberUtils;
+import android.telephony.TelephonyManager;
 
 import androidx.annotation.MainThread;
 import androidx.annotation.NonNull;
@@ -69,16 +69,15 @@
     if (builder.getPhoneAccountHandle() != null) {
       return false;
     }
-    if (PhoneNumberUtils.isEmergencyNumber(builder.getUri().getSchemeSpecificPart())) {
+
+    TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class);
+    if (telephonyManager.isEmergencyNumber(builder.getUri().getSchemeSpecificPart())) {
       return false;
     }
 
     TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
     List<PhoneAccountHandle> accounts = telecomManager.getCallCapablePhoneAccounts();
-    if (accounts.size() <= 1) {
-      return false;
-    }
-    return true;
+    return accounts.size() > 1;
   }
 
   @Override
diff --git a/java/com/android/dialer/precall/impl/PermissionCheckAction.java b/java/com/android/dialer/precall/impl/PermissionCheckAction.java
index 85e9ceb..9377c25 100644
--- a/java/com/android/dialer/precall/impl/PermissionCheckAction.java
+++ b/java/com/android/dialer/precall/impl/PermissionCheckAction.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,14 +22,14 @@
 import com.android.dialer.callintent.CallIntentBuilder;
 import com.android.dialer.precall.PreCallAction;
 import com.android.dialer.precall.PreCallCoordinator;
-import com.android.dialer.telecom.TelecomUtil;
+import com.android.dialer.util.PermissionsUtil;
 
 /** Aborts call and show a toast if phone permissions are missing. */
 public class PermissionCheckAction implements PreCallAction {
 
   @Override
   public boolean requiresUi(Context context, CallIntentBuilder builder) {
-    return !TelecomUtil.hasCallPhonePermission(context);
+    return !PermissionsUtil.hasPhonePermissions(context);
   }
 
   @Override
diff --git a/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java b/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java
index 18ac29c..476202b 100644
--- a/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java
+++ b/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java
@@ -69,9 +69,11 @@
     LogUtil.enterBlock("PreCallCoordinatorImpl.onCreate");
     if (savedInstanceState != null) {
       currentActionIndex = savedInstanceState.getInt(SAVED_STATE_CURRENT_ACTION);
-      builder = Assert.isNotNull(savedInstanceState.getParcelable(EXTRA_CALL_INTENT_BUILDER));
+      builder = Assert.isNotNull(savedInstanceState.getParcelable(EXTRA_CALL_INTENT_BUILDER,
+              CallIntentBuilder.class));
     } else {
-      builder = Assert.isNotNull(intent.getParcelableExtra(EXTRA_CALL_INTENT_BUILDER));
+      builder = Assert.isNotNull(intent.getParcelableExtra(EXTRA_CALL_INTENT_BUILDER,
+              CallIntentBuilder.class));
     }
     uiListener =
         DialerExecutorComponent.get(activity)
@@ -81,7 +83,7 @@
 
   void onRestoreInstanceState(Bundle savedInstanceState) {
     currentActionIndex = savedInstanceState.getInt(SAVED_STATE_CURRENT_ACTION);
-    builder = savedInstanceState.getParcelable(EXTRA_CALL_INTENT_BUILDER);
+    builder = savedInstanceState.getParcelable(EXTRA_CALL_INTENT_BUILDER, CallIntentBuilder.class);
   }
 
   void onResume() {
diff --git a/java/com/android/dialer/preferredsim/impl/PreferredAccountWorkerImpl.java b/java/com/android/dialer/preferredsim/impl/PreferredAccountWorkerImpl.java
index 527baa4..0302232 100644
--- a/java/com/android/dialer/preferredsim/impl/PreferredAccountWorkerImpl.java
+++ b/java/com/android/dialer/preferredsim/impl/PreferredAccountWorkerImpl.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -334,10 +335,9 @@
     Assert.isWorkerThread();
 
     Intent quickContactIntent = getQuickContactIntent();
-    ResolveInfo resolveInfo =
-        context
-            .getPackageManager()
-            .resolveActivity(quickContactIntent, PackageManager.GET_META_DATA);
+    ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(
+            quickContactIntent,
+            PackageManager.ResolveInfoFlags.of(PackageManager.GET_META_DATA));
     if (resolveInfo == null
         || resolveInfo.activityInfo == null
         || resolveInfo.activityInfo.applicationInfo == null
diff --git a/java/com/android/dialer/searchfragment/cp2/ContactFilterCursor.java b/java/com/android/dialer/searchfragment/cp2/ContactFilterCursor.java
index 6cc57b9..3a6c702 100644
--- a/java/com/android/dialer/searchfragment/cp2/ContactFilterCursor.java
+++ b/java/com/android/dialer/searchfragment/cp2/ContactFilterCursor.java
@@ -480,12 +480,12 @@
 
   @Override
   public void deactivate() {
-    cursor.deactivate();
+
   }
 
   @Override
   public boolean requery() {
-    return cursor.requery();
+    return false;
   }
 
   @Override
diff --git a/java/com/android/dialer/shortcuts/CallContactActivity.java b/java/com/android/dialer/shortcuts/CallContactActivity.java
index 0874752..87fe5e6 100644
--- a/java/com/android/dialer/shortcuts/CallContactActivity.java
+++ b/java/com/android/dialer/shortcuts/CallContactActivity.java
@@ -120,7 +120,7 @@
     if (savedInstanceState == null) {
       return;
     }
-    contactUri = savedInstanceState.getParcelable(CONTACT_URI_KEY);
+    contactUri = savedInstanceState.getParcelable(CONTACT_URI_KEY, Uri.class);
   }
 
   @Override
diff --git a/java/com/android/dialer/simulator/impl/SimulatorConnection.java b/java/com/android/dialer/simulator/impl/SimulatorConnection.java
index 6c73447..d813373 100644
--- a/java/com/android/dialer/simulator/impl/SimulatorConnection.java
+++ b/java/com/android/dialer/simulator/impl/SimulatorConnection.java
@@ -50,7 +50,8 @@
         CAPABILITY_MUTE
             | CAPABILITY_SUPPORT_HOLD
             | CAPABILITY_HOLD
-            | CAPABILITY_CAN_UPGRADE_TO_VIDEO
+            | CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL
+            | CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL
             | CAPABILITY_DISCONNECT_FROM_CONFERENCE);
 
     if (request.getExtras() != null) {
diff --git a/java/com/android/dialer/simulator/impl/SimulatorRemoteVideo.java b/java/com/android/dialer/simulator/impl/SimulatorRemoteVideo.java
index 060e629..96a2826 100644
--- a/java/com/android/dialer/simulator/impl/SimulatorRemoteVideo.java
+++ b/java/com/android/dialer/simulator/impl/SimulatorRemoteVideo.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
 import android.graphics.Paint;
 import android.os.Handler;
 import android.os.HandlerThread;
+import android.os.Looper;
 import android.view.Surface;
 
 import androidx.annotation.NonNull;
@@ -78,7 +80,7 @@
     @WorkerThread
     void schedule() {
       Assert.isWorkerThread();
-      new Handler().postDelayed(this, FRAME_DELAY_MILLIS);
+      new Handler(Looper.getMainLooper()).postDelayed(this, FRAME_DELAY_MILLIS);
     }
 
     @WorkerThread
diff --git a/java/com/android/dialer/telecom/TelecomUtil.java b/java/com/android/dialer/telecom/TelecomUtil.java
index cb769b9..6e21860 100644
--- a/java/com/android/dialer/telecom/TelecomUtil.java
+++ b/java/com/android/dialer/telecom/TelecomUtil.java
@@ -18,7 +18,6 @@
 package com.android.dialer.telecom;
 
 import android.app.role.RoleManager;
-import android.Manifest;
 import android.Manifest.permission;
 import android.content.ComponentName;
 import android.content.Context;
@@ -41,6 +40,7 @@
 import androidx.core.content.ContextCompat;
 
 import com.android.dialer.common.LogUtil;
+import com.android.dialer.util.PermissionsUtil;
 import com.google.common.base.Optional;
 
 import java.util.ArrayList;
@@ -70,7 +70,7 @@
       new ConcurrentHashMap<>();
 
   public static void showInCallScreen(Context context, boolean showDialpad) {
-    if (hasReadPhoneStatePermission(context)) {
+    if (PermissionsUtil.hasReadPhoneStatePermissions(context)) {
       try {
         getTelecomManager(context).showInCallScreen(showDialpad);
       } catch (SecurityException e) {
@@ -81,7 +81,7 @@
   }
 
   public static void silenceRinger(Context context) {
-    if (hasModifyPhoneStatePermission(context)) {
+    if (PermissionsUtil.hasModifyPhoneStatePermissions(context)) {
       try {
         getTelecomManager(context).silenceRinger();
       } catch (SecurityException e) {
@@ -92,7 +92,7 @@
   }
 
   public static void cancelMissedCallsNotification(Context context) {
-    if (hasModifyPhoneStatePermission(context)) {
+    if (PermissionsUtil.hasModifyPhoneStatePermissions(context)) {
       try {
         getTelecomManager(context).cancelMissedCallsNotification();
       } catch (SecurityException e) {
@@ -102,7 +102,7 @@
   }
 
   public static Uri getAdnUriForPhoneAccount(Context context, PhoneAccountHandle handle) {
-    if (hasModifyPhoneStatePermission(context)) {
+    if (PermissionsUtil.hasModifyPhoneStatePermissions(context)) {
       try {
         return getTelecomManager(context).getAdnUriForPhoneAccount(handle);
       } catch (SecurityException e) {
@@ -114,7 +114,7 @@
 
   public static boolean handleMmi(
       Context context, String dialString, @Nullable PhoneAccountHandle handle) {
-    if (hasModifyPhoneStatePermission(context)) {
+    if (PermissionsUtil.hasModifyPhoneStatePermissions(context)) {
       try {
         if (handle == null) {
           return getTelecomManager(context).handleMmi(dialString);
@@ -131,7 +131,7 @@
   @Nullable
   public static PhoneAccountHandle getDefaultOutgoingPhoneAccount(
       Context context, String uriScheme) {
-    if (hasReadPhoneStatePermission(context)) {
+    if (PermissionsUtil.hasReadPhoneStatePermissions(context)) {
       return getTelecomManager(context).getDefaultOutgoingPhoneAccount(uriScheme);
     }
     return null;
@@ -142,7 +142,7 @@
   }
 
   public static List<PhoneAccountHandle> getCallCapablePhoneAccounts(Context context) {
-    if (hasReadPhoneStatePermission(context)) {
+    if (PermissionsUtil.hasReadPhoneStatePermissions(context)) {
       return Optional.fromNullable(getTelecomManager(context).getCallCapablePhoneAccounts())
           .or(new ArrayList<>());
     }
@@ -198,7 +198,7 @@
     if (TextUtils.isEmpty(phoneAccountHandle.getId())) {
       return Optional.absent();
     }
-    if (!hasPermission(context, permission.READ_PHONE_STATE)) {
+    if (!PermissionsUtil.hasReadPhoneStatePermissions(context)) {
       return Optional.absent();
     }
     SubscriptionManager subscriptionManager = context.getSystemService(SubscriptionManager.class);
@@ -242,7 +242,7 @@
       return isVoicemailNumberCache.get(cacheKey);
     }
     boolean result = false;
-    if (hasReadPhoneStatePermission(context)) {
+    if (PermissionsUtil.hasReadPhoneStatePermissions(context)) {
       result = getTelecomManager(context).isVoiceMailNumber(accountHandle, number);
     }
     isVoicemailNumberCache.put(cacheKey, result);
@@ -251,7 +251,7 @@
 
   @Nullable
   public static String getVoicemailNumber(Context context, PhoneAccountHandle accountHandle) {
-    if (hasReadPhoneStatePermission(context)) {
+    if (PermissionsUtil.hasReadPhoneStatePermissions(context)) {
       return getTelecomManager(context).getVoiceMailNumber(accountHandle);
     }
     return null;
@@ -266,7 +266,7 @@
    *     due to a permission check.
    */
   public static boolean placeCall(Context context, Intent intent) {
-    if (hasCallPhonePermission(context)) {
+    if (PermissionsUtil.hasPhonePermissions(context)) {
       getTelecomManager(context).placeCall(intent.getData(), intent.getExtras());
       return true;
     }
@@ -281,31 +281,8 @@
 
   public static boolean hasReadWriteVoicemailPermissions(Context context) {
     return isDefaultDialer(context)
-        || (hasPermission(context, Manifest.permission.READ_VOICEMAIL)
-            && hasPermission(context, Manifest.permission.WRITE_VOICEMAIL));
-  }
-
-  /** @deprecated use {@link com.android.dialer.util.PermissionsUtil} */
-  @Deprecated
-  public static boolean hasModifyPhoneStatePermission(Context context) {
-    return isDefaultDialer(context)
-        || hasPermission(context, Manifest.permission.MODIFY_PHONE_STATE);
-  }
-
-  /** @deprecated use {@link com.android.dialer.util.PermissionsUtil} */
-  @Deprecated
-  public static boolean hasReadPhoneStatePermission(Context context) {
-    return isDefaultDialer(context) || hasPermission(context, Manifest.permission.READ_PHONE_STATE);
-  }
-
-  /** @deprecated use {@link com.android.dialer.util.PermissionsUtil} */
-  @Deprecated
-  public static boolean hasCallPhonePermission(Context context) {
-    return isDefaultDialer(context) || hasPermission(context, Manifest.permission.CALL_PHONE);
-  }
-
-  private static boolean hasPermission(Context context, String permission) {
-    return instance.hasPermission(context, permission);
+        || (PermissionsUtil.hasReadVoicemailPermissions(context)
+            && PermissionsUtil.hasWriteVoicemailPermissions(context));
   }
 
   private static TelecomManager getTelecomManager(Context context) {
@@ -343,7 +320,7 @@
   private static class TelecomUtilImpl {
 
     public boolean isInManagedCall(Context context) {
-      if (hasReadPhoneStatePermission(context)) {
+      if (PermissionsUtil.hasReadPhoneStatePermissions(context)) {
         // The TelecomManager#isInCall method returns true anytime the user is in a call.
         // Starting in O, the APIs include support for self-managed ConnectionServices so that other
         // apps like Duo can tell Telecom about its calls.  So, if the user is in a Duo call,
@@ -358,7 +335,8 @@
     }
 
     public boolean isInCall(Context context) {
-      return hasReadPhoneStatePermission(context) && getTelecomManager(context).isInCall();
+      return PermissionsUtil.hasReadPhoneStatePermissions(context) &&
+              getTelecomManager(context).isInCall();
     }
 
     public boolean hasPermission(Context context, String permission) {
diff --git a/java/com/android/dialer/util/DialerUtils.java b/java/com/android/dialer/util/DialerUtils.java
index ff0ba4f..b877619 100644
--- a/java/com/android/dialer/util/DialerUtils.java
+++ b/java/com/android/dialer/util/DialerUtils.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2014 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -80,7 +81,8 @@
           Bundle extras;
           // Make sure to not accidentally clobber any existing extras
           if (intent.hasExtra(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS)) {
-            extras = intent.getParcelableExtra(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS);
+            extras = intent.getParcelableExtra(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS,
+                    Bundle.class);
           } else {
             extras = new Bundle();
           }
@@ -127,11 +129,11 @@
   @SuppressLint("MissingPermission")
   private static boolean shouldWarnForOutgoingWps(Context context, String number) {
     if (number != null && number.startsWith(WPS_PREFIX)) {
+      TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
       TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class);
       boolean isOnVolte =
           telephonyManager.getVoiceNetworkType() == TelephonyManager.NETWORK_TYPE_LTE;
-      boolean hasCurrentActiveCall =
-          telephonyManager.getCallState() == TelephonyManager.CALL_STATE_OFFHOOK;
+      boolean hasCurrentActiveCall = telecomManager.isInCall();
       return isOnVolte && hasCurrentActiveCall;
     }
     return false;
diff --git a/java/com/android/dialer/util/PermissionsUtil.java b/java/com/android/dialer/util/PermissionsUtil.java
index c526b6a..13fdbdd 100644
--- a/java/com/android/dialer/util/PermissionsUtil.java
+++ b/java/com/android/dialer/util/PermissionsUtil.java
@@ -90,6 +90,10 @@
     return hasPermission(context, permission.READ_PHONE_STATE);
   }
 
+  public static boolean hasModifyPhoneStatePermissions(Context context) {
+    return hasPermission(context, MODIFY_PHONE_STATE);
+  }
+
   public static boolean hasContactsReadPermissions(Context context) {
     return hasPermission(context, permission.READ_CONTACTS);
   }
diff --git a/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java b/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java
index 45c5cc0..43b65e6 100644
--- a/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java
+++ b/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java
@@ -24,6 +24,7 @@
 import android.content.DialogInterface.OnDismissListener;
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.Looper;
 import android.os.Message;
 import android.telecom.PhoneAccountHandle;
 import android.text.Editable;
@@ -321,7 +322,8 @@
   public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
 
-    phoneAccountHandle = getIntent().getParcelableExtra(VoicemailClient.PARAM_PHONE_ACCOUNT_HANDLE);
+    phoneAccountHandle = getIntent().getParcelableExtra(VoicemailClient.PARAM_PHONE_ACCOUNT_HANDLE,
+            PhoneAccountHandle.class);
     pinChanger =
         VoicemailComponent.get(this)
             .getVoicemailClient()
@@ -561,6 +563,7 @@
     private final WeakReference<VoicemailChangePinActivity> activityWeakReference;
 
     private ChangePinHandler(WeakReference<VoicemailChangePinActivity> activityWeakReference) {
+      super(Looper.getMainLooper());
       this.activityWeakReference = activityWeakReference;
     }
 
diff --git a/java/com/android/incallui/AccelerometerListener.java b/java/com/android/incallui/AccelerometerListener.java
index 378971a..8bd1515 100644
--- a/java/com/android/incallui/AccelerometerListener.java
+++ b/java/com/android/incallui/AccelerometerListener.java
@@ -23,6 +23,7 @@
 import android.hardware.SensorEventListener;
 import android.hardware.SensorManager;
 import android.os.Handler;
+import android.os.Looper;
 import android.os.Message;
 import com.android.dialer.common.LogUtil;
 
@@ -52,30 +53,29 @@
   // mOrientation.
   private int pendingOrientation;
   private OrientationListener listener;
-  Handler handler =
-      new Handler() {
-        @Override
-        public void handleMessage(Message msg) {
-          switch (msg.what) {
-            case ORIENTATION_CHANGED:
-              synchronized (this) {
-                orientation = pendingOrientation;
-                if (DEBUG) {
-                  LogUtil.d(
-                      TAG,
-                      "orientation: "
-                          + (orientation == ORIENTATION_HORIZONTAL
-                              ? "horizontal"
-                              : (orientation == ORIENTATION_VERTICAL ? "vertical" : "unknown")));
-                }
-                if (listener != null) {
-                  listener.orientationChanged(orientation);
-                }
-              }
-              break;
+  final Handler handler = new Handler(Looper.getMainLooper()) {
+    @Override
+    public void handleMessage(Message msg) {
+      switch (msg.what) {
+        case ORIENTATION_CHANGED:
+          synchronized (this) {
+            orientation = pendingOrientation;
+            if (DEBUG) {
+              LogUtil.d(
+                  TAG,
+                  "orientation: "
+                      + (orientation == ORIENTATION_HORIZONTAL
+                          ? "horizontal"
+                          : (orientation == ORIENTATION_VERTICAL ? "vertical" : "unknown")));
+            }
+            if (listener != null) {
+              listener.orientationChanged(orientation);
+            }
           }
-        }
-      };
+          break;
+      }
+    }
+  };
   final SensorEventListener sensorListener =
       new SensorEventListener() {
         @Override
diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java
index 2cd111a..efcca39 100644
--- a/java/com/android/incallui/CallCardPresenter.java
+++ b/java/com/android/incallui/CallCardPresenter.java
@@ -27,6 +27,7 @@
 import android.graphics.drawable.Drawable;
 import android.hardware.display.DisplayManager;
 import android.os.Handler;
+import android.os.Looper;
 import android.os.Trace;
 import android.telecom.Call.Details;
 import android.telecom.StatusHints;
@@ -103,7 +104,7 @@
   private static final long CONFIG_MIN_BATTERY_PERCENT_FOR_EMERGENCY_LOCATION_DEFAULT = 10;
 
   private final Context context;
-  private final Handler handler = new Handler();
+  private final Handler handler = new Handler(Looper.getMainLooper());
 
   private DialerCall primary;
   private String primaryNumber;
@@ -783,8 +784,9 @@
       // Return the label for the gateway app on outgoing calls.
       final PackageManager pm = context.getPackageManager();
       try {
-        ApplicationInfo info =
-            pm.getApplicationInfo(primary.getGatewayInfo().getGatewayProviderPackageName(), 0);
+        ApplicationInfo info = pm.getApplicationInfo(
+                primary.getGatewayInfo().getGatewayProviderPackageName(),
+                PackageManager.ApplicationInfoFlags.of(0));
         return pm.getApplicationLabel(info).toString();
       } catch (PackageManager.NameNotFoundException e) {
         LogUtil.e("CallCardPresenter.getConnectionLabel", "gateway Application Not Found.", e);
diff --git a/java/com/android/incallui/ExternalCallNotifier.java b/java/com/android/incallui/ExternalCallNotifier.java
index 3be820d..62b1957 100644
--- a/java/com/android/incallui/ExternalCallNotifier.java
+++ b/java/com/android/incallui/ExternalCallNotifier.java
@@ -19,6 +19,7 @@
 
 import android.app.Notification;
 import android.app.PendingIntent;
+import android.app.Person;
 import android.content.Context;
 import android.content.Intent;
 import android.graphics.Bitmap;
@@ -219,7 +220,7 @@
 
   /** Rebuild an existing or show a new notification given {@link NotificationInfo}. */
   private void postNotification(NotificationInfo info) {
-    Notification.Builder builder = new Notification.Builder(context);
+    Notification.Builder builder = new Notification.Builder(context, NotificationChannelId.DEFAULT);
     // Set notification as ongoing since calls are long-running versus a point-in-time notice.
     builder.setOngoing(true);
     // Make the notification prioritized over the other normal notifications.
@@ -237,8 +238,7 @@
     builder.setContentTitle(info.getContentTitle());
     builder.setLargeIcon(info.getLargeIcon());
     builder.setColor(ThemeComponent.get(context).theme().getColorCallNotificationBackground());
-    builder.addPerson(info.getPersonReference());
-    builder.setChannelId(NotificationChannelId.DEFAULT);
+    builder.addPerson(new Person.Builder().setUri(info.getPersonReference()).build());
 
     // Where the external call supports being transferred to the local device, add an action
     // to the notification to initiate the call pull process.
diff --git a/java/com/android/incallui/InCallActivity.java b/java/com/android/incallui/InCallActivity.java
index 99e109c..8213678 100644
--- a/java/com/android/incallui/InCallActivity.java
+++ b/java/com/android/incallui/InCallActivity.java
@@ -33,6 +33,7 @@
 import android.telecom.Call;
 import android.telecom.CallAudioState;
 import android.telecom.PhoneAccountHandle;
+import android.telecom.PhoneAccountSuggestion;
 import android.telephony.TelephonyManager;
 import android.view.KeyEvent;
 import android.view.MenuItem;
@@ -342,10 +343,17 @@
         PreferredSimComponent.get(this).preferredAccountWorker();
 
     Bundle extras = waitingForAccountCall.getIntentExtras();
-    List<PhoneAccountHandle> phoneAccountHandles =
+    List<PhoneAccountSuggestion> phoneAccountSuggestions =
         extras == null
             ? new ArrayList<>()
-            : extras.getParcelableArrayList(Call.AVAILABLE_PHONE_ACCOUNTS);
+            : extras.getParcelableArrayList(Call.EXTRA_SUGGESTED_PHONE_ACCOUNTS,
+                PhoneAccountSuggestion.class);
+    List<PhoneAccountHandle> phoneAccountHandles = new ArrayList<>();
+    if (phoneAccountSuggestions != null) {
+      for (PhoneAccountSuggestion suggestion : phoneAccountSuggestions) {
+        phoneAccountHandles.add(suggestion.getPhoneAccountHandle());
+      }
+    }
 
     ListenableFuture<PreferredAccountWorker.Result> preferredAccountFuture =
         preferredAccountWorker.selectAccount(
@@ -1028,7 +1036,7 @@
     List<AppTask> tasks = getSystemService(ActivityManager.class).getAppTasks();
     for (AppTask task : tasks) {
       try {
-        if (task.getTaskInfo().id == taskId) {
+        if (task.getTaskInfo().taskId == taskId) {
           task.setExcludeFromRecents(exclude);
         }
       } catch (RuntimeException e) {
diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java
index ada3935..77bf562 100644
--- a/java/com/android/incallui/InCallPresenter.java
+++ b/java/com/android/incallui/InCallPresenter.java
@@ -23,14 +23,16 @@
 import android.os.Bundle;
 import android.os.Trace;
 import android.provider.BlockedNumberContract;
+import android.telecom.Call;
 import android.telecom.Call.Details;
 import android.telecom.CallAudioState;
 import android.telecom.DisconnectCause;
 import android.telecom.PhoneAccount;
 import android.telecom.PhoneAccountHandle;
+import android.telecom.PhoneAccountSuggestion;
 import android.telecom.TelecomManager;
 import android.telecom.VideoProfile;
-import android.telephony.PhoneStateListener;
+import android.telephony.PhoneNumberUtils;
 import android.telephony.TelephonyManager;
 import android.util.ArraySet;
 import android.view.Window;
@@ -183,23 +185,6 @@
 
   private boolean screenTimeoutEnabled = true;
 
-  private PhoneStateListener phoneStateListener =
-      new PhoneStateListener() {
-        @Override
-        public void onCallStateChanged(int state, String incomingNumber) {
-          if (state == TelephonyManager.CALL_STATE_RINGING) {
-            if (EmergencyCallUtil.hasRecentEmergencyCall(context)) {
-              return;
-            }
-            // Check if the number is blocked, to silence the ringer.
-            if (BlockedNumberContract.canCurrentUserBlockNumbers(context) &&
-                    BlockedNumberContract.isBlocked(context, incomingNumber)) {
-              TelecomUtil.silenceRinger(context);
-            }
-          }
-        }
-      };
-
   /** Whether or not InCallService is bound to Telecom. */
   private boolean serviceBound = false;
 
@@ -275,8 +260,9 @@
         extras = EMPTY_EXTRAS;
       }
 
-      final List<PhoneAccountHandle> phoneAccountHandles =
-          extras.getParcelableArrayList(android.telecom.Call.AVAILABLE_PHONE_ACCOUNTS);
+      final List<PhoneAccountSuggestion> phoneAccountHandles =
+          extras.getParcelableArrayList(android.telecom.Call.EXTRA_SUGGESTED_PHONE_ACCOUNTS,
+                  PhoneAccountSuggestion.class);
 
       if ((call.getAccountHandle() == null
           && (phoneAccountHandles == null || phoneAccountHandles.isEmpty()))) {
@@ -357,9 +343,6 @@
     this.callList.addListener(activeCallsListener);
 
     VideoPauseController.getInstance().setUp(this);
-    this.context
-        .getSystemService(TelephonyManager.class)
-        .listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
 
     AudioModeProvider.getInstance().addListener(this);
 
@@ -387,10 +370,6 @@
 
     serviceConnected = false;
 
-    context
-        .getSystemService(TelephonyManager.class)
-        .listen(phoneStateListener, PhoneStateListener.LISTEN_NONE);
-
     attemptCleanup();
     VideoPauseController.getInstance().tearDown();
     AudioModeProvider.getInstance().removeListener(this);
@@ -524,6 +503,24 @@
       callList.onCallAdded(context, call);
     }
 
+    if (call.getDetails().getState() == Call.STATE_RINGING) {
+      if (EmergencyCallUtil.hasRecentEmergencyCall(context)) {
+        return;
+      }
+
+      TelephonyManager tm = context.getSystemService(TelephonyManager.class);
+      String countryIso = tm.getSimCountryIso().toUpperCase();
+      String incomingNumber = call.getDetails().getHandle().getSchemeSpecificPart();
+
+      incomingNumber = PhoneNumberUtils.formatNumberToE164(incomingNumber, countryIso);
+
+      // Check if the number is blocked, to silence the ringer.
+      if (BlockedNumberContract.canCurrentUserBlockNumbers(context) &&
+              BlockedNumberContract.isBlocked(context, incomingNumber)) {
+        TelecomUtil.silenceRinger(context);
+      }
+    }
+
     // Since a call has been added we are no longer waiting for Telecom to send us a call.
     setBoundAndWaitingForOutgoingCall(false, null);
     call.registerCallback(callCallback);
@@ -1360,10 +1357,11 @@
       extras = new Bundle();
     }
 
-    final List<PhoneAccountHandle> phoneAccountHandles =
-        extras.getParcelableArrayList(android.telecom.Call.AVAILABLE_PHONE_ACCOUNTS);
+    final List<PhoneAccountSuggestion> phoneAccountSuggestions =
+        extras.getParcelableArrayList(Call.EXTRA_SUGGESTED_PHONE_ACCOUNTS,
+                PhoneAccountSuggestion.class);
 
-    if (phoneAccountHandles == null || phoneAccountHandles.isEmpty()) {
+    if (phoneAccountSuggestions == null || phoneAccountSuggestions.isEmpty()) {
       String scheme = call.getHandle().getScheme();
       final String errorMsg =
           PhoneAccount.SCHEME_TEL.equals(scheme)
@@ -1481,14 +1479,15 @@
       return;
     }
 
-    if (extras.containsKey(android.telecom.Call.AVAILABLE_PHONE_ACCOUNTS)) {
+    if (extras.containsKey(Call.EXTRA_SUGGESTED_PHONE_ACCOUNTS)) {
       // Account selection dialog will show up so don't show the animation.
       return;
     }
 
     final PhoneAccountHandle accountHandle =
-        intent.getParcelableExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
-    final Point touchPoint = extras.getParcelable(TouchPointManager.TOUCH_POINT);
+            intent.getParcelableExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE,
+                    PhoneAccountHandle.class);
+    final Point touchPoint = extras.getParcelable(TouchPointManager.TOUCH_POINT, Point.class);
 
     setBoundAndWaitingForOutgoingCall(true, accountHandle);
 
diff --git a/java/com/android/incallui/InCallVibrationHandler.java b/java/com/android/incallui/InCallVibrationHandler.java
index 8ce8d0b..cde882a 100644
--- a/java/com/android/incallui/InCallVibrationHandler.java
+++ b/java/com/android/incallui/InCallVibrationHandler.java
@@ -20,8 +20,11 @@
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.os.Handler;
+import android.os.Looper;
 import android.os.Message;
+import android.os.VibrationEffect;
 import android.os.Vibrator;
+import android.os.VibratorManager;
 import android.telecom.DisconnectCause;
 
 import androidx.preference.PreferenceManager;
@@ -46,10 +49,11 @@
   private DialerCall activeCall;
 
   public InCallVibrationHandler(Context context) {
+    super(Looper.getMainLooper());
     String name = context.getPackageName() + "_preferences";
     prefs = context.createDeviceProtectedStorageContext()
             .getSharedPreferences(name, Context.MODE_PRIVATE);
-    vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
+    vibrator = context.getSystemService(VibratorManager.class).getDefaultVibrator();
   }
 
   @Override
@@ -142,6 +146,7 @@
     long[] pattern = new long[] {
       0, v1, p1, v2
     };
-    vibrator.vibrate(pattern, -1);
+    VibrationEffect effect = VibrationEffect.createWaveform(pattern, -1);
+    vibrator.vibrate(effect);
   }
 }
diff --git a/java/com/android/incallui/StatusBarNotifier.java b/java/com/android/incallui/StatusBarNotifier.java
index 423e401..2a94cd4 100644
--- a/java/com/android/incallui/StatusBarNotifier.java
+++ b/java/com/android/incallui/StatusBarNotifier.java
@@ -336,8 +336,6 @@
         configureFullScreenIntent(builder, createLaunchPendingIntent(true /* isFullScreen */));
         // Set the notification category and bump the priority for incoming calls
         builder.setCategory(Notification.CATEGORY_CALL);
-        // This will be ignored on O+ and handled by the channel
-        builder.setPriority(Notification.PRIORITY_MAX);
         if (currentNotification != NOTIFICATION_INCOMING_CALL) {
           LogUtil.i(
               "StatusBarNotifier.buildAndSendNotification",
@@ -549,10 +547,14 @@
     // Query {@link Contacts#CONTENT_LOOKUP_URI} directly with work lookup key is not allowed.
     // So, do not pass {@link Contacts#CONTENT_LOOKUP_URI} to NotificationManager to avoid
     // NotificationManager using it.
+    String uri = null;
     if (contactInfo.lookupUri != null && contactInfo.userType != ContactsUtils.USER_TYPE_WORK) {
-      builder.addPerson(contactInfo.lookupUri.toString());
+      uri = contactInfo.lookupUri.toString();
     } else if (!TextUtils.isEmpty(call.getNumber())) {
-      builder.addPerson(Uri.fromParts(PhoneAccount.SCHEME_TEL, call.getNumber(), null).toString());
+      uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, call.getNumber(), null).toString();
+    }
+    if (uri != null) {
+      builder.addPerson(new Person.Builder().setUri(uri).build());
     }
   }
 
diff --git a/java/com/android/incallui/VideoCallPresenter.java b/java/com/android/incallui/VideoCallPresenter.java
index 3f92453..2402394 100644
--- a/java/com/android/incallui/VideoCallPresenter.java
+++ b/java/com/android/incallui/VideoCallPresenter.java
@@ -21,6 +21,7 @@
 import android.content.Context;
 import android.graphics.Point;
 import android.os.Handler;
+import android.os.Looper;
 import android.telecom.InCallService.VideoCall;
 import android.telecom.VideoProfile;
 import android.telecom.VideoProfile.CameraCapabilities;
@@ -88,7 +89,7 @@
 
   private static boolean isVideoMode = false;
 
-  private final Handler handler = new Handler();
+  private final Handler handler = new Handler(Looper.getMainLooper());
   private VideoCallScreen videoCallScreen;
 
   /** The current context. */
@@ -1115,7 +1116,7 @@
     Activity activity = videoCallScreen.getVideoCallScreenFragment().getActivity();
     if (activity != null) {
       Point screenSize = new Point();
-      activity.getWindowManager().getDefaultDisplay().getSize(screenSize);
+      activity.getDisplay().getSize(screenSize);
       getRemoteVideoSurfaceTexture().setSurfaceDimensions(screenSize);
     }
   }
diff --git a/java/com/android/incallui/answerproximitysensor/SystemProximityWakeLock.java b/java/com/android/incallui/answerproximitysensor/SystemProximityWakeLock.java
index da3917f..c30ffb5 100644
--- a/java/com/android/incallui/answerproximitysensor/SystemProximityWakeLock.java
+++ b/java/com/android/incallui/answerproximitysensor/SystemProximityWakeLock.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,7 +30,7 @@
 /** The normal PROXIMITY_SCREEN_OFF_WAKE_LOCK provided by the OS. */
 public class SystemProximityWakeLock implements AnswerProximityWakeLock, DisplayListener {
 
-  private static final String TAG = "SystemProximityWakeLock";
+  private static final String TAG = "SystemProximity:WakeLock";
 
   private final Context context;
   private final PowerManager.WakeLock wakeLock;
diff --git a/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java b/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java
index ef28c64..c5836e3 100644
--- a/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java
+++ b/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java
@@ -95,7 +95,7 @@
   public View onCreateView(
       LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
     View view = layoutInflater.inflate(R.layout.audioroute_selector, viewGroup, false);
-    CallAudioState audioState = getArguments().getParcelable(ARG_AUDIO_STATE);
+    CallAudioState audioState = getArguments().getParcelable(ARG_AUDIO_STATE, CallAudioState.class);
 
     // Create items for all connected Bluetooth devices
     Collection<BluetoothDevice> bluetoothDeviceSet = audioState.getSupportedBluetoothDevices();
diff --git a/java/com/android/incallui/call/CallList.java b/java/com/android/incallui/call/CallList.java
index fb03a48..1ff6c47 100644
--- a/java/com/android/incallui/call/CallList.java
+++ b/java/com/android/incallui/call/CallList.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +19,7 @@
 
 import android.content.Context;
 import android.os.Handler;
+import android.os.Looper;
 import android.os.Message;
 import android.os.Trace;
 import android.provider.BlockedNumberContract;
@@ -75,21 +77,20 @@
 
   private UiListener uiListeners;
   /** Handles the timeout for destroying disconnected calls. */
-  private final Handler handler =
-      new Handler() {
-        @Override
-        public void handleMessage(Message msg) {
-          switch (msg.what) {
-            case EVENT_DISCONNECTED_TIMEOUT:
-              LogUtil.d("CallList.handleMessage", "EVENT_DISCONNECTED_TIMEOUT ", msg.obj);
-              finishDisconnectedCall((DialerCall) msg.obj);
-              break;
-            default:
-              LogUtil.e("CallList.handleMessage", "Message not expected: " + msg.what);
-              break;
-          }
-        }
-      };
+  private final Handler handler = new Handler(Looper.getMainLooper()) {
+    @Override
+    public void handleMessage(Message msg) {
+      switch (msg.what) {
+        case EVENT_DISCONNECTED_TIMEOUT:
+          LogUtil.d("CallList.handleMessage", "EVENT_DISCONNECTED_TIMEOUT ", msg.obj);
+          finishDisconnectedCall((DialerCall) msg.obj);
+          break;
+        default:
+          LogUtil.e("CallList.handleMessage", "Message not expected: " + msg.what);
+          break;
+      }
+    }
+  };
 
   /**
    * USED ONLY FOR TESTING Testing-only constructor. Instance should only be acquired through
diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java
index 87aa087..485a6c7 100644
--- a/java/com/android/incallui/call/DialerCall.java
+++ b/java/com/android/incallui/call/DialerCall.java
@@ -543,9 +543,10 @@
     Trace.beginSection("DialerCall.updateFromTelecomCall");
     LogUtil.v("DialerCall.updateFromTelecomCall", telecomCall.toString());
 
-    videoTechManager.dispatchCallStateChanged(telecomCall.getState(), getAccountHandle());
+    videoTechManager.dispatchCallStateChanged(telecomCall.getDetails().getState(),
+            getAccountHandle());
 
-    final int translatedState = translateState(telecomCall.getState());
+    final int translatedState = translateState(telecomCall.getDetails().getState());
     if (state != DialerCallState.BLOCKED) {
       setState(translatedState);
       setDisconnectCause(telecomCall.getDetails().getDisconnectCause());
@@ -1097,7 +1098,8 @@
    * repeated calls to isEmergencyNumber.
    */
   private void updateEmergencyCallState() {
-    isEmergencyCall = TelecomCallUtil.isEmergencyCall(telecomCall);
+    TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class);
+    isEmergencyCall = TelecomCallUtil.isEmergencyCall(telephonyManager, telecomCall);
   }
 
   public LogState getLogState() {
diff --git a/java/com/android/incallui/callpending/CallPendingActivity.java b/java/com/android/incallui/callpending/CallPendingActivity.java
index 38e0eeb..eb140a9 100644
--- a/java/com/android/incallui/callpending/CallPendingActivity.java
+++ b/java/com/android/incallui/callpending/CallPendingActivity.java
@@ -344,6 +344,6 @@
   }
 
   private Uri getPhotoUri() {
-    return getIntent().getParcelableExtra(EXTRA_PHOTO_URI);
+    return getIntent().getParcelableExtra(EXTRA_PHOTO_URI, Uri.class);
   }
 }
diff --git a/java/com/android/incallui/hold/OnHoldFragment.java b/java/com/android/incallui/hold/OnHoldFragment.java
index a94517a..0304185 100644
--- a/java/com/android/incallui/hold/OnHoldFragment.java
+++ b/java/com/android/incallui/hold/OnHoldFragment.java
@@ -26,6 +26,7 @@
 import android.view.View;
 import android.view.View.OnAttachStateChangeListener;
 import android.view.ViewGroup;
+import android.view.WindowInsets;
 import android.widget.ImageView;
 import android.widget.TextView;
 
@@ -58,7 +59,7 @@
       LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
     final View view = layoutInflater.inflate(R.layout.incall_on_hold_banner, viewGroup, false);
 
-    SecondaryInfo secondaryInfo = getArguments().getParcelable(ARG_INFO);
+    SecondaryInfo secondaryInfo = getArguments().getParcelable(ARG_INFO, SecondaryInfo.class);
     secondaryInfo = Assert.isNotNull(secondaryInfo);
 
     ((TextView) view.findViewById(R.id.hold_contact_name))
@@ -77,7 +78,7 @@
         new OnAttachStateChangeListener() {
           @Override
           public void onViewAttachedToWindow(View v) {
-            topInset = v.getRootWindowInsets().getSystemWindowInsetTop();
+            topInset = v.getRootWindowInsets().getInsets(WindowInsets.Type.systemBars()).top;
             applyInset();
           }
 
diff --git a/java/com/android/incallui/incall/impl/InCallFragment.java b/java/com/android/incallui/incall/impl/InCallFragment.java
index 12e1927..9ffb934 100644
--- a/java/com/android/incallui/incall/impl/InCallFragment.java
+++ b/java/com/android/incallui/incall/impl/InCallFragment.java
@@ -22,8 +22,10 @@
 import android.app.Activity;
 import android.content.Context;
 import android.content.pm.PackageManager;
+import android.graphics.Insets;
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.Looper;
 import android.telecom.CallAudioState;
 import android.telephony.TelephonyManager;
 import android.transition.TransitionManager;
@@ -33,6 +35,7 @@
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.view.Window;
+import android.view.WindowInsets;
 import android.view.accessibility.AccessibilityEvent;
 import android.widget.ImageView;
 import android.widget.Toast;
@@ -101,7 +104,7 @@
 
   // Add animation to educate users. If a call has enriched calling attachments then we'll
   // initially show the attachment page. After a delay seconds we'll animate to the button grid.
-  private final Handler handler = new Handler();
+  private final Handler handler = new Handler(Looper.getMainLooper());
   private final Runnable pagerRunnable =
       new Runnable() {
         @Override
@@ -192,8 +195,9 @@
           @Override
           public void onViewAttachedToWindow(View v) {
             View container = v.findViewById(R.id.incall_ui_container);
-            int topInset = v.getRootWindowInsets().getSystemWindowInsetTop();
-            int bottomInset = v.getRootWindowInsets().getSystemWindowInsetBottom();
+            Insets insets = v.getRootWindowInsets().getInsets(WindowInsets.Type.systemBars());
+            int topInset = insets.top;
+            int bottomInset = insets.bottom;
             if (topInset != container.getPaddingTop()) {
               TransitionManager.beginDelayedTransition(((ViewGroup) container.getParent()));
               container.setPadding(0, topInset, 0, bottomInset);
diff --git a/java/com/android/incallui/sessiondata/MultimediaFragment.java b/java/com/android/incallui/sessiondata/MultimediaFragment.java
index f374713..8e7ab8f 100644
--- a/java/com/android/incallui/sessiondata/MultimediaFragment.java
+++ b/java/com/android/incallui/sessiondata/MultimediaFragment.java
@@ -227,12 +227,12 @@
 
   @Nullable
   public Uri getImageUri() {
-    return getArguments().getParcelable(ARG_IMAGE);
+    return getArguments().getParcelable(ARG_IMAGE, Uri.class);
   }
 
   @Nullable
   public Location getLocation() {
-    return getArguments().getParcelable(ARG_LOCATION);
+    return getArguments().getParcelable(ARG_LOCATION, Location.class);
   }
 
   /** Interface for notifying the fragment parent of changes. */
diff --git a/java/com/android/incallui/video/impl/VideoCallFragment.java b/java/com/android/incallui/video/impl/VideoCallFragment.java
index 5408af2..1d8037f 100644
--- a/java/com/android/incallui/video/impl/VideoCallFragment.java
+++ b/java/com/android/incallui/video/impl/VideoCallFragment.java
@@ -22,6 +22,7 @@
 import android.content.pm.PackageManager;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
+import android.graphics.Insets;
 import android.graphics.Outline;
 import android.graphics.Point;
 import android.graphics.drawable.Animatable;
@@ -43,6 +44,7 @@
 import android.view.ViewGroup;
 import android.view.ViewGroup.MarginLayoutParams;
 import android.view.ViewOutlineProvider;
+import android.view.WindowInsets;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.animation.AccelerateDecelerateInterpolator;
 import android.view.animation.Interpolator;
@@ -524,14 +526,15 @@
     if (getActivity().isInMultiWindowMode()) {
       return new Point();
     }
+    Insets insets = getView().getRootWindowInsets().getInsets(WindowInsets.Type.systemBars());
     if (isLandscape()) {
       int systemWindowInsetEnd =
           getView().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL
-              ? getView().getRootWindowInsets().getSystemWindowInsetLeft()
-              : -getView().getRootWindowInsets().getSystemWindowInsetRight();
+              ? insets.left
+              : -insets.right;
       return new Point(systemWindowInsetEnd, 0);
     } else {
-      return new Point(0, -getView().getRootWindowInsets().getSystemWindowInsetBottom());
+      return new Point(0, -insets.bottom);
     }
   }
 
@@ -1041,7 +1044,7 @@
 
   private boolean isLandscape() {
     // Choose orientation based on display orientation, not window orientation
-    int rotation = getActivity().getWindowManager().getDefaultDisplay().getRotation();
+    int rotation = getActivity().getDisplay().getRotation();
     return rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270;
   }
 
diff --git a/java/com/android/incallui/videotech/ims/ImsVideoCallCallback.java b/java/com/android/incallui/videotech/ims/ImsVideoCallCallback.java
index d41d497..9baef64 100644
--- a/java/com/android/incallui/videotech/ims/ImsVideoCallCallback.java
+++ b/java/com/android/incallui/videotech/ims/ImsVideoCallCallback.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +19,7 @@
 
 import android.content.Context;
 import android.os.Handler;
+import android.os.Looper;
 import android.telecom.Call;
 import android.telecom.Connection;
 import android.telecom.Connection.VideoProvider;
@@ -31,7 +33,7 @@
 /** Receives IMS video call state updates. */
 public class ImsVideoCallCallback extends VideoCall.Callback {
   private static final int CLEAR_FAILED_REQUEST_TIMEOUT_MILLIS = 4000;
-  private final Handler handler = new Handler();
+  private final Handler handler = new Handler(Looper.getMainLooper());
   private final Call call;
   private final ImsVideoTech videoTech;
   private final VideoTechListener listener;
diff --git a/java/com/android/incallui/videotech/ims/ImsVideoTech.java b/java/com/android/incallui/videotech/ims/ImsVideoTech.java
index 142f1e6..f71f2fd 100644
--- a/java/com/android/incallui/videotech/ims/ImsVideoTech.java
+++ b/java/com/android/incallui/videotech/ims/ImsVideoTech.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -238,7 +239,7 @@
 
   @Override
   public void pause() {
-    if (call.getState() != Call.STATE_ACTIVE) {
+    if (call.getDetails().getState() != Call.STATE_ACTIVE) {
       LogUtil.i("ImsVideoTech.pause", "not pausing because call is not active");
       return;
     }
@@ -272,7 +273,7 @@
 
   @Override
   public void unpause() {
-    if (call.getState() != Call.STATE_ACTIVE) {
+    if (call.getDetails().getState() != Call.STATE_ACTIVE) {
       LogUtil.i("ImsVideoTech.unpause", "not unpausing because call is not active");
       return;
     }
diff --git a/java/com/android/voicemail/impl/ActivationTask.java b/java/com/android/voicemail/impl/ActivationTask.java
index 8797006..895f406 100644
--- a/java/com/android/voicemail/impl/ActivationTask.java
+++ b/java/com/android/voicemail/impl/ActivationTask.java
@@ -102,7 +102,7 @@
   @Override
   public void onCreate(Context context, Bundle extras) {
     super.onCreate(context, extras);
-    messageData = extras.getParcelable(EXTRA_MESSAGE_DATA_BUNDLE);
+    messageData = extras.getParcelable(EXTRA_MESSAGE_DATA_BUNDLE, Bundle.class);
   }
 
   @Override
diff --git a/java/com/android/voicemail/impl/DeviceProvisionedJobService.java b/java/com/android/voicemail/impl/DeviceProvisionedJobService.java
index 379ee50..80b8b6c 100644
--- a/java/com/android/voicemail/impl/DeviceProvisionedJobService.java
+++ b/java/com/android/voicemail/impl/DeviceProvisionedJobService.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +59,7 @@
     VvmLog.i("DeviceProvisionedJobService.onStartJob", "device provisioned");
     for (JobWorkItem item = params.dequeueWork(); item != null; item = params.dequeueWork()) {
       PhoneAccountHandle phoneAccountHandle =
-          item.getIntent().getParcelableExtra(EXTRA_PHONE_ACCOUNT_HANDLE);
+          item.getIntent().getParcelableExtra(EXTRA_PHONE_ACCOUNT_HANDLE, PhoneAccountHandle.class);
       VvmLog.i(
           "DeviceProvisionedJobService.onStartJob",
           "restarting activation for " + phoneAccountHandle);
diff --git a/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java b/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java
index 9178bbe..c6110c9 100644
--- a/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java
+++ b/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java
@@ -19,6 +19,7 @@
 import android.app.PendingIntent;
 import android.content.Context;
 import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.os.Bundle;
 import android.os.PersistableBundle;
@@ -483,7 +484,8 @@
     }
     for (String packageName : carrierPackages) {
       try {
-        ApplicationInfo info = getContext().getPackageManager().getApplicationInfo(packageName, 0);
+        ApplicationInfo info = getContext().getPackageManager().getApplicationInfo(packageName,
+                PackageManager.ApplicationInfoFlags.of(0));
         if (!info.enabled) {
           continue;
         }
diff --git a/java/com/android/voicemail/impl/imap/ImapHelper.java b/java/com/android/voicemail/impl/imap/ImapHelper.java
index f2c2e5f..4ebba33 100644
--- a/java/com/android/voicemail/impl/imap/ImapHelper.java
+++ b/java/com/android/voicemail/impl/imap/ImapHelper.java
@@ -19,7 +19,7 @@
 import android.content.Context;
 import android.net.ConnectivityManager;
 import android.net.Network;
-import android.net.NetworkInfo;
+import android.net.NetworkCapabilities;
 import android.telecom.PhoneAccountHandle;
 import android.util.Base64;
 
@@ -145,11 +145,11 @@
   public boolean isRoaming() {
     ConnectivityManager connectivityManager =
         (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
-    NetworkInfo info = connectivityManager.getNetworkInfo(network);
-    if (info == null) {
+    NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(network);
+    if (capabilities == null) {
       return false;
     }
-    return info.isRoaming();
+    return !capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING);
   }
 
   public OmtpVvmCarrierConfigHelper getConfig() {
diff --git a/java/com/android/voicemail/impl/scheduling/BaseTask.java b/java/com/android/voicemail/impl/scheduling/BaseTask.java
index aaceefb..96ebc84 100644
--- a/java/com/android/voicemail/impl/scheduling/BaseTask.java
+++ b/java/com/android/voicemail/impl/scheduling/BaseTask.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -159,7 +160,7 @@
   public void onCreate(Context context, Bundle extras) {
     this.context = context;
     this.extras = extras;
-    phoneAccountHandle = extras.getParcelable(EXTRA_PHONE_ACCOUNT_HANDLE);
+    phoneAccountHandle = extras.getParcelable(EXTRA_PHONE_ACCOUNT_HANDLE, PhoneAccountHandle.class);
     for (Policy policy : policies) {
       policy.onCreate(this, extras);
     }
diff --git a/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java b/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java
index e71dca0..0bab169 100644
--- a/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java
+++ b/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,8 +50,9 @@
   @Override
   public void onReceive(Context context, Intent intent) {
     this.context = context;
-    VisualVoicemailSms sms = intent.getExtras().getParcelable(OmtpService.EXTRA_VOICEMAIL_SMS);
-    PhoneAccountHandle phone = sms.getPhoneAccountHandle();
+    VisualVoicemailSms sms = intent.getExtras().getParcelable(OmtpService.EXTRA_VOICEMAIL_SMS,
+            VisualVoicemailSms.class);
+    PhoneAccountHandle phone = sms != null ? sms.getPhoneAccountHandle() : null;
 
     if (phone == null) {
       // This should never happen
diff --git a/java/com/android/voicemail/impl/sync/SyncOneTask.java b/java/com/android/voicemail/impl/sync/SyncOneTask.java
index a11a3c1..95f4ceb 100644
--- a/java/com/android/voicemail/impl/sync/SyncOneTask.java
+++ b/java/com/android/voicemail/impl/sync/SyncOneTask.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,8 +58,8 @@
   @Override
   public void onCreate(Context context, Bundle extras) {
     super.onCreate(context, extras);
-    phone = extras.getParcelable(EXTRA_PHONE_ACCOUNT_HANDLE);
-    voicemail = extras.getParcelable(EXTRA_VOICEMAIL);
+    phone = extras.getParcelable(EXTRA_PHONE_ACCOUNT_HANDLE, PhoneAccountHandle.class);
+    voicemail = extras.getParcelable(EXTRA_VOICEMAIL, Voicemail.class);
   }
 
   @Override
diff --git a/java/com/android/voicemail/impl/sync/SyncTask.java b/java/com/android/voicemail/impl/sync/SyncTask.java
index 89d3c0b..b04c434 100644
--- a/java/com/android/voicemail/impl/sync/SyncTask.java
+++ b/java/com/android/voicemail/impl/sync/SyncTask.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -56,7 +57,7 @@
   @Override
   public void onCreate(Context context, Bundle extras) {
     super.onCreate(context, extras);
-    phone = extras.getParcelable(EXTRA_PHONE_ACCOUNT_HANDLE);
+    phone = extras.getParcelable(EXTRA_PHONE_ACCOUNT_HANDLE, PhoneAccountHandle.class);
   }
 
   @Override