1 package com.intel.realsense.camera;
3 import android.app.Activity;
4 import android.app.AlertDialog;
5 import android.app.Dialog;
6 import android.app.DialogFragment;
7 import android.content.Context;
8 import android.graphics.Color;
9 import android.graphics.drawable.ColorDrawable;
10 import android.os.Bundle;
11 import android.util.Log;
12 import android.view.LayoutInflater;
13 import android.view.View;
14 import android.widget.ProgressBar;
27 import java.io.FileInputStream;
28 import java.io.IOException;
29 import java.io.InputStream;
38 final Activity activity = getActivity();
40 Bundle bundle = getArguments();
41 mFirmwareFilePath = bundle == null ?
"" : bundle.getString(getString(
R.string.firmware_update_file_path),
"");
43 LayoutInflater inflater = activity.getLayoutInflater();
44 View fragmentView = inflater.inflate(
R.layout.firmware_update_progress, null);
46 mProgressBar = fragmentView.findViewById(
R.id.firmwareUpdateProgressBar);
51 AlertDialog.Builder builder =
new AlertDialog.Builder(getActivity());
52 builder.setView(fragmentView);
53 AlertDialog rv = builder.create();
54 rv.getWindow().setBackgroundDrawable(
new ColorDrawable(
Color.TRANSPARENT));
62 case D400:
return R.raw.fw_d4xx;
63 case SR300:
return R.raw.fw_sr3xx;
64 case L500:
return R.raw.fw_l5xx;
67 throw new RuntimeException(
"FW update is not supported for the connected device");
73 int len =
in.read(rv,0, rv.length);
79 File fwFile =
new File(
path);
80 return new FileInputStream(fwFile);
83 private static InputStream
getInputStream(Context context,
int fwResId)
throws IOException {
84 return context.getResources().openRawResource(fwResId);
92 boolean notify =
false;
94 if(dl.getDeviceCount() == 0)
96 try(
Device d = dl.createDevice(0)){
109 }
catch (Exception
e) {
110 Log.e(TAG,
"firmware update failed, error: " + e.getMessage());
114 dismissAllowingStateLoss();
122 public void onProgress(
final float progress) {
123 getActivity().runOnUiThread(
new Runnable() {
126 int perc = (int) (progress * 100);
127 mProgressBar.setProgress(perc);
132 Log.i(TAG,
"Firmware update process finished successfully");
138 public void onProgress(
final float progress) {
139 getActivity().runOnUiThread(
new Runnable() {
142 int perc = (int) (progress * 100);
143 mProgressBar.setProgress(perc);
148 Log.i(TAG,
"Firmware update process finished successfully");
String getInfo(CameraInfo info)
::rosgraph_msgs::Log_< std::allocator< void > > Log
IMGUI_API void ProgressBar(float fraction, const ImVec2 &size_arg=ImVec2(-1, 0), const char *overlay=NULL)
int getFwImageId(Device device)
void updateFirmware(UpdateDevice device, final byte[] bytes)
GLsizei const GLchar *const * path
::std_msgs::String_< std::allocator< void > > String
void updateFirmware(Updatable device, final byte[] bytes)
synchronized void updateUnsigned(byte[] image, ProgressListener listener)
void update(byte[] image)
def run(include_folder_path, addon_folder_path)
static InputStream getInputStream(Context context, int fwResId)
Dialog onCreateDialog(Bundle savedInstanceState)
GLenum GLuint GLenum GLsizei length
static byte[] readFwFile(InputStream in)
DeviceList queryDevices()
static InputStream getInputStream(String path)
boolean supportsInfo(CameraInfo info)