1 package com.intel.realsense.camera;
3 import android.Manifest;
4 import android.content.Context;
5 import android.content.Intent;
6 import android.content.SharedPreferences;
7 import android.content.pm.PackageManager;
8 import android.os.Bundle;
9 import androidx.core.app.ActivityCompat;
10 import androidx.core.content.ContextCompat;
11 import androidx.appcompat.app.AppCompatActivity;
12 import android.util.Log;
13 import android.view.View;
14 import android.widget.Button;
15 import android.widget.TextView;
16 import android.widget.Toast;
27 import java.util.ArrayList;
28 import java.util.HashMap;
32 private static final String TAG =
"librs camera detached";
46 protected void onCreate(Bundle savedInstanceState) {
47 super.onCreate(savedInstanceState);
48 setContentView(
R.layout.activity_detached);
50 mAppContext = getApplicationContext();
58 ArrayList<String> permissions =
new ArrayList<>();
60 permissions.add(Manifest.permission.CAMERA);
64 permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
66 if (!permissions.isEmpty())
82 if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.O)
84 return ContextCompat.checkSelfPermission(
this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
88 return ContextCompat.checkSelfPermission(
this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
91 private synchronized void init()
93 mPlaybackButton = findViewById(
R.id.playbackButton);
94 mPlaybackButton.setOnClickListener(
new View.OnClickListener() {
96 public void onClick(View
view) {
100 startActivityForResult(intent, PLAYBACK_REQUEST_CODE);
104 runOnUiThread(
new Runnable() {
107 String appVersion = BuildConfig.VERSION_NAME;
109 TextView versions = findViewById(
R.id.versionsText);
110 versions.setText(
"librealsense version: " + lrsVersion +
"\ncamera app version: " + appVersion);
121 if(dl.getDeviceCount() == 0) {
129 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
130 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
131 intent.putExtra(
"keepalive",
false);
132 startActivity(intent);
138 try(
Device d = dl.createDevice(0)){
143 fupd.setCancelable(
false);
144 fupd.show(getFragmentManager(), null);
158 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
159 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
160 intent.putExtra(
"keepalive",
true);
161 startActivity(intent);
164 }
catch (Exception
e){
165 Log.e(TAG,
"error while validating device, error: " + e.getMessage());
172 if(mMinimalFirmwares.containsKey(pl)){
173 final String minimalFw = mMinimalFirmwares.get(pl);
176 Bundle bundle =
new Bundle();
177 bundle.putBoolean(getString(
R.string.firmware_update_required),
true);
178 fud.setArguments(bundle);
179 fud.show(getFragmentManager(), null);
184 SharedPreferences sharedPref = getSharedPreferences(getString(
R.string.app_settings), Context.MODE_PRIVATE);
185 boolean showUpdateMessage = sharedPref.getBoolean(getString(
R.string.show_update_firmware),
true);
192 fud.show(getFragmentManager(), null);
199 String[] sFw = currFw.split(
"\\.");
200 String[] sRecFw = otherFw.split(
"\\.");
201 for (
int i = 0;
i < sRecFw.length;
i++) {
202 if (Integer.parseInt(sFw[
i]) > Integer.parseInt(sRecFw[i]))
204 if (Integer.parseInt(sFw[i]) < Integer.parseInt(sRecFw[i])) {
214 runOnUiThread(
new Runnable() {
217 String msg = status ?
"firmware update done" :
"firmware update failed";
225 public void onDeviceAttach() {
230 public void onDeviceDetach() {
String getInfo(CameraInfo info)
::rosgraph_msgs::Log_< std::allocator< void > > Log
boolean compareFwVersion(String currFw, String otherFw)
uvc_xu_option< int > super
synchronized void setDevicesChangedCallback(DeviceListener listener)
void requestPermissionsIfNeeded()
synchronized void validatedDevice()
RECOMMENDED_FIRMWARE_VERSION
static final int PLAYBACK_REQUEST_CODE
boolean isWritePermissionGranted()
::std_msgs::String_< std::allocator< void > > String
static void init(Context context)
status
Defines return codes that SDK interfaces use. Negative values indicate errors, a zero value indicates...
static final String MINIMAL_D400_FW_VERSION
static String getVersion()
Map< ProductLine, String > mMinimalFirmwares
void onCreate(Bundle savedInstanceState)
def run(include_folder_path, addon_folder_path)
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
static final int PERMISSIONS_REQUEST_ALL
boolean validateFwVersion(Device device)
boolean isCameraPermissionGranted()
void onFwUpdateStatus(final boolean status)
DeviceList queryDevices()
boolean supportsInfo(CameraInfo info)