Make an Android app able to capture images, preferably RAW #65

Open
opened 2024-05-02 01:36:48 +02:00 by Benjamin_Loison · 5 comments

Related to #64 and Benjamin-Loison/termux-api-package/issues/10.

Log.i(null, "Hello from Camera app!");
05-02 01:32:36.545 29678 29678 D CompatibilityChangeReporter: Compat change id reported: 63938206; UID 10132; state: DISABLED
05-02 01:32:36.549 29678 29678 I rtphones.camera: Hello from Camera app!
05-02 01:32:36.553 29678 29678 D CompatibilityChangeReporter: Compat change id reported: 237531167; UID 10132; state: DISABLED
Log.i("MyCameraTag", "Hello from Camera app!!");
05-02 01:38:14.889 30595 30595 D CompatibilityChangeReporter: Compat change id reported: 63938206; UID 10132; state: DISABLED
05-02 01:38:14.893 30595 30595 I MyCameraTag: Hello from Camera app!!
05-02 01:38:14.898 30595 30595 D CompatibilityChangeReporter: Compat change id reported: 237531167; UID 10132; state: DISABLED

Could have used:

static final String TAG = "Robust image source identification on modern smartphones camera";
Related to #64 and [Benjamin-Loison/termux-api-package/issues/10](https://github.com/Benjamin-Loison/termux-api-package/issues/10). ```java Log.i(null, "Hello from Camera app!"); ``` ``` 05-02 01:32:36.545 29678 29678 D CompatibilityChangeReporter: Compat change id reported: 63938206; UID 10132; state: DISABLED 05-02 01:32:36.549 29678 29678 I rtphones.camera: Hello from Camera app! 05-02 01:32:36.553 29678 29678 D CompatibilityChangeReporter: Compat change id reported: 237531167; UID 10132; state: DISABLED ``` ```java Log.i("MyCameraTag", "Hello from Camera app!!"); ``` ``` 05-02 01:38:14.889 30595 30595 D CompatibilityChangeReporter: Compat change id reported: 63938206; UID 10132; state: DISABLED 05-02 01:38:14.893 30595 30595 I MyCameraTag: Hello from Camera app!! 05-02 01:38:14.898 30595 30595 D CompatibilityChangeReporter: Compat change id reported: 237531167; UID 10132; state: DISABLED ``` Could have used: ```java static final String TAG = "Robust image source identification on modern smartphones camera"; ```
Benjamin_Loison added the
enhancement
medium priority
medium
labels 2024-05-02 01:36:48 +02:00
Author
Owner

cff225e41e/app/src/main/java/com/termux/api/apis/CameraInfoAPI.java

cff225e41e/app/src/main/java/com/termux/api/apis/CameraPhotoAPI.java (L79)

e62bdadea3/scripts/termux-camera-photo.in

Is not there an open-source app able to capture RAW images? But maybe have to pay attention how they proceed then.

As a first step just taking a JPEG picture would be a good start.

https://developer.android.com/media/camera/camerax/take-photo#java

https://developer.android.com/media/camera/camera2/capture-sessions-requests

Just copy-pasting and correcting errors of cff225e41e/app/src/main/java/com/termux/api/apis/CameraPhotoAPI.java seems to be the most promising.

May have to modify AndroidManifest.xml and provide permissions.

cff225e41e/app/src/main/AndroidManifest.xml

Currently facing:

AndroidManifest.xml:7: error: Error parsing XML: unbound prefix

I forgot:

cff225e41e/app/src/main/AndroidManifest.xml (L3):

xmlns:tools="http://schemas.android.com/tools"

Now have a compilable app but /sdcard/0.jpg is not created. Note that App info > Permissions only mentions Camera, there is nothing related to file access. According to System.getProperty("user.dir") current working directory is /, my idea was to leverage the given app default folder.

Well I based my AndroidManifest.xml on Termux API one but the Termux one seems necessary from the file system access point of view:

image

image

The purpose currently is to have a superset of required permissions that we will be able to minimize afterwards.

find -maxdepth 4 -name 'AndroidManifest.xml'
./app/src/main/AndroidManifest.xml
./terminal-view/src/main/AndroidManifest.xml
./termux-shared/src/main/AndroidManifest.xml
./terminal-emulator/src/main/AndroidManifest.xml
./app/src/main/AndroidManifest.xml

does not seem to have any interesting addition.

