Android keystore jks pk8 x509.pem

Lists entries in a keystore

  1. keytool -list -v -keystore platform.keystore

Generate Signed APK Using jarsigner

  1. jarsigner -verbose -keystore platform.keystore -signedjar app-debug-signed.apk app-debug.apk alias-name

pk8 & x509.pem -> keystore

  1. ./keytool-importkeypair -k ./oldplatform.keystore -p password -pk8 ../platform.pk8 -cert ../platform.x509.pem -alias alias-name

keystore -> p12 -> jks

  1. keytool -importkeystore -srckeystore platform.keystore -srcstoretype JKS -deststoretype PKCS12 -destkeystore platform.keystore.p12
  2. keytool -v -importkeystore -srckeystore platform.keystore.p12 -srcstoretype PKCS12 -destkeystore platform.keystore.jks -deststoretype JKS

Generate Signed APK Using Android Studio


Using X11 for GUI

Result

Code

  1. #include <X11/Xlib.h>
  2. #include <X11/Xlocale.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6.  
  7. void
  8. DrawCenteredMbString(Display* dpy, Window w, XFontSet fontset, GC gc, char* str, int num_bytes, int x, int y, int width,
  9. 	int height) {
  10. 	XRectangle boundingbox;
  11. 	XRectangle dummy;
  12. 	int originx, originy;
  13.  
  14. 	(void)XmbTextExtents(fontset, str, num_bytes, &dummy, &boundingbox);
  15.  
  16. 	originx = x + (width - boundingbox.width) / 2 - boundingbox.x;
  17. 	originy = y + (height - boundingbox.height) / 2 - boundingbox.y;
  18.  
  19. 	XmbDrawString(dpy, w, fontset, gc, originx, originy, str, num_bytes);
  20. }
  21.  
  22. int main(void) {
  23. 	Display* d;
  24. 	Window w;
  25. 	GC gc;
  26. 	XGCValues values;
  27. 	XEvent e;
  28. 	XFontStruct* fs, * fs16;
  29. 	char** fonts;
  30. 	int font_count;
  31. 	XFontSet fontset;
  32. 	char** missing_charsets;
  33. 	int num_missing_charsets;
  34. 	char* default_string;
  35.  
  36. 	char* msg = "Hello, World!";
  37. 	char* msg2 = "啊,世界,啊啊啊";
  38. 	int s;
  39.  
  40. 	if (setlocale(LC_ALL, "") == NULL) {
  41. 		printf("cannot set locale \n");
  42. 		exit(1);
  43. 	}
  44.  
  45. 	if (!XSupportsLocale()) {
  46. 		printf("X does not support locale %s\n", setlocale(LC_ALL, NULL));
  47. 		exit(1);
  48. 	}
  49.  
  50. 	if (XSetLocaleModifiers("") == NULL) {
  51. 		printf("Warning: cannot set locale modifiers\n");
  52. 	}
  53.  
  54.  
  55. 	d = XOpenDisplay(NULL);
  56. 	if (d == NULL) {
  57. 		fprintf(stderr, "Cannot open display\n");
  58. 		exit(1);
  59. 	}
  60.  
  61. 	fonts = XListFonts(d, "*hanzi*", 10000, &font_count);
  62. 	for (int i = 0; i < font_count; i++)
  63. 		printf("%s\n", fonts[i]);
  64. 	XFreeFontNames(fonts);
  65.  
  66. 	if ((fs16 = XLoadQueryFont(d, "hanzigb16st")) == NULL) {
  67. 		printf("Cannot load font\n");
  68. 		exit(1);
  69. 	}
  70.  
  71. 	s = DefaultScreen(d);
  72. 	w = XCreateSimpleWindow(d, RootWindow(d, s), 100, 100, 500, 500, 1,
  73. 		777215, 111111);
  74. 	printf("BlackPixel(d, s) is %d\n", (int)BlackPixel(d, s));
  75. 	printf("WhitePixel(d, s) is %d\n", (int)WhitePixel(d, s));
  76.  
  77. 	fontset = XCreateFontSet(
  78. 		d, "-*-*-*-*-*-*-16-*-*-*-*-*-*-*",
  79. 		&missing_charsets, &num_missing_charsets,
  80. 		&default_string);
  81. 	if (num_missing_charsets > 0) {
  82. 		printf("The following charsets are missing\n");
  83. 		for (int i = 0; i < num_missing_charsets; i++) {
  84. 			printf("%s \n", missing_charsets);
  85. 			printf("The string is %s \n", default_string);
  86. 			printf("of any characters from those sets\n");
  87. 		}
  88. 		XFreeStringList(missing_charsets);
  89. 	}
  90. 	XSetLineAttributes(d, gc, 5, LineSolid, CapRound, JoinRound);
  91.  
  92.  
  93. 	XSelectInput(d, w, ExposureMask | KeyPressMask);
  94. 	gc = XCreateGC(d, w, 0, &values);
  95. 	XMapWindow(d, w);
  96.  
  97. 	int y = 50;
  98. 	for (int i = 0; i < 10; i++) {
  99.  
  100. 		//XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10);
  101. 		XDrawString(d, w, DefaultGC(d, s), 10, y + i * 20, msg, strlen(msg));
  102.  
  103. 		//XSetFont(d, gc, fs16->fid);
  104. 		//XDrawString16(d, w, gc, 100, y + i * 20, (XChar2b *) msg2, strlen(msg2) / 2);
  105.  
  106. 		int msg_len = strlen(msg2);
  107.  
  108. 		DrawCenteredMbString(
  109. 			d, w, fontset, gc,
  110. 			msg2,
  111. 			msg_len, 50, y + i * 20, 100, 50);
  112.  
  113. 		XFlush(d);
  114. 		sleep(1);
  115.  
  116. 	}
  117.  
  118. 	/*while(1) {
  119. 		XNextEvent(d, &e);
  120. 		if (e.type == KeyPress)
  121. 		  break;
  122. 	}*/
  123.  
  124. 	XCloseDisplay(d);
  125. 	return 0;
  126. }

