From 1e6edb3e5728f82d45bc2677fd72aa654b37ee73 Mon Sep 17 00:00:00 2001
From: Ken Wakasa <kwakasa@google.com>
Date: Mon, 17 Dec 2012 18:27:20 +0900
Subject: [PATCH] Remove AudioManagerCompatWrapper.java

It is actually no longer needed for API 14+

Change-Id: I379809eae881351fdf210dd8eaa5e0b5662fb59f
---
 .../accessibility/AccessibilityUtils.java     | 28 ++++------
 .../compat/AudioManagerCompatWrapper.java     | 54 -------------------
 2 files changed, 11 insertions(+), 71 deletions(-)
 delete mode 100644 java/src/com/android/inputmethod/compat/AudioManagerCompatWrapper.java

diff --git a/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java b/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java
index 1eee1df873..0a700bda48 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java
@@ -32,7 +32,6 @@ import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityManager;
 import android.view.inputmethod.EditorInfo;
 
-import com.android.inputmethod.compat.AudioManagerCompatWrapper;
 import com.android.inputmethod.compat.SettingsSecureCompatUtils;
 import com.android.inputmethod.latin.InputTypeUtils;
 import com.android.inputmethod.latin.R;
@@ -40,14 +39,14 @@ import com.android.inputmethod.latin.R;
 public final class AccessibilityUtils {
     private static final String TAG = AccessibilityUtils.class.getSimpleName();
     private static final String CLASS = AccessibilityUtils.class.getClass().getName();
-    private static final String PACKAGE = AccessibilityUtils.class.getClass().getPackage()
-            .getName();
+    private static final String PACKAGE =
+            AccessibilityUtils.class.getClass().getPackage().getName();
 
     private static final AccessibilityUtils sInstance = new AccessibilityUtils();
 
     private Context mContext;
     private AccessibilityManager mAccessibilityManager;
-    private AudioManagerCompatWrapper mAudioManager;
+    private AudioManager mAudioManager;
 
     /*
      * Setting this constant to {@code false} will disable all keyboard
@@ -57,8 +56,7 @@ public final class AccessibilityUtils {
     private static final boolean ENABLE_ACCESSIBILITY = true;
 
     public static void init(InputMethodService inputMethod) {
-        if (!ENABLE_ACCESSIBILITY)
-            return;
+        if (!ENABLE_ACCESSIBILITY) return;
 
         // These only need to be initialized if the kill switch is off.
         sInstance.initInternal(inputMethod);
@@ -76,12 +74,9 @@ public final class AccessibilityUtils {
 
     private void initInternal(Context context) {
         mContext = context;
-        mAccessibilityManager = (AccessibilityManager) context
-                .getSystemService(Context.ACCESSIBILITY_SERVICE);
-
-        final AudioManager audioManager = (AudioManager) context
-                .getSystemService(Context.AUDIO_SERVICE);
-        mAudioManager = new AudioManagerCompatWrapper(audioManager);
+        mAccessibilityManager =
+                (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
+        mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
     }
 
     /**
@@ -120,20 +115,19 @@ public final class AccessibilityUtils {
      * @return {@code true} if the device should obscure password characters.
      */
     public boolean shouldObscureInput(EditorInfo editorInfo) {
-        if (editorInfo == null)
-            return false;
+        if (editorInfo == null) return false;
 
         // The user can optionally force speaking passwords.
         if (SettingsSecureCompatUtils.ACCESSIBILITY_SPEAK_PASSWORD != null) {
             final boolean speakPassword = Settings.Secure.getInt(mContext.getContentResolver(),
                     SettingsSecureCompatUtils.ACCESSIBILITY_SPEAK_PASSWORD, 0) != 0;
-            if (speakPassword)
-                return false;
+            if (speakPassword) return false;
         }
 
         // Always speak if the user is listening through headphones.
-        if (mAudioManager.isWiredHeadsetOn() || mAudioManager.isBluetoothA2dpOn())
+        if (mAudioManager.isWiredHeadsetOn() || mAudioManager.isBluetoothA2dpOn()) {
             return false;
+        }
 
         // Don't speak if the IME is connected to a password field.
         return InputTypeUtils.isPasswordInputType(editorInfo.inputType);
diff --git a/java/src/com/android/inputmethod/compat/AudioManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/AudioManagerCompatWrapper.java
deleted file mode 100644
index 40eed91f20..0000000000
--- a/java/src/com/android/inputmethod/compat/AudioManagerCompatWrapper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2011 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.inputmethod.compat;
-
-import android.media.AudioManager;
-
-import java.lang.reflect.Method;
-
-public final class AudioManagerCompatWrapper {
-    private static final Method METHOD_isWiredHeadsetOn = CompatUtils.getMethod(
-            AudioManager.class, "isWiredHeadsetOn");
-    private static final Method METHOD_isBluetoothA2dpOn = CompatUtils.getMethod(
-            AudioManager.class, "isBluetoothA2dpOn");
-
-    private final AudioManager mManager;
-
-    public AudioManagerCompatWrapper(AudioManager manager) {
-        mManager = manager;
-    }
-
-    /**
-     * Checks whether audio routing to the wired headset is on or off.
-     *
-     * @return true if audio is being routed to/from wired headset;
-     *         false if otherwise
-     */
-    public boolean isWiredHeadsetOn() {
-        return (Boolean) CompatUtils.invoke(mManager, false, METHOD_isWiredHeadsetOn);
-    }
-
-    /**
-     * Checks whether A2DP audio routing to the Bluetooth headset is on or off.
-     *
-     * @return true if A2DP audio is being routed to/from Bluetooth headset;
-     *         false if otherwise
-     */
-    public boolean isBluetoothA2dpOn() {
-        return (Boolean) CompatUtils.invoke(mManager, false, METHOD_isBluetoothA2dpOn);
-    }
-}
-- 
GitLab