am 40a3712a: Merge "Show version in dumped info"
* commit '40a3712a4c3e64fc074033ca8e20cc3a6175bcb6': Show version in dumped infomain
commit
69a0b5374f
|
@ -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