Skip to content

Commit

Permalink
Address changes of FTC SDK 10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
serivesmejia committed Sep 22, 2024
1 parent cc66232 commit be3c08a
Show file tree
Hide file tree
Showing 14 changed files with 1,723 additions and 9 deletions.
37 changes: 37 additions & 0 deletions Common/src/main/java/androidx/annotation/ColorInt.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.annotation;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.CLASS;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Denotes that the annotated element represents a packed color
* int, {@code AARRGGBB}. If applied to an int array, every element
* in the array represents a color integer.
* <p>
* Example:
* <pre>{@code
* public abstract void setTextColor(@ColorInt int color);
* }</pre>
*/
@Retention(CLASS)
@Target({PARAMETER,METHOD,LOCAL_VARIABLE,FIELD})
public @interface ColorInt {
}
28 changes: 28 additions & 0 deletions Common/src/main/java/com/qualcomm/robotcore/util/SortOrder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2024 FIRST
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.qualcomm.robotcore.util;

public enum SortOrder
{
ASCENDING,
DESCENDING
}
14 changes: 11 additions & 3 deletions EOCV-Sim/src/main/java/com/github/serivesmejia/eocvsim/EOCVSim.kt
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class EOCVSim(val params: Parameters = Parameters()) {
* @see destroy
*/
enum class DestroyReason {
USER_REQUESTED, RESTART, CRASH
USER_REQUESTED, THREAD_EXIT, RESTART, CRASH
}

/**
Expand Down Expand Up @@ -437,9 +437,12 @@ class EOCVSim(val params: Parameters = Parameters()) {

logger.warn("Main thread interrupted ($hexCode)")

if(!destroying) {
destroy(DestroyReason.THREAD_EXIT)
}

if (isRestarting) {
Thread.interrupted() //clear interrupted flag

EOCVSim(params).init()
}
}
Expand All @@ -464,9 +467,14 @@ class EOCVSim(val params: Parameters = Parameters()) {
configManager.saveToFile()
visualizer.close()

eocvSimThread.interrupt()
destroying = true

if(reason == DestroyReason.THREAD_EXIT) {
exitProcess(0)
} else {
eocvSimThread.interrupt()
}

if (reason == DestroyReason.USER_REQUESTED || reason == DestroyReason.CRASH) jvmMainThread.interrupt()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ class PluginManager(val eocvSim: EOCVSim) {
loaders[pluginFile] = PluginLoader(pluginFile, eocvSim)
}

Runtime.getRuntime().addShutdownHook(Thread {
disablePlugins()
})

isEnabled = true
}

Expand Down Expand Up @@ -151,7 +147,7 @@ class PluginManager(val eocvSim: EOCVSim) {

var warning = "<html>$GENERIC_SUPERACCESS_WARN"
if(reason.trim().isNotBlank()) {
warning += "<br><br>$reason"
warning += "<br><br><i>$reason</i>"
}

warning += GENERIC_LAWYER_YEET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class SandboxFileSystem(loader: PluginLoader) : FileSystem() {

init {
logger.info("Loading filesystem ${loader.hash()}")
Runtime.getRuntime().addShutdownHook(Thread {
if(isOpen) {
logger.info("Unloading filesystem ${loader.hash()} on shutdown")
close()
}
})
}

private fun checkForPath(path: Path) = Files.exists(path)
Expand Down
3 changes: 3 additions & 0 deletions Vision/src/main/java/android/graphics/Canvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public Canvas drawLine(float x, float y, float x1, float y1, Paint paint) {
return this;
}

public void drawPoint(float x, float y, Paint paint) {
theCanvas.drawPoint(x, y, paint.thePaint);
}

public void drawRoundRect(float l, float t, float r, float b, float xRad, float yRad, Paint rectPaint) {
theCanvas.drawRRect(RRect.makeLTRB(l, t, r, b, xRad, yRad), rectPaint.thePaint);
Expand Down
Loading

0 comments on commit be3c08a

Please sign in to comment.