Check-in [0be3a22a72]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:more improvements in NFC support
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0be3a22a726222e876434374c3a4135e564733c5
User & Date: chw 2016-12-06 14:17:51.490
Context
2016-12-06
22:17
fix for obscure crashes on app tear down (hopefully) check-in: 1e65c19fdf user: chw tags: trunk
14:17
more improvements in NFC support check-in: 0be3a22a72 user: chw tags: trunk
2016-12-04
14:48
add thread upstream changes check-in: bdef243ba2 user: chw tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to jni/src/tkBorg.c.
591
592
593
594
595
596
597



598
599
600
601
602
603
604
/* Cached method IDs from android.os.Trace */
static jmethodID M_android_os_Trace_beginSection = NULL;
static jmethodID M_android_os_Trace_endSection = NULL;

/* Indicator for sending broadcast */
static const char *sendBC = "sendBroadcast";




#if !defined(__arm__)
/* Tables for NV12->RGB conversion */
static const int nv12rgb_y[256] = {
         0,   1192,   2384,   3576,   4768,   5960,   7152,   8344,
      9536,  10728,  11920,  13112,  14304,  15496,  16688,  17880,
     19072,  20264,  21456,  22648,  23840,  25032,  26224,  27416,
     28608,  29800,  30992,  32184,  33376,  34568,  35760,  36952,







>
>
>







591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
/* Cached method IDs from android.os.Trace */
static jmethodID M_android_os_Trace_beginSection = NULL;
static jmethodID M_android_os_Trace_endSection = NULL;

/* Indicator for sending broadcast */
static const char *sendBC = "sendBroadcast";

/* Indicator for exit handler */
static int exitHandlerAdded = 0;

#if !defined(__arm__)
/* Tables for NV12->RGB conversion */
static const int nv12rgb_y[256] = {
         0,   1192,   2384,   3576,   4768,   5960,   7152,   8344,
      9536,  10728,  11920,  13112,  14304,  15496,  16688,  17880,
     19072,  20264,  21456,  22648,  23840,  25032,  26224,  27416,
     28608,  29800,  30992,  32184,  33376,  34568,  35760,  36952,
6473
6474
6475
6476
6477
6478
6479
























6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490




6491
6492
6493
6494
6495
6496
6497
Borg_Activity(void)
{
    if (GetJNIEnv() != NULL) {
	return jactivity;
    }
    return NULL;
}

























int
Borg_Init(Tcl_Interp *interp)
{
    Tcl_MutexLock(&mutex);
    if (startupFile != NULL) {
	Tcl_SetVar(interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY);
	Tcl_SetVar(interp, "argv0", startupFile, TCL_GLOBAL_ONLY);
	Tcl_SetStartupScript(Tcl_NewStringObj(startupFile, -1), NULL);
	free(startupFile);
	startupFile = NULL;




    }
    Tcl_MutexUnlock(&mutex);
    Tcl_CreateObjCommand(interp, "borg", BorgObjCmd, (ClientData) interp,
			 (Tcl_CmdDeleteProc *) BorgObjCmdDeleted);
    Tcl_PkgProvide(interp, "borg", "1.0");
    return TCL_OK;
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>











>
>
>
>







6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
Borg_Activity(void)
{
    if (GetJNIEnv() != NULL) {
	return jactivity;
    }
    return NULL;
}

/*
 * Unfortunately, the process-wide exit handler seems necessary to
 * ensure that NFC foreground dispatch is turned off when the app exits.
 */

static void
Borg_ExitHandler(ClientData clientData)
{
    if (jactivity != NULL) {
	JNIEnv *env = GetJNIEnv();

	if (env != NULL) {
	    jstring jaction = (*env)->NewStringUTF(env, "tk.tcl.wish.nfc");
	    int ret;

	    ret = (*env)->CallStaticIntMethod(env, jactivity,
					      M_AW_handleBroadcastListener,
					      0, jaction);
	    (*env)->ExceptionClear(env);
	    (*env)->DeleteLocalRef(env, jaction);
	}
    }
}

int
Borg_Init(Tcl_Interp *interp)
{
    Tcl_MutexLock(&mutex);
    if (startupFile != NULL) {
	Tcl_SetVar(interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY);
	Tcl_SetVar(interp, "argv0", startupFile, TCL_GLOBAL_ONLY);
	Tcl_SetStartupScript(Tcl_NewStringObj(startupFile, -1), NULL);
	free(startupFile);
	startupFile = NULL;
    }
    if (!exitHandlerAdded) {
	Tcl_CreateExitHandler(Borg_ExitHandler, NULL);
	exitHandlerAdded = 1;
    }
    Tcl_MutexUnlock(&mutex);
    Tcl_CreateObjCommand(interp, "borg", BorgObjCmd, (ClientData) interp,
			 (Tcl_CmdDeleteProc *) BorgObjCmdDeleted);
    Tcl_PkgProvide(interp, "borg", "1.0");
    return TCL_OK;
}
Changes to src/tk/tcl/wish/AndroWish.java.
310
311
312
313
314
315
316

317
318
319
320
321
322
323

324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
	    mLocationMgr.removeNmeaListener(mNmeaInfo);
	    mNmeaInfo = null;
	}
	if (mLocationMgr != null) {
	    mLocationMgr.removeUpdates(this);
	    mLocationMgr = null;
	}

	synchronized (mBCRecvrs) {
	    for (Entry<String, BCRecvr> entry : mBCRecvrs.entrySet()) {
		BCRecvr bcr = entry.getValue();
		unregisterReceiver(bcr);
	    }
	    mBCRecvrs.clear();
	}

	if (mCamera != null) {
	    mCamera.onDestroy();
	    mCamera = null;
	}
	if (mUsbRecvr != null) {
	    unregisterReceiver(mUsbRecvr);
	    mUsbRecvr = null;
	}
	if (mUsbHold != null) {
	    for (final UsbDeviceConnection c : mUsbHold.values()) {
		c.close();
	    }
	    mUsbHold.clear();
	    mUsbHold = null;
	}
	mNfcBCRecvr = null;
	nfcEnable(false);
    }

    /*
     * Find out if OpenGL ES >= 2.x is available.
     */

    private static int getGLESVersion(Context context) {







>







>















<
<







310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340


341
342
343
344
345
346
347
	    mLocationMgr.removeNmeaListener(mNmeaInfo);
	    mNmeaInfo = null;
	}
	if (mLocationMgr != null) {
	    mLocationMgr.removeUpdates(this);
	    mLocationMgr = null;
	}
	nfcEnable(false);
	synchronized (mBCRecvrs) {
	    for (Entry<String, BCRecvr> entry : mBCRecvrs.entrySet()) {
		BCRecvr bcr = entry.getValue();
		unregisterReceiver(bcr);
	    }
	    mBCRecvrs.clear();
	}
	mNfcBCRecvr = null;
	if (mCamera != null) {
	    mCamera.onDestroy();
	    mCamera = null;
	}
	if (mUsbRecvr != null) {
	    unregisterReceiver(mUsbRecvr);
	    mUsbRecvr = null;
	}
	if (mUsbHold != null) {
	    for (final UsbDeviceConnection c : mUsbHold.values()) {
		c.close();
	    }
	    mUsbHold.clear();
	    mUsbHold = null;
	}


    }

    /*
     * Find out if OpenGL ES >= 2.x is available.
     */

    private static int getGLESVersion(Context context) {