AppWorkaroundsUtils.java revision 7058b02a9c798c21b169b778be2befc7739f4e9b
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 17package com.android.inputmethod.compat; 18 19import android.content.pm.PackageInfo; 20import android.os.Build.VERSION_CODES; 21 22/** 23 * A class to encapsulate work-arounds specific to particular apps. 24 */ 25public class AppWorkaroundsUtils { 26 private PackageInfo mPackageInfo; // May be null 27 28 public void setPackageInfo(final PackageInfo packageInfo) { 29 mPackageInfo = packageInfo; 30 } 31 32 public boolean isBeforeJellyBean() { 33 if (null == mPackageInfo || null == mPackageInfo.applicationInfo) { 34 return false; 35 } 36 return mPackageInfo.applicationInfo.targetSdkVersion < VERSION_CODES.JELLY_BEAN; 37 } 38 39 @Override 40 public String toString() { 41 if (null == mPackageInfo || null == mPackageInfo.applicationInfo) { 42 return ""; 43 } 44 final StringBuilder s = new StringBuilder(); 45 s.append("Target application : ") 46 .append(mPackageInfo.applicationInfo.name) 47 .append("\nPackage : ") 48 .append(mPackageInfo.applicationInfo.packageName) 49 .append("\nTarget app sdk version : ") 50 .append(mPackageInfo.applicationInfo.targetSdkVersion); 51 return s.toString(); 52 } 53} 54