• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.inputmethod.compat;
18 
19 import android.content.pm.PackageManager;
20 import android.content.pm.ServiceInfo;
21 import android.view.inputmethod.InputMethodInfo;
22 
23 import java.lang.reflect.Method;
24 
25 public class InputMethodInfoCompatWrapper {
26     private final InputMethodInfo mImi;
27     private static final Method METHOD_getSubtypeAt = CompatUtils.getMethod(
28             InputMethodInfo.class, "getSubtypeAt", int.class);
29     private static final Method METHOD_getSubtypeCount = CompatUtils.getMethod(
30             InputMethodInfo.class, "getSubtypeCount");
31 
InputMethodInfoCompatWrapper(InputMethodInfo imi)32     public InputMethodInfoCompatWrapper(InputMethodInfo imi) {
33         mImi = imi;
34     }
35 
getInputMethodInfo()36     public InputMethodInfo getInputMethodInfo() {
37         return mImi;
38     }
39 
getId()40     public String getId() {
41         return mImi.getId();
42     }
43 
getPackageName()44     public String getPackageName() {
45         return mImi.getPackageName();
46     }
47 
getServiceInfo()48     public ServiceInfo getServiceInfo() {
49         return mImi.getServiceInfo();
50     }
51 
getSubtypeCount()52     public int getSubtypeCount() {
53         return (Integer) CompatUtils.invoke(mImi, 0, METHOD_getSubtypeCount);
54     }
55 
getSubtypeAt(int index)56     public InputMethodSubtypeCompatWrapper getSubtypeAt(int index) {
57         return new InputMethodSubtypeCompatWrapper(CompatUtils.invoke(mImi, null,
58                 METHOD_getSubtypeAt, index));
59     }
60 
loadLabel(PackageManager pm)61     public CharSequence loadLabel(PackageManager pm) {
62         return mImi.loadLabel(pm);
63     }
64 
65     @Override
equals(Object o)66     public boolean equals(Object o) {
67         if (o instanceof InputMethodInfoCompatWrapper) {
68             return mImi.equals(((InputMethodInfoCompatWrapper)o).mImi);
69         }
70         return false;
71     }
72 
73     @Override
hashCode()74     public int hashCode() {
75         return mImi.hashCode();
76     }
77 }
78