Skip to content

Commit

Permalink
Force update of update branch to head of master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
iamwood committed Nov 6, 2018
1 parent bb6690e commit 38610ad
Show file tree
Hide file tree
Showing 41 changed files with 3,585 additions and 251 deletions.
8 changes: 4 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
defaultConfig {
minSdkVersion 19
targetSdkVersion 19
versionCode 11
versionName "4.0.0"
versionCode 12
versionName "4.3.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

ndk {
Expand All @@ -32,9 +32,9 @@ version = android.defaultConfig.versionName
project.archivesBaseName = 'robotcore-repackaged'

dependencies {
implementation 'com.android.support:support-annotations:27.1.1'
implementation 'com.android.support:support-annotations:28.0.0'

implementation 'com.github.modular-ftc:vuforia-repackaged:4.0.1'
implementation 'com.github.modular-ftc:vuforia-repackaged:4.3.0'

implementation 'com.google.code.gson:gson:2.8.5'
implementation 'org.danilopianini:gson-extras:0.2.1'
Expand Down
5 changes: 3 additions & 2 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http:https://schemas.android.com/apk/res/android"
package="com.qualcomm.robotcore"
android:versionCode="46"
android:versionName="8.0" >
android:versionCode="55"
android:versionName="8.9" >

<uses-permission
android:name="android.permission.ACCESS_WIFI_STATE"
Expand Down Expand Up @@ -52,6 +52,7 @@
android:name="android.permission.WAKE_LOCK"
android:required="true" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<uses-feature android:name="android.hardware.usb.accessory" />
<uses-feature android:glEsVersion="0x00020000" />
Expand Down
Binary file modified library/src/main/assets/java/onbotjava-classes.jar
Binary file not shown.
58 changes: 22 additions & 36 deletions library/src/main/assets/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ var fetchRcInfoAndScaleText = function () {

var hideElement = function(element, hide) {
if (hide) {
removeClass(element, "hidden");
addClass(element, "hidden");
} else {
removeClass(element, "hidden");
Expand Down Expand Up @@ -215,42 +216,34 @@ var loadRcInfo = function(callback) {
});
};

// undoubtedly this could be sped up :-)
//This is conservative only allow alphanumerics and underscore
var makeAndroidSafeFileName = function(fileName) {
return fileName.replace(/[^\w\d_\-+,@£\$€!½§~'=()[]{}]/g, '_');
return fileName.replace(/\W/g, '_');
};

// Uploads the file by posting to the indicted URL. progress is periodically
// called while this occurs
// https://en.wikipedia.org/wiki/XMLHttpRequest
// https://xhr.spec.whatwg.org/
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest
// https://developer.mozilla.org/en-US/docs/Web/Events/progress
// https://developer.mozilla.org/en-US/docs/Web/API/File
var uploadFile = function (localFile /*a File*/, url, progress, success, failure) {
var uploadFile = function (localFile /*a File*/, url, success, failure) {
var xhr = new XMLHttpRequest();

if (progress) {
// Note: on Chrome, the progress events do eventually fire, but only, it seems,
// after the upload is complete. Not very useful. IE and other browsers are fine.
var progressEvent = function (e) { progress(xhr, e); }
xhr.upload.addEventListener("progress", progressEvent, false /*useCapture*/);
}
if (success) {
var successEvent = function (e) { success(xhr, e); }
xhr.upload.addEventListener("load", successEvent);
}
if (failure) {
var failureEvent = function (e) { failure(xhr, e); }
xhr.upload.addEventListener("error", failureEvent);
xhr.upload.addEventListener("abort", failureEvent);
xhr.upload.addEventListener("timeout", failureEvent);
}
var lastDotIndex = localFile.name.lastIndexOf(".");
var base = localFile.name.substring(0, lastDotIndex);
var ext = localFile.name.substring(lastDotIndex, localFile.name.length);
var fileName = makeAndroidSafeFileName(base) + ext;

xhr.open("POST", url);
xhr.setRequestHeader('Content-type', 'application/octet-stream');
xhr.overrideMimeType('application/octet-stream');
xhr.setRequestHeader('Content-Disposition', 'attachment; filename=' + '"' + makeAndroidSafeFileName(localFile.name) + '"'); // TODO: do we need to URI-encode this?
xhr.setRequestHeader('Content-Disposition', 'attachment; filename=' + '"' + fileName + '"');

xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
success();
}
else {
failure();
alert("Failed to upload file: " + localFile.name + " : " + xhr.responseText);
}
}
}

// On Chrome, give the wait cursor a chance to show up, dang it.
addClass(document.documentElement, "wait");
Expand All @@ -264,7 +257,7 @@ var uploadFile = function (localFile /*a File*/, url, progress, success, failure
};
console.log("reading " + localFile.name);
reader.readAsArrayBuffer(localFile);
}, hasFunctionalProgress() ? 0 : 1000);
}, 1000);
}

//----------------------------------------------------------------------------------------------
Expand All @@ -285,13 +278,6 @@ window.isFtcRobotController = function isFtcRobotController() {
return ftcUserAgentCategory !== null && ftcUserAgentCategory !== 'OTHER';
};

// Returns whether we get progress callbacks in a reasonable time or not. Chrome is notorious:
// it defers all the progress callbacks until the end, which is of course, useless. We haven't
// tested (yet) on Safari.
var hasFunctionalProgress = function() {
return isInternetExplorer() || isFireFox();
};

// The endsWith() method is not supported in IE 11 (and earlier versions). So we roll our own.
var endsWith = function (str, suffix) {
var cch = suffix.length;
Expand Down
92 changes: 26 additions & 66 deletions library/src/main/assets/manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<script type="text/javascript" src="/js/less.min.js"></script>
</head>
<body>
<div id="blocker" style="display: none; z-index: 10; width: 100%; height: 200%; background-color: rgba(201,201,201,.7); position: absolute; top: 0; left: 0;">
<h2 style="margin:auto; margin-top: 10%; width: 60%; text-align: center; background-color: #ffffff; border: 2px solid black ">Please
wait while upload finishes</h2>
</div>
<div class="bordered-text-block">
<div>
<h1>Robot Controller Name</h1>
Expand Down Expand Up @@ -70,31 +74,20 @@ <h1>Upload Expansion Hub Firmware</h1>
<button id="id_action_firmware" class="aligned-action-button" onclick="uploadFirmware();">Upload</button>
</p>
<p id="id_firmware_upload_complete" class="text-ok"></p>
<div class="progress hidden">
<div id="id_firmware_progress" class="progress-bar" role="progressbar"
aria-valuemin="0" aria-valuemax="100" aria-valuenow="70" style="width:70%">
70%
</div>
</div>
</div>
</div>
<div id="id_update_robot_controller_application">
<h1>Update Robot Controller App &amp; Reboot</h1>
<p>Upload and install a new Robot Controller App to the REV Control Hub. Once the
upload completes, the Control Hub will be rebooted to allow the new app to complete installation.</p>
<p>Upload and install a new Robot Controller App to the REV Control Hub. Once the upload completes, the Control Hub will
be rebooted to allow the new app to complete installation.</p>
<div>
<p>
<input id="id_input_file_apk" type="file" class="hidden hidden-input-file">
<input id="id_apk_feedback" readonly class="upload-feedback" type="text" value="(apk)"><button id="id_apk_button" class="aligned-select-button">Select App...</button>
<input id="id_apk_feedback" readonly class="upload-feedback" type="text" value="(apk)"><button id="id_apk_button"
class="aligned-select-button">Select App...</button>
<button id="id_action_apk" class="aligned-action-button" onclick="updateApk();">Update &amp; Reboot</button>
</p>
<div class="progress hidden">
<div id="id_apk_progress" class="progress-bar" role="progressbar"
aria-valuemin="0" aria-valuemax="100" aria-valuenow="30" style="width:30%">
30%
</div>
</div>
</div>
</div>
</div>
<div id="id_upload_webcam_calibration">
<h1>Upload Webcam Calibration File</h1>
Expand All @@ -107,12 +100,6 @@ <h1>Upload Webcam Calibration File</h1>
<button id="id_action_webcam_calibration" class="aligned-action-button" onclick="uploadWebcamCalibration();">Upload</button>
</p>
<p id="id_webcam_calibration_upload_complete" class="text-ok"></p>
<div class="progress hidden">
<div id="id_webcam_calibration_progress" class="progress-bar" role="progressbar"
aria-valuemin="0" aria-valuemax="100" aria-valuenow="70" style="width:70%">
70%
</div>
</div>
</div>
</div>
</div>
Expand All @@ -121,24 +108,18 @@ <h1>Upload Webcam Calibration File</h1>
<script type="text/javascript" src="/js/util.js"></script>
<script type="text/javascript">

var barOfProgress = function(progress) {
return progress ? progress.parentElement : null;
}

var initUpload = function (idInput, idFeedback, idButton, ext, idAction, idProgress) {
var initUpload = function (idInput, idFeedback, idButton, ext, idAction) {
var input = document.getElementById(idInput);
var feedback = document.getElementById(idFeedback);
var button = document.getElementById(idButton);
var action = document.getElementById(idAction);
var progress = idProgress ? document.getElementById(idProgress) : null;

feedback.value = "";
feedback.onclick = function () { input.click(); };
button.onclick = function () { input.click(); };
input.accept = ext;
input.onchange = function () { fileInputChange(input, feedback, ext, action); };
hideElement(action, true);
if (progress) hideElement(barOfProgress(progress), true);
}

var fileInputChange = function(input, feedback, ext, action) {
Expand All @@ -158,64 +139,44 @@ <h1>Upload Webcam Calibration File</h1>
}

$('#id_firmware_upload_complete').hide();
initUpload('id_input_file_firmware', 'id_firmware_feedback', 'id_firmware_button', '.bin', 'id_action_firmware', null /* 'id_firmware_progress' */);
initUpload('id_input_file_apk', 'id_apk_feedback', 'id_apk_button', '.apk', 'id_action_apk', 'id_apk_progress');
initUpload('id_input_file_firmware', 'id_firmware_feedback', 'id_firmware_button', '.bin', 'id_action_firmware');
initUpload('id_input_file_apk', 'id_apk_feedback', 'id_apk_button', '.apk', 'id_action_apk',);

$('#id_id_webcam_calibration_upload_complete').hide();
initUpload('id_input_file_webcam_calibration', 'id_webcam_calibration_feedback', 'id_webcam_calibration_button', '.xml', 'id_action_webcam_calibration', null /* 'id_webcam_calibration_progress' */);

var uploadProgress = function(file, progress, xhr, e) {
if (e.lengthComputable) {
var loaded = Math.round(100 * (e.loaded / e.total));
var percent = loaded + "%";
console.log("loaded: " + percent);
if (progress) {
hideElement(barOfProgress(progress), false);
progress.style.width = percent;
progress.innerHTML = percent;
progress.setAttribute("aria-valuenow", loaded);
}
}
}
initUpload('id_input_file_webcam_calibration', 'id_webcam_calibration_feedback', 'id_webcam_calibration_button', '.xml', 'id_action_webcam_calibration');

var uploadSuccess = function(file, progress, xhr, e) {
if (progress) {
hideElement(barOfProgress(progress), true);
}
var uploadSuccess = function(file, xhr, e) {
$('#blocker').hide();
}

var uploadFailure = function(file, progress, xhr, e) {
if (progress) {
hideElement(barOfProgress(progress), true);
}
var uploadFailure = function(file, xhr, e) {
$('#blocker').hide();
alert("Failed to upload file: " + file.name);
}

var uploadFirmware = function () {
var feedback = document.getElementById('id_firmware_feedback');
var progress = null // hasFunctionalProgress() ? document.getElementById('id_firmware_progress') : null;
var file = feedback.dataFile;
console.log("uploadFirmware() name=" + file.name);
var url = URI_UPLOAD_EXPANSION_HUB_FIRMWARE;
$('#blocker').show();
uploadFile(file, url,
function(xhr, e) { uploadProgress(file, progress, xhr, e); },
function(xhr, e) {
uploadSuccess(file, progress, xhr, e);
uploadSuccess(file, xhr, e);
showToast('id_firmware_upload_complete', 'Firmware upload complete');
},
function(xhr, e) { uploadFailure(file, progress, xhr, e); });
function(xhr, e) { uploadFailure(file, xhr, e); });
}

var updateApk = function() {
var feedback = document.getElementById('id_apk_feedback');
var progress = hasFunctionalProgress() ? document.getElementById('id_apk_progress') : null;
var file = feedback.dataFile;
console.log("updateApk() name=" + file.name);
var url = URI_UPDATE_CONTROL_HUB_APK;
$('#blocker').show();
uploadFile(file, url,
function(xhr, e) { uploadProgress(file, progress, xhr, e); },
function(xhr, e) { uploadSuccess(file, progress, xhr, e); reboot(); },
function(xhr, e) { uploadFailure(file, progress, xhr, e); });
function(xhr, e) { uploadSuccess(file, xhr, e); reboot(); },
function(xhr, e) { uploadFailure(file, xhr, e); });
}

var reboot = function() {
Expand All @@ -236,17 +197,16 @@ <h1>Upload Webcam Calibration File</h1>

var uploadWebcamCalibration = function () {
var feedback = document.getElementById('id_webcam_calibration_feedback');
var progress = null // hasFunctionalProgress() ? document.getElementById('id_webcam_calibration_progress') : null;
var file = feedback.dataFile;
console.log("uploadWebcamCalibration() name=" + file.name);
var url = URI_UPLOAD_WEBCAM_CALIBRATION_FILE;
$('#blocker').show();
uploadFile(file, url,
function(xhr, e) { uploadProgress(file, progress, xhr, e); },
function(xhr, e) {
uploadSuccess(file, progress, xhr, e);
uploadSuccess(file, xhr, e);
showToast('id_webcam_calibration_upload_complete', 'Webcam Calibration upload complete');
},
function(xhr, e) { uploadFailure(file, progress, xhr, e); });
function(xhr, e) { uploadFailure(file, xhr, e); });
}

var onRenameRC = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ else if (!warningMessage.isEmpty()) {

@Override public CallbackResult onNetworkConnectionEvent(NetworkConnection.NetworkEvent event) {
CallbackResult result = CallbackResult.NOT_HANDLED;
RobotLog.ii(TAG, "onNetworkConnectionEvent: " + event.toString());
switch (event) {
case PEERS_AVAILABLE:
result = networkConnectionHandler.handlePeersAvailable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ protected void deserializeChildElement(ConfigurationType configurationType, XmlP
{
LynxModuleConfiguration moduleConfiguration = new LynxModuleConfiguration();
moduleConfiguration.deserialize(parser, xmlReader);
moduleConfiguration.setIsParent(moduleConfiguration.getModuleAddress() == parentModuleAddress);
getModules().add(moduleConfiguration);
}
}
Expand All @@ -154,7 +155,6 @@ private void initialize()
for (LynxModuleConfiguration module : getModules())
{
module.setUsbDeviceSerialNumber(getSerialNumber());
module.setIsParent(module.getModuleAddress() == parentModuleAddress);
if (module.isParent())
{
this.setParentModuleAddress(module.getModuleAddress());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public abstract class UserConfigurationType implements ConfigurationType, Serial

private @Expose @NonNull final DeviceFlavor flavor;
private @Expose @NonNull String xmlTag;
private @Expose @NonNull String[] xmlTagAliases;
private @Expose String[] xmlTagAliases;
private @Expose boolean builtIn = false;
private @Expose boolean isOnBotJava;
private @Expose @NonNull ControlSystem[] compatibleControlSystems = {MODERN_ROBOTICS, REV_HUB};
Expand Down Expand Up @@ -110,6 +110,11 @@ public void finishedAnnotations(Class clazz)
{
name = clazz.getSimpleName();
}

if (xmlTagAliases == null)
{
xmlTagAliases = new String[]{};
}
}

public boolean isCompatibleWith(ControlSystem controlSystem)
Expand Down
13 changes: 0 additions & 13 deletions library/src/main/java/com/qualcomm/robotcore/util/Version.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public void onReceive(Context context, Intent intent) {

} else if (WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION.equals(action)) {
RobotLog.dd(TAG, "broadcast: peers changed");
// TODO(Permissions): We probably need to request location permission before scanning
wifiP2pManager.requestPeers(wifiP2pChannel, peerListListener);

} else if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)) {
Expand Down
Loading

0 comments on commit 38610ad

Please sign in to comment.