rhodes 3.0.0.beta.4 → 3.0.0.beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. data/Manifest.txt +9 -4
  2. data/doc/build.txt +6 -0
  3. data/lib/extensions/debugger/debugger.rb +1 -1
  4. data/lib/extensions/nfc/ext/nfc/platform/android/AndroidManifest.xml +15 -3
  5. data/lib/extensions/nfc/ext/nfc/platform/android/Rakefile +6 -0
  6. data/lib/extensions/nfc/ext/nfc/platform/android/ext_build.files +6 -4
  7. data/lib/extensions/nfc/ext/nfc/platform/android/jni/src/nfc.cpp +98 -11
  8. data/lib/extensions/nfc/ext/nfc/platform/android/res/xml/filter_nfc.xml +13 -0
  9. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/Nfc.java +291 -0
  10. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcActivity.java +52 -0
  11. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/{nfc → rhomobile/nfc}/NfcMessage.java +1 -1
  12. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/{nfc → rhomobile/nfc}/NfcMessagePack.java +1 -1
  13. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/{nfc → rhomobile/nfc}/NfcRecord.java +1 -1
  14. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcTechActivity.java +42 -0
  15. data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc.i +50 -0
  16. data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c +305 -0
  17. data/lib/extensions/nfc/nfc.rb +134 -0
  18. data/platform/android/Rhodes/res/xml/filter_nfc.xml +13 -0
  19. data/platform/android/build/android.rake +35 -19
  20. data/platform/android/build/androidcommon.rb +34 -2
  21. data/platform/win32/RhoSimulator/QTLICENSE.LGPL +504 -0
  22. data/platform/wp7/build/wp.rake +11 -11
  23. data/rhodes.gemspec +1 -1
  24. metadata +13 -8
  25. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/Nfc.java +0 -150
data/Manifest.txt CHANGED
@@ -723,10 +723,13 @@ lib/extensions/nfc/ext/nfc/platform/android/AndroidManifest.xml
723
723
  lib/extensions/nfc/ext/nfc/platform/android/ext_build.files
724
724
  lib/extensions/nfc/ext/nfc/platform/android/jni/src/nfc.cpp
725
725
  lib/extensions/nfc/ext/nfc/platform/android/Rakefile
726
- lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/Nfc.java
727
- lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcMessage.java
728
- lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcMessagePack.java
729
- lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcRecord.java
726
+ lib/extensions/nfc/ext/nfc/platform/android/res/xml/filter_nfc.xml
727
+ lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/Nfc.java
728
+ lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcActivity.java
729
+ lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcMessage.java
730
+ lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcMessagePack.java
731
+ lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcRecord.java
732
+ lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcTechActivity.java
730
733
  lib/extensions/nfc/ext/nfc/shared/ruby/nfc.i
731
734
  lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c
732
735
  lib/extensions/nfc/ext.yml
@@ -1040,6 +1043,7 @@ platform/android/Rhodes/res/layout/status_bar_ongoing_event_progress_bar.xml
1040
1043
  platform/android/Rhodes/res/menu/options.xml
1041
1044
  platform/android/Rhodes/res/values/strings.xml
1042
1045
  platform/android/Rhodes/res/values/styles.xml
1046
+ platform/android/Rhodes/res/xml/filter_nfc.xml
1043
1047
  platform/android/Rhodes/rhobundle.xml
1044
1048
  platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java
1045
1049
  platform/android/Rhodes/src/com/rhomobile/rhodes/alert/PopupActivity.java
@@ -4104,6 +4108,7 @@ platform/win32/RhoSimulator/imageformats/qgif4.dll
4104
4108
  platform/win32/RhoSimulator/imageformats/qjpeg4.dll
4105
4109
  platform/win32/RhoSimulator/QtCore4.dll
4106
4110
  platform/win32/RhoSimulator/QtGui4.dll
4111
+ platform/win32/RhoSimulator/QTLICENSE.LGPL
4107
4112
  platform/win32/RhoSimulator/QtNetwork4.dll
