Skip to content

Commit 6a4dcbf

Browse files
committed
IOIO: android integration
1 parent 3fe97c5 commit 6a4dcbf

3 files changed

Lines changed: 10 additions & 11 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="net.sourceforge.smallbasic.ioio" >
4+
<uses-feature android:name="android.hardware.usb.accessory" android:required="false" />
5+
</manifest>

ioio/ioio/src/main/java/ioio/lib/android/AccessoryConnectionBootstrap.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import android.content.IntentFilter;
3838
import android.os.Build;
3939
import android.os.ParcelFileDescriptor;
40-
import android.util.Log;
4140

4241
import net.sourceforge.smallbasic.ioio.IOIOLoader;
4342

@@ -56,6 +55,7 @@
5655
import ioio.lib.impl.FixedReadBufferedInputStream;
5756
import ioio.lib.spi.IOIOConnectionBootstrap;
5857
import ioio.lib.spi.IOIOConnectionFactory;
58+
import ioio.lib.spi.Log;
5959
import ioio.lib.spi.NoRuntimeSupportException;
6060

6161
public class AccessoryConnectionBootstrap extends BroadcastReceiver implements IOIOConnectionBootstrap, IOIOConnectionFactory {
@@ -191,8 +191,7 @@ private boolean tryOpen() {
191191
if (!usbManager.hasPermission(accessory)) {
192192
if (pendingIntent == null) {
193193
Log.v(TAG, "Requesting permission.");
194-
pendingIntent = PendingIntent.getBroadcast(activity, 0, new Intent(
195-
ACTION_USB_PERMISSION), 0);
194+
pendingIntent = PendingIntent.getBroadcast(activity, 0, new Intent(ACTION_USB_PERMISSION), 0);
196195
usbManager.requestPermission(accessory, pendingIntent);
197196
}
198197
return false;
@@ -228,7 +227,7 @@ private boolean tryOpen() {
228227
// bug:
229228
// http://code.google.com/p/android/issues/detail?id=20545
230229
while (inputStream.read() != 1) {
231-
trySleep(1000);
230+
trySleep();
232231
}
233232

234233
success = true;
@@ -262,10 +261,10 @@ private void registerReceiver() {
262261
}
263262
}
264263

265-
private void trySleep(long time) {
264+
private void trySleep() {
266265
synchronized (AccessoryConnectionBootstrap.this) {
267266
try {
268-
AccessoryConnectionBootstrap.this.wait(time);
267+
AccessoryConnectionBootstrap.this.wait(1000);
269268
} catch (InterruptedException e) {
270269
Log.e(TAG, e.toString());
271270
}

ioio/main.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,13 @@ struct IOTask {
134134
auto exc = g_env->ExceptionOccurred();
135135
if (exc) {
136136
if (retval) {
137-
#if defined(ANDROID_MODULE)
138-
// avoid: JNI DETECTED ERROR IN APPLICATION: JNI FindClass called with pending exception
139-
error(retval, "Java exception - see adb logcat");
140137
g_env->ExceptionClear();
141-
#else
142138
jclass clazz = g_env->FindClass("java/lang/Object");
143139
jmethodID methodId = g_env->GetMethodID(clazz, "toString", "()Ljava/lang/String;");
144140
jstring jstr = (jstring) g_env->CallObjectMethod(exc, methodId);
145141
const char *message = g_env->GetStringUTFChars(jstr, JNI_FALSE);
146142
error(retval, message);
147143
g_env->ReleaseStringUTFChars(jstr, message);
148-
#endif
149144
} else {
150145
g_env->ExceptionDescribe();
151146
g_env->ExceptionClear();

0 commit comments

Comments
 (0)