Merge "Show version in dumped info"
commit
40a3712a4c
|
@ -3276,6 +3276,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
|
||||
final Printer p = new PrintWriterPrinter(fout);
|
||||
p.println("LatinIME state :");
|
||||
p.println(" VersionCode = " + ApplicationUtils.getVersionCode(this));
|
||||
p.println(" VersionName = " + ApplicationUtils.getVersionName(this));
|
||||
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
||||
final int keyboardMode = keyboard != null ? keyboard.mId.mMode : -1;
|
||||
p.println(" Keyboard mode = " + keyboardMode);
|
||||
|
|
|
@ -62,4 +62,22 @@ public final class ApplicationUtils {
|
|||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility method to get the application's PackageInfo.versionCode
|
||||
* @return the application's PackageInfo.versionCode
|
||||
*/
|
||||
public static int getVersionCode(final Context context) {
|
||||
try {
|
||||
if (context == null) {
|
||||
return 0;
|
||||
}
|
||||
final String packageName = context.getPackageName();
|
||||
final PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0);
|
||||
return info.versionCode;
|
||||
} catch (final NameNotFoundException e) {
|
||||
Log.e(TAG, "Could not find version info.", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue