mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-06-16 10:00:08 +02:00
Compare commits
2 Commits
6ae409a213
...
7d38d4e3e3
Author | SHA1 | Date | |
---|---|---|---|
|
7d38d4e3e3 | ||
|
cb8c58d92a |
|
@ -212,6 +212,10 @@ dependencies {
|
|||
// testImplementation "ch.qos.logback:logback-classic:1.1.3"
|
||||
// testImplementation "ch.qos.logback:logback-core:1.1.3"
|
||||
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
|
||||
implementation "androidx.camera:camera-core:1.2.3"
|
||||
implementation "androidx.camera:camera-camera2:1.2.3"
|
||||
implementation 'androidx.camera:camera-view:1.2.3'
|
||||
implementation 'androidx.camera:camera-lifecycle:1.2.3'
|
||||
testImplementation "junit:junit:4.13.2"
|
||||
testImplementation "org.mockito:mockito-core:2.28.2"
|
||||
testImplementation "org.robolectric:robolectric:4.12"
|
||||
|
|
|
@ -74,6 +74,8 @@
|
|||
<!-- Used for starting activities from the background with intents -->
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
|
||||
<!--
|
||||
SDK 30 & Android 11 - Used for getting app name from notifications, and for starting
|
||||
services from other packages via intents, when targeting Android API level 30 or later
|
||||
|
@ -99,6 +101,9 @@
|
|||
<uses-feature
|
||||
android:name="android.software.companion_device_setup"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera"
|
||||
android:required="false" />
|
||||
|
||||
<application
|
||||
android:name=".GBApplication"
|
||||
|
@ -875,6 +880,11 @@
|
|||
android:name=".activities.dashboard.DashboardCalendarActivity"
|
||||
android:label="@string/menuitem_calendar"
|
||||
android:parentActivityName=".activities.ControlCenterv2" />
|
||||
|
||||
<activity
|
||||
android:name=".activities.CameraActivity"
|
||||
android:launchMode="singleInstance"
|
||||
android:exported="false" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,218 @@
|
|||
/* Copyright (C) 2024 Martin.JM
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.result.ActivityResultCallback;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.camera.core.CameraSelector;
|
||||
import androidx.camera.core.ImageCapture;
|
||||
import androidx.camera.core.ImageCaptureException;
|
||||
import androidx.camera.core.Preview;
|
||||
import androidx.camera.lifecycle.ProcessCameraProvider;
|
||||
import androidx.camera.view.PreviewView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class CameraActivity extends AppCompatActivity {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CameraActivity.class);
|
||||
|
||||
public static final String intentExtraEvent = "EVENT";
|
||||
|
||||
private ListenableFuture<ProcessCameraProvider> cameraProviderListenableFuture;
|
||||
private ImageCapture imageCapture;
|
||||
|
||||
private boolean reportClosing = true;
|
||||
|
||||
public static boolean supportsCamera() {
|
||||
return GBApplication.getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
|
||||
}
|
||||
|
||||
public static boolean hasCameraPermission() {
|
||||
return GBApplication.getContext().checkCallingOrSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_camera);
|
||||
|
||||
if (!supportsCamera()) {
|
||||
LOG.error("No camera support");
|
||||
GB.toast(getString(R.string.toast_camera_support_required), Toast.LENGTH_SHORT, GB.ERROR);
|
||||
GBApplication.deviceService().onCameraStatusChange(GBDeviceEventCameraRemote.Event.EXCEPTION, null);
|
||||
reportClosing = false;
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasCameraPermission()) {
|
||||
LOG.info("Requesting camera permission");
|
||||
|
||||
ActivityResultLauncher<String> requestPermissionLauncher =
|
||||
registerForActivityResult(new ActivityResultContracts.RequestPermission(), new ActivityResultCallback<Boolean>() {
|
||||
@Override
|
||||
public void onActivityResult(Boolean isGranted) {
|
||||
if (isGranted) {
|
||||
initCamera();
|
||||
} else {
|
||||
LOG.error("Did not receive camera permission");
|
||||
GB.toast(getString(R.string.toast_camera_permission_required), Toast.LENGTH_SHORT, GB.ERROR);
|
||||
GBApplication.deviceService().onCameraStatusChange(GBDeviceEventCameraRemote.Event.EXCEPTION, null);
|
||||
reportClosing = false;
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
requestPermissionLauncher.launch(Manifest.permission.CAMERA);
|
||||
return;
|
||||
}
|
||||
|
||||
initCamera();
|
||||
}
|
||||
|
||||
private void initCamera() {
|
||||
cameraProviderListenableFuture = ProcessCameraProvider.getInstance(this);
|
||||
cameraProviderListenableFuture.addListener(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
ProcessCameraProvider cameraProvider = cameraProviderListenableFuture.get();
|
||||
|
||||
PreviewView previewView = findViewById(R.id.preview);
|
||||
|
||||
Preview preview = new Preview.Builder().build();
|
||||
|
||||
CameraSelector cameraSelector = new CameraSelector.Builder()
|
||||
.requireLensFacing(CameraSelector.LENS_FACING_BACK) // TODO: make setting
|
||||
.build();
|
||||
|
||||
preview.setSurfaceProvider(previewView.getSurfaceProvider());
|
||||
|
||||
imageCapture = new ImageCapture.Builder()
|
||||
.setTargetRotation(preview.getTargetRotation())
|
||||
.build();
|
||||
|
||||
cameraProvider.bindToLifecycle(
|
||||
CameraActivity.this,
|
||||
cameraSelector,
|
||||
imageCapture,
|
||||
preview
|
||||
);
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}, ContextCompat.getMainExecutor(this));
|
||||
|
||||
handleIntent(getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
handleIntent(intent);
|
||||
}
|
||||
|
||||
private void handleIntent(Intent intent) {
|
||||
if (!intent.hasExtra(intentExtraEvent)) {
|
||||
this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
GBDeviceEventCameraRemote.Event event = GBDeviceEventCameraRemote.intToEvent(intent.getIntExtra(intentExtraEvent, 0));
|
||||
|
||||
LOG.info("Camera received event: " + event.name());
|
||||
|
||||
// Nothing to do for unknown events
|
||||
|
||||
if (event == GBDeviceEventCameraRemote.Event.CLOSE_CAMERA) {
|
||||
finish();
|
||||
} else if (event == GBDeviceEventCameraRemote.Event.OPEN_CAMERA) {
|
||||
GBApplication.deviceService().onCameraStatusChange(GBDeviceEventCameraRemote.Event.OPEN_CAMERA, null);
|
||||
} else if (event == GBDeviceEventCameraRemote.Event.TAKE_PICTURE) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(MediaStore.Images.Media.TITLE, "Gadgetbridge photo");
|
||||
contentValues.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
|
||||
|
||||
ImageCapture.OutputFileOptions outputFileOptions = new ImageCapture.OutputFileOptions.Builder(
|
||||
getContentResolver(),
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
contentValues
|
||||
).build();
|
||||
imageCapture.takePicture(outputFileOptions, ContextCompat.getMainExecutor(this), new ImageCapture.OnImageSavedCallback() {
|
||||
@Override
|
||||
public void onImageSaved(@NonNull ImageCapture.OutputFileResults outputFileResults) {
|
||||
if (outputFileResults.getSavedUri() == null) {
|
||||
// Shouldn't ever happen
|
||||
GBApplication.deviceService().onCameraStatusChange(GBDeviceEventCameraRemote.Event.EXCEPTION, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: improve feedback that the photo has been taken
|
||||
GB.toast(
|
||||
String.format(getString(R.string.toast_camera_photo_taken),
|
||||
outputFileResults.getSavedUri().getPath()),
|
||||
Toast.LENGTH_LONG,
|
||||
GB.INFO
|
||||
);
|
||||
|
||||
GBApplication.deviceService().onCameraStatusChange(
|
||||
GBDeviceEventCameraRemote.Event.TAKE_PICTURE,
|
||||
outputFileResults.getSavedUri().getPath()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull ImageCaptureException exception) {
|
||||
LOG.error("Failed to save image", exception);
|
||||
GBApplication.deviceService().onCameraStatusChange(GBDeviceEventCameraRemote.Event.EXCEPTION, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
|
||||
if (reportClosing)
|
||||
GBApplication.deviceService().onCameraStatusChange(GBDeviceEventCameraRemote.Event.CLOSE_CAMERA, null);
|
||||
}
|
||||
}
|
|
@ -102,6 +102,7 @@ import nodomain.freeyourgadget.gadgetbridge.adapter.SpinnerWithIconAdapter;
|
|||
import nodomain.freeyourgadget.gadgetbridge.adapter.SpinnerWithIconItem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
|
@ -752,6 +753,18 @@ public class DebugActivity extends AbstractGBActivity {
|
|||
handler.postDelayed(runnable, delay);
|
||||
}
|
||||
});
|
||||
|
||||
Button cameraOpenButton = findViewById(R.id.cameraOpen);
|
||||
cameraOpenButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
Intent cameraIntent = new Intent(getApplicationContext(), CameraActivity.class);
|
||||
cameraIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
cameraIntent.putExtra(CameraActivity.intentExtraEvent, GBDeviceEventCameraRemote.eventToInt(GBDeviceEventCameraRemote.Event.OPEN_CAMERA));
|
||||
getApplicationContext().startActivity(cameraIntent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/* Copyright (C) 2024 Martin.JM
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.deviceevents;
|
||||
|
||||
public class GBDeviceEventCameraRemote extends GBDeviceEvent {
|
||||
public Event event = Event.UNKNOWN;
|
||||
|
||||
public enum Event {
|
||||
UNKNOWN,
|
||||
OPEN_CAMERA,
|
||||
TAKE_PICTURE,
|
||||
CLOSE_CAMERA,
|
||||
EXCEPTION
|
||||
}
|
||||
|
||||
static public int eventToInt(Event event) {
|
||||
switch (event) {
|
||||
case UNKNOWN:
|
||||
return 0;
|
||||
case OPEN_CAMERA:
|
||||
return 1;
|
||||
case TAKE_PICTURE:
|
||||
return 2;
|
||||
case CLOSE_CAMERA:
|
||||
return 3;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static public Event intToEvent(int event) {
|
||||
switch (event) {
|
||||
case 0:
|
||||
return Event.UNKNOWN;
|
||||
case 1:
|
||||
return Event.OPEN_CAMERA;
|
||||
case 2:
|
||||
return Event.TAKE_PICTURE;
|
||||
case 3:
|
||||
return Event.CLOSE_CAMERA;
|
||||
}
|
||||
return Event.EXCEPTION;
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ import java.util.ArrayList;
|
|||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.capabilities.loyaltycards.LoyaltyCard;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||
|
@ -151,4 +152,6 @@ public interface EventHandler {
|
|||
void onSetGpsLocation(Location location);
|
||||
|
||||
void onSleepAsAndroidAction(String action, Bundle extras);
|
||||
|
||||
void onCameraStatusChange(GBDeviceEventCameraRemote.Event event, String filename);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.slf4j.Logger;
|
|||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.CameraActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AppManagerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettings;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsScreen;
|
||||
|
@ -220,6 +221,10 @@ public class HuaweiCoordinator {
|
|||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_disable_find_phone_with_dnd);
|
||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_allow_accept_reject_calls);
|
||||
|
||||
// Camera control
|
||||
if (supportsCameraRemote())
|
||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_camera_remote);
|
||||
|
||||
// Time
|
||||
if (supportsDateFormat()) {
|
||||
final List<Integer> dateTime = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.DATE_TIME);
|
||||
|
@ -281,6 +286,10 @@ public class HuaweiCoordinator {
|
|||
return supportsCommandForService(0x01, 0x1d);
|
||||
}
|
||||
|
||||
public boolean supportsCameraRemote() {
|
||||
return supportsCommandForService(0x01, 0x29) && CameraActivity.supportsCamera();
|
||||
}
|
||||
|
||||
public boolean supportsAcceptAgreement() {
|
||||
return supportsCommandForService(0x01, 0x30);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.Alarms;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.AccountRelated;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.Calls;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.CameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.GpsAndTime;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.Watchface;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.Weather;
|
||||
|
@ -430,6 +431,11 @@ public class HuaweiPacket {
|
|||
return new DeviceConfig.SecurityNegotiation.Response(paramsProvider).fromPacket(this);
|
||||
case DeviceConfig.WearStatus.id:
|
||||
return new DeviceConfig.WearStatus.Response(paramsProvider).fromPacket(this);
|
||||
|
||||
// Camera remote has same ID as DeviceConfig
|
||||
case CameraRemote.CameraRemoteStatus.id:
|
||||
return new CameraRemote.CameraRemoteStatus.Response(paramsProvider).fromPacket(this);
|
||||
|
||||
default:
|
||||
this.isEncrypted = this.attemptDecrypt(); // Helps with debugging
|
||||
return this;
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/* Copyright (C) 2024 Martin.JM
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiTLV;
|
||||
|
||||
public class CameraRemote {
|
||||
public static final byte id = 0x01;
|
||||
|
||||
public static class CameraRemoteSetup {
|
||||
public static final byte id = 0x2a;
|
||||
|
||||
public static class Request extends HuaweiPacket {
|
||||
public enum Event {
|
||||
ENABLE_CAMERA,
|
||||
CAMERA_STARTED,
|
||||
CAMERA_STOPPED
|
||||
}
|
||||
|
||||
public Request(ParamsProvider paramsProvider, Event event) {
|
||||
super(paramsProvider);
|
||||
|
||||
this.serviceId = CameraRemote.id;
|
||||
this.commandId = id;
|
||||
|
||||
this.tlv = new HuaweiTLV();
|
||||
switch (event) {
|
||||
case ENABLE_CAMERA:
|
||||
this.tlv.put(0x01, (byte) 0x00);
|
||||
break;
|
||||
case CAMERA_STARTED:
|
||||
this.tlv.put(0x01, (byte) 0x01);
|
||||
break;
|
||||
case CAMERA_STOPPED:
|
||||
this.tlv.put(0x01, (byte) 0x02);
|
||||
break;
|
||||
}
|
||||
|
||||
this.complete = true;
|
||||
this.isEncrypted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CameraRemoteStatus {
|
||||
public static final byte id = 0x29;
|
||||
|
||||
public static class Request extends HuaweiPacket {
|
||||
// All responses are async, and must be ACK-ed
|
||||
public Request(ParamsProvider paramsProvider) {
|
||||
super(paramsProvider);
|
||||
|
||||
this.serviceId = CameraRemote.id;
|
||||
this.commandId = id;
|
||||
|
||||
this.tlv = new HuaweiTLV()
|
||||
.put(0x7f, 0x186A0);
|
||||
|
||||
this.complete = true;
|
||||
this.isEncrypted = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Response extends HuaweiPacket {
|
||||
public enum Event {
|
||||
OPEN_CAMERA,
|
||||
TAKE_PICTURE,
|
||||
CLOSE_CAMERA
|
||||
}
|
||||
|
||||
public Event event;
|
||||
|
||||
public Response(ParamsProvider paramsProvider) {
|
||||
super(paramsProvider);
|
||||
this.serviceId = CameraRemote.id;
|
||||
this.commandId = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseTlv() throws ParseException {
|
||||
switch (this.tlv.getByte(0x01)) {
|
||||
case 1:
|
||||
this.event = Event.OPEN_CAMERA;
|
||||
break;
|
||||
case 2:
|
||||
this.event = Event.TAKE_PICTURE;
|
||||
break;
|
||||
case 3:
|
||||
this.event = Event.CLOSE_CAMERA;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@ import java.util.UUID;
|
|||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.capabilities.loyaltycards.LoyaltyCard;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||
|
@ -558,4 +559,13 @@ public class GBDeviceService implements DeviceService {
|
|||
}
|
||||
invokeService(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraStatusChange(GBDeviceEventCameraRemote.Event event, String filename) {
|
||||
Intent intent = createIntent().setAction(ACTION_CAMERA_STATUS_CHANGE);
|
||||
intent.putExtra(EXTRA_CAMERA_EVENT, GBDeviceEventCameraRemote.eventToInt(event));
|
||||
if (event == GBDeviceEventCameraRemote.Event.TAKE_PICTURE)
|
||||
intent.putExtra(EXTRA_CAMERA_FILENAME, filename);
|
||||
invokeService(intent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ public interface DeviceService extends EventHandler {
|
|||
String ACTION_SET_GPS_LOCATION = PREFIX + ".action.set_gps_location";
|
||||
String ACTION_SET_LED_COLOR = PREFIX + ".action.set_led_color";
|
||||
String ACTION_POWER_OFF = PREFIX + ".action.power_off";
|
||||
String ACTION_CAMERA_STATUS_CHANGE = PREFIX + ".action.camera_status_change";
|
||||
|
||||
String ACTION_SLEEP_AS_ANDROID = ".action.sleep_as_android";
|
||||
String EXTRA_SLEEP_AS_ANDROID_ACTION = "sleepasandroid_action";
|
||||
|
@ -144,6 +145,8 @@ public interface DeviceService extends EventHandler {
|
|||
String EXTRA_LED_COLOR = "led_color";
|
||||
String EXTRA_GPS_LOCATION = "gps_location";
|
||||
String EXTRA_RESET_FLAGS = "reset_flags";
|
||||
String EXTRA_CAMERA_EVENT = "event";
|
||||
String EXTRA_CAMERA_FILENAME = "filename";
|
||||
|
||||
/**
|
||||
* Use EXTRA_REALTIME_SAMPLE instead
|
||||
|
|
|
@ -58,6 +58,7 @@ import java.util.UUID;
|
|||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.CameraActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.FindPhoneActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AbstractAppManagerFragment;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||
|
@ -69,6 +70,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
|||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDisplayMessage;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFmFrequency;
|
||||
|
@ -207,6 +209,8 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
|
|||
handleGBDeviceEvent((GBDeviceEventMusicControl) deviceEvent);
|
||||
} else if (deviceEvent instanceof GBDeviceEventCallControl) {
|
||||
handleGBDeviceEvent((GBDeviceEventCallControl) deviceEvent);
|
||||
} else if (deviceEvent instanceof GBDeviceEventCameraRemote) {
|
||||
handleGBDeviceEvent((GBDeviceEventCameraRemote) deviceEvent);
|
||||
} else if (deviceEvent instanceof GBDeviceEventVersionInfo) {
|
||||
handleGBDeviceEvent((GBDeviceEventVersionInfo) deviceEvent);
|
||||
} else if (deviceEvent instanceof GBDeviceEventAppInfo) {
|
||||
|
@ -338,6 +342,13 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
|
|||
context.sendBroadcast(callIntent);
|
||||
}
|
||||
|
||||
protected void handleGBDeviceEvent(GBDeviceEventCameraRemote cameraRemoteEvent) {
|
||||
Intent cameraIntent = new Intent(getContext(), CameraActivity.class);
|
||||
cameraIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
cameraIntent.putExtra(CameraActivity.intentExtraEvent, GBDeviceEventCameraRemote.eventToInt(cameraRemoteEvent.event));
|
||||
getContext().startActivity(cameraIntent);
|
||||
}
|
||||
|
||||
protected void handleGBDeviceEvent(GBDeviceEventVersionInfo infoEvent) {
|
||||
Context context = getContext();
|
||||
LOG.info("Got event for VERSION_INFO: " + infoEvent);
|
||||
|
@ -1187,4 +1198,7 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
|
|||
public void onSleepAsAndroidAction(String action, Bundle extras) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraStatusChange(GBDeviceEventCameraRemote.Event event, String filename) {}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,9 @@ import nodomain.freeyourgadget.gadgetbridge.GBException;
|
|||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.HeartRateUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.capabilities.loyaltycards.LoyaltyCard;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.CameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.externalevents.AlarmClockReceiver;
|
||||
import nodomain.freeyourgadget.gadgetbridge.externalevents.AlarmReceiver;
|
||||
import nodomain.freeyourgadget.gadgetbridge.externalevents.BluetoothConnectReceiver;
|
||||
|
@ -1093,6 +1095,14 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
|||
deviceSupport.onSleepAsAndroidAction(sleepAsAndroidAction, intent.getExtras());
|
||||
}
|
||||
break;
|
||||
case ACTION_CAMERA_STATUS_CHANGE:
|
||||
final GBDeviceEventCameraRemote.Event event = GBDeviceEventCameraRemote.intToEvent(intent.getIntExtra(EXTRA_CAMERA_EVENT, -1));
|
||||
String filename = null;
|
||||
if (event == GBDeviceEventCameraRemote.Event.TAKE_PICTURE) {
|
||||
filename = intent.getStringExtra(EXTRA_CAMERA_FILENAME);
|
||||
}
|
||||
deviceSupport.onCameraStatusChange(event, filename);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.EnumSet;
|
|||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.capabilities.loyaltycards.LoyaltyCard;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||
|
@ -520,4 +521,12 @@ public class ServiceDeviceSupport implements DeviceSupport {
|
|||
}
|
||||
delegate.onSleepAsAndroidAction(action, extras);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraStatusChange(GBDeviceEventCameraRemote.Event event, String filename) {
|
||||
if (checkBusy("camera status")) {
|
||||
return;
|
||||
}
|
||||
delegate.onCameraStatusChange(event, filename);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,12 +37,15 @@ import java.util.HashMap;
|
|||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.CameraActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.Calls;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.CameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.DeviceConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.FindPhone;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.GpsAndTime;
|
||||
|
@ -110,6 +113,7 @@ public class AsynchronousResponse {
|
|||
handleGpsRequest(response);
|
||||
handleFileUpload(response);
|
||||
handleWatchface(response);
|
||||
handleCameraRemote(response);
|
||||
} catch (Request.ResponseParseException e) {
|
||||
LOG.error("Response parse exception", e);
|
||||
}
|
||||
|
@ -490,4 +494,37 @@ public class AsynchronousResponse {
|
|||
support.setGps(((GpsAndTime.GpsStatus.Response) response).enableGps);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCameraRemote(HuaweiPacket response) {
|
||||
if (response.serviceId == CameraRemote.id && response.commandId == CameraRemote.CameraRemoteStatus.id) {
|
||||
if (!(response instanceof CameraRemote.CameraRemoteStatus.Response)) {
|
||||
// TODO: exception?
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CameraActivity.supportsCamera()) {
|
||||
LOG.error("No camera present");
|
||||
// TODO: Toast?
|
||||
return;
|
||||
}
|
||||
|
||||
switch (((CameraRemote.CameraRemoteStatus.Response) response).event) {
|
||||
case OPEN_CAMERA:
|
||||
GBDeviceEventCameraRemote openCameraEvent = new GBDeviceEventCameraRemote();
|
||||
openCameraEvent.event = GBDeviceEventCameraRemote.Event.OPEN_CAMERA;
|
||||
support.evaluateGBDeviceEvent(openCameraEvent);
|
||||
break;
|
||||
case TAKE_PICTURE:
|
||||
GBDeviceEventCameraRemote takePictureEvent = new GBDeviceEventCameraRemote();
|
||||
takePictureEvent.event = GBDeviceEventCameraRemote.Event.TAKE_PICTURE;
|
||||
support.evaluateGBDeviceEvent(takePictureEvent);
|
||||
break;
|
||||
case CLOSE_CAMERA:
|
||||
GBDeviceEventCameraRemote closeCameraEvent = new GBDeviceEventCameraRemote();
|
||||
closeCameraEvent.event = GBDeviceEventCameraRemote.Event.CLOSE_CAMERA;
|
||||
support.evaluateGBDeviceEvent(closeCameraEvent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory;
|
|||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||
|
@ -155,4 +156,8 @@ public class HuaweiBRSupport extends AbstractBTBRDeviceSupport {
|
|||
supportProvider.onAppDelete(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraStatusChange(GBDeviceEventCameraRemote.Event event, String filename) {
|
||||
supportProvider.onCameraStatusChange(event, filename);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
|
|||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||
|
@ -163,5 +164,8 @@ public class HuaweiLESupport extends AbstractBTLEDeviceSupport {
|
|||
supportProvider.onAppDelete(uuid);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCameraStatusChange(GBDeviceEventCameraRemote.Event event, String filename) {
|
||||
supportProvider.onCameraStatusChange(event, filename);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.location.Location;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -44,6 +46,7 @@ import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSett
|
|||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiCoordinator;
|
||||
|
@ -52,6 +55,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiCoordinatorSupp
|
|||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiCrypto;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiSampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.CameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.GpsAndTime;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.Weather;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.Workout;
|
||||
|
@ -87,6 +91,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.GetG
|
|||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.GetNotificationConstraintsRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.GetSmartAlarmList;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.GetWatchfaceParams;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendCameraRemoteSetupEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendExtendedAccountRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendGpsAndTimeToDeviceRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests.SendGpsDataRequest;
|
||||
|
@ -740,6 +745,11 @@ public class HuaweiSupportProvider {
|
|||
GetWatchfaceParams getWatchfaceParams = new GetWatchfaceParams(this);
|
||||
getWatchfaceParams.doPerform();
|
||||
}
|
||||
|
||||
if (getHuaweiCoordinator().supportsCameraRemote() && GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREF_CAMERA_REMOTE, false)) {
|
||||
SendCameraRemoteSetupEvent sendCameraRemoteSetupEvent = new SendCameraRemoteSetupEvent(this, CameraRemote.CameraRemoteSetup.Request.Event.ENABLE_CAMERA);
|
||||
sendCameraRemoteSetupEvent.doPerform();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Initialize dynamic services of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR,
|
||||
e);
|
||||
|
@ -963,6 +973,15 @@ public class HuaweiSupportProvider {
|
|||
case ActivityUser.PREF_USER_STEPS_GOAL:
|
||||
new SendFitnessGoalRequest(this).doPerform();
|
||||
break;
|
||||
case DeviceSettingsPreferenceConst.PREF_CAMERA_REMOTE:
|
||||
if (GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREF_CAMERA_REMOTE, false)) {
|
||||
SendCameraRemoteSetupEvent sendCameraRemoteSetupEvent = new SendCameraRemoteSetupEvent(this, CameraRemote.CameraRemoteSetup.Request.Event.ENABLE_CAMERA);
|
||||
sendCameraRemoteSetupEvent.doPerform();
|
||||
} else {
|
||||
// Somehow it is impossible to disable the camera remote
|
||||
// But it will disappear after reconnection - until it is enabled again
|
||||
GB.toast(context, context.getString(R.string.toast_setting_requires_reconnect), Toast.LENGTH_SHORT, GB.INFO);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO: Use translatable string
|
||||
|
@ -1903,4 +1922,32 @@ public class HuaweiSupportProvider {
|
|||
huaweiWatchfaceManager.deleteWatchface(uuid);
|
||||
}
|
||||
|
||||
public void onCameraStatusChange(GBDeviceEventCameraRemote.Event event, String filename) {
|
||||
if (event == GBDeviceEventCameraRemote.Event.OPEN_CAMERA) {
|
||||
// Somehow a delay is necessary for the watch
|
||||
new Handler(GBApplication.getContext().getMainLooper()).postDelayed(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SendCameraRemoteSetupEvent sendCameraRemoteSetupEvent = new SendCameraRemoteSetupEvent(HuaweiSupportProvider.this, CameraRemote.CameraRemoteSetup.Request.Event.CAMERA_STARTED);
|
||||
try {
|
||||
sendCameraRemoteSetupEvent.doPerform();
|
||||
} catch (IOException e) {
|
||||
GB.toast("Failed to send open camera request", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||
LOG.error("Failed to send open camera request", e);
|
||||
}
|
||||
}
|
||||
},
|
||||
3000
|
||||
);
|
||||
} else if (event == GBDeviceEventCameraRemote.Event.CLOSE_CAMERA) {
|
||||
SendCameraRemoteSetupEvent sendCameraRemoteSetupEvent2 = new SendCameraRemoteSetupEvent(this, CameraRemote.CameraRemoteSetup.Request.Event.CAMERA_STOPPED);
|
||||
try {
|
||||
sendCameraRemoteSetupEvent2.doPerform();
|
||||
} catch (IOException e) {
|
||||
GB.toast("Failed to send open camera request", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||
LOG.error("Failed to send open camera request", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/* Copyright (C) 2024 Martin.JM
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.CameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
|
||||
|
||||
public class SendCameraRemoteSetupEvent extends Request {
|
||||
|
||||
CameraRemote.CameraRemoteSetup.Request.Event event;
|
||||
|
||||
public SendCameraRemoteSetupEvent(HuaweiSupportProvider support, CameraRemote.CameraRemoteSetup.Request.Event event) {
|
||||
super(support);
|
||||
this.serviceId = CameraRemote.id;
|
||||
this.commandId = CameraRemote.CameraRemoteSetup.id;
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<byte[]> createRequest() throws RequestCreationException {
|
||||
try {
|
||||
return new CameraRemote.CameraRemoteSetup.Request(
|
||||
supportProvider.getParamsProvider(),
|
||||
this.event
|
||||
).serialize();
|
||||
} catch (HuaweiPacket.CryptoException e) {
|
||||
throw new RequestCreationException(e);
|
||||
}
|
||||
}
|
||||
}
|
11
app/src/main/res/layout/activity_camera.xml
Normal file
11
app/src/main/res/layout/activity_camera.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.camera.view.PreviewView
|
||||
android:id="@+id/preview"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -301,6 +301,14 @@
|
|||
grid:layout_columnSpan="2"
|
||||
grid:layout_gravity="fill_horizontal"
|
||||
android:text="@string/debug_companion_pair_current" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/cameraOpen"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
grid:layout_columnSpan="2"
|
||||
grid:layout_gravity="fill_horizontal"
|
||||
android:text="@string/open_camera" />
|
||||
</androidx.gridlayout.widget.GridLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
|
|
@ -2821,4 +2821,11 @@
|
|||
<string name="pref_title_huawei_account">Huawei Account</string>
|
||||
<string name="pref_summary_huawei_account">Huawei account used in pairing process. Setting it allows to pair without factory reset.</string>
|
||||
<string name="watchface_resolution_doesnt_match">Watchface resolution doesnt match device screen. Watchface is %1$s device screen is %2$s</string>
|
||||
<string name="toast_setting_requires_reconnect">This setting will take effect after a reconnect</string>
|
||||
|
||||
<!-- Camera strings -->
|
||||
<string name="open_camera">Open Camera</string>
|
||||
<string name="toast_camera_permission_required">Camera permission is required for this function.</string>
|
||||
<string name="toast_camera_support_required">Camera support is required for this function.</string>
|
||||
<string name="toast_camera_photo_taken">Photo has been taken and saved at: %s</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue
Block a user