Remove voicemail/impl/TelephonyMangerCompat

These reflection calls are used for the transition period when amending VVM APIs in O. The public version should be used now.

TEST=TAP
Bug: 77334965
Test: TAP
PiperOrigin-RevId: 193095281
Change-Id: Ifaf2e78f007a155221146b40369aaed66d4325c6
diff --git a/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java b/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java
index 032153d..b56f792 100644
--- a/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java
+++ b/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java
@@ -369,10 +369,13 @@
 
   public void activateSmsFilter() {
     Assert.checkArgument(isValid());
-    TelephonyMangerCompat.setVisualVoicemailSmsFilterSettings(
-        context,
-        getPhoneAccountHandle(),
-        new VisualVoicemailSmsFilterSettings.Builder().setClientPrefix(getClientPrefix()).build());
+    context
+        .getSystemService(TelephonyManager.class)
+        .createForPhoneAccountHandle(getPhoneAccountHandle())
+        .setVisualVoicemailSmsFilterSettings(
+            new VisualVoicemailSmsFilterSettings.Builder()
+                .setClientPrefix(getClientPrefix())
+                .build());
   }
 
   public void startDeactivation() {
@@ -380,8 +383,10 @@
     VvmLog.i(TAG, "startDeactivation");
     if (!isLegacyModeEnabled()) {
       // SMS should still be filtered in legacy mode
-      TelephonyMangerCompat.setVisualVoicemailSmsFilterSettings(
-          context, getPhoneAccountHandle(), null);
+      context
+          .getSystemService(TelephonyManager.class)
+          .createForPhoneAccountHandle(getPhoneAccountHandle())
+          .setVisualVoicemailSmsFilterSettings(null);
       VvmLog.i(TAG, "filter disabled");
     }
     if (protocol != null) {
diff --git a/java/com/android/voicemail/impl/TelephonyMangerCompat.java b/java/com/android/voicemail/impl/TelephonyMangerCompat.java
deleted file mode 100644
index 404b4d6..0000000
--- a/java/com/android/voicemail/impl/TelephonyMangerCompat.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.voicemail.impl;
-
-import android.app.PendingIntent;
-import android.content.Context;
-import android.telecom.PhoneAccountHandle;
-import android.telephony.TelephonyManager;
-import android.telephony.VisualVoicemailService;
-import android.telephony.VisualVoicemailSmsFilterSettings;
-import com.android.dialer.common.LogUtil;
-import java.lang.reflect.Method;
-
-/** Handles {@link TelephonyManager} API changes in experimental SDK */
-public class TelephonyMangerCompat {
-  /** Moved from VisualVoicemailService to TelephonyManager */
-  public static String sendVisualVoicemailSms(
-      Context context,
-      PhoneAccountHandle phoneAccountHandle,
-      String number,
-      int port,
-      String text,
-      PendingIntent sentIntent) {
-    try {
-      Method method =
-          TelephonyManager.class.getMethod(
-              "sendVisualVoicemailSms", String.class, int.class, String.class, PendingIntent.class);
-      try {
-        LogUtil.i("TelephonyMangerCompat.sendVisualVoicemailSms", "using TelephonyManager");
-        TelephonyManager telephonyManager =
-            context
-                .getSystemService(TelephonyManager.class)
-                .createForPhoneAccountHandle(phoneAccountHandle);
-        return (String) method.invoke(telephonyManager, number, port, text, sentIntent);
-      } catch (ReflectiveOperationException e) {
-        throw new RuntimeException(e);
-      }
-    } catch (NoSuchMethodException e) {
-      // Do nothing, try the next version.
-    }
-
-    try {
-      LogUtil.i("TelephonyMangerCompat.sendVisualVoicemailSms", "using VisualVoicemailService");
-      Method method =
-          VisualVoicemailService.class.getMethod(
-              "sendVisualVoicemailSms",
-              Context.class,
-              PhoneAccountHandle.class,
-              String.class,
-              short.class,
-              String.class,
-              PendingIntent.class);
-      return (String)
-          method.invoke(null, context, phoneAccountHandle, number, (short) port, text, sentIntent);
-
-    } catch (ReflectiveOperationException e) {
-      throw new RuntimeException(e);
-    }
-  }
-
-  /** Moved from VisualVoicemailService to TelephonyManager */
-  public static String setVisualVoicemailSmsFilterSettings(
-      Context context,
-      PhoneAccountHandle phoneAccountHandle,
-      VisualVoicemailSmsFilterSettings settings) {
-    try {
-      Method method =
-          TelephonyManager.class.getMethod(
-              "setVisualVoicemailSmsFilterSettings", VisualVoicemailSmsFilterSettings.class);
-      try {
-        LogUtil.i(
-            "TelephonyMangerCompat.setVisualVoicemailSmsFilterSettings", "using TelephonyManager");
-        TelephonyManager telephonyManager =
-            context
-                .getSystemService(TelephonyManager.class)
-                .createForPhoneAccountHandle(phoneAccountHandle);
-        return (String) method.invoke(telephonyManager, settings);
-      } catch (ReflectiveOperationException e) {
-        throw new RuntimeException(e);
-      }
-    } catch (NoSuchMethodException e) {
-      // Do nothing, try the next version.
-    }
-
-    try {
-      LogUtil.i(
-          "TelephonyMangerCompat.setVisualVoicemailSmsFilterSettings",
-          "using VisualVoicemailService");
-      Method method =
-          VisualVoicemailService.class.getMethod(
-              "setSmsFilterSettings",
-              Context.class,
-              PhoneAccountHandle.class,
-              VisualVoicemailSmsFilterSettings.class);
-      return (String) method.invoke(null, context, phoneAccountHandle, settings);
-
-    } catch (ReflectiveOperationException e) {
-      throw new RuntimeException(e);
-    }
-  }
-}
diff --git a/java/com/android/voicemail/impl/sms/OmtpMessageSender.java b/java/com/android/voicemail/impl/sms/OmtpMessageSender.java
index 76a2583..8b9e049 100644
--- a/java/com/android/voicemail/impl/sms/OmtpMessageSender.java
+++ b/java/com/android/voicemail/impl/sms/OmtpMessageSender.java
@@ -15,13 +15,15 @@
  */
 package com.android.voicemail.impl.sms;
 
+import android.annotation.TargetApi;
 import android.app.PendingIntent;
 import android.content.Context;
+import android.os.Build.VERSION_CODES;
 import android.support.annotation.Nullable;
 import android.telecom.PhoneAccountHandle;
 import android.telephony.SmsManager;
+import android.telephony.TelephonyManager;
 import com.android.voicemail.impl.OmtpConstants;
-import com.android.voicemail.impl.TelephonyMangerCompat;
 import com.android.voicemail.impl.VvmLog;
 
 /**
@@ -33,6 +35,7 @@
  *
  * <p>Provides simple APIs to send different types of mobile originated OMTP SMS to the VVM server.
  */
+@TargetApi(VERSION_CODES.O)
 public abstract class OmtpMessageSender {
   protected static final String TAG = "OmtpMessageSender";
   protected final Context context;
@@ -80,8 +83,10 @@
     VvmLog.v(
         TAG, String.format("Sending sms '%s' to %s:%d", text, destinationNumber, applicationPort));
 
-    TelephonyMangerCompat.sendVisualVoicemailSms(
-        context, phoneAccountHandle, destinationNumber, applicationPort, text, sentIntent);
+    context
+        .getSystemService(TelephonyManager.class)
+        .createForPhoneAccountHandle(phoneAccountHandle)
+        .sendVisualVoicemailSms(destinationNumber, applicationPort, text, sentIntent);
   }
 
   protected void appendField(StringBuilder sb, String field, Object value) {