|
@@ -91,7 +91,7 @@ import android.os.Messenger;
|
|
|
import android.os.SystemClock;
|
|
|
|
|
|
public class Godot extends Activity implements SensorEventListener, IDownloaderClient {
|
|
|
-
|
|
|
+ private static final String TAG = "Godot";
|
|
|
static final int MAX_SINGLETONS = 64;
|
|
|
private IStub mDownloaderClientStub;
|
|
|
private IDownloaderService mRemoteService;
|
|
@@ -149,21 +149,16 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
Method[] methods = clazz.getDeclaredMethods();
|
|
|
for (Method method : methods) {
|
|
|
boolean found = false;
|
|
|
- Log.d("XXX", "METHOD: %s\n" + method.getName());
|
|
|
|
|
|
for (String s : p_methods) {
|
|
|
- Log.d("XXX", "METHOD CMP WITH: %s\n" + s);
|
|
|
if (s.equals(method.getName())) {
|
|
|
found = true;
|
|
|
- Log.d("XXX", "METHOD CMP VALID");
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (!found)
|
|
|
continue;
|
|
|
|
|
|
- Log.d("XXX", "METHOD FOUND: %s\n" + method.getName());
|
|
|
-
|
|
|
List<String> ptr = new ArrayList<String>();
|
|
|
|
|
|
Class[] paramTypes = method.getParameterTypes();
|
|
@@ -190,21 +185,10 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
|
protected void onGLDrawFrame(GL10 gl) {}
|
|
|
protected void onGLSurfaceChanged(GL10 gl, int width, int height) {} // singletons will always miss first onGLSurfaceChanged call
|
|
|
- //protected void onGLSurfaceCreated(GL10 gl, EGLConfig config) {} // singletons won't be ready until first GodotLib.step()
|
|
|
|
|
|
public void registerMethods() {}
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- protected List<SingletonBase> singletons = new ArrayList<SingletonBase>();
|
|
|
- protected void instanceSingleton(SingletonBase s) {
|
|
|
-
|
|
|
- s.registerMethods();
|
|
|
- singletons.add(s);
|
|
|
- }
|
|
|
-
|
|
|
-*/
|
|
|
-
|
|
|
private String[] command_line;
|
|
|
|
|
|
public GodotView mView;
|
|
@@ -222,7 +206,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
static public GodotIO io;
|
|
|
|
|
|
public static void setWindowTitle(String title) {
|
|
|
- //setTitle(title);
|
|
|
}
|
|
|
|
|
|
static SingletonBase singletons[] = new SingletonBase[MAX_SINGLETONS];
|
|
@@ -253,9 +236,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
|
public void onVideoInit(boolean use_gl2) {
|
|
|
|
|
|
- // mView = new GodotView(getApplication(),io,use_gl2);
|
|
|
- // setContentView(mView);
|
|
|
-
|
|
|
layout = new FrameLayout(this);
|
|
|
layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
|
|
setContentView(layout);
|
|
@@ -273,7 +253,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
edittext.setView(mView);
|
|
|
io.setEdit(edittext);
|
|
|
|
|
|
- // Ad layout
|
|
|
+ // Add layout
|
|
|
adLayout = new RelativeLayout(this);
|
|
|
adLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
|
|
layout.addView(adLayout);
|
|
@@ -323,8 +303,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
byte[] len = new byte[4];
|
|
|
int r = is.read(len);
|
|
|
if (r < 4) {
|
|
|
- Log.d("XXX", "**ERROR** Wrong cmdline length.\n");
|
|
|
- Log.d("GODOT", "**ERROR** Wrong cmdline length.\n");
|
|
|
+ Log.w(TAG, "Wrong cmdline length.\n");
|
|
|
return new String[0];
|
|
|
}
|
|
|
int argc = ((int)(len[3] & 0xFF) << 24) | ((int)(len[2] & 0xFF) << 16) | ((int)(len[1] & 0xFF) << 8) | ((int)(len[0] & 0xFF));
|
|
@@ -334,12 +313,12 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
r = is.read(len);
|
|
|
if (r < 4) {
|
|
|
|
|
|
- Log.d("GODOT", "**ERROR** Wrong cmdline param lenght.\n");
|
|
|
+ Log.w(TAG, "Wrong cmdline param length.\n");
|
|
|
return new String[0];
|
|
|
}
|
|
|
int strlen = ((int)(len[3] & 0xFF) << 24) | ((int)(len[2] & 0xFF) << 16) | ((int)(len[1] & 0xFF) << 8) | ((int)(len[0] & 0xFF));
|
|
|
if (strlen > 65535) {
|
|
|
- Log.d("GODOT", "**ERROR** Wrong command len\n");
|
|
|
+ Log.w(TAG, "Wrong command length\n");
|
|
|
return new String[0];
|
|
|
}
|
|
|
byte[] arg = new byte[strlen];
|
|
@@ -351,7 +330,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
return cmdline;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- Log.d("GODOT", "**ERROR** Exception " + e.getClass().getName() + ":" + e.getMessage());
|
|
|
+ Log.w(TAG, "Exception " + e.getClass().getName() + ":" + e.getMessage());
|
|
|
return new String[0];
|
|
|
}
|
|
|
}
|
|
@@ -365,14 +344,14 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
String[] new_cmdline;
|
|
|
int cll = 0;
|
|
|
if (command_line != null) {
|
|
|
- Log.d("GODOT", "initializeGodot: command_line: is not null");
|
|
|
+ Log.d(TAG, "initializeGodot: command_line: is not null");
|
|
|
new_cmdline = new String[command_line.length + 2];
|
|
|
cll = command_line.length;
|
|
|
for (int i = 0; i < command_line.length; i++) {
|
|
|
new_cmdline[i] = command_line[i];
|
|
|
}
|
|
|
} else {
|
|
|
- Log.d("GODOT", "initializeGodot: command_line: is null");
|
|
|
+ Log.d(TAG, "initializeGodot: command_line: is null");
|
|
|
new_cmdline = new String[2];
|
|
|
}
|
|
|
|
|
@@ -384,13 +363,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
io = new GodotIO(this);
|
|
|
io.unique_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
|
|
|
GodotLib.io = io;
|
|
|
- Log.d("GODOT", "command_line is null? " + ((command_line == null) ? "yes" : "no"));
|
|
|
- /*if(command_line != null){
|
|
|
- Log.d("GODOT", "Command Line:");
|
|
|
- for(int w=0;w <command_line.length;w++){
|
|
|
- Log.d("GODOT"," " + command_line[w]);
|
|
|
- }
|
|
|
- }*/
|
|
|
+ Log.d(TAG, "command_line is null? " + ((command_line == null) ? "yes" : "no"));
|
|
|
GodotLib.initialize(this, io.needsReloadHooks(), command_line, getAssets());
|
|
|
mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
|
|
|
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
|
@@ -417,15 +390,13 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
@Override
|
|
|
protected void onCreate(Bundle icicle) {
|
|
|
|
|
|
- Log.d("GODOT", "** GODOT ACTIVITY CREATED HERE ***\n");
|
|
|
+ Log.d(TAG, "** GODOT ACTIVITY CREATED HERE ***\n");
|
|
|
|
|
|
super.onCreate(icicle);
|
|
|
_self = this;
|
|
|
Window window = getWindow();
|
|
|
- //window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
|
|
|
|
|
|
- //check for apk expansion API
|
|
|
if (true) {
|
|
|
boolean md5mismatch = false;
|
|
|
command_line = getCommandLine();
|
|
@@ -477,7 +448,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
if (use_apk_expansion && main_pack_md5 != null && main_pack_key != null) {
|
|
|
//check that environment is ok!
|
|
|
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
|
|
- Log.d("GODOT", "**ERROR! No media mounted!");
|
|
|
+ Log.d(TAG, "**ERROR! No media mounted!");
|
|
|
//show popup and die
|
|
|
}
|
|
|
|
|
@@ -493,25 +464,25 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
File f = new File(expansion_pack_path);
|
|
|
|
|
|
boolean pack_valid = true;
|
|
|
- Log.d("GODOT", "**PACK** - Path " + expansion_pack_path);
|
|
|
+ Log.d(TAG, "**PACK** - Path " + expansion_pack_path);
|
|
|
|
|
|
if (!f.exists()) {
|
|
|
|
|
|
pack_valid = false;
|
|
|
- Log.d("GODOT", "**PACK** - File does not exist");
|
|
|
+ Log.d(TAG, "**PACK** - File does not exist");
|
|
|
|
|
|
} else if (obbIsCorrupted(expansion_pack_path, main_pack_md5)) {
|
|
|
- Log.d("GODOT", "**PACK** - Expansion pack (obb) is corrupted");
|
|
|
+ Log.d(TAG, "**PACK** - Expansion pack (obb) is corrupted");
|
|
|
pack_valid = false;
|
|
|
try {
|
|
|
f.delete();
|
|
|
} catch (Exception e) {
|
|
|
- Log.d("GODOT", "**PACK** - Error deleting corrupted expansion pack (obb)");
|
|
|
+ Log.d(TAG, "**PACK** - Error deleting corrupted expansion pack (obb)");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!pack_valid) {
|
|
|
- Log.d("GODOT", "Pack Invalid, try re-downloading.");
|
|
|
+ Log.d(TAG, "Pack Invalid, try re-downloading.");
|
|
|
|
|
|
Intent notifierIntent = new Intent(this, this.getClass());
|
|
|
notifierIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
|
|
@@ -522,15 +493,15 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
|
int startResult;
|
|
|
try {
|
|
|
- Log.d("GODOT", "INITIALIZING DOWNLOAD");
|
|
|
+ Log.d(TAG, "INITIALIZING DOWNLOAD");
|
|
|
startResult = DownloaderClientMarshaller.startDownloadServiceIfRequired(
|
|
|
getApplicationContext(),
|
|
|
pendingIntent,
|
|
|
GodotDownloaderService.class);
|
|
|
- Log.d("GODOT", "DOWNLOAD SERVICE FINISHED:" + startResult);
|
|
|
+ Log.d(TAG, "DOWNLOAD SERVICE FINISHED:" + startResult);
|
|
|
|
|
|
if (startResult != DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED) {
|
|
|
- Log.d("GODOT", "DOWNLOAD REQUIRED");
|
|
|
+ Log.d(TAG, "DOWNLOAD REQUIRED");
|
|
|
// This is where you do set up to display the download
|
|
|
// progress (next step)
|
|
|
mDownloaderClientStub = DownloaderClientMarshaller.CreateStub(this,
|
|
@@ -550,11 +521,10 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
|
return;
|
|
|
} else {
|
|
|
- Log.d("GODOT", "NO DOWNLOAD REQUIRED");
|
|
|
+ Log.d(TAG, "NO DOWNLOAD REQUIRED");
|
|
|
}
|
|
|
} catch (NameNotFoundException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- Log.d("GODOT", "Error downloading expansion package:" + e.getMessage());
|
|
|
+ Log.w(TAG, "Error downloading expansion package:" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -563,8 +533,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
mCurrentIntent = getIntent();
|
|
|
|
|
|
initializeGodot();
|
|
|
-
|
|
|
- // instanceSingleton( new GodotFacebook(this) );
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -645,11 +613,11 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
|
float[] adjustedValues = new float[3];
|
|
|
final int axisSwap[][] = {
|
|
|
- { 1, -1, 0, 1 }, // ROTATION_0
|
|
|
+ { 1, -1, 0, 1 }, // ROTATION_0
|
|
|
{ -1, -1, 1, 0 }, // ROTATION_90
|
|
|
- { -1, 1, 0, 1 }, // ROTATION_180
|
|
|
- { 1, 1, 1, 0 }
|
|
|
- }; // ROTATION_270
|
|
|
+ { -1, 1, 0, 1 }, // ROTATION_180
|
|
|
+ { 1, 1, 1, 0 } // ROTATION_270
|
|
|
+ };
|
|
|
|
|
|
final int[] as = axisSwap[displayRotation];
|
|
|
adjustedValues[0] = (float)as[0] * event.values[as[2]];
|
|
@@ -680,22 +648,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
// Do something here if sensor accuracy changes.
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- @Override public boolean dispatchKeyEvent(KeyEvent event) {
|
|
|
-
|
|
|
- if (event.getKeyCode()==KeyEvent.KEYCODE_BACK) {
|
|
|
-
|
|
|
- System.out.printf("** BACK REQUEST!\n");
|
|
|
-
|
|
|
- GodotLib.quit();
|
|
|
- return true;
|
|
|
- }
|
|
|
- System.out.printf("** OTHER KEY!\n");
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
-*/
|
|
|
-
|
|
|
@Override
|
|
|
public void onBackPressed() {
|
|
|
boolean shouldQuit = true;
|
|
@@ -751,15 +703,14 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
}
|
|
|
String md5str = hexString.toString();
|
|
|
|
|
|
- //Log.d("GODOT","**PACK** - My MD5: "+hexString+" - APK md5: "+main_pack_md5);
|
|
|
if (!md5str.equals(main_pack_md5)) {
|
|
|
- Log.d("GODOT", "**PACK MD5 MISMATCH???** - MD5 Found: " + md5str + " " + Integer.toString(md5str.length()) + " - MD5 Expected: " + main_pack_md5 + " " + Integer.toString(main_pack_md5.length()));
|
|
|
+ Log.w(TAG, "Pack MD5 Mismatch - actual: " + md5str + " " + Integer.toString(md5str.length()) + " - expected: " + main_pack_md5 + " " + Integer.toString(main_pack_md5.length()));
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- Log.d("GODOT", "**PACK FAIL**");
|
|
|
+ Log.w(TAG, "Pack failed");
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -781,36 +732,26 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
arr[i * 3 + 2] = (int)event.getY(i);
|
|
|
}
|
|
|
|
|
|
- //System.out.printf("gaction: %d\n",event.getAction());
|
|
|
switch (event.getAction() & MotionEvent.ACTION_MASK) {
|
|
|
|
|
|
case MotionEvent.ACTION_DOWN: {
|
|
|
GodotLib.touch(0, 0, evcount, arr);
|
|
|
- //System.out.printf("action down at: %f,%f\n", event.getX(),event.getY());
|
|
|
} break;
|
|
|
case MotionEvent.ACTION_MOVE: {
|
|
|
GodotLib.touch(1, 0, evcount, arr);
|
|
|
- //for(int i=0;i<event.getPointerCount();i++) {
|
|
|
- // System.out.printf("%d - moved to: %f,%f\n",i, event.getX(i),event.getY(i));
|
|
|
- //}
|
|
|
} break;
|
|
|
case MotionEvent.ACTION_POINTER_UP: {
|
|
|
final int indexPointUp = event.getActionIndex();
|
|
|
final int pointer_idx = event.getPointerId(indexPointUp);
|
|
|
GodotLib.touch(4, pointer_idx, evcount, arr);
|
|
|
- //System.out.printf("%d - s.up at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
|
|
|
} break;
|
|
|
case MotionEvent.ACTION_POINTER_DOWN: {
|
|
|
int pointer_idx = event.getActionIndex();
|
|
|
GodotLib.touch(3, pointer_idx, evcount, arr);
|
|
|
- //System.out.printf("%d - s.down at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
|
|
|
} break;
|
|
|
case MotionEvent.ACTION_CANCEL:
|
|
|
case MotionEvent.ACTION_UP: {
|
|
|
GodotLib.touch(2, 0, evcount, arr);
|
|
|
- //for(int i=0;i<event.getPointerCount();i++) {
|
|
|
- // System.out.printf("%d - up! %f,%f\n",i, event.getX(i),event.getY(i));
|
|
|
- //}
|
|
|
} break;
|
|
|
}
|
|
|
return true;
|
|
@@ -852,10 +793,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
return mPaymentsManager;
|
|
|
}
|
|
|
|
|
|
- // public void setPaymentsManager(PaymentsManager mPaymentsManager) {
|
|
|
- // this.mPaymentsManager = mPaymentsManager;
|
|
|
- // };
|
|
|
-
|
|
|
// Audio
|
|
|
|
|
|
/**
|
|
@@ -865,7 +802,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
*/
|
|
|
@Override
|
|
|
public void onDownloadStateChanged(int newState) {
|
|
|
- Log.d("GODOT", "onDownloadStateChanged:" + newState);
|
|
|
+ Log.d(TAG, "onDownloadStateChanged:" + newState);
|
|
|
setState(newState);
|
|
|
boolean showDashboard = true;
|
|
|
boolean showCellMessage = false;
|
|
@@ -873,7 +810,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
boolean indeterminate;
|
|
|
switch (newState) {
|
|
|
case IDownloaderClient.STATE_IDLE:
|
|
|
- Log.d("GODOT", "STATE IDLE");
|
|
|
+ Log.d(TAG, "Download state changed to: STATE IDLE");
|
|
|
// STATE_IDLE means the service is listening, so it's
|
|
|
// safe to start making calls via mRemoteService.
|
|
|
paused = false;
|
|
@@ -881,13 +818,13 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
break;
|
|
|
case IDownloaderClient.STATE_CONNECTING:
|
|
|
case IDownloaderClient.STATE_FETCHING_URL:
|
|
|
- Log.d("GODOT", "STATE CONNECTION / FETCHING URL");
|
|
|
+ Log.d(TAG, "Download state changed to: STATE CONNECTION / FETCHING URL");
|
|
|
showDashboard = true;
|
|
|
paused = false;
|
|
|
indeterminate = true;
|
|
|
break;
|
|
|
case IDownloaderClient.STATE_DOWNLOADING:
|
|
|
- Log.d("GODOT", "STATE DOWNLOADING");
|
|
|
+ Log.d(TAG, "Download state changed to: STATE DOWNLOADING");
|
|
|
paused = false;
|
|
|
showDashboard = true;
|
|
|
indeterminate = false;
|
|
@@ -897,14 +834,14 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
case IDownloaderClient.STATE_FAILED:
|
|
|
case IDownloaderClient.STATE_FAILED_FETCHING_URL:
|
|
|
case IDownloaderClient.STATE_FAILED_UNLICENSED:
|
|
|
- Log.d("GODOT", "MANY TYPES OF FAILING");
|
|
|
+ Log.d(TAG, "Download state changed to: MANY TYPES OF FAILING");
|
|
|
paused = true;
|
|
|
showDashboard = false;
|
|
|
indeterminate = false;
|
|
|
break;
|
|
|
case IDownloaderClient.STATE_PAUSED_NEED_CELLULAR_PERMISSION:
|
|
|
case IDownloaderClient.STATE_PAUSED_WIFI_DISABLED_NEED_CELLULAR_PERMISSION:
|
|
|
- Log.d("GODOT", "PAUSED FOR SOME STUPID REASON");
|
|
|
+ Log.d(TAG, "Download state changed to: PAUSED FOR NETWORK PERMISSION NEEDED");
|
|
|
showDashboard = false;
|
|
|
paused = true;
|
|
|
indeterminate = false;
|
|
@@ -912,26 +849,26 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
break;
|
|
|
|
|
|
case IDownloaderClient.STATE_PAUSED_BY_REQUEST:
|
|
|
- Log.d("GODOT", "PAUSED BY STUPID USER");
|
|
|
+ Log.d(TAG, "Download state changed to: PAUSED BY USER");
|
|
|
paused = true;
|
|
|
indeterminate = false;
|
|
|
break;
|
|
|
case IDownloaderClient.STATE_PAUSED_ROAMING:
|
|
|
case IDownloaderClient.STATE_PAUSED_SDCARD_UNAVAILABLE:
|
|
|
- Log.d("GODOT", "PAUSED BY ROAMING WTF!?");
|
|
|
+ Log.d(TAG, "Download state changed to: PAUSED BY ROAMING");
|
|
|
paused = true;
|
|
|
indeterminate = false;
|
|
|
break;
|
|
|
case IDownloaderClient.STATE_COMPLETED:
|
|
|
- Log.d("GODOT", "COMPLETED");
|
|
|
+ Log.d(TAG, "Download state changed to: COMPLETED");
|
|
|
showDashboard = false;
|
|
|
paused = false;
|
|
|
indeterminate = false;
|
|
|
- // validateXAPKZipFiles();
|
|
|
initializeGodot();
|
|
|
return;
|
|
|
default:
|
|
|
- Log.d("GODOT", "DEFAULT ????");
|
|
|
+ Log.w(TAG, "Invalid download state");
|
|
|
+
|
|
|
paused = true;
|
|
|
indeterminate = true;
|
|
|
showDashboard = true;
|