4108
4113
  platform/win32/RhoSimulator/QtWebKit4.dll
4109
4114
  platform/win32/RhoSimulator/rhosimulator.exe
data/doc/build.txt CHANGED
@@ -267,7 +267,13 @@ List of capabilities related to changes in AndroidManifest - add or remove this
267
267
  sdcard
268
268
  push
269
269
 
270
+ ### Set up minimal Andoid SDK API level
270
271
 
272
+ The minimal API level supported by Rhodes is 4 (Android 1.6)
273
+ It is possible to set greated minimal API level with build.yml. This will restrict installing an application on any Android OS prior to 3.0:
274
+
275
+ android:
276
+ minSDK: 11
271
277
 
272
278
  ### Building app and running it in emulator from the command line
273
279
 
@@ -17,7 +17,7 @@ end
17
17
 
18
18
  def execute_cmd(cmd, advanced)
19
19
  cmd = URI.unescape(cmd.gsub(/\+/,' ')) if advanced
20
- puts "[Debugger] Executing: #{cmd}"
20
+ puts "[Debugger] Executing: #{cmd.inspect}"
21
21
  result = ""
22
22
  error = '0';
23
23
  begin
@@ -5,18 +5,30 @@
5
5
  android:versionCode="29"
6
6
  android:versionName="2.3.1">
7
7
 
8
- <uses-sdk android:minSdkVersion="9" />
8
+ <uses-sdk android:minSdkVersion="10" />
9
9
 
10
10
  <uses-feature android:name="android.hardware.nfc" android:required="false" />
11
11
 
12
12
  <application>
13
13
 
14
- <receiver android:name="com.nfc.Nfc">
14
+ <activity android:name="com.rhomobile.nfc.NfcActivity">
15
15
  <intent-filter>
16
16
  <action android:name="android.nfc.action.TAG_DISCOVERED"/>
17
17
  <category android:name="android.intent.category.DEFAULT"/>
18
18
  </intent-filter>
19
- </receiver>
19
+ </activity>
20
+
21
+ <activity android:name="com.rhomobile.nfc.NfcTechActivity">
22
+ <intent-filter>
23
+ <category android:name="android.intent.category.DEFAULT"/>
24
+ <action android:name="android.nfc.action.TECH_DISCOVERED" />
25
+ </intent-filter>
26
+
27
+ <meta-data android:name="android.nfc.action.TECH_DISCOVERED"
28
+ android:resource="@xml/filter_nfc"
29
+ />
30
+
31
+ </activity>
20
32
 
21
33
  </application>
22
34
 
@@ -51,6 +51,8 @@ namespace "build" do
51
51
  raise "TEMP_FILES_DIR is not set" if $tempdir.nil?
52
52
  $rootdir = ENV['RHO_ROOT']
53
53
  raise "RHO_ROOT is not set" if $rootdir.nil?
54
+ $rho_build_dir = ENV['RHO_ANDROID_TMP_DIR']
55
+ raise "RHO_ANDROID_TMP_DIR is not set" if $rho_build_dir.nil?
54
56
 
55
57
  require File.join($rootdir, 'platform/android/build/androidcommon.rb')
56
58
 
@@ -88,6 +90,10 @@ namespace "build" do
88
90
 
89
91
  cp_r mymaniname, maniname
90
92
 
93
+ # copy xml NFC filter
94
+ myres = $nfcdir + '/ext/nfc/platform/android/res'
95
+ cp_r myres, $rho_build_dir
96
+
91
97
  end
92
98
  end
93
99
 
