Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
merge MentorSandbox -> master
Browse files Browse the repository at this point in the history
Former-commit-id: 2c1e299ca638aea914177e35507aedf40290b0a6
Former-commit-id: c916336
  • Loading branch information
rgatkinson committed Feb 2, 2016
2 parents 440b5ba + d1dc257 commit 56229ef
Show file tree
Hide file tree
Showing 75 changed files with 2,594 additions and 1,772 deletions.
101 changes: 0 additions & 101 deletions FtcRobotController/FtcRobotController.iml

This file was deleted.

Binary file modified FtcRobotController/libs/Analytics-release.aar
Binary file not shown.
Binary file modified FtcRobotController/libs/FtcCommon-release.aar
Binary file not shown.
Binary file modified FtcRobotController/libs/Hardware-release.aar
Binary file not shown.
Binary file modified FtcRobotController/libs/ModernRobotics-release.aar
Binary file not shown.
Binary file modified FtcRobotController/libs/RobotCore-release.aar
Binary file not shown.
Binary file modified FtcRobotController/libs/WirelessP2p-release.aar
Binary file not shown.
11 changes: 9 additions & 2 deletions FtcRobotController/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.qualcomm.ftcrobotcontroller"
android:versionCode="5"
android:versionName="1.25">
android:versionCode="6"
android:versionName="1.5.2">


<uses-permission
Expand All @@ -12,6 +12,9 @@
<uses-permission
android:name="android.permission.CHANGE_WIFI_STATE"
android:required="true" />
<uses-permission
android:name="android.permission.WAKE_LOCK"
android:required="true" />
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"
android:required="true" />
Expand Down Expand Up @@ -46,8 +49,12 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>

<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.IBinder;
import android.net.wifi.p2p.WifiP2pDevice;
import android.os.*;
import android.preference.PreferenceManager;
Expand Down Expand Up @@ -78,6 +82,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.Serializable;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.regex.Pattern;

import org.swerverobotics.library.*;
Expand All @@ -91,6 +97,7 @@ public class FtcRobotControllerActivity extends Activity {

public static final String CONFIGURE_FILENAME = "CONFIGURE_FILENAME";

protected WifiManager.WifiLock wifiLock;
protected SharedPreferences preferences;

protected UpdateUI.Callback callback;
Expand All @@ -115,6 +122,7 @@ public class FtcRobotControllerActivity extends Activity {
protected FtcRobotControllerService controllerService;

protected FtcEventLoop eventLoop;
protected Queue<UsbDevice> receivedUsbAttachmentNotifications;

protected class RobotRestarter implements Restarter {

Expand All @@ -140,16 +148,45 @@ public void onServiceDisconnected(ComponentName name) {
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (UsbManager.ACTION_USB_ACCESSORY_ATTACHED.equals(intent.getAction())) {
// a new USB device has been attached
DbgLog.msg("USB Device attached; app restart may be needed");

if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(intent.getAction())) {
UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
if (usbDevice != null) { // paranoia
// We might get attachment notifications before the event loop is set up, so
// we hold on to them and pass them along only when we're good and ready.
if (receivedUsbAttachmentNotifications != null) { // *total* paranoia
receivedUsbAttachmentNotifications.add(usbDevice);
passReceivedUsbAttachmentsToEventLoop();
}
}
}
}

protected void passReceivedUsbAttachmentsToEventLoop() {
if (this.eventLoop != null) {
for (;;) {
UsbDevice usbDevice = receivedUsbAttachmentNotifications.poll();
if (usbDevice == null)
break;
this.eventLoop.onUsbDeviceAttached(usbDevice);
}
}
else {
// Paranoia: we don't want the pending list to grow without bound when we don't
// (yet) have an event loop
while (receivedUsbAttachmentNotifications.size() > 100) {
receivedUsbAttachmentNotifications.poll();
}
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

receivedUsbAttachmentNotifications = new ConcurrentLinkedQueue<UsbDevice>();
eventLoop = null;

setContentView(R.layout.activity_ftc_controller);

utility = new Utility(this);
Expand Down Expand Up @@ -186,6 +223,9 @@ public void onClick(View v) {
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
preferences = PreferenceManager.getDefaultSharedPreferences(this);

WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "");

hittingMenuButtonBrightensScreen();

if (USE_DEVICE_EMULATION) { HardwareFactory.enableDeviceEmulation(); }
Expand All @@ -206,13 +246,14 @@ protected void onStart() {
callback.wifiDirectUpdate(WifiDirectAssistant.Event.DISCONNECTED);

entireScreenLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
dimmer.handleDimTimer();
return false;
@Override
public boolean onTouch(View v, MotionEvent event) {
dimmer.handleDimTimer();
return false;
}
});

wifiLock.acquire();
}

@Override
Expand All @@ -232,6 +273,8 @@ protected void onStop() {
if (controllerService != null) unbindService(connection);

RobotLog.cancelWriteLogcatToDisk(this);

wifiLock.release();
}

@Override
Expand Down Expand Up @@ -289,10 +332,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
startActivity(viewLogsIntent);
return true;
}
return super.onOptionsItemSelected(item);
}
return super.onOptionsItemSelected(item);
}

@Override
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// don't destroy assets on screen rotation
Expand Down Expand Up @@ -346,6 +389,8 @@ private void requestRobotSetup() {

controllerService.setCallback(callback);
controllerService.setupRobot(eventLoop);

passReceivedUsbAttachmentsToEventLoop();
}

private FileInputStream fileSetup() {
Expand Down Expand Up @@ -501,11 +546,18 @@ public synchronized static void installIfNecessary(FtcRobotControllerService ser
public void onStateChange(RobotState newState)
{
this.prevMonitor.onStateChange(newState);

RobotStateTransitionNotifier.onRobotStateChange(newState);

if (newState == RobotState.RUNNING)
this.activity.nameVerifier.verifyLegalPhoneNames();
}

@Override
public void onErrorOrWarning()
{
this.prevMonitor.onErrorOrWarning();
}
}

class SwervePhoneNameVerifier
Expand Down Expand Up @@ -654,12 +706,12 @@ public void run()
{
activity.textWifiDirectPassphrase.setText(message);
}
});
}
});
}

}
}
}
}



Expand Down
Loading

0 comments on commit 56229ef

Please sign in to comment.