-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MultiCamera App Changes for Coverity Fix #46
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,6 @@ public class CtsCamIntents { | |
protected CameraCaptureSession cameraCaptureSessions; | ||
protected CaptureRequest.Builder captureRequestBuilder; | ||
private Size previewSize; | ||
private ImageReader imageReader; | ||
private File file; | ||
private Handler mBackgroundHandler; | ||
private HandlerThread mBackgroundThread; | ||
|
@@ -103,7 +102,7 @@ public class CtsCamIntents { | |
// The video file that the hardware camera is about to record into | ||
// (or is recording into. | ||
private String mVideoFilename, mPictureFilename; | ||
private ContentValues mCurrentVideoValues, mCurrentPictureValues; | ||
private ContentValues mCurrentPictureValues; | ||
byte[] jpegLength; | ||
|
||
private boolean mIsVideoCaptureIntent, mIsImageCaptureIntent; | ||
|
@@ -480,10 +479,6 @@ public void closeCamera() { | |
cameraDevice.close(); | ||
cameraDevice = null; | ||
} | ||
if (null != imageReader) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, it wont create leak ? |
||
imageReader.close(); | ||
imageReader = null; | ||
} | ||
if (null != mMediaRecorder) { | ||
releaseMedia(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,6 +189,7 @@ public View getView(int position, View convertView, ViewGroup parent) { | |
tv = (TextView)LayoutInflater.from(mContext).inflate(R.layout.details, parent, | ||
false); | ||
} else { | ||
assert convertView instanceof TextView : convertView;//Coverity Fix: Asserted View is TextView here | ||
tv = (TextView)convertView; | ||
} | ||
tv.setText(mItems.get(position)); | ||
|
@@ -234,9 +235,9 @@ private String toLocalNumber(int n) { | |
} | ||
|
||
/** Converts the given double to a localized String version. */ | ||
private String toLocalNumber(double n) { | ||
/*private String toLocalNumber(double n) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this commented code, if not used |
||
return mDecimalFormat.format(n); | ||
} | ||
}*/ | ||
} | ||
|
||
public static String getDetailsName(Context context, int key) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
import java.io.File; | ||
import java.util.Optional; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.Objects; | ||
|
||
import static com.intel.multicamera.MultiViewActivity.updateStorageSpace; | ||
|
||
|
@@ -106,6 +107,7 @@ protected void onCreate(Bundle savedInstanceState) { | |
|
||
checkPermissions(); | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove newly added unwanted line |
||
OpenCamera(); | ||
try { | ||
final IntentFilter filter = new IntentFilter(); | ||
|
@@ -165,6 +167,7 @@ public void onReceive(Context context, Intent intent) { | |
|
||
registerReceiver(mUsbReceiver , filter); | ||
} catch (Exception e) { | ||
Log.e(TAG, "Exception OnCreate()"); | ||
} | ||
|
||
mCameraSwitch.setOnClickListener(new View.OnClickListener() { | ||
|
@@ -228,7 +231,6 @@ public void onClick(View v) { | |
public void onClick(View v) { | ||
|
||
getFragmentManager().beginTransaction().remove(Fragment).commit(); | ||
MultiCamera ic_camera = MultiCamera.getInstance(); | ||
v.setVisibility(v.GONE); | ||
mSettings.setVisibility(View.VISIBLE); | ||
|
||
|
@@ -344,7 +346,6 @@ private void closeCamera() { | |
} | ||
} | ||
|
||
|
||
public void GetCameraCnt() { | ||
CameraManager manager = (CameraManager)getSystemService(Context.CAMERA_SERVICE); | ||
|
||
|
@@ -367,15 +368,17 @@ private void Open_Camera() { | |
Log.e(TAG, "fail to find surface for back camera"); | ||
return; | ||
} | ||
if (mCamera == null) { | ||
if (Objects.isNull(mCamera)) | ||
{ | ||
Open_Camera_ById(); | ||
} | ||
if (mCamera_BackView.isAvailable()) { | ||
mCamera.textureListener.onSurfaceTextureAvailable( | ||
mCamera_BackView.getSurfaceTexture(), mCamera_BackView.getWidth(), | ||
mCamera_BackView.getHeight()); | ||
} else { | ||
mCamera_BackView.setSurfaceTextureListener(mCamera.textureListener); | ||
if(mCamera != null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use Objects.isNull |
||
mCamera_BackView.setSurfaceTextureListener(mCamera.textureListener); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,7 @@ | |
import androidx.preference.PreferenceFragment; | ||
|
||
public class SettingsActivity extends AppCompatActivity { | ||
private String TAG = "settings"; | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
@@ -74,4 +73,4 @@ public void onPause() { | |
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String Key) { | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ | |
|
||
import java.util.Optional; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.Objects; | ||
|
||
import static android.hardware.usb.UsbManager.ACTION_USB_DEVICE_ATTACHED; | ||
import static com.intel.multicamera.MultiViewActivity.updateStorageSpace; | ||
|
@@ -99,6 +100,7 @@ protected void onCreate(Bundle savedInstanceState) { | |
mRoundedThumbnailView = findViewById(R.id.rounded_thumbnail_view); | ||
|
||
checkPermissions(); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
OpenCamera(); | ||
try { | ||
final IntentFilter filter = new IntentFilter(); | ||
|
@@ -260,7 +262,6 @@ public void onClick(View v) { | |
mSettingClose.setVisibility(View.VISIBLE); | ||
|
||
bundle = new Bundle(); | ||
MultiCamera ic_camera = MultiCamera.getInstance(); | ||
bundle.putString("Camera_id", CameraIds[0]); | ||
bundle.putInt("root_preferences", R.xml.root_preferences); | ||
bundle.putString("pref_resolution", "pref_resolution"); | ||
|
@@ -355,15 +356,16 @@ private void Open_Camera() { | |
return; | ||
} | ||
|
||
if (mCamera == null) { | ||
if (Objects.isNull(mCamera)) { | ||
Open_Camera_ById(); | ||
} | ||
if (mCamera_BackView.isAvailable()) { | ||
mCamera.textureListener.onSurfaceTextureAvailable( | ||
mCamera_BackView.getSurfaceTexture(), mCamera_BackView.getWidth(), | ||
mCamera_BackView.getHeight()); | ||
} else { | ||
mCamera_BackView.setSurfaceTextureListener(mCamera.textureListener); | ||
if(mCamera != null) | ||
mCamera_BackView.setSurfaceTextureListener(mCamera.textureListener); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,7 @@ public class Utils { | |
public static final long UNKNOWN_SIZE = -3L; | ||
public static final long LOW_STORAGE_THRESHOLD_BYTES = 50000000; | ||
|
||
private static Uri mCurrentPictureUri, mCurrentVideoUri; | ||
private static Uri mCurrentPictureUri; | ||
|
||
/** | ||
* Has to be in sync with the receiving MovieActivity. | ||
|
@@ -126,8 +126,9 @@ public static Uri broadcastNewPicture(Context context, ContentValues values) { | |
} finally { | ||
Log.v(TAG, "Current Picture URI: " + uri); | ||
} | ||
|
||
context.sendBroadcast(new Intent(ACTION_NEW_PICTURE, uri)); | ||
Intent pictureIntent = new Intent(ACTION_NEW_PICTURE, uri); | ||
pictureIntent.setPackage(context.getPackageName()); | ||
context.sendBroadcast(pictureIntent); | ||
return uri; | ||
} | ||
|
||
|
@@ -176,6 +177,7 @@ public static String[] generateFileDetails(int type) { | |
fileDetails[0] = dateFormat.format(date); | ||
fileDetails[1] = fileDetails[0] + ".jpg"; | ||
fileDetails[2] = "image/jpeg"; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
} else if (type == MEDIA_TYPE_VIDEO) { | ||
dateFormat = new SimpleDateFormat(VIDEO_FILE_NAME_FORMAT); | ||
fileDetails[0] = dateFormat.format(date); | ||
|
@@ -394,13 +396,6 @@ public static Optional<Bitmap> generateThumbnail(File path, int boundingWidthPx, | |
|
||
Point dim = resizeToFill(width, height, orientation, boundingWidthPx, boundingHeightPx); | ||
|
||
// If the orientation is not vertical | ||
if (orientation % 180 != 0) { | ||
int dummy = dim.x; | ||
dim.x = dim.y; | ||
dim.y = dummy; | ||
} | ||
|
||
bitmap = loadImageThumbnailFromStream(stream, width, height, (int)(dim.x * 0.7f), | ||
(int)(dim.y * 0.7), 0, MAX_PEEK_BITMAP_PIXELS); | ||
|
||
|
@@ -566,7 +561,6 @@ public static Optional<MediaDetails> getMediaDetails(Context mContext, ContentVa | |
final DateFormat mDateFormatter = DateFormat.getDateTimeInstance(); | ||
|
||
if (info.get(MediaStore.Video.Media.MIME_TYPE).equals("video/mp4") == true) { | ||
File file = new File(info.getAsString(MediaStore.Video.Media.DATA)); | ||
|
||
mediaDetails.addDetail(MediaDetails.INDEX_TITLE, | ||
info.get(MediaStore.Video.Media.TITLE)); | ||
|
@@ -598,7 +592,6 @@ public static Optional<MediaDetails> getMediaDetails(Context mContext, ContentVa | |
mediaDetails.addDetail(MediaDetails.INDEX_DURATION, duration); | ||
|
||
} else if (info.get(MediaStore.Video.Media.MIME_TYPE).equals("image/jpeg") == true) { | ||
File file = new File(info.getAsString(MediaStore.Images.ImageColumns.DATA)); | ||
mediaDetails.addDetail(MediaDetails.INDEX_TITLE, | ||
info.get(MediaStore.Images.ImageColumns.TITLE)); | ||
mediaDetails.addDetail(MediaDetails.INDEX_PATH, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this wont create leak ?