MainActivity¶
-
public class
MainActivityextends AppCompatActivity¶ The MainActivity class contains, you guessed it, the main part of the code. This does basically EVERYTHING! It provides a UI, but that isn’t really functional anymore (I mean, you’re not going up with your high altitude balloon). It’s better explained in the chunks of code down below, because this whole thing is sort of an amalgamation of various bits of functionality and strokes of genius (maybe just strokes, idk).
Author: Alan Zhu, Joshua Morin-Baxter
Fields¶
Methods¶
flashLightOff¶
-
public void
flashLightOff(View view)¶ This one turns the flashlight off if the flashlight is on. It’s not called because
flashLightOn(View)doesn’t work either and isn’t called.Parameters: - view – Just in case you wanted to open call this method with a UI button, but passing in null is fine.
flashLightOn¶
-
public void
flashLightOn(View view)¶ A piece of code that wrestles control of the camera from the main photo-taking thread before turning on the camera flashlight on the back, in order to make the payload easier to find at night. It is not used primarily because it’s so difficult to implement interlacing between the main camera and this flashlight camera, but hopefully it can be fixed at some point.
Parameters: - view – Just in case you wanted to open call this method with a UI button, but passing in null is fine.
getBatteryPercentage¶
-
public static int
getBatteryPercentage(Context context)¶ Gets the current battery to be used for
rCameraandrSensorsin determining battery saving and to be saved for data analysisParameters: - context – the context of the application from which battery stats can be pulled
Returns: the current percentage of the battery
getBatteryTemp¶
giveCameraBackToOtherThread¶
-
public void
giveCameraBackToOtherThread()¶ In life, sometimes you’ve got to return things you’ve taken forcefully. Control of the camera is no exception. This is like the yin to the
takeCameraFromOtherThread()‘s yang. It makes the main camera active again and starts the rCamera runnable again.
hackInt¶
-
public int
hackInt()¶ At some point, this was used in attempt to solve a problem with the camera of the Samsung Galaxy S4 in order to create SurfaceTextures from within a Runnable. It’s still used but not in the way it was originally intended.
Returns: an id to be used to initialize SurfaceTextures from within a runnable
onClickClear¶
-
public void
onClickClear(View view)¶ Clears both the text of the incoming messages and outgoing messages for Arduino connection, meaning that it is no longer used but can be revived along with everything else.
Parameters: - view – can be called with null, used to support button clicks
onCreate¶
-
protected void
onCreate(Bundle savedInstanceState)¶ Creates the activity and all of its parts. Better to read it than write a description.
Parameters: - savedInstanceState – past to the super function, maintaining the saved instance state
onStart¶
-
protected void
onStart()¶ Initializes sensors and other things that should not be done in onCreate
onStop¶
-
protected void
onStop()¶ de-initializes sensors and things that should be destroyed before onDestroyed
record¶
-
public void
record(View view)¶ Starts recording data and taking photos at the start of the activity and in testing with the UI. It changes rates depending on heat to avoid overheating the phone at altitude. Some of this is better to read than to describe.
Parameters: - view – Used to allow for UI interaction to start the recording
rootTest¶
-
public boolean
rootTest()¶ Tests if the phone is rooted, although that is unimportant to the app as of now. This could be used to further exploit the abilities of the phone being used.
Returns: True if root is available on the phone, False if not
setUiEnabled¶
-
public void
setUiEnabled(boolean bool)¶ Code that enables/disables the Arduino connection UI. It is no longer used by the app but should be revived with the Arduino code when the time comes.
Parameters: - bool – state of the variables - if connected, it should be true
stopRecord¶
-
public void
stopRecord(View view)¶ Stops all recording of sensors and photos.
Parameters: - view – to be used from UI
takeCameraFromOtherThread¶
-
public void
takeCameraFromOtherThread()¶ This is the code that does the actual wrestling for
flashLightOn(View). It kills the camera and opens it up to domination by another thread.