1 /* 2 * Copyright (C) 2013 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.PackageInfo; 20 import android.os.Build.VERSION_CODES; 21 22 /** 23 * A class to encapsulate work-arounds specific to particular apps. 24 */ 25 public class AppWorkaroundsUtils { 26 private final PackageInfo mPackageInfo; // May be null 27 private final boolean mIsBrokenByRecorrection; 28 AppWorkaroundsUtils(final PackageInfo packageInfo)29 public AppWorkaroundsUtils(final PackageInfo packageInfo) { 30 mPackageInfo = packageInfo; 31 mIsBrokenByRecorrection = AppWorkaroundsHelper.evaluateIsBrokenByRecorrection( 32 packageInfo); 33 } 34 isBrokenByRecorrection()35 public boolean isBrokenByRecorrection() { 36 return mIsBrokenByRecorrection; 37 } 38 isBeforeJellyBean()39 public boolean isBeforeJellyBean() { 40 if (null == mPackageInfo || null == mPackageInfo.applicationInfo) { 41 return false; 42 } 43 return mPackageInfo.applicationInfo.targetSdkVersion < VERSION_CODES.JELLY_BEAN; 44 } 45 46 @Override toString()47 public String toString() { 48 if (null == mPackageInfo || null == mPackageInfo.applicationInfo) { 49 return ""; 50 } 51 final StringBuilder s = new StringBuilder(); 52 s.append("Target application : ") 53 .append(mPackageInfo.applicationInfo.name) 54 .append("\nPackage : ") 55 .append(mPackageInfo.applicationInfo.packageName) 56 .append("\nTarget app sdk version : ") 57 .append(mPackageInfo.applicationInfo.targetSdkVersion); 58 return s.toString(); 59 } 60 } 61