Android ADB Shell Commands Notes

Prints a list of all attached emulator/device

  1. >adb devices
  2. List of devices attached
  3. xxxxxxxxxx      device

Forward socket connections

  1. >adb forward tcp:10172 tcp:9999

Restarts the adbd daemon with Root permissions

>adb root

Put /system partition in Writable mode

>adb remount
remount succeeded

Upload a specified file from your computer to an emulator/device

  1. >adb -s xxxxxxxxxx push term_emv_clc2 /system/tmp

Shell command mode

  1. >adb shell

How to compile Lua for Android

Update lmathlib.c

  1. Index: lmathlib.c
  2. ===================================================================
  3. --- lmathlib.c	(revision 4050)
  4. +++ lmathlib.c	(revision 4051)
  5. @@ -183,10 +183,10 @@
  6.      res = l_mathop(log)(x);
  7.    else {
  8.      lua_Number base = luaL_checknumber(L, 2);
  9. -#if !defined(LUA_USE_C89)
  10. -    if (base == l_mathop(2.0))
  11. -      res = l_mathop(log2)(x); else
  12. -#endif
  13. +//#if !defined(LUA_USE_C89)
  14. +//    if (base == l_mathop(2.0))
  15. +//      res = l_mathop(log2)(x); else
  16. +//#endif
  17.      if (base == l_mathop(10.0))
  18.        res = l_mathop(log10)(x);
  19.      else

Update luaconf.h

  1. Index: luaconf.h
  2. ===================================================================
  3. --- luaconf.h	(revision 4050)
  4. +++ luaconf.h	(revision 4051)
  5. @@ -677,7 +677,7 @@
  6.  ** macro must include header 'locale.h'.)
  7.  */
  8.  #if !defined(lua_getlocaledecpoint)
  9. -#define lua_getlocaledecpoint()		(localeconv()->decimal_point[0])
  10. +#define lua_getlocaledecpoint()		('.')
  11.  #endif
  12.  
  13.  /* }================================================================== */