@@ -1,4 +1,6 @@
1
- ext/nfc/platform/android/src/com/nfc/Nfc.java
2
- ext/nfc/platform/android/src/com/nfc/NfcMessagePack.java
3
- ext/nfc/platform/android/src/com/nfc/NfcMessage.java
4
- ext/nfc/platform/android/src/com/nfc/NfcRecord.java
1
+ ext/nfc/platform/android/src/com/rhomobile/nfc/Nfc.java
2
+ ext/nfc/platform/android/src/com/rhomobile/nfc/NfcActivity.java
3
+ ext/nfc/platform/android/src/com/rhomobile/nfc/NfcTechActivity.java
4
+ ext/nfc/platform/android/src/com/rhomobile/nfc/NfcMessagePack.java
5
+ ext/nfc/platform/android/src/com/rhomobile/nfc/NfcMessage.java
6
+ ext/nfc/platform/android/src/com/rhomobile/nfc/NfcRecord.java
@@ -29,7 +29,7 @@ void logi(const char* text) {
29
29
 
30
30
  extern "C" void rho_nfc_set_callback(const char* callback_url) {
31
31
  JNIEnv *env = jnienv();
32
- jclass cls = rho_find_class(env, "com/nfc/Nfc");
32
+ jclass cls = rho_find_class(env, "com/rhomobile/nfc/Nfc");
33
33
  if (!cls) return;
34
34
  jmethodID mid = env->GetStaticMethodID( cls, "setCallback", "(Ljava/lang/String;)V");
35
35
  if (!mid) return;
@@ -40,7 +40,7 @@ extern "C" void rho_nfc_set_callback(const char* callback_url) {
40
40
 
41
41
  extern "C" void rho_nfc_enable(int enable) {
42
42
  JNIEnv *env = jnienv();
43
- jclass cls = rho_find_class(env, "com/nfc/Nfc");
43
+ jclass cls = rho_find_class(env, "com/rhomobile/nfc/Nfc");
44
44
  if (!cls) return;
45
45
  jmethodID mid = env->GetStaticMethodID( cls, "setEnable", "(I)V");
46
46
  if (!mid) return;
@@ -49,7 +49,7 @@ extern "C" void rho_nfc_enable(int enable) {
49
49
 
50
50
  extern "C" int rho_nfc_is_enabled(void) {
51
51
  JNIEnv *env = jnienv();
52
- jclass cls = rho_find_class(env, "com/nfc/Nfc");
52
+ jclass cls = rho_find_class(env, "com/rhomobile/nfc/Nfc");
53
53
  if (!cls) return 0;
54
54
  jmethodID mid = env->GetStaticMethodID( cls, "isEnabled", "()I");
55
55
  if (!mid) return 0;
@@ -58,7 +58,7 @@ extern "C" int rho_nfc_is_enabled(void) {
58
58
 
59
59
  extern "C" int rho_nfc_is_supported(void) {
60
60
  JNIEnv *env = jnienv();
61
- jclass cls = rho_find_class(env, "com/nfc/Nfc");
61
+ jclass cls = rho_find_class(env, "com/rhomobile/nfc/Nfc");
62
62
  if (!cls) return 0;
63
63
  jmethodID mid = env->GetStaticMethodID( cls, "isSupported", "()I");
64
64
  if (!mid) return 0;
@@ -66,6 +66,93 @@ extern "C" int rho_nfc_is_supported(void) {
66
66
  }
67
67
 
68
68
 
69
+
70
+ extern "C" void rho_nfc_set_tech_callback(const char* callback_url) {
71
+ JNIEnv *env = jnienv();
72
+ jclass cls = rho_find_class(env, "com/rhomobile/nfc/Nfc");
73
+ if (!cls) return;
74
+ jmethodID mid = env->GetStaticMethodID( cls, "setTechCallback", "(Ljava/lang/String;)V");
75
+ if (!mid) return;
76
+ jstring objCallback = env->NewStringUTF(callback_url);
77
+ env->CallStaticVoidMethod(cls, mid, objCallback);
78
+ env->DeleteLocalRef(objCallback);
79
+ }
80
+
81
+ extern "C" void rho_nfc_set_listen_tech_list(VALUE tech_list) {
82
+
83
+ }
84
+
85
+ extern "C" VALUE rho_nfc_get_tech_list() {
86
+ return rho_ruby_get_NIL();
87
+ }
88
+
89
+ extern "C" void rho_nfc_tech_connect(const char* name) {
90
+
91
+ }
92
+
93
+ extern "C" void rho_nfc_tech_close(const char* name) {
94
+
95
+ }
96
+
97
+ extern "C" int rho_nfc_tech_is_connected(const char* name) {
98
+ return 0;
99
+ }
100
+
101
+ extern "C" int rho_nfc_tech_MifareClassic_get_size() {
102
+ return 0;
103
+ }
104
+
105
+ extern "C" void rho_nfc_tech_MifareClassic_write_block(int index, VALUE block) {
106
+
107
+ }
108
+
109
+ extern "C" VALUE rho_nfc_tech_MifareClassic_read_block(int index) {
110
+ return rho_ruby_get_NIL();
111
+ }
112
+
113
+ extern "C" int rho_nfc_tech_MifareUltralight_get_size() {
114
+ return 0;
115
+ }
116
+
117
+ extern "C" void rho_nfc_tech_MifareUltralight_write_page(int index, VALUE block) {
118
+
119
+ }
120
+
121
+ extern "C" VALUE rho_nfc_tech_MifareUltralight_read_pages(int index) {
122
+ return rho_ruby_get_NIL();
123
+ }
124
+
125
+
126
+ // private native void callTechCallback(String callback_url, String event);
127
+ extern "C" void JNICALL Java_com_rhomobile_nfc_Nfc_callTechCallback
128
+ (JNIEnv *env, jclass, jstring js_callback_url, jstring js_event)
129
+ {
130
+ char url[2048];
131
+ char body[2048];
132
+
133
+ const char* jurl = env->GetStringUTFChars(js_callback_url,0);
134
+ const char* jevent = env->GetStringUTFChars(js_event,0);
135
+ strcpy(url, jurl);
136
+ env->ReleaseStringUTFChars(js_callback_url, jurl);
137
+
138
+ strcpy(body, "&rho_callback=1");
139
+ strcat(body, "&");
140
+ strcat(body, "Tag_event=");
141
+ strcat(body, jevent);
142
+ env->ReleaseStringUTFChars(js_event, jevent);
143
+
144
+ rho_net_request_with_data(rho_http_normalizeurl(url), body);
145
+ }
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
69
156
  static jclass jclass_NfcMessagePack = NULL;
70
157
  static jclass jclass_NfcMessage = NULL;
71
158
  static jclass jclass_NfcRecord = NULL;
@@ -350,20 +437,20 @@ private:
350
437
 
351
438
 
352
439
  // private native void callCallback(String callback_url, NfcMessagePack msgpack);
353
- extern "C" void JNICALL Java_com_nfc_Nfc_callCallback
440
+ extern "C" void JNICALL Java_com_rhomobile_nfc_Nfc_callCallback
354
441
  (JNIEnv *env, jclass, jstring js_callback_url, jobject jo_msgpack)
355
442
  {
356
443
  logi("native callback START");
357
444
  // fill java ids
358
- jclass_NfcMessagePack = env->FindClass("com/nfc/NfcMessagePack");
359
- jclass_NfcMessage = env->FindClass("com/nfc/NfcMessage");
360
- jclass_NfcRecord = env->FindClass("com/nfc/NfcRecord");
445
+ jclass_NfcMessagePack = env->FindClass("com/rhomobile/nfc/NfcMessagePack");
446
+ jclass_NfcMessage = env->FindClass("com/rhomobile/nfc/NfcMessage");
447
+ jclass_NfcRecord = env->FindClass("com/rhomobile/nfc/NfcRecord");
361
448
 
362
449
  jmethod_NfcMessagePack_getItemCount = env->GetMethodID( jclass_NfcMessagePack, "getItemCount", "()I");
363
- jmethod_NfcMessagePack_getItem = env->GetMethodID( jclass_NfcMessagePack, "getItem", "(I)Lcom/nfc/NfcMessage;");
450
+ jmethod_NfcMessagePack_getItem = env->GetMethodID( jclass_NfcMessagePack, "getItem", "(I)Lcom/rhomobile/nfc/NfcMessage;");
364
451
 
365
452
  jmethod_NfcMessage_getItemCount = env->GetMethodID( jclass_NfcMessage, "getItemCount", "()I");
366
- jmethod_NfcMessage_getItem = env->GetMethodID( jclass_NfcMessage, "getItem", "(I)Lcom/nfc/NfcRecord;");
453
+ jmethod_NfcMessage_getItem = env->GetMethodID( jclass_NfcMessage, "getItem", "(I)Lcom/rhomobile/nfc/NfcRecord;");
367
454
  jmethod_NfcMessage_getByteArray = env->GetMethodID( jclass_NfcMessage, "getByteArray", "()[B");
368
455
 
369
456
  jmethod_NfcRecord_getId = env->GetMethodID( jclass_NfcRecord, "getId", "()[B");
@@ -372,7 +459,7 @@ extern "C" void JNICALL Java_com_nfc_Nfc_callCallback
372
459
  jmethod_NfcRecord_getTnf = env->GetMethodID( jclass_NfcRecord, "getTnf", "()I");
373
460
  jmethod_NfcRecord_getType = env->GetMethodID( jclass_NfcRecord, "getType", "()[B");
374
461
  jmethod_NfcRecord_getByteArray = env->GetMethodID( jclass_NfcRecord, "getByteArray", "()[B");
375
- jmethod_NfcRecord_getSubrecords = env->GetMethodID( jclass_NfcRecord, "getSubrecords", "()Lcom/nfc/NfcMessage;");
462
+ jmethod_NfcRecord_getSubrecords = env->GetMethodID( jclass_NfcRecord, "getSubrecords", "()Lcom/rhomobile/nfc/NfcMessage;");
376
463
 
377
464
  logi("native callback TMP 01 java IDs collected");
378
465
 
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
3
+ <tech-list>
4
+ <tech>android.nfc.tech.MifareClassic</tech>
5
+ </tech-list>
6
+ <tech-list>
7
+ <tech>android.nfc.tech.MifareUltralight</tech>
8
+ </tech-list>
9
+ <tech-list>
10
+ <tech>android.nfc.tech.MifareClassic</tech>
11
+ <tech>android.nfc.tech.MifareUltralight</tech>
12
+ </tech-list>
13
+ </resources>
@@ -0,0 +1,291 @@
1
+ package com.rhomobile.nfc;
2
+
3
+ import java.io.IOException;
4
+
5
+ import android.app.Activity;
6
+ import android.content.BroadcastReceiver;
7
+ import android.content.Context;
8
+ import android.content.Intent;
9
+ import android.nfc.NdefMessage;
10
+ import android.nfc.NdefRecord;
11
+ import android.nfc.NfcAdapter;
12
+ import android.nfc.Tag;
13
+ import android.nfc.tech.MifareClassic;
14
+ import android.nfc.tech.MifareUltralight;
15
+ import android.os.Build;
16
+ import android.os.Bundle;
17
+ import android.os.Parcelable;
18
+ import android.util.Log;
19
+
20
+ import com.rhomobile.rhodes.PushService;
21
+ import com.rhomobile.rhodes.RhodesActivity;
22
+ import com.rhomobile.rhodes.RhodesService;
23
+ import com.rhomobile.rhodes.Utils;
24
+
25
+ public class Nfc {
26
+
27
+
28
+ private static final String TAG = Nfc.class.getSimpleName();
29
+
30
+ private static boolean ourIsEnable = false;
31
+ private static String ourCallback = null;
32
+ private static String ourTechCallback = null;
33
+
34
+ private static Nfc ourInstance = null;
35
+
36
+ private static native void callCallback(String callback_url, NfcMessagePack msgpack);
37
+ private static native void callTechCallback(String callback_url, String tech_event);
38
+
39
+ private static Tag ourTag = null;
40
+
41
+
42
+ private MifareClassic mMifareClassic = null;
43
+ private MifareUltralight mMifareUltralight = null;
44
+
45
+ private String[] mTechList = null;
46
+
47
+
48
+ public static Nfc getInstance() {
49
+ if (ourInstance == null) {
50
+ ourInstance = new Nfc();
51
+ }
52
+ return ourInstance;
53
+ }
54
+
55
+
56
+ public static int isSupported() {
57
+ NfcAdapter da = null;
58
+ try {
59
+ int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
60
+ if (sdkVersion >= Build.VERSION_CODES.GINGERBREAD_MR1) {
61
+ da = NfcAdapter.getDefaultAdapter(RhodesService.getContext());
62
+ }
63
+ else if (sdkVersion >= Build.VERSION_CODES.GINGERBREAD) {
64
+ da = NfcAdapter.getDefaultAdapter();
65
+ }
66
+ }
67
+ catch (Exception e) {
68
+ // nothing
69
+ }
70
+ if (da == null) {
71
+ return 0;
72
+ }
73
+ int res = 0;
74
+ if (da.isEnabled()) {
75
+ res = 1;
76
+ }
77
+ return res;
78
+ }
79
+
80
+ public static int isEnabled() {
81
+ int res = 0;
82
+ if (ourIsEnable) {
83
+ res = 1;
84
+ }
85
+ return res;
86
+ }
87
+
88
+ public static void setEnable(int enable) {
89
+ ourIsEnable = (enable != 0);
90
+ }
91
+
92
+ public static void setCallback(String callback) {
93
+ ourCallback = callback;
94
+ }
95
+
96
+ public static void setTechCallback(String callback) {
97
+ ourTechCallback = callback;
98
+ }
99
+
100
+ //@Override
101
+ //public void onReceive(Context context, Intent intent) {
102
+
103
+ private static boolean isRhodesApplicationRun() {
104
+ return RhodesService.getInstance()!=null;
105
+ }
106
+
107
+
108
+ public void onReceiveTag(Tag tag) {
109
+ if (tag == null) {
110
+ return;
111
+ }
112
+
113
+ ourTag = tag;
114
+
115
+ int count = 0;
116
+ mMifareClassic = MifareClassic.get(tag);
117
+ mMifareUltralight = MifareUltralight.get(tag);
118
+
119
+ if (mMifareClassic != null) {
120
+ count++;
121
+ }
122
+ if (mMifareUltralight != null) {
123
+ count++;
124
+ }
125
+ mTechList = new String[count];
126
+
127
+ count = 0;
128
+ if (mMifareClassic != null) {
129
+ mTechList[count++] = "MifareClassic";
130
+ }
131
+ if (mMifareUltralight != null) {
132
+ mTechList[count++] = "MifareUltralight";
133
+ }
134
+
135
+ Utils.platformLog(TAG, "NFC TAG Tech Received ! Service started = "+String.valueOf(isRhodesApplicationRun()));
136
+
137
+ if (isRhodesApplicationRun()) {
138
+ if (ourIsEnable) {
139
+ if (ourTechCallback != null) {
140
+ if (ourTechCallback.length() > 0) {
141
+ callTechCallback(ourTechCallback, "discovered");
142
+ }
143
+ else {
144
+ Utils.platformLog(TAG, "Nfc callback is empty");
145
+ }
146
+ }
147
+ else {
148
+ Utils.platformLog(TAG, "Nfc callback is null");
149
+ }
150
+ }
151
+ else {
152
+ Utils.platformLog(TAG, "Nfc is not enabled");
153
+ }
154
+ }
155
+
156
+ }
157
+
158
+ public void onReceiveMessages(NdefMessage[] msgs) {
159
+ if (msgs == null || msgs.length == 0) {
160
+ return;
161
+ }
162
+
163
+ Utils.platformLog(TAG, "NFC TAG Received ! Service started = "+String.valueOf(isRhodesApplicationRun()));
164
+
165
+ NfcMessagePack pack = new NfcMessagePack(msgs);
166
+
167
+ Utils.platformLog(TAG, "Message Pack created");
168
+ if (isRhodesApplicationRun()) {
169
+ if (ourIsEnable) {
170
+ if (ourCallback != null) {
171
+ if (ourCallback.length() > 0) {
172
+ callCallback(ourCallback, pack);
173
+ }
174
+ else {
175
+ Utils.platformLog(TAG, "Nfc callback is empty");
176
+ }
177
+ }
178
+ else {
179
+ Utils.platformLog(TAG, "Nfc callback is null");
180
+ }
181
+ }
182
+ else {
183
+ Utils.platformLog(TAG, "Nfc is not enabled");
184
+ }
185
+ }
186
+
187
+ }
188
+
189
+
190
+ public static void clear_listen_tech_list() {
191
+ // listen all now
192
+ }
193
+
194
+ public static void add_listen_tech(String tech_name) {
195
+ // listen all now
196
+ }
197
+
198
+ public static int get_tech_list_count() {
199
+ return getInstance().mTechList.length;
200
+ }
201
+
202
+ public static String get_tech_list(int index) {
203
+ return getInstance().mTechList[index];
204
+ }
205
+
206
+ public static void tech_connect(String tech_name) {
207
+ if (tech_name.equals("MifareClassic")) {
208
+ try {
209
+ if (getInstance().mMifareClassic != null)
210
+ getInstance().mMifareClassic.connect();
211
+ } catch (IOException e) {
212
+ // TODO Auto-generated catch block
213
+ e.printStackTrace();
214
+ }
215
+ }
216
+ if (tech_name.equals("MifareUltralight")) {
217
+ try {
218
+ if (getInstance().mMifareUltralight != null)
219
+ getInstance().mMifareUltralight.connect();
220
+ } catch (IOException e) {
221
+ // TODO Auto-generated catch block
222
+ e.printStackTrace();
223
+ }
224
+ }
225
+ }
226
+
227
+ public static void tech_close(String tech_name) {
228
+ if (tech_name.equals("MifareClassic")) {
229
+ try {
230
+ if (getInstance().mMifareClassic != null)
231
+ getInstance().mMifareClassic.close();
232
+ } catch (IOException e) {
233
+ // TODO Auto-generated catch block
234
+ e.printStackTrace();
235
+ }
236
+ }
237
+ if (tech_name.equals("MifareUltralight")) {
238
+ try {
239
+ if (getInstance().mMifareUltralight != null)
240
+ getInstance().mMifareUltralight.close();
241
+ } catch (IOException e) {
242
+ // TODO Auto-generated catch block
243
+ e.printStackTrace();
244
+ }
245
+ }
246
+ }
247
+
248
+ public static int tech_is_connected(String tech_name) {
249
+ if (tech_name.equals("MifareClassic")) {
250
+ if (getInstance().mMifareClassic != null)
251
+ if (getInstance().mMifareClassic.isConnected() )
252
+ return 1;
253
+ }
254
+ if (tech_name.equals("MifareUltralight")) {
255
+ if (getInstance().mMifareUltralight != null)
256
+ if (getInstance().mMifareUltralight.isConnected() )
257
+ return 1;
258
+ }
259
+ return 0;
260
+ }
261
+
262
+ public static int tech_MifareClassic_get_size() {
263
+ return 0;
264
+ }
265
+
266
+ public static void tech_MifareClassic_write_block(int index, byte[] block) {
267
+
268
+ }
269
+
270
+ public static void tech_MifareClassic_read_block(int index, byte[] block) {
271
+
272
+ }
273
+
274
+
275
+ public static int tech_MifareUltralight_get_size() {
276
+ return 0;
277
+ }
278
+
279
+ public static void tech_MifareUltralight_write_page(int index, byte[] page) {
280
+
281
+ }
282
+
283
+ public static void tech_MifareUltralight_read_pages(int index, byte[] pages) {
284
+
285
+ }
286
+
287
+
288
+
289
+
290
+
291
+ }