Commit 2cb70490 authored by Jeffrey I. Schiller's avatar Jeffrey I. Schiller

Only use Bugsense for the Wireless MIT AICompanion (and *not* for the

USB Debugger) and send exceptions from Kawa so we get exceptions on
the Main UI thread as well as background threads. Upgrade to Bugsense
3.1.

Move the Bugsense API Key to GitBuildId template. You provide it at
compile time on the "ant" build command line as "-Dbugsense.apikey=<key>"
If you do not provide it, Bugsense is diabled.

Change-Id: I127d3f84636687721bce1557139acb5a781e8f3c
parent 9ca6035b
......@@ -16,8 +16,8 @@
<ant inheritAll="false" useNativeBasedir="true" dir="appengine"/>
<ant inheritAll="false" useNativeBasedir="true" dir="blockseditor"/>
<ant inheritAll="false" useNativeBasedir="true" dir="blockslib"/>
<ant inheritAll="false" useNativeBasedir="true" dir="buildserver"/>
<ant inheritAll="false" useNativeBasedir="true" dir="common"/>
<ant inheritAll="false" useNativeBasedir="true" dir="buildserver"/>
<ant inheritAll="false" useNativeBasedir="true" dir="components"/>
</target>
......
......@@ -129,7 +129,7 @@
</copy>
<copy toFile="${classes.files.dir}/YailGenerator.jar" file="${local.build.dir}/YailGenerator.jar" />
<copy toFile="${classes.files.dir}/kawa.jar" file="${lib.dir}/kawa/kawa-1.11-modified.jar" />
<copy toFile="${classes.files.dir}/bugsense3.0.8.jar" file="${lib.dir}/bugsense/bugsense3.0.8.jar" />
<copy toFile="${classes.files.dir}/bugsense3.1.jar" file="${lib.dir}/bugsense/bugsense3.1.jar" />
<copy toFile="${classes.files.dir}/twitter4j.jar" file="${lib.dir}/twitter/twitter4j-core-android-2.2.6.jar" />
<copy toFile="${classes.files.dir}/fusiontables.jar" file="${lib.dir}/fusiontables/fusiontables.jar" />
<copy toFile="${classes.files.dir}/google-api-client-beta.jar" file="${lib.dir}/oauth/google-api-client-1.10.3-beta.jar" />
......@@ -138,9 +138,10 @@
<copy toFile="${classes.files.dir}/google-http-client-android2-beta.jar" file="${lib.dir}/oauth/google-http-client-android2-1.10.3-beta.jar" />
<copy toFile="${classes.files.dir}/google-http-client-android3-beta.jar" file="${lib.dir}/oauth/google-http-client-android3-1.10.3-beta.jar" />
<copy toFile="${classes.files.dir}/google-oauth-client-beta.jar" file="${lib.dir}/oauth/google-oauth-client-1.10.1-beta.jar" />
<copy toFile="${classes.files.dir}/guava-11.0.1.jar" file="${lib.dir}/guava/guava-11.0.1.jar" />
<copy toFile="${classes.files.dir}/guava-11.0.1.jar" file="${lib.dir}/guava/guava-11.0.1.jar" />
<copy toFile="${classes.files.dir}/android.jar" file="${lib.dir}/android/2.2/android.jar" />
<copy toFile="${classes.files.dir}/dx.jar" file="${lib.dir}/android/tools/dx.jar" />
<copy toFile="${classes.files.dir}/CommonVersion.jar" file="${build.dir}/common/CommonVersion.jar" />
<property name="classes.tools.dir" location="${BuildServer-class.dir}/tools" />
<copy todir="${classes.tools.dir}">
......@@ -151,7 +152,7 @@
<fileset dir="${lib.dir}/android/tools" includes="*/zipalign" />
</copy>
<chmod dir="${classes.tools.dir}" includes="*/zipalign" perm="ugo+rx"/>
<!-- jar up the classes and resource files -->
<jar destfile="${run.lib.dir}/BuildServer.jar" filesonly="true">
<fileset dir="${BuildServer-class.dir}" />
......
......@@ -95,7 +95,7 @@ public final class Compiler {
private static final String KAWA_RUNTIME =
RUNTIME_FILES_DIR + "kawa.jar";
private static final String BUGSENSE_RUNTIME =
RUNTIME_FILES_DIR + "bugsense3.0.8.jar";
RUNTIME_FILES_DIR + "bugsense3.1.jar";
private static final String DX_JAR =
RUNTIME_FILES_DIR + "dx.jar";
......@@ -279,6 +279,9 @@ public final class Compiler {
out.write("android:debuggable=\"false\" ");
out.write("android:label=\"" + projectName + "\" ");
out.write("android:icon=\"@drawable/ya\" ");
if (isForWireless) { // This is to hook into Bugsense
out.write("android:name=\"com.google.appinventor.components.runtime.ReplApplication\" ");
}
out.write(">\n");
for (Project.SourceDescriptor source : project.getSources()) {
......
......@@ -375,6 +375,8 @@
(define (process-exception ex)
(define-alias YailRuntimeError <com.google.appinventor.components.runtime.errors.YailRuntimeError>)
;; The call below is a no-op unless we are in the wireless repl
(com.google.appinventor.components.runtime.ReplApplication:reportError ex)
(if (lookup-in-form-environment 'repl)
(when ((this):toastAllowed)
(begin
......@@ -390,14 +392,14 @@
(ex:getMessage)
(*close-bracket*:get)))
(force-output)))
;; TODO(sharon): it would be nice to log the stack trace for the code
;; that threw the exception too.
(com.google.appinventor.components.runtime.util.RuntimeErrorAlert:alert
(this)
(ex:getMessage)
(if (instance? ex YailRuntimeError) ((as YailRuntimeError ex):getErrorType) "Runtime Error")
"End Application")))
;; For the HandlesEventDispatching interface
(define (dispatchEvent componentObject :: com.google.appinventor.components.runtime.Component
registeredComponentName :: java.lang.String
......
......@@ -5,6 +5,11 @@ package com.google.appinventor.common.version;
/**
* Class containing constants for the git version and fingerprint
* and another one for the Ant Build date
*
* We also put the Bugsense API key here so it can be loaded
* from an argument to the ant build. If it isn't provided, it
* will be a blank string which will disable Bugsense.
*
*/
public final class GitBuildId {
......@@ -12,6 +17,7 @@ public final class GitBuildId {
public static final String GIT_BUILD_VERSION = "@git.build.version@";
public static final String GIT_BUILD_FINGERPRINT = "@git.build.fingerprint@";
public static final String ANT_BUILD_DATE = "@ant.build.date@";
public static final String BUGSENSE_API_KEY = "@bugsense.apikey@";
private GitBuildId() {
}
......@@ -37,4 +43,11 @@ public final class GitBuildId {
public static String getDate() {
return ANT_BUILD_DATE;
}
public static String getBugsenseApiKey() {
if (BUGSENSE_API_KEY.equals("${bugsense.apikey}")) // This is the value if no value is provided to ant
return("");
return BUGSENSE_API_KEY.trim();
}
}
......@@ -66,7 +66,7 @@
<path id="libsForCommonUtilsTests.path">
<pathelement location="${public.build.dir}/CommonUtils.jar" />
<pathelement location="${lib.dir}/guava/guava-11.0.1.jar" />
<pathelement location="${lib.dir}/guava/guava-11.0.1.jar" />
<pathelement location="${lib.dir}/junit/junit-4.8.2.jar" />
</path>
......@@ -100,7 +100,7 @@
<arg line = "describe " />
</exec>
<filter token="git.build.version" value="${git.build.version}" />
<exec executable="git" outputproperty="git.build.fingerprint">
<arg line = "rev-parse HEAD " />
</exec>
......@@ -109,7 +109,9 @@
<tstamp/>
<property name="ant.build.date" value="${TODAY}" />
<filter token="ant.build.date" value="${ant.build.date}" />
<filter token="bugsense.apikey" value="${bugsense.apikey}" />
<mkdir dir="${local.build.dir}/src/${common.pkg}/version/"/>
<copy tofile="${local.build.dir}/src/${common.pkg}/version/GitBuildId.java" file="GitBuildId.template" filtering="true" />
......
......@@ -116,9 +116,10 @@
<classpath>
<pathelement location="${local.build.dir}/HtmlEntities.jar" />
<pathelement location="${public.build.dir}/CommonConstants.jar" />
<pathelement location="${build.dir}/common/CommonVersion.jar" />
<pathelement location="${lib.dir}/android/2.2/android.jar" />
<pathelement location="${lib.dir}/kawa/kawa-1.11-modified.jar" />
<pathelement location="${lib.dir}/bugsense/bugsense3.0.8.jar" />
<pathelement location="${lib.dir}/bugsense/bugsense3.1.jar" />
<pathelement location="${lib.dir}/twitter/twitter4j-core-android-2.2.6.jar" />
<pathelement location="${lib.dir}/fusiontables/fusiontables.jar" />
<pathelement location="${lib.dir}/oauth/google-api-client-1.10.3-beta.jar" />
......@@ -127,7 +128,7 @@
<pathelement location="${lib.dir}/oauth/google-http-client-android2-1.10.3-beta.jar" />
<pathelement location="${lib.dir}/oauth/google-http-client-android3-1.10.3-beta.jar" />
<pathelement location="${lib.dir}/oauth/google-oauth-client-1.10.1-beta.jar" />
<pathelement location="${lib.dir}/guava/guava-11.0.1.jar" />
<pathelement location="${lib.dir}/guava/guava-11.0.1.jar" />
</classpath>
</ai.javac>
......@@ -135,6 +136,7 @@
destfile="${public.build.dir}/AndroidRuntime.jar">
<zipfileset src="${local.build.dir}/HtmlEntities.jar"/>
<zipfileset src="${public.build.dir}/CommonConstants.jar"/>
<zipfileset src="${build.dir}/common/CommonVersion.jar" />
</jar>
</target>
......@@ -149,7 +151,7 @@
<pathelement location="${lib.dir}/junit/junit-4.8.2.jar" />
<pathelement location="${lib.dir}/junit4/tl4j-junit4-1.1.3.jar" />
<pathelement location="${lib.dir}/kawa/kawa-1.11-modified.jar" />
<pathelement location="${lib.dir}/bugsense/bugsense3.0.8.jar" />
<pathelement location="${lib.dir}/bugsense/bugsense3.1.jar" />
<pathelement location="${lib.dir}/powermock/cglib-nodep-2.2.jar" />
<pathelement location="${lib.dir}/powermock/easymock-3.0.jar" />
<pathelement location="${lib.dir}/powermock/javassist-3.15.0-GA.jar" />
......@@ -212,18 +214,18 @@
<pathelement location="${local.build.dir}/HtmlEntities.jar" />
<pathelement location="${public.build.dir}/CommonConstants.jar" />
<pathelement location="${lib.dir}/android/2.2/android.jar" />
<pathelement location="${lib.dir}/guava/guava-11.0.1.jar" />
<pathelement location="${lib.dir}/guava/guava-11.0.1.jar" />
<pathelement location="${lib.dir}/kawa/kawa-1.11-modified.jar" />
<pathelement location="${lib.dir}/bugsense/bugsense3.0.8.jar" />
<pathelement location="${lib.dir}/bugsense/bugsense3.1.jar" />
<pathelement location="${lib.dir}/twitter/twitter4j-core-android-2.2.6.jar" />
<pathelement location="${lib.dir}/fusiontables/fusiontables.jar" />
<pathelement location="${lib.dir}/oauth/google-api-client-1.10.3-beta.jar" />
<pathelement location="${lib.dir}/oauth/google-api-client-android2-1.10.3-beta.jar" />
<pathelement location="${lib.dir}/oauth/google-http-client-1.10.3-beta.jar" />
<pathelement location="${lib.dir}/oauth/google-http-client-android2-1.10.3-beta.jar" />
<pathelement location="${lib.dir}/oauth/google-http-client-android3-1.10.3-beta.jar" />
<pathelement location="${lib.dir}/oauth/google-oauth-client-1.10.1-beta.jar" />
<pathelement location="${lib.dir}/guava/guava-11.0.1.jar" />
<pathelement location="${lib.dir}/fusiontables/fusiontables.jar" />
<pathelement location="${lib.dir}/oauth/google-api-client-1.10.3-beta.jar" />
<pathelement location="${lib.dir}/oauth/google-api-client-android2-1.10.3-beta.jar" />
<pathelement location="${lib.dir}/oauth/google-http-client-1.10.3-beta.jar" />
<pathelement location="${lib.dir}/oauth/google-http-client-android2-1.10.3-beta.jar" />
<pathelement location="${lib.dir}/oauth/google-http-client-android3-1.10.3-beta.jar" />
<pathelement location="${lib.dir}/oauth/google-oauth-client-1.10.1-beta.jar" />
<pathelement location="${lib.dir}/guava/guava-11.0.1.jar" />
</classpath>
<compilerarg line="-processorpath ${local.build.dir}/AnnotationProcessors.jar"/>
<compilerarg line="-processor @{apt-processor}" />
......@@ -275,7 +277,7 @@
<pathelement location="${local.build.dir}/ComponentProcessingLib.jar"/>
<pathelement location="${local.build.dir}/HtmlEntities.jar" />
<pathelement location="${public.build.dir}/CommonConstants.jar" />
<pathelement location="${lib.dir}/guava/guava-11.0.1.jar" />
<pathelement location="${lib.dir}/guava/guava-11.0.1.jar" />
</classpath>
</ai.javac>
......
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2012 MIT, All rights reserved
// Released under the MIT License https://raw.github.com/mit-cml/app-inventor/master/mitlicense.txt
package com.google.appinventor.components.runtime;
import android.app.Application;
import android.content.Context;
import android.util.Log;
import com.google.appinventor.common.version.GitBuildId;
import com.google.appinventor.components.runtime.util.EclairUtil;
import com.google.appinventor.components.runtime.util.SdkLevel;
/**
* Subclass of Application. Normally App Inventor apps just use the
* android.app.Application class as their main application. However we
* use the Bugsense debugging application with the MIT AI Companion
* app. This class is only pointed to by the Android Manifest if
* Compiler.java (which builds the Manifest) is building the Wireless
* version of the MIT AI Companion. In this fashion we only turn on
* bugsense when using the Wireless MIT AI Companion.
*
* Bugsense *can* be hooked into an Activity as well as an
* Application, however ACRA, which we may use as an alternative, only
* hooks into an Application object, so that is why we hook bugsense
* here. It Makes changing over to ACRA reasonably easy.
*
* @author jis@mit.edu (Jeffrey I. Schiller)
*/
public class ReplApplication extends Application {
private static ReplApplication theInstance = null;
private boolean active = false;
@Override
public void onCreate() {
super.onCreate();
String apikey = GitBuildId.getBugsenseApiKey();
if ((SdkLevel.getLevel() > SdkLevel.LEVEL_DONUT) && !apikey.equals("")) {
EclairUtil.setupBugSense((Context) this, apikey);
theInstance = this;
active = true;
Log.i("ReplApplication", "Bugsense Active APIKEY = " + apikey);
} else {
Log.i("ReplApplication", "Bugsense NOT ACTIVE");
}
}
public static void reportError(Exception ex) {
if (theInstance != null && theInstance.active) {
EclairUtil.sendBugSenseException(ex);
}
}
}
......@@ -44,7 +44,6 @@ public class ReplForm extends Form {
private AppInvHTTPD assetServer = null;
public static ReplForm topform;
private static final String REPL_ASSET_DIR = "/sdcard/AppInventor/assets/";
private static final String BUGSENSE_API_KEY = "195de24b";
private boolean IsUSBRepl = false;
public ReplForm() {
......@@ -55,8 +54,7 @@ public class ReplForm extends Form {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (SdkLevel.getLevel() > SdkLevel.LEVEL_DONUT)
EclairUtil.setupBugSense((Context) this, BUGSENSE_API_KEY);
if (IsUSBRepl) {
PackageManager packageManager = this.$context().getPackageManager();
// the following is intended to prevent the application from being restarted
......
......@@ -35,4 +35,8 @@ public class EclairUtil {
BugSenseHandler.initAndStartSession(context, api_key);
}
public static void sendBugSenseException(Exception ex) {
BugSenseHandler.sendException(ex);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment