Skip to content

Commit

Permalink
Add an option to blow up the camera
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Jul 26, 2023
1 parent f50439e commit 8e370f7
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/dev/danielc/fujiapp/Backend.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static void clear() {
public native synchronized static byte[] cPtpGetThumb(int handle);
public native synchronized static byte[] cFujiGetFile(int handle);
public native synchronized static boolean cIsMultipleMode();
public native synchronized static int cTestStuff();

// Enable disable verbose logging to file
public native synchronized static int cRouteLogs(String filename);
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/dev/danielc/fujiapp/Bluetooth.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public class Bluetooth {
private final BluetoothGattCallback callback = new BluetoothGattCallback() {
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
if (newState == BluetoothProfile.STATE_CONNECTED) {
log("Bluetooth Connected");
//log("Bluetooth Connected");
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
log("Bluetooth disconnected");
//log("Bluetooth disconnected");
}

if (status == BluetoothGatt.GATT_SUCCESS) {
Expand Down Expand Up @@ -66,7 +66,7 @@ public void onDescriptorRead (BluetoothGatt gatt, BluetoothGattDescriptor descri
public void onDescriptorWrite (BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {

}
}
};

// Return an Intent that is to be run by the caller
public Intent getIntent() throws Exception {
Expand All @@ -88,7 +88,7 @@ public Intent getIntent() throws Exception {
throw new Exception("Bluetooth adapter is disabled");
}

public connectGATT() {
public void connectGATT() {
// Connected to adapter.getName();
}
}
17 changes: 16 additions & 1 deletion app/src/main/java/dev/danielc/fujiapp/Gallery.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.View;
import android.widget.Toast;
import android.content.Intent;
import android.os.Bundle;
Expand Down Expand Up @@ -43,6 +45,19 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_gallery);
instance = this;

findViewById(R.id.blowup).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Thread testThread = new Thread(new Runnable() {
@Override
public void run() {
Backend.jni_print("Attempted to detonate internal camera time bomb: " + Backend.cTestStuff());
}
});
testThread.start();
}
});

recyclerView = findViewById(R.id.galleryView);
recyclerView.setLayoutManager(new GridLayoutManager(this, 4));

Expand Down Expand Up @@ -160,7 +175,7 @@ public void run() {
// When back pressed in gallery, do nothing
@Override
public void onBackPressed() {
//super.onBackPressed();
// TODO: Press again to terminate connection
}
}

3 changes: 3 additions & 0 deletions app/src/main/java/dev/danielc/fujiapp/Viewer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Download the image, button for share and download
// Copyright 2023 Daniel C - https://github.com/petabyt/fujiapp

// TODO: prevent back arrow when downloading image

package dev.danielc.fujiapp;

import android.util.Log;
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/activity_gallery.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
app:layout_constraintTop_toTopOf="parent">

<Button
android:id="@+id/button"
android:id="@+id/blowup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
Expand Down Expand Up @@ -76,5 +76,4 @@
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>

</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources>
<string name="app_name">Fuji Wifi App</string>
<string name="help_text">This app is a complete reimplementation of Fujifilm\'s WiFi app. Expect bugs! There are no promises that it will be better than the official app.</string>
<string name="help_text">This app is a reimplementation of Fujifilm\'s WiFi app. Expect bugs! There are no promises that it will be better than the official app.</string>
<string name="troubleshooting"><b>Troubleshooting:</b>\n
- Your camera\'s WiFi menu should be accessible from the \'Fn\' button on the top of the body.\n
- Sorry, modern cameras with Bluetooth aren\'t supported yet. We are working on that!\n
Expand Down
3 changes: 1 addition & 2 deletions lib/fuji.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int fuji_wait_for_access(struct PtpRuntime *r) {
return PTP_RUNTIME_ERR;
}

ptp_verbose_log("unlocked %d\n", value);
ptp_verbose_log("unlocked_mode: %d\n", value);
fuji_known.unlocked_mode = value;

// We don't need to poll the device
Expand All @@ -48,7 +48,6 @@ int fuji_wait_for_access(struct PtpRuntime *r) {

// Apply events structure to payload, and check for unlocked event (PTP_PC_FUJI_Unlocked)
struct PtpFujiEvents *ev = (struct PtpFujiEvents *)(ptp_get_payload(r));

ptp_verbose_log("Found %d events\n", ev->length);
for (int i = 0; i < ev->length; i++) {
ptp_verbose_log("%X changed to %d\n", ev->events[i].code, ev->events[i].value);
Expand Down
2 changes: 1 addition & 1 deletion lib/fujiptp.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define FUJI_FULL_ACCESS 2
#define FUJI_REMOTE_ACCESS 6

// Stuff from libgphoto2 ptp.h
// Stuff from libgphoto2 ptp.h - a lot of USB stuff
#define PTP_EC_FUJI_PreviewAvailable 0xC001
#define PTP_EC_FUJI_ObjectAdded 0xC004

Expand Down
8 changes: 8 additions & 0 deletions lib/jni.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,11 @@ JNI_FUNC(jboolean, cIsMultipleMode)(JNIEnv *env, jobject thiz) {

return fuji_known.unlocked_mode == FUJI_MULTIPLE_TRANSFER;
}

JNI_FUNC(jint, cTestStuff)(JNIEnv *env, jobject thiz) {
backend.env = env;

int rc = ptp_set_prop_value(&backend.r, PTP_PC_FUJI_Mode, FUJI_CAMERA_ERR);

return rc;
}

0 comments on commit 8e370f7

Please sign in to comment.