Android.mk

  1. #
  2. # Android.mk
  3. #
  4. # Lua
  5. #
  6. LOCAL_PATH := $(call my-dir)/../src
  7.  
  8. include $(CLEAR_VARS)
  9.  
  10. LOCAL_MODULE     := Lua
  11. LOCAL_CPPFLAGS   := -std=c++17
  12. LOCAL_SRC_FILES := \
  13.     $(LOCAL_PATH)/lapi.c \
  14.     $(LOCAL_PATH)/lauxlib.c \
  15.     $(LOCAL_PATH)/lbaselib.c \
  16.     $(LOCAL_PATH)/lbitlib.c \
  17.     $(LOCAL_PATH)/lcode.c \
  18.     $(LOCAL_PATH)/lcorolib.c \
  19.     $(LOCAL_PATH)/lctype.c \
  20.     $(LOCAL_PATH)/ldblib.c \
  21.     $(LOCAL_PATH)/ldebug.c \
  22.     $(LOCAL_PATH)/ldo.c \
  23.     $(LOCAL_PATH)/ldump.c \
  24.     $(LOCAL_PATH)/lfunc.c \
  25.     $(LOCAL_PATH)/lgc.c \
  26.     $(LOCAL_PATH)/linit.c \
  27.     $(LOCAL_PATH)/liolib.c \
  28.     $(LOCAL_PATH)/llex.c \
  29.     $(LOCAL_PATH)/lmathlib.c \
  30.     $(LOCAL_PATH)/lmem.c \
  31.     $(LOCAL_PATH)/loadlib.c \
  32.     $(LOCAL_PATH)/lobject.c \
  33.     $(LOCAL_PATH)/lopcodes.c \
  34.     $(LOCAL_PATH)/loslib.c \
  35.     $(LOCAL_PATH)/lparser.c \
  36.     $(LOCAL_PATH)/lstate.c \
  37.     $(LOCAL_PATH)/lstring.c \
  38.     $(LOCAL_PATH)/lstrlib.c \
  39.     $(LOCAL_PATH)/ltable.c \
  40.     $(LOCAL_PATH)/ltablib.c \
  41.     $(LOCAL_PATH)/ltm.c \
  42.     $(LOCAL_PATH)/lua.c \
  43.     $(LOCAL_PATH)/luac.c \
  44.     $(LOCAL_PATH)/lundump.c \
  45.     $(LOCAL_PATH)/lutf8lib.c \
  46.     $(LOCAL_PATH)/lvm.c \
  47.     $(LOCAL_PATH)/lzio.c
  48.  
  49. include $(BUILD_STATIC_LIBRARY)

Android NDK C++17 Support

build.gradle

  1. apply plugin: 'com.android.application'
  2.  
  3. android {
  4.     compileSdkVersion 29
  5.     buildToolsVersion "29.0.2"
  6.     defaultConfig {
  7.         applicationId "com.example.myapplication"
  8.         minSdkVersion 15
  9.         targetSdkVersion 29
  10.         versionCode 1
  11.         versionName "1.0"
  12.         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  13.         externalNativeBuild {
  14.             cmake {
  15.                 cppFlags "-std=c++17"
  16.             }
  17.         }
  18.     }
  19.     buildTypes {
  20.         release {
  21.             minifyEnabled false
  22.             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  23.         }
  24.     }
  25.     externalNativeBuild {
  26.         cmake {
  27.             path "src/main/cpp/CMakeLists.txt"
  28.             version "3.10.2"
  29.         }
  30.     }
  31. }
  32.  
  33. dependencies {
  34.     implementation fileTree(dir: 'libs', include: ['*.jar'])
  35.     implementation 'androidx.appcompat:appcompat:1.0.2'
  36.     implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
  37.     testImplementation 'junit:junit:4.12'
  38.     androidTestImplementation 'androidx.test:runner:1.1.1'
  39.     androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
  40. }