rhodes 3.3.2.beta.1 → 3.3.2.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +5 -5
- data/Rakefile +1 -1
- data/doc/build.txt +27 -1
- data/doc/device-caps.txt +65 -18
- data/doc/install.txt +5 -3
- data/lib/extensions/barcode/ext/barcode/platform/wm/Barcode.sln +30 -0
- data/lib/extensions/barcode/ext/barcode/platform/wm/Barcode.vcproj +159 -5
- data/lib/extensions/barcode/ext/barcode/platform/wm/Rakefile +1 -1
- data/lib/extensions/digest-md5/ext/Rakefile +2 -2
- data/lib/extensions/digest-md5/ext/digest-md5.sln +44 -0
- data/lib/extensions/digest-sha1/ext/Rakefile +2 -2
- data/lib/extensions/digest-sha1/ext/digest-sha1.sln +44 -0
- data/lib/framework/rho/rhofsconnector.rb +9 -6
- data/lib/framework/rhom/rhom_db_adapter.rb +10 -0
- data/platform/android/Rhodes/jni/src/logconf.cpp +5 -0
- data/platform/android/Rhodes/jni/src/rhodesapp.cpp +7 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +82 -37
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoLogConf.java +2 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +8 -9
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +87 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +77 -159
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SplashScreen.java +4 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/GoogleMapView.java +6 -31
- data/platform/iphone/Classes/AppManager/AppManager.m +106 -29
- data/platform/iphone/Classes/Rhodes.m +27 -0
- data/platform/iphone/rbuild/iphone.rake +1 -1
- data/platform/shared/common/RhodesApp.cpp +10 -2
- data/platform/shared/common/RhodesAppBase.cpp +20 -4
- data/platform/shared/common/RhodesAppBase.h +4 -0
- data/platform/shared/db/DBAdapter.cpp +4 -6
- data/platform/shared/logging/RhoLogConf.cpp +2 -7
- data/platform/shared/logging/RhoLogConf.h +4 -0
- data/platform/shared/net/HttpServer.cpp +2 -2
- data/platform/shared/net/RawSocket.cpp +3 -0
- data/platform/shared/ruby/ext/rho/rhoruby.c +7 -3
- data/platform/shared/ruby/ext/rho/rhoruby.h +2 -1
- data/platform/shared/ruby/ext/rho/rhosupport.c +9 -3
- data/platform/shared/ruby/ext/system/system.i +4 -0
- data/platform/shared/ruby/ext/system/system_wrap.c +40 -1
- data/platform/wm/build/wm.rake +15 -5
- data/platform/wm/rhodes/LogView.cpp +25 -1
- data/platform/wm/rhodes/LogView.h +13 -0
- data/platform/wm/rhodes/MainWindow.cpp +4 -0
- data/platform/wm/rhodes/Rhodes.cpp +1 -1
- data/platform/wm/rhodes/rho/rubyext/RhoSignature.cpp +240 -145
- data/platform/wm/rhodes/rho/rubyext/RhoSignature.h +24 -5
- data/platform/wm/rhodes/rho/rubyext/calendar.cpp +8 -1
- data/platform/wm/tools/detool/detool.cpp +88 -7
- data/platform/wm/tools/detool/detool.vcproj +2 -2
- data/platform/wm/tools/detool/stdafx.h +1 -0
- data/platform/wp7/RhoRubyExtGen/RhoSyncEngine.cs +2 -2
- data/platform/wp7/RhoRubyLib/Initializers.Generated.cs +4 -4
- data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +8 -3
- data/platform/wp7/RhoRubyLib/net/HttpServer.cs +25 -6
- data/platform/wp7/RhoRubyLib/net/NetRequest.cs +1 -1
- data/platform/wp7/RhoRubyLib/rubyext/RhoSyncEngine.cs +23 -13
- data/platform/wp7/RhoRubyLib/sync/SyncProtocol_3.cs +6 -1
- data/platform/wp7/RhoRubyLib/views/RhoView.xaml.cs +33 -2
- data/platform/wp7/build/wp.rake +52 -0
- data/rakefile.rb +1 -1
- data/res/build-tools/detool.exe +0 -0
- data/res/generators/rhogen.rb +5 -0
- data/res/generators/templates/application/app/Settings/controller.rb +1 -1
- data/res/generators/templates/application/app/Settings/err_sync.erb +11 -0
- data/res/generators/templates/extension/extensions/montana/ext/montana/platform/wm/Montana.sln +22 -0
- data/res/generators/templates/extension/extensions/montana/ext/montana/platform/wm/Rakefile +2 -2
- data/spec/phone_spec/app/SpecRunner/index.erb +0 -1
- data/spec/phone_spec/app/spec/asynchttp_spec.rb +1 -11
- data/spec/phone_spec/app/spec/blobsync_spec.rb +7 -2
- data/spec/phone_spec/app/spec/date_spec.rb +1 -1
- data/spec/phone_spec/app/spec/json_spec.rb +0 -3
- data/spec/phone_spec/app/spec/syncengine_spec.rb +6 -2
- data/spec/phone_spec/app/spec_runner.rb +10 -7
- data/version +1 -1
- metadata +9 -9
- data/platform/wm/tools/wmdc_connect/stdafx.cpp +0 -27
- data/platform/wm/tools/wmdc_connect/stdafx.h +0 -35
- data/platform/wm/tools/wmdc_connect/wmdc_connect.cpp +0 -119
- data/platform/wm/tools/wmdc_connect/wmdc_connect.vcproj +0 -205
- data/platform/wm/tools/wmdc_connect.sln +0 -20
@@ -62,7 +62,7 @@ if defined?( RHODES_EMULATOR )
|
|
62
62
|
File.join(__rhoGetCurrentDir(), RHO_EMULATOR_DIR + '/db/syncdb' + postfix + '.sqlite')
|
63
63
|
else
|
64
64
|
if System::get_property('platform') == 'APPLE'
|
65
|
-
File.join(
|
65
|
+
File.join(__rhoGetDBDir(), 'db/syncdb' + postfix + '.sqlite')
|
66
66
|
else
|
67
67
|
File.join(__rhoGetCurrentDir(), 'db/syncdb' + postfix + '.sqlite')
|
68
68
|
end
|
@@ -75,7 +75,7 @@ if defined?( RHODES_EMULATOR )
|
|
75
75
|
File.join(__rhoGetCurrentDir(), RHO_EMULATOR_DIR + '/db/db-files')
|
76
76
|
else
|
77
77
|
if System::get_property('platform') == 'APPLE'
|
78
|
-
return File.join(
|
78
|
+
return File.join(__rhoGetDBDir(), 'db/db-files')
|
79
79
|
else
|
80
80
|
return File.join(__rhoGetCurrentDir(), 'db/db-files')
|
81
81
|
end
|
@@ -90,18 +90,21 @@ end
|
|
90
90
|
def get_blob_path(relative_path)
|
91
91
|
cur_dir = __rhoGetCurrentDir()
|
92
92
|
if System::get_property('platform') == 'APPLE'
|
93
|
-
cur_dir =
|
93
|
+
cur_dir = __rhoGetDBDir()
|
94
94
|
end
|
95
95
|
if defined?( RHODES_EMULATOR )
|
96
96
|
cur_dir = __rhoGetCurrentDir()
|
97
97
|
cur_dir = File.join(cur_dir, RHO_EMULATOR_DIR)
|
98
98
|
end
|
99
|
+
ress = ''
|
99
100
|
if cur_dir && cur_dir.length()>0
|
100
|
-
File.join(cur_dir, relative_path)
|
101
|
+
ress = File.join(cur_dir, relative_path)
|
101
102
|
else
|
102
|
-
relative_path.start_with?('/') ? relative_path : "/" + relative_path
|
103
|
+
ress = relative_path.start_with?('/') ? relative_path : "/" + relative_path
|
103
104
|
|
104
|
-
end
|
105
|
+
end
|
106
|
+
#puts '$$$ blob path ['+ress.to_s+'] for ['+relative_path.to_s+']'
|
107
|
+
return ress
|
105
108
|
end
|
106
109
|
|
107
110
|
end
|
@@ -30,10 +30,12 @@ module Rhom
|
|
30
30
|
class RhomDbAdapter
|
31
31
|
|
32
32
|
@database = nil
|
33
|
+
@dbpath = nil
|
33
34
|
|
34
35
|
# maintains a single database connection
|
35
36
|
def initialize(dbfile, partition)
|
36
37
|
unless @database
|
38
|
+
@dbpath = dbfile
|
37
39
|
@database = SQLite3::Database.new(dbfile,partition)
|
38
40
|
end
|
39
41
|
end
|
@@ -43,6 +45,7 @@ class RhomDbAdapter
|
|
43
45
|
if @database
|
44
46
|
@database.close
|
45
47
|
@database = nil
|
48
|
+
@dbpath = nil
|
46
49
|
else
|
47
50
|
return false
|
48
51
|
end
|
@@ -275,6 +278,13 @@ class RhomDbAdapter
|
|
275
278
|
return cols,quests,vals
|
276
279
|
end
|
277
280
|
|
281
|
+
def set_do_not_bakup_attribute(attr=1)
|
282
|
+
if System::get_property('platform') == 'APPLE'
|
283
|
+
System.set_do_not_bakup_attribute(@dbpath, attr)
|
284
|
+
System.set_do_not_bakup_attribute(@dbpath+'.version', attr)
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
278
288
|
# deletes rows from a table which satisfy condition (hash)
|
279
289
|
# example usage is the following:
|
280
290
|
# delete_from_table('object_values',{"object"=>"some-object"})
|
@@ -88,19 +88,23 @@ jclass rho_find_class(JNIEnv *env, const char *c)
|
|
88
88
|
return cls;
|
89
89
|
}
|
90
90
|
|
91
|
-
RHO_GLOBAL void JNICALL
|
92
|
-
(JNIEnv *env,
|
91
|
+
RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_RhodesApplication_initClassLoader
|
92
|
+
(JNIEnv *env, jclass, jobject cl)
|
93
93
|
{
|
94
94
|
g_classLoader = env->NewGlobalRef(cl);
|
95
95
|
jclass javaLangClassLoader = env->FindClass("java/lang/ClassLoader");
|
96
96
|
g_loadClass = env->GetMethodID(javaLangClassLoader, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;");
|
97
97
|
}
|
98
98
|
|
99
|
-
RHO_GLOBAL void JNICALL
|
99
|
+
RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_RhodesApplication_setupRhodesApp
|
100
100
|
(JNIEnv *env, jclass)
|
101
101
|
{
|
102
102
|
android_setup(env);
|
103
|
+
}
|
103
104
|
|
105
|
+
RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_RhodesApplication_createRhodesApp
|
106
|
+
(JNIEnv *env, jclass)
|
107
|
+
{
|
104
108
|
// Start Rhodes application
|
105
109
|
rho_rhodesapp_create(rho_native_rhopath());
|
106
110
|
}
|
@@ -34,45 +34,90 @@ import android.content.ServiceConnection;
|
|
34
34
|
import android.content.res.Configuration;
|
35
35
|
import android.os.Bundle;
|
36
36
|
import android.os.IBinder;
|
37
|
+
import android.util.DisplayMetrics;
|
37
38
|
import android.util.Log;
|
38
39
|
import android.view.Display;
|
40
|
+
import android.view.WindowManager;
|
39
41
|
|
40
42
|
public class BaseActivity extends Activity implements ServiceConnection {
|
41
43
|
|
42
|
-
private static final String TAG = BaseActivity.class.
|
44
|
+
private static final String TAG = BaseActivity.class.getSimpleName();
|
43
45
|
|
44
46
|
private static final boolean DEBUG = false;
|
45
47
|
|
46
48
|
public static final String INTENT_SOURCE = BaseActivity.class.getName();
|
47
49
|
|
48
|
-
|
50
|
+
public static class ScreenProperties {
|
51
|
+
private int mScreenWidth;
|
52
|
+
private int mScreenHeight;
|
53
|
+
private int mScreenOrientation;
|
54
|
+
private float mScreenPpiX;
|
55
|
+
private float mScreenPpiY;
|
56
|
+
|
57
|
+
ScreenProperties(Context context) {
|
58
|
+
reread(context);
|
59
|
+
}
|
60
|
+
|
61
|
+
public void reread(Context context) {
|
62
|
+
Logger.T(TAG, "Updating screen properties");
|
63
|
+
|
64
|
+
WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
|
65
|
+
|
66
|
+
Display d = wm.getDefaultDisplay();
|
67
|
+
|
68
|
+
mScreenWidth = d.getWidth();
|
69
|
+
mScreenHeight = d.getHeight();
|
70
|
+
|
71
|
+
DisplayMetrics metrics = new DisplayMetrics();
|
72
|
+
d.getMetrics(metrics);
|
73
|
+
|
74
|
+
mScreenPpiX = metrics.xdpi;
|
75
|
+
mScreenPpiY = metrics.ydpi;
|
76
|
+
|
77
|
+
int orientation;
|
78
|
+
orientation = context.getResources().getConfiguration().orientation;
|
79
|
+
Logger.D(TAG, "Resources orientation: "+ orientation);
|
80
|
+
|
81
|
+
if (orientation == Configuration.ORIENTATION_UNDEFINED)
|
82
|
+
{
|
83
|
+
orientation = d.getOrientation();
|
84
|
+
Logger.D(TAG, "DisplayMetrics orientation: "+ orientation);
|
85
|
+
|
86
|
+
if (orientation == Configuration.ORIENTATION_UNDEFINED) {
|
87
|
+
if (d.getWidth() == d.getHeight())
|
88
|
+
orientation = Configuration.ORIENTATION_SQUARE;
|
89
|
+
else if(d.getWidth() < d.getHeight())
|
90
|
+
orientation = Configuration.ORIENTATION_PORTRAIT;
|
91
|
+
else
|
92
|
+
orientation = Configuration.ORIENTATION_LANDSCAPE;
|
93
|
+
|
94
|
+
Logger.D(TAG, "Screen resolution orientation: " + orientation);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
mScreenOrientation = orientation;
|
98
|
+
|
99
|
+
Logger.D(TAG, "New screen properties - width: " + mScreenWidth + ", height: " + mScreenHeight + ", orientation: " + mScreenOrientation);
|
100
|
+
}
|
101
|
+
|
102
|
+
public int getWidth() { return mScreenWidth; }
|
103
|
+
public int getHeight() { return mScreenHeight; }
|
104
|
+
public int getOrientation() { return mScreenOrientation; }
|
105
|
+
public float getPpiX() { return mScreenPpiX; }
|
106
|
+
public float getPpiY() { return mScreenPpiY; }
|
107
|
+
}
|
108
|
+
|
109
|
+
private static ScreenProperties sScreenProp = null;
|
110
|
+
|
111
|
+
public static ScreenProperties getScreenProperties() { return sScreenProp; }
|
112
|
+
|
113
|
+
protected RhodesService mRhodesService;
|
49
114
|
private boolean mBoundToService;
|
50
|
-
private int mRuntimeOrientation;
|
51
|
-
|
52
|
-
protected int getScreenOrientation() {
|
53
|
-
Display display = getWindowManager().getDefaultDisplay();
|
54
|
-
int orientation = display.getOrientation();
|
55
|
-
|
56
|
-
if (orientation == Configuration.ORIENTATION_UNDEFINED)
|
57
|
-
{
|
58
|
-
orientation = getResources().getConfiguration().orientation;
|
59
|
-
|
60
|
-
if (orientation == Configuration.ORIENTATION_UNDEFINED) {
|
61
|
-
if (display.getWidth() == display.getHeight())
|
62
|
-
orientation = Configuration.ORIENTATION_SQUARE;
|
63
|
-
else if(display.getWidth() < display.getHeight())
|
64
|
-
orientation = Configuration.ORIENTATION_PORTRAIT;
|
65
|
-
else
|
66
|
-
orientation = Configuration.ORIENTATION_LANDSCAPE;
|
67
|
-
}
|
68
|
-
}
|
69
|
-
return orientation;
|
70
|
-
}
|
71
115
|
|
72
116
|
@Override
|
73
117
|
protected void onCreate(Bundle savedInstanceState) {
|
74
118
|
super.onCreate(savedInstanceState);
|
75
|
-
|
119
|
+
Logger.T(TAG, "onCreate");
|
120
|
+
|
76
121
|
Intent intent = new Intent(this, RhodesService.class);
|
77
122
|
intent.putExtra(RhodesService.INTENT_SOURCE, INTENT_SOURCE);
|
78
123
|
ComponentName serviceName = startService(intent);
|
@@ -80,8 +125,15 @@ public class BaseActivity extends Activity implements ServiceConnection {
|
|
80
125
|
throw new RuntimeException("Can not start Rhodes service");
|
81
126
|
bindService(intent, this, Context.BIND_AUTO_CREATE);
|
82
127
|
mBoundToService = true;
|
83
|
-
|
84
|
-
|
128
|
+
|
129
|
+
if (sScreenProp == null) {
|
130
|
+
sScreenProp = new ScreenProperties(this);
|
131
|
+
} else {
|
132
|
+
if (RhoConf.getBool("disable_screen_rotation")) {
|
133
|
+
Logger.D(TAG, "Screen rotation is disabled. Force orientation: " + getScreenProperties().getOrientation());
|
134
|
+
setRequestedOrientation(getScreenProperties().getOrientation());
|
135
|
+
}
|
136
|
+
}
|
85
137
|
}
|
86
138
|
|
87
139
|
@Override
|
@@ -107,26 +159,19 @@ public class BaseActivity extends Activity implements ServiceConnection {
|
|
107
159
|
|
108
160
|
@Override
|
109
161
|
public void onConfigurationChanged(Configuration newConfig) {
|
110
|
-
Logger.T(TAG, "
|
162
|
+
Logger.T(TAG, "onConfigurationChanged");
|
111
163
|
if (RhoConf.getBool("disable_screen_rotation"))
|
112
164
|
{
|
113
165
|
super.onConfigurationChanged(newConfig);
|
114
|
-
|
166
|
+
Logger.D(TAG, "Screen rotation is disabled. Force old orientation: " + getScreenProperties().getOrientation());
|
167
|
+
setRequestedOrientation(getScreenProperties().getOrientation());
|
115
168
|
}
|
116
169
|
else
|
117
170
|
{
|
118
|
-
mRuntimeOrientation = this.getScreenOrientation();
|
119
171
|
super.onConfigurationChanged(newConfig);
|
120
|
-
|
172
|
+
getScreenProperties().reread(this);
|
121
173
|
}
|
122
174
|
}
|
123
|
-
|
124
|
-
// public NativeApplication getRhodesApplication() {
|
125
|
-
// Application app = super.getApplication();
|
126
|
-
// if (DEBUG)
|
127
|
-
// Log.d(TAG, "getApplication: " + app);
|
128
|
-
// return (NativeApplication)app;
|
129
|
-
// }
|
130
175
|
|
131
176
|
@Override
|
132
177
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
@@ -135,9 +135,8 @@ public class RhodesActivity extends BaseActivity {
|
|
135
135
|
|
136
136
|
@Override
|
137
137
|
protected void onCreate(Bundle savedInstanceState) {
|
138
|
-
|
138
|
+
Logger.T(TAG, "onCreate");
|
139
139
|
super.onCreate(savedInstanceState);
|
140
|
-
Log.i(TAG, ">>>>>>>>>>>>>>> onCreate()");
|
141
140
|
|
142
141
|
mListeners = new ArrayList<RhodesActivityListener>();
|
143
142
|
|
@@ -223,7 +222,7 @@ public class RhodesActivity extends BaseActivity {
|
|
223
222
|
protected void onNewIntent(Intent intent) {
|
224
223
|
super.onNewIntent(intent);
|
225
224
|
|
226
|
-
|
225
|
+
Logger.D(TAG, "onNewIntent");
|
227
226
|
|
228
227
|
handleStartParams(intent);
|
229
228
|
|
@@ -239,7 +238,7 @@ public class RhodesActivity extends BaseActivity {
|
|
239
238
|
public void onStart() {
|
240
239
|
super.onStart();
|
241
240
|
|
242
|
-
|
241
|
+
Logger.D(TAG, "onStart");
|
243
242
|
mIsInsideStartStop = true;
|
244
243
|
|
245
244
|
RhodesApplication.stateChanged(RhodesApplication.UiState.MainActivityStarted);
|
@@ -247,7 +246,7 @@ public class RhodesActivity extends BaseActivity {
|
|
247
246
|
|
248
247
|
@Override
|
249
248
|
public void onResume() {
|
250
|
-
|
249
|
+
Logger.D(TAG, "onResume");
|
251
250
|
mIsForeground = true;
|
252
251
|
super.onResume();
|
253
252
|
{
|
@@ -270,7 +269,7 @@ public class RhodesActivity extends BaseActivity {
|
|
270
269
|
}
|
271
270
|
|
272
271
|
super.onPause();
|
273
|
-
|
272
|
+
Logger.D(TAG, "onPause");
|
274
273
|
|
275
274
|
RhodesApplication.stateChanged(RhodesApplication.UiState.MainActivityPaused);
|
276
275
|
}
|
@@ -279,13 +278,13 @@ public class RhodesActivity extends BaseActivity {
|
|
279
278
|
public void onStop()
|
280
279
|
{
|
281
280
|
super.onStop();
|
282
|
-
|
281
|
+
Logger.D(TAG, "onStop");
|
283
282
|
mIsInsideStartStop = false;
|
284
283
|
}
|
285
284
|
|
286
285
|
@Override
|
287
286
|
public void onDestroy() {
|
288
|
-
|
287
|
+
Logger.D(TAG, "onDestroy");
|
289
288
|
|
290
289
|
//TODO: Check is it really correct in case activity killed immediately after onPause()
|
291
290
|
sInstance = null;
|
@@ -298,7 +297,7 @@ public class RhodesActivity extends BaseActivity {
|
|
298
297
|
case KeyEvent.KEYCODE_BACK:
|
299
298
|
RhodesService r = RhodesService.getInstance();
|
300
299
|
if (DEBUG)
|
301
|
-
|
300
|
+
Logger.D(TAG, "onKeyDown: r=" + r);
|
302
301
|
if (r == null)
|
303
302
|
return false;
|
304
303
|
|
@@ -26,12 +26,23 @@
|
|
26
26
|
|
27
27
|
package com.rhomobile.rhodes;
|
28
28
|
|
29
|
+
import java.io.File;
|
30
|
+
import java.io.IOException;
|
29
31
|
import java.util.Collection;
|
30
32
|
import java.util.Vector;
|
31
33
|
|
34
|
+
import com.rhomobile.rhodes.file.RhoFileApi;
|
35
|
+
import com.rhomobile.rhodes.util.Utils;
|
36
|
+
import com.rhomobile.rhodes.util.Utils.AssetsSource;
|
37
|
+
import com.rhomobile.rhodes.util.Utils.FileSource;
|
38
|
+
|
32
39
|
import android.app.Application;
|
40
|
+
import android.content.Context;
|
41
|
+
import android.content.pm.ApplicationInfo;
|
42
|
+
import android.content.pm.PackageManager.NameNotFoundException;
|
33
43
|
import android.os.Handler;
|
34
44
|
import android.os.Process;
|
45
|
+
import android.util.Log;
|
35
46
|
|
36
47
|
public class RhodesApplication extends Application{
|
37
48
|
|
@@ -40,11 +51,39 @@ public class RhodesApplication extends Application{
|
|
40
51
|
static {
|
41
52
|
NativeLibraries.load();
|
42
53
|
}
|
43
|
-
|
54
|
+
|
55
|
+
private ApplicationInfo getAppInfo() {
|
56
|
+
Context context = this;
|
57
|
+
String pkgName = context.getPackageName();
|
58
|
+
try {
|
59
|
+
ApplicationInfo info = context.getPackageManager().getApplicationInfo(pkgName, 0);
|
60
|
+
return info;
|
61
|
+
} catch (NameNotFoundException e) {
|
62
|
+
throw new RuntimeException("Internal error: package " + pkgName + " not found: " + e.getMessage());
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
private boolean isAppHashChanged(String rootPath) {
|
67
|
+
try {
|
68
|
+
File hash = new File(rootPath, "hash");
|
69
|
+
if (!hash.exists())
|
70
|
+
return true;
|
71
|
+
|
72
|
+
FileSource as = new AssetsSource(getResources().getAssets());
|
73
|
+
FileSource fs = new FileSource();
|
74
|
+
return !Utils.isContentsEquals(as, "hash", fs, hash.getPath());
|
75
|
+
}
|
76
|
+
catch (IOException e) {
|
77
|
+
return true;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
44
81
|
@Override
|
45
82
|
public void onCreate(){
|
46
83
|
super.onCreate();
|
47
84
|
|
85
|
+
Log.i(TAG, "Initializing...");
|
86
|
+
|
48
87
|
RhodesApplication.runWhen(
|
49
88
|
UiState.MainActivityStarted,
|
50
89
|
new StateHandler(false) {
|
@@ -65,6 +104,50 @@ public class RhodesApplication extends Application{
|
|
65
104
|
}
|
66
105
|
}
|
67
106
|
});
|
107
|
+
|
108
|
+
initClassLoader(getClassLoader());
|
109
|
+
|
110
|
+
ApplicationInfo appInfo = getAppInfo();
|
111
|
+
String rootPath;
|
112
|
+
|
113
|
+
try {
|
114
|
+
rootPath = RhoFileApi.initRootPath(appInfo.dataDir, appInfo.sourceDir);
|
115
|
+
Log.d(TAG, "Root path: " + rootPath);
|
116
|
+
|
117
|
+
RhoFileApi.init(this);
|
118
|
+
} catch (IOException e) {
|
119
|
+
Log.e(TAG, e.getMessage());
|
120
|
+
stop();
|
121
|
+
return;
|
122
|
+
}
|
123
|
+
|
124
|
+
if (this.isAppHashChanged(rootPath)) {
|
125
|
+
try {
|
126
|
+
Log.i(TAG, "Application hash was changed");
|
127
|
+
|
128
|
+
File libDir = new File(rootPath, "lib");
|
129
|
+
File testLib = new File(libDir.getPath(), "rhoframework.iseq");
|
130
|
+
if(libDir.isDirectory() && testLib.isFile())
|
131
|
+
{
|
132
|
+
Log.i(TAG, "Updating from very old rhodes version, clean filesystem.");
|
133
|
+
Utils.deleteChildrenIgnoreFirstLevel(new File(rootPath, "apps"), "rhoconfig.txt");
|
134
|
+
Utils.deleteRecursively(libDir);
|
135
|
+
}
|
136
|
+
|
137
|
+
rootPath = RhoFileApi.initRootPath(appInfo.dataDir, appInfo.sourceDir);
|
138
|
+
Log.d(TAG, "Root path: " + rootPath);
|
139
|
+
|
140
|
+
RhoFileApi.init(this);
|
141
|
+
RhoFileApi.copy("hash");
|
142
|
+
} catch (IOException e) {
|
143
|
+
Log.e(TAG, e.getMessage());
|
144
|
+
stop();
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
setupRhodesApp();
|
150
|
+
Log.i(TAG, "Initialized");
|
68
151
|
}
|
69
152
|
private static boolean sRhodesActivityStarted = false;
|
70
153
|
|
@@ -76,11 +159,13 @@ public class RhodesApplication extends Application{
|
|
76
159
|
synchronized
|
77
160
|
public static boolean isRhodesActivityStarted() { return sRhodesActivityStarted; }
|
78
161
|
|
162
|
+
private native static void initClassLoader(ClassLoader c);
|
163
|
+
private native static void setupRhodesApp();
|
79
164
|
private native static void createRhodesApp();
|
80
165
|
private native static void startRhodesApp();
|
81
166
|
private native static void stopRhodesApp();
|
82
167
|
private native static boolean canStartApp(String strCmdLine, String strSeparators);
|
83
|
-
|
168
|
+
|
84
169
|
public static void create()
|
85
170
|
{
|
86
171
|
if (sAppState != AppState.Undefined) {
|