diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e304db0c01..48864170d1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -42,6 +42,13 @@ + + + + + + + @@ -67,8 +74,7 @@ android:name=".ui.activities.MainActivity" android:theme="@style/appCompatBlack" android:configChanges="uiMode" - android:windowSoftInputMode="adjustPan" - > + android:windowSoftInputMode="adjustPan"> @@ -180,6 +186,7 @@ + diff --git a/app/src/main/java/com/amaze/filemanager/filesystem/files/FileUtils.java b/app/src/main/java/com/amaze/filemanager/filesystem/files/FileUtils.java index 1363b6a2f2..5a76cdfd03 100644 --- a/app/src/main/java/com/amaze/filemanager/filesystem/files/FileUtils.java +++ b/app/src/main/java/com/amaze/filemanager/filesystem/files/FileUtils.java @@ -102,7 +102,7 @@ public class FileUtils { private static final String[] COMPRESSED_FILE_EXTENSIONS = new String[] { - "zip", "rar", "cab", "bz2", "ace", "bz", "gz", "7z", "jar", "apk", "xz", "lzma", "Z" + "zip", "cab", "bz2", "ace", "bz", "gz", "7z", "jar", "apk", "xz", "lzma", "Z", "rar" }; public static final String FILE_PROVIDER_PREFIX = "storage_root"; diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java index 2e835df77c..f7e292b67c 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java @@ -884,10 +884,8 @@ public synchronized ArrayList getStorageDirectoriesL File usb = getUsbDrive(); if (usb != null && !rv.contains(usb.getPath())) rv.add(usb.getPath()); - if (SDK_INT >= KITKAT) { - if (SingletonUsbOtg.getInstance().isDeviceConnected()) { - rv.add(OTGUtil.PREFIX_OTG + "/"); - } + if (SDK_INT >= KITKAT && SingletonUsbOtg.INSTANCE.isDeviceConnected()) { + rv.add(OTGUtil.PREFIX_OTG + "/"); } // Assign a label and icon to each directory @@ -1383,28 +1381,27 @@ private void updateUsbInformation() { List connectedDevices = OTGUtil.getMassStorageDevicesConnected(this); if (!connectedDevices.isEmpty()) { - if (SingletonUsbOtg.getInstance().getUsbOtgRoot() != null - && OTGUtil.isUsbUriAccessible(this)) { + if (SingletonUsbOtg.INSTANCE.getUsbOtgRoot() != null && OTGUtil.isUsbUriAccessible(this)) { for (UsbOtgRepresentation device : connectedDevices) { - if (SingletonUsbOtg.getInstance().checkIfRootIsFromDevice(device)) { + if (SingletonUsbOtg.INSTANCE.checkIfRootIsFromDevice(device)) { isInformationUpdated = true; break; } } if (!isInformationUpdated) { - SingletonUsbOtg.getInstance().resetUsbOtgRoot(); + SingletonUsbOtg.INSTANCE.resetUsbOtgRoot(); } } if (!isInformationUpdated) { - SingletonUsbOtg.getInstance().setConnectedDevice(connectedDevices.get(0)); + SingletonUsbOtg.INSTANCE.setConnectedDevice(connectedDevices.get(0)); isInformationUpdated = true; } } if (!isInformationUpdated) { - SingletonUsbOtg.getInstance().resetUsbOtgRoot(); + SingletonUsbOtg.INSTANCE.resetUsbOtgRoot(); drawer.refreshDrawer(); } @@ -1424,12 +1421,12 @@ public void onReceive(Context context, Intent intent) { List connectedDevices = OTGUtil.getMassStorageDevicesConnected(MainActivity.this); if (!connectedDevices.isEmpty()) { - SingletonUsbOtg.getInstance().resetUsbOtgRoot(); - SingletonUsbOtg.getInstance().setConnectedDevice(connectedDevices.get(0)); + SingletonUsbOtg.INSTANCE.resetUsbOtgRoot(); + SingletonUsbOtg.INSTANCE.setConnectedDevice(connectedDevices.get(0)); drawer.refreshDrawer(); } } else if (intent.getAction().equals(UsbManager.ACTION_USB_DEVICE_DETACHED)) { - SingletonUsbOtg.getInstance().resetUsbOtgRoot(); + SingletonUsbOtg.INSTANCE.resetUsbOtgRoot(); drawer.refreshDrawer(); goToMain(null); } @@ -1695,7 +1692,7 @@ protected void onActivityResult(int requestCode, int responseCode, Intent intent if (responseCode == Activity.RESULT_OK && intent.getData() != null) { // otg access Uri usbOtgRoot = intent.getData(); - SingletonUsbOtg.getInstance().setUsbOtgRoot(usbOtgRoot); + SingletonUsbOtg.INSTANCE.setUsbOtgRoot(usbOtgRoot); mainFragment.loadlist(OTGUtil.PREFIX_OTG, false, OpenMode.OTG, true); drawer.closeIfNotLocked(); if (drawer.isLocked()) drawer.onDrawerClosed(); @@ -2048,7 +2045,7 @@ public void onNewIntent(Intent i) { if (SDK_INT >= KITKAT) { if (intent.getAction().equals(UsbManager.ACTION_USB_DEVICE_DETACHED)) { - SingletonUsbOtg.getInstance().resetUsbOtgRoot(); + SingletonUsbOtg.INSTANCE.resetUsbOtgRoot(); drawer.refreshDrawer(); } } diff --git a/app/src/main/java/com/amaze/filemanager/ui/icons/MimeTypes.java b/app/src/main/java/com/amaze/filemanager/ui/icons/MimeTypes.java index 1f203d3c37..06d6e19323 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/icons/MimeTypes.java +++ b/app/src/main/java/com/amaze/filemanager/ui/icons/MimeTypes.java @@ -80,8 +80,10 @@ public final class MimeTypes { MIME_TYPES.put("ksh", "text/plain"); MIME_TYPES.put("sh", "application/x-sh"); - MIME_TYPES.put("db", "application/octet-stream"); - MIME_TYPES.put("db3", "application/octet-stream"); + MIME_TYPES.put("db", "application/vnd.sqlite3"); + MIME_TYPES.put("db3", "application/vnd.sqlite3"); + MIME_TYPES.put("sqlite", "application/vnd.sqlite3"); + MIME_TYPES.put("sqlite3", "application/vnd.sqlite3"); MIME_TYPES.put("otf", "application/x-font-otf"); MIME_TYPES.put("ttf", "application/x-font-ttf"); diff --git a/app/src/main/java/com/amaze/filemanager/ui/views/drawer/Drawer.java b/app/src/main/java/com/amaze/filemanager/ui/views/drawer/Drawer.java index 358bfeb869..7a552e79bd 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/views/drawer/Drawer.java +++ b/app/src/main/java/com/amaze/filemanager/ui/views/drawer/Drawer.java @@ -828,7 +828,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && (meta.path.contains(OTGUtil.PREFIX_OTG) || meta.path.startsWith(OTGUtil.PREFIX_MEDIA_REMOVABLE)) - && SingletonUsbOtg.getInstance().getUsbOtgRoot() == null) { + && SingletonUsbOtg.INSTANCE.getUsbOtgRoot() == null) { MaterialDialog dialog = GeneralDialogCreation.showOtgSafExplanationDialog(mainActivity); dialog .getActionButton(DialogAction.POSITIVE) diff --git a/app/src/main/java/com/amaze/filemanager/utils/OTGUtil.kt b/app/src/main/java/com/amaze/filemanager/utils/OTGUtil.kt index cad7ae00d1..dc88fb9092 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/OTGUtil.kt +++ b/app/src/main/java/com/amaze/filemanager/utils/OTGUtil.kt @@ -93,7 +93,7 @@ object OTGUtil { fileFound: OnFileFound, ) { val rootUriString = - SingletonUsbOtg.getInstance().usbOtgRoot + SingletonUsbOtg.getUsbOtgRoot() ?: throw NullPointerException("USB OTG root not set!") return getDocumentFiles(rootUriString, path, context, OpenMode.OTG, fileFound) } @@ -163,7 +163,7 @@ object OTGUtil { createRecursive: Boolean, ): DocumentFile? { val rootUriString = - SingletonUsbOtg.getInstance().usbOtgRoot + SingletonUsbOtg.getUsbOtgRoot() ?: throw NullPointerException("USB OTG root not set!") return getDocumentFile(path, rootUriString, context, OpenMode.OTG, createRecursive) @@ -208,7 +208,7 @@ object OTGUtil { @RequiresApi(api = KITKAT) @JvmStatic fun isUsbUriAccessible(context: Context?): Boolean { - val rootUriString = SingletonUsbOtg.getInstance().usbOtgRoot + val rootUriString = SingletonUsbOtg.getUsbOtgRoot() return DocumentsContract.isDocumentUri(context, rootUriString) } diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/usb/SingletonUsbOtgTest.java b/app/src/test/java/com/amaze/filemanager/filesystem/usb/SingletonUsbOtgTest.java index 038b31b035..b73b1e6313 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/usb/SingletonUsbOtgTest.java +++ b/app/src/test/java/com/amaze/filemanager/filesystem/usb/SingletonUsbOtgTest.java @@ -58,11 +58,11 @@ public void usbConnectionTest() { Uri rootBefore = Uri.parse("ssh://testuser:testpassword@127.0.0.1:22222"); - SingletonUsbOtg.getInstance().setUsbOtgRoot(rootBefore); + SingletonUsbOtg.INSTANCE.setUsbOtgRoot(rootBefore); controller.pause().resume().get(); - Uri rootAfter = SingletonUsbOtg.getInstance().getUsbOtgRoot(); + Uri rootAfter = SingletonUsbOtg.INSTANCE.getUsbOtgRoot(); assertEquals( "Uris are different: (before:) " + rootBefore + " (after:) " + rootAfter, diff --git a/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/cloud/CloudStreamServer.java b/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/cloud/CloudStreamServer.java index b13b84958b..ffaed10e0a 100644 --- a/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/cloud/CloudStreamServer.java +++ b/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/cloud/CloudStreamServer.java @@ -91,6 +91,7 @@ * * See the end of the source file for distribution license (Modified BSD licence) */ +@SuppressWarnings("PMD") public abstract class CloudStreamServer { private static final Logger LOG = LoggerFactory.getLogger(CloudStreamServer.class); diff --git a/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/smbstreamer/StreamServer.java b/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/smbstreamer/StreamServer.java index 83242cacb8..43e10e1857 100644 --- a/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/smbstreamer/StreamServer.java +++ b/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/smbstreamer/StreamServer.java @@ -91,6 +91,7 @@ * * See the end of the source file for distribution license (Modified BSD licence) */ +@SuppressWarnings("PMD") public abstract class StreamServer { private static final Logger LOG = LoggerFactory.getLogger(StreamServer.class); diff --git a/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/usb/SingletonUsbOtg.java b/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/usb/SingletonUsbOtg.java deleted file mode 100644 index 50b066785e..0000000000 --- a/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/usb/SingletonUsbOtg.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2014-2024 Arpit Khurana , Vishal Nehra , - * Emmanuel Messulam, Raymond Lai and Contributors. - * - * This file is part of Amaze File Manager. - * - * Amaze File Manager is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.amaze.filemanager.fileoperations.filesystem.usb; - -import android.net.Uri; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -public class SingletonUsbOtg { - private static SingletonUsbOtg instance = null; - - public static SingletonUsbOtg getInstance() { - if (instance == null) instance = new SingletonUsbOtg(); - return instance; - } - - private UsbOtgRepresentation connectedDevice = null; - private @Nullable Uri usbOtgRoot; - - private SingletonUsbOtg() {} - - public void setConnectedDevice(UsbOtgRepresentation connectedDevice) { - this.connectedDevice = connectedDevice; - } - - public boolean isDeviceConnected() { - return connectedDevice != null; - } - - public void setUsbOtgRoot(@Nullable Uri root) { - if (connectedDevice == null) throw new IllegalStateException("No device connected!"); - usbOtgRoot = root; - } - - public void resetUsbOtgRoot() { - connectedDevice = null; - usbOtgRoot = null; - } - - public @Nullable Uri getUsbOtgRoot() { - return usbOtgRoot; - } - - public boolean checkIfRootIsFromDevice(@NonNull UsbOtgRepresentation device) { - return usbOtgRoot != null && connectedDevice.hashCode() == device.hashCode(); - } -} diff --git a/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/usb/SingletonUsbOtg.kt b/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/usb/SingletonUsbOtg.kt new file mode 100644 index 0000000000..f6a7a40b58 --- /dev/null +++ b/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/usb/SingletonUsbOtg.kt @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2014-2024 Arpit Khurana , Vishal Nehra , + * Emmanuel Messulam, Raymond Lai and Contributors. + * + * This file is part of Amaze File Manager. + * + * Amaze File Manager is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.amaze.filemanager.fileoperations.filesystem.usb + +import android.net.Uri + +/** + * USB OTG device representation. + */ +object SingletonUsbOtg { + var connectedDevice: UsbOtgRepresentation? = null + var _usbOtgRoot: Uri? = null + + val isDeviceConnected: Boolean + get() = connectedDevice != null + + /** + * Get the root of the connected USB OTG device. + * + * @return the root URI of the connected USB OTG device, or null if no device is connected. + */ + fun getUsbOtgRoot(): Uri? { + return _usbOtgRoot + } + + /** + * Set the root of the connected USB OTG device. Will throw exception if no device is connected. + * + * @param root the root URI of the connected USB OTG device. + */ + fun setUsbOtgRoot(root: Uri?) { + checkNotNull(connectedDevice) { "No device connected!" } + _usbOtgRoot = root + } + + /** + * Clear the reference to connected device and root. + */ + fun resetUsbOtgRoot() { + connectedDevice = null + _usbOtgRoot = null + } + + /** + * Check if the root is from the given device. + * + * Used by [MainActivity.updateUsbInformation]. + */ + fun checkIfRootIsFromDevice(device: UsbOtgRepresentation): Boolean { + return _usbOtgRoot != null && connectedDevice.hashCode() == device.hashCode() + } +} diff --git a/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/usb/UsbOtgRepresentation.java b/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/usb/UsbOtgRepresentation.java deleted file mode 100644 index 6c27ab84e2..0000000000 --- a/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/usb/UsbOtgRepresentation.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2014-2024 Arpit Khurana , Vishal Nehra , - * Emmanuel Messulam, Raymond Lai and Contributors. - * - * This file is part of Amaze File Manager. - * - * Amaze File Manager is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.amaze.filemanager.fileoperations.filesystem.usb; - -import androidx.annotation.Nullable; - -/** - * This class replesents a usb device. - * - * @see UsbOtgRepresentation#equals(Object) - */ -public class UsbOtgRepresentation { - - public final int productID, vendorID; - public final @Nullable String serialNumber; - - public UsbOtgRepresentation(int productID, int vendorID, @Nullable String serialNumber) { - this.productID = productID; - this.vendorID = vendorID; - this.serialNumber = serialNumber; - } - - /** - * This does not ensure a device is equal to another! This tests parameters to know to a certain - * degree of certanty that a device is "similar enough" to another one to be the same one. - */ - @Override - public boolean equals(Object obj) { - if (!(obj instanceof UsbOtgRepresentation)) return false; - - UsbOtgRepresentation other = (UsbOtgRepresentation) obj; - return productID == other.productID - && vendorID == other.vendorID - && ((serialNumber == null && other.serialNumber == null) - || serialNumber.equals(other.serialNumber)); - } - - @Override - public int hashCode() { - int result = productID; - result = 37 * result + vendorID; - result = 37 * result + (serialNumber != null ? serialNumber.hashCode() : 0); - return result; - } -} diff --git a/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/usb/UsbOtgRepresentation.kt b/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/usb/UsbOtgRepresentation.kt new file mode 100644 index 0000000000..92070758c8 --- /dev/null +++ b/file_operations/src/main/java/com/amaze/filemanager/fileoperations/filesystem/usb/UsbOtgRepresentation.kt @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2014-2024 Arpit Khurana , Vishal Nehra , + * Emmanuel Messulam, Raymond Lai and Contributors. + * + * This file is part of Amaze File Manager. + * + * Amaze File Manager is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.amaze.filemanager.fileoperations.filesystem.usb + +/** + * This class replesents a usb device. + * + * @see UsbOtgRepresentation.equals + */ +data class UsbOtgRepresentation(val productID: Int, val vendorID: Int, val serialNumber: String?) { + /** + * This does not ensure a device is equal to another! This tests parameters to know to a certain + * degree of certainty that a device is "similar enough" to another one to be the same one. + */ + override fun equals(obj: Any?): Boolean { + if (obj !is UsbOtgRepresentation) return false + + return productID == obj.productID && + vendorID == obj.vendorID && + ( + (serialNumber == null && obj.serialNumber == null) || + serialNumber == obj.serialNumber + ) + } + + override fun hashCode(): Int { + var result = productID + result = 37 * result + vendorID + result = 37 * result + (serialNumber?.hashCode() ?: 0) + return result + } +} diff --git a/file_operations/src/test/java/com/amaze/filemanager/fileoperations/filesystem/cloud/CloudStreamSourceTest.java b/file_operations/src/test/java/com/amaze/filemanager/fileoperations/filesystem/cloud/CloudStreamSourceTest.java index c6d3bcee74..e56195c17c 100644 --- a/file_operations/src/test/java/com/amaze/filemanager/fileoperations/filesystem/cloud/CloudStreamSourceTest.java +++ b/file_operations/src/test/java/com/amaze/filemanager/fileoperations/filesystem/cloud/CloudStreamSourceTest.java @@ -115,11 +115,11 @@ public void openNoFileException() throws IOException { @Test public void read() throws IOException { byte[] buff = new byte[10]; - int n = cs.read(buff); + int bytesRead = cs.read(buff); byte[] temp = Arrays.copyOfRange(text, 0, buff.length); assertArrayEquals(temp, buff); - assertEquals(buff.length, n); + assertEquals(buff.length, bytesRead); } /** @@ -129,12 +129,12 @@ public void read() throws IOException { @Test public void readExceed() throws IOException { byte[] buff = new byte[100]; - int n = cs.read(buff); + int bytesRead = cs.read(buff); // erase dummy values in the end of buffer - byte[] buffer = Arrays.copyOfRange(buff, 0, n); + byte[] buffer = Arrays.copyOfRange(buff, 0, bytesRead); assertArrayEquals(text, buffer); - assertEquals(len, n); + assertEquals(len, bytesRead); } /** @@ -145,7 +145,7 @@ public void readExceed() throws IOException { public void readClosedException() throws IOException { cs.close(); byte[] buff = new byte[(int) len]; - int n = cs.read(buff); + cs.read(buff); } /** @@ -158,12 +158,12 @@ public void readStartEnd() throws IOException { int start = 5; int end = 10; - int n = cs.read(buff, start, end); + int bytesRead = cs.read(buff, start, end); byte[] file = Arrays.copyOfRange(text, 0, end - start); byte[] buffer = Arrays.copyOfRange(buff, start, end); assertArrayEquals(file, buffer); - assertEquals(end, n); + assertEquals(end, bytesRead); } /** @@ -191,7 +191,7 @@ public void readStartEndClosedException() throws IOException { int start = 5; int end = 10; - int n = cs.read(buff, start, end); + cs.read(buff, start, end); } /** @@ -206,9 +206,9 @@ public void moveTo() throws IOException { cs.moveTo(readPosition); cs.open(); - int n = cs.read(buff); + int bytesRead = cs.read(buff); assertEquals(text[readPosition], buff[0]); - assertEquals(buff.length, n); + assertEquals(buff.length, bytesRead); } /** @@ -229,14 +229,14 @@ public void moveToException() throws IllegalArgumentException, IOException { public void close() { cs.close(); - int n = -1; + int bytesRead = -1; try { byte[] buff = new byte[1]; - n = cs.read(buff); + bytesRead = cs.read(buff); } catch (IOException ignored) { } - assertEquals(-1, n); + assertEquals(-1, bytesRead); } /** Purpose: Get length of the text from a file Input: no Expected: return len */ diff --git a/file_operations/src/test/java/com/amaze/filemanager/fileoperations/filesystem/smbstreamer/StreamSourceTest.java b/file_operations/src/test/java/com/amaze/filemanager/fileoperations/filesystem/smbstreamer/StreamSourceTest.java index 9415dcf1f6..33af95ed14 100644 --- a/file_operations/src/test/java/com/amaze/filemanager/fileoperations/filesystem/smbstreamer/StreamSourceTest.java +++ b/file_operations/src/test/java/com/amaze/filemanager/fileoperations/filesystem/smbstreamer/StreamSourceTest.java @@ -110,11 +110,11 @@ public void openExisting() throws IOException { public void read() throws IOException { ss.open(); byte[] buff = new byte[10]; - int n = ss.read(buff); + int bytesRead = ss.read(buff); byte[] temp = Arrays.copyOfRange(text, 0, buff.length); assertArrayEquals(temp, buff); - assertEquals(buff.length, n); + assertEquals(buff.length, bytesRead); } /** @@ -125,12 +125,12 @@ public void read() throws IOException { public void readExceed() throws IOException { ss.open(); byte[] buff = new byte[100]; - int n = ss.read(buff); + int bytesRead = ss.read(buff); // erase dummy values in the end of buffer - byte[] buffer = Arrays.copyOfRange(buff, 0, n); + byte[] buffer = Arrays.copyOfRange(buff, 0, bytesRead); assertArrayEquals(text, buffer); - assertEquals(text.length, n); + assertEquals(text.length, bytesRead); } /** @@ -142,7 +142,7 @@ public void readClosedException() throws IOException { ss.open(); ss.close(); byte[] buff = new byte[text.length]; - int n = ss.read(buff); + ss.read(buff); } /** @@ -156,12 +156,12 @@ public void readStartEnd() throws IOException { int start = 5; int end = 10; - int n = ss.read(buff, start, end); + int bytesRead = ss.read(buff, start, end); byte[] file = Arrays.copyOfRange(text, 0, end - start); byte[] buffer = Arrays.copyOfRange(buff, start, end); assertArrayEquals(file, buffer); - assertEquals(end, n); + assertEquals(end, bytesRead); } /** @@ -192,7 +192,7 @@ public void readStartEndClosedException() throws IOException { int start = 5; int end = 10; - int n = ss.read(buff, start, end); + ss.read(buff, start, end); } /** @@ -207,9 +207,9 @@ public void moveTo() throws IOException { ss.moveTo(readPosition); ss.open(); - int n = ss.read(buff); + int bytesRead = ss.read(buff); assertEquals(text[readPosition], buff[0]); - assertEquals(buff.length, n); + assertEquals(buff.length, bytesRead); } /** @@ -231,14 +231,14 @@ public void close() throws IOException { ss.open(); ss.close(); - int n = -1; + int bytesRead = -1; try { byte[] buff = new byte[1]; - n = ss.read(buff); + bytesRead = ss.read(buff); } catch (IOException ignored) { } - assertEquals(-1, n); + assertEquals(-1, bytesRead); } /** Purpose: Get MIME type Input: no Expected: return "txt" */ diff --git a/testShared/src/test/java/com/amaze/filemanager/shadows/jcifs/smb/ShadowSmbFile.java b/testShared/src/test/java/com/amaze/filemanager/shadows/jcifs/smb/ShadowSmbFile.java index d4b6568e7e..82e48931aa 100644 --- a/testShared/src/test/java/com/amaze/filemanager/shadows/jcifs/smb/ShadowSmbFile.java +++ b/testShared/src/test/java/com/amaze/filemanager/shadows/jcifs/smb/ShadowSmbFile.java @@ -39,6 +39,7 @@ public class ShadowSmbFile { private File file = null; @Implementation + @SuppressWarnings("PMD") public void __constructor__(URL url, NtlmPasswordAuthentication auth) { // intentionally empty }