mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-08 14:56:12 -04:00
Android: Use device UUID for key so passwords are remembered
This commit is contained in:
parent
8a3216cb99
commit
de71be97bd
@ -22,6 +22,7 @@ import android.graphics.PixelFormat;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.StrictMode;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.Selection;
|
||||
@ -102,9 +103,9 @@ public class MainActivity extends Activity implements SurfaceHolder.Callback2 {
|
||||
final static int CMD_KEY_CHAR = 2;
|
||||
final static int CMD_KEY_TEXT = 19;
|
||||
|
||||
final static int CMD_MOUSE_DOWN = 3;
|
||||
final static int CMD_MOUSE_UP = 4;
|
||||
final static int CMD_MOUSE_MOVE = 5;
|
||||
final static int CMD_POINTER_DOWN = 3;
|
||||
final static int CMD_POINTER_UP = 4;
|
||||
final static int CMD_POINTER_MOVE = 5;
|
||||
|
||||
final static int CMD_WIN_CREATED = 6;
|
||||
final static int CMD_WIN_DESTROYED = 7;
|
||||
@ -112,15 +113,15 @@ public class MainActivity extends Activity implements SurfaceHolder.Callback2 {
|
||||
final static int CMD_WIN_REDRAW = 9;
|
||||
|
||||
final static int CMD_APP_START = 10;
|
||||
final static int CMD_APP_STOP = 11;
|
||||
final static int CMD_APP_STOP = 11;
|
||||
final static int CMD_APP_RESUME = 12;
|
||||
final static int CMD_APP_PAUSE = 13;
|
||||
final static int CMD_APP_DESTROY = 14;
|
||||
|
||||
final static int CMD_GOT_FOCUS = 15;
|
||||
final static int CMD_LOST_FOCUS = 16;
|
||||
final static int CMD_GOT_FOCUS = 15;
|
||||
final static int CMD_LOST_FOCUS = 16;
|
||||
final static int CMD_CONFIG_CHANGED = 17;
|
||||
final static int CMD_LOW_MEMORY = 18;
|
||||
final static int CMD_LOW_MEMORY = 18;
|
||||
|
||||
// ======================================
|
||||
// --------------- EVENTS ---------------
|
||||
@ -199,17 +200,17 @@ public class MainActivity extends Activity implements SurfaceHolder.Callback2 {
|
||||
switch (event.getActionMasked()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
case MotionEvent.ACTION_POINTER_DOWN:
|
||||
pushTouch(CMD_MOUSE_DOWN, event, event.getActionIndex());
|
||||
pushTouch(CMD_POINTER_DOWN, event, event.getActionIndex());
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
pushTouch(CMD_MOUSE_UP, event, event.getActionIndex());
|
||||
pushTouch(CMD_POINTER_UP, event, event.getActionIndex());
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
for (int i = 0; i < event.getPointerCount(); i++) {
|
||||
pushTouch(CMD_MOUSE_MOVE, event, i);
|
||||
pushTouch(CMD_POINTER_MOVE, event, i);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -294,9 +295,9 @@ public class MainActivity extends Activity implements SurfaceHolder.Callback2 {
|
||||
case CMD_KEY_CHAR: processKeyChar(c.arg1); break;
|
||||
case CMD_KEY_TEXT: processKeyText(c.str); break;
|
||||
|
||||
case CMD_MOUSE_DOWN: processMouseDown(c.arg1, c.arg2, c.arg3); break;
|
||||
case CMD_MOUSE_UP: processMouseUp(c.arg1, c.arg2, c.arg3); break;
|
||||
case CMD_MOUSE_MOVE: processMouseMove(c.arg1, c.arg2, c.arg3); break;
|
||||
case CMD_POINTER_DOWN: processPointerDown(c.arg1, c.arg2, c.arg3, 0); break;
|
||||
case CMD_POINTER_UP: processPointerUp( c.arg1, c.arg2, c.arg3, 0); break;
|
||||
case CMD_POINTER_MOVE: processPointerMove(c.arg1, c.arg2, c.arg3, 0); break;
|
||||
|
||||
case CMD_WIN_CREATED: processSurfaceCreated(c.sur); break;
|
||||
case CMD_WIN_DESTROYED: processSurfaceDestroyed(); break;
|
||||
@ -326,9 +327,9 @@ public class MainActivity extends Activity implements SurfaceHolder.Callback2 {
|
||||
native void processKeyChar(int code);
|
||||
native void processKeyText(String str);
|
||||
|
||||
native void processMouseDown(int id, int x, int y);
|
||||
native void processMouseUp(int id, int x, int y);
|
||||
native void processMouseMove(int id, int x, int y);
|
||||
native void processPointerDown(int id, int x, int y, int isMouse);
|
||||
native void processPointerUp( int id, int x, int y, int isMouse);
|
||||
native void processPointerMove(int id, int x, int y, int isMouse);
|
||||
|
||||
native void processSurfaceCreated(Surface sur);
|
||||
native void processSurfaceDestroyed();
|
||||
@ -517,6 +518,10 @@ public class MainActivity extends Activity implements SurfaceHolder.Callback2 {
|
||||
return getExternalFilesDir(null).getAbsolutePath();
|
||||
}
|
||||
|
||||
public String getUUID() {
|
||||
return Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID);
|
||||
}
|
||||
|
||||
public long getApkUpdateTime() {
|
||||
try {
|
||||
//String name = getPackageName();
|
||||
|
@ -133,7 +133,7 @@ build_android() {
|
||||
rm classes.dex
|
||||
# copy required native libraries
|
||||
rm -rf lib
|
||||
mkdir lib lib/armeabi lib/armeabi-v7a lib/arm64-v8alib/x86 lib/x86_64
|
||||
mkdir lib lib/armeabi lib/armeabi-v7a lib/arm64-v8a lib/x86 lib/x86_64
|
||||
cp $ROOT_DIR/src/cc-droid-arm_16 lib/armeabi/libclassicube.so
|
||||
cp $ROOT_DIR/src/cc-droid-arm_32 lib/armeabi-v7a/libclassicube.so
|
||||
cp $ROOT_DIR/src/cc-droid-arm_64 lib/arm64-v8a/libclassicube.so
|
||||
|
@ -1916,6 +1916,15 @@ static cc_result GetMachineID(cc_uint32* key) {
|
||||
DecodeMachineID(host, HW_HOSTID_LEN, key);
|
||||
return 0;
|
||||
}
|
||||
#elif defined CC_BUILD_ANDROID
|
||||
static cc_result GetMachineID(cc_uint32* key) {
|
||||
cc_string dir; char dirBuffer[STRING_SIZE];
|
||||
String_InitArray(dir, dirBuffer);
|
||||
|
||||
JavaCall_Void_String("getUUID", &dir);
|
||||
DecodeMachineID(dirBuffer, dir.length, key);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static cc_result GetMachineID(cc_uint32* key) { return ERR_NOT_SUPPORTED; }
|
||||
#endif
|
||||
|
18
src/Window.c
18
src/Window.c
@ -3543,18 +3543,18 @@ static void JNICALL java_processKeyText(JNIEnv* env, jobject o, jstring str) {
|
||||
Event_RaiseString(&InputEvents.TextChanged, &text);
|
||||
}
|
||||
|
||||
static void JNICALL java_processMouseDown(JNIEnv* env, jobject o, jint id, jint x, jint y) {
|
||||
Platform_Log3("MOUSE %i - DOWN %i,%i", &id, &x, &y);
|
||||
static void JNICALL java_processPointerDown(JNIEnv* env, jobject o, jint id, jint x, jint y, jint isMouse) {
|
||||
Platform_Log4("POINTER %i (%i) - DOWN %i,%i", &id, &isMouse, &x, &y);
|
||||
Input_AddTouch(id, x, y);
|
||||
}
|
||||
|
||||
static void JNICALL java_processMouseUp(JNIEnv* env, jobject o, jint id, jint x, jint y) {
|
||||
Platform_Log3("MOUSE %i - UP %i,%i", &id, &x, &y);
|
||||
static void JNICALL java_processPointerUp(JNIEnv* env, jobject o, jint id, jint x, jint y, jint isMouse) {
|
||||
Platform_Log4("POINTER %i (%i) - UP %i,%i", &id, &isMouse, &x, &y);
|
||||
Input_RemoveTouch(id, x, y);
|
||||
}
|
||||
|
||||
static void JNICALL java_processMouseMove(JNIEnv* env, jobject o, jint id, jint x, jint y) {
|
||||
Platform_Log3("MOUSE %i - MOVE %i,%i", &id, &x, &y);
|
||||
static void JNICALL java_processPointerMove(JNIEnv* env, jobject o, jint id, jint x, jint y, jint isMouse) {
|
||||
Platform_Log4("POINTER %i (%i) - MOVE %i,%i", &id, &isMouse, &x, &y);
|
||||
Input_UpdateTouch(id, x, y);
|
||||
}
|
||||
|
||||
@ -3640,9 +3640,9 @@ static const JNINativeMethod methods[19] = {
|
||||
{ "processKeyChar", "(I)V", java_processKeyChar },
|
||||
{ "processKeyText", "(Ljava/lang/String;)V", java_processKeyText },
|
||||
|
||||
{ "processMouseDown", "(III)V", java_processMouseDown },
|
||||
{ "processMouseUp", "(III)V", java_processMouseUp },
|
||||
{ "processMouseMove", "(III)V", java_processMouseMove },
|
||||
{ "processPointerDown", "(IIII)V", java_processPointerDown },
|
||||
{ "processPointerUp", "(IIII)V", java_processPointerUp },
|
||||
{ "processPointerMove", "(IIII)V", java_processPointerMove },
|
||||
|
||||
{ "processSurfaceCreated", "(Landroid/view/Surface;)V", java_processSurfaceCreated },
|
||||
{ "processSurfaceDestroyed", "()V", java_processSurfaceDestroyed },
|
||||
|
Loading…
x
Reference in New Issue
Block a user