https://github.com/termux/termux-api/blob/cff225e41e963267a8e5fdd59a83b5fe224dcb5d/app/src/main/java/com/termux/api/apis/CameraInfoAPI.java https://github.com/termux/termux-api/blob/cff225e41e963267a8e5fdd59a83b5fe224dcb5d/app/src/main/java/com/termux/api/apis/CameraPhotoAPI.java#L79 https://github.com/termux/termux-api-package/blob/e62bdadea3f26b60430bb85248f300fee68ecdcc/scripts/termux-camera-photo.in Is not there an open-source app able to capture RAW images? But maybe have to pay attention how they proceed then. As a first step just taking a JPEG picture would be a good start. https://developer.android.com/media/camera/camerax/take-photo#java https://developer.android.com/media/camera/camera2/capture-sessions-requests Just copy-pasting and correcting errors of https://github.com/termux/termux-api/blob/cff225e41e963267a8e5fdd59a83b5fe224dcb5d/app/src/main/java/com/termux/api/apis/CameraPhotoAPI.java seems to be the most promising. May have to modify `AndroidManifest.xml` and provide permissions. https://github.com/termux/termux-api/blob/cff225e41e963267a8e5fdd59a83b5fe224dcb5d/app/src/main/AndroidManifest.xml Currently facing: ``` AndroidManifest.xml:7: error: Error parsing XML: unbound prefix ``` I forgot: https://github.com/termux/termux-api/blob/cff225e41e963267a8e5fdd59a83b5fe224dcb5d/app/src/main/AndroidManifest.xml#L3: ```xml xmlns:tools="http://schemas.android.com/tools" ``` Now have a compilable app but `/sdcard/0.jpg` is not created. Note that `App info` > `Permissions` only mentions `Camera`, there is nothing related to file access. According to `System.getProperty("user.dir")` current working directory is `/`, my idea was to leverage the given app default folder. Well I based my `AndroidManifest.xml` on Termux API one but the Termux one seems necessary from the file system access point of view: ![image](/attachments/19e189cc-eb2f-4e35-858a-be251cda15a9) ![image](/attachments/74c59af7-f820-4864-8c98-1b7795cbd9c2) The purpose currently is to have a superset of required permissions that we will be able to minimize afterwards. ```bash find -maxdepth 4 -name 'AndroidManifest.xml' ``` ``` ./app/src/main/AndroidManifest.xml ./terminal-view/src/main/AndroidManifest.xml ./termux-shared/src/main/AndroidManifest.xml ./terminal-emulator/src/main/AndroidManifest.xml ``` ``` ./app/src/main/AndroidManifest.xml ``` does not seem to have any interesting addition.
107 KiB
157 KiB
Author
Owner
diff --git a/datasets/android/AndroidManifest.xml b/datasets/android/AndroidManifest.xml
index cebbf0e..efca1ef 100644
--- a/datasets/android/AndroidManifest.xml
+++ b/datasets/android/AndroidManifest.xml
@@ -1,8 +1,24 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
+             xmlns:tools="http://schemas.android.com/tools"
           package="com.robust_image_source_identification_on_modern_smartphones.camera"
           versionCode="1"
           versionName="0.1">
+    <uses-permission android:name="android.permission.CAMERA" />
+    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+    <!-- This permission is not used, but a permission is needed on the sharedfiles contentprovider,
+         which will always use FLAG_GRANT_READ_URI_PERMISSION. -->
+   <!-- <permission android:name="com.robust_image_source_identification_on_modern_smartphones.camera.sharedfiles.READ_WRITE" android:protectionLevel="signature" /> -->
+
+    <!-- Some of the used permissions imply uses-feature, so we need to make it optional.
+         See http://developer.android.com/guide/topics/manifest/uses-feature-element.html#permissions -->
+    <uses-feature android:name="android.hardware.camera" android:required="false" />
+    <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
+
     <uses-sdk android:minSdkVersion="33"/>
     <application android:label="Camera">
         <activity android:name=".MainActivity" android:exported="true">
```diff diff --git a/datasets/android/AndroidManifest.xml b/datasets/android/AndroidManifest.xml index cebbf0e..efca1ef 100644 --- a/datasets/android/AndroidManifest.xml +++ b/datasets/android/AndroidManifest.xml @@ -1,8 +1,24 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" package="com.robust_image_source_identification_on_modern_smartphones.camera" versionCode="1" versionName="0.1"> + <uses-permission android:name="android.permission.CAMERA" /> + <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" /> + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + + <!-- This permission is not used, but a permission is needed on the sharedfiles contentprovider, + which will always use FLAG_GRANT_READ_URI_PERMISSION. --> + <!-- <permission android:name="com.robust_image_source_identification_on_modern_smartphones.camera.sharedfiles.READ_WRITE" android:protectionLevel="signature" /> --> + + <!-- Some of the used permissions imply uses-feature, so we need to make it optional. + See http://developer.android.com/guide/topics/manifest/uses-feature-element.html#permissions --> + <uses-feature android:name="android.hardware.camera" android:required="false" /> + <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" /> + <uses-sdk android:minSdkVersion="33"/> <application android:label="Camera"> <activity android:name=".MainActivity" android:exported="true"> ```
Author
Owner

Should check that we log exceptions correctly and monitor if some are triggered.

Should check that we log exceptions correctly and monitor if some are triggered.
Author
Owner

https://search.f-droid.org/?q=raw&lang=en Find in page... raw does not return interesting entries.

https://search.f-droid.org/?q=raw&lang=en `Find in page...` `raw` does not return interesting entries.
Author
Owner
https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/src/commit/3c4cf90b19c2fc36d42c433a9b9564ff59e6d534/datasets/android
Sign in to join this conversation.
No description provided.