Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/scripts/generate-quality-report.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ def main() -> None:
cross_project_rules = {
"DE_MIGHT_IGNORE",
"BC_IMPOSSIBLE_CAST",
"DM_DEFAULT_ENCODING"
}
cross_project_violations: List[Tuple[str, Finding]] = []
for label, report in spotbugs_reports.items():
Expand Down
3 changes: 3 additions & 0 deletions CodenameOne/src/com/codename1/io/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -2617,6 +2617,9 @@ public static Date toDateValue(Object o) {
public static String xorDecode(String s) {
try {
byte[] dat = Base64.decode(s.getBytes("UTF-8"));
if (dat == null) {
return "";
}
for (int iter = 0; iter < dat.length; iter++) {
dat[iter] = (byte) (dat[iter] ^ (iter % 254 + 1));
}
Expand Down
66 changes: 33 additions & 33 deletions CodenameOne/src/com/codename1/ui/Image.java
Original file line number Diff line number Diff line change
Expand Up @@ -426,25 +426,25 @@ public static Image createImage(byte[] bytes, int offset, int len) {
/// SuccessCallback callback = (String capturedPhoto) -> {
/// String rotatedPhoto = FileSystemStorage.getInstance().getAppHomePath() + "rotatedPhoto.jpg";
/// if (capturedPhoto != null) {
/// try {
/// // note: we set a maxSize to perform a faster rotation
/// int maxSize = CN.convertToPixels(50);
/// Image img = Image.exifRotation(capturedPhoto, rotatedPhoto, maxSize);
/// imageLbl.setIcon(img);
/// hi.revalidate();
/// } catch (IOException ex) {
/// Log.e(ex);
/// }
/// try {
/// // note: we set a maxSize to perform a faster rotation
/// int maxSize = CN.convertToPixels(50);
/// Image img = Image.exifRotation(capturedPhoto, rotatedPhoto, maxSize);
/// imageLbl.setIcon(img);
/// hi.revalidate();
/// } catch (IOException ex) {
/// Log.e(ex);
/// }
/// };
/// };
/// cameraBtn.addActionListener(a -> Capture.capturePhoto(l -> {
/// if (l != null && l.getSource() != null) {
/// callback.onSucess((String) l.getSource());
/// callback.onSucess((String) l.getSource());
/// }
/// }));
/// galleryBtn.addActionListener(a -> CN.openGallery(l -> {
/// if (l != null && l.getSource() != null) {
/// callback.onSucess((String) l.getSource());
/// callback.onSucess((String) l.getSource());
/// }
/// }, CN.GALLERY_IMAGE));
/// ```
Expand Down Expand Up @@ -492,25 +492,25 @@ public static Image exifRotation(String capturedImage) throws IOException {
/// SuccessCallback callback = (String capturedPhoto) -> {
/// String rotatedPhoto = FileSystemStorage.getInstance().getAppHomePath() + "rotatedPhoto.jpg";
/// if (capturedPhoto != null) {
/// try {
/// // note: we set a maxSize to perform a faster rotation
/// int maxSize = CN.convertToPixels(50);
/// Image img = Image.exifRotation(capturedPhoto, rotatedPhoto, maxSize);
/// imageLbl.setIcon(img);
/// hi.revalidate();
/// } catch (IOException ex) {
/// Log.e(ex);
/// }
/// try {
/// // note: we set a maxSize to perform a faster rotation
/// int maxSize = CN.convertToPixels(50);
/// Image img = Image.exifRotation(capturedPhoto, rotatedPhoto, maxSize);
/// imageLbl.setIcon(img);
/// hi.revalidate();
/// } catch (IOException ex) {
/// Log.e(ex);
/// }
/// };
/// };
/// cameraBtn.addActionListener(a -> Capture.capturePhoto(l -> {
/// if (l != null && l.getSource() != null) {
/// callback.onSucess((String) l.getSource());
/// callback.onSucess((String) l.getSource());
/// }
/// }));
/// galleryBtn.addActionListener(a -> CN.openGallery(l -> {
/// if (l != null && l.getSource() != null) {
/// callback.onSucess((String) l.getSource());
/// callback.onSucess((String) l.getSource());
/// }
/// }, CN.GALLERY_IMAGE));
/// ```
Expand Down Expand Up @@ -567,25 +567,25 @@ public static Image exifRotation(String capturedImage, String rotatedImage) thro
/// SuccessCallback callback = (String capturedPhoto) -> {
/// String rotatedPhoto = FileSystemStorage.getInstance().getAppHomePath() + "rotatedPhoto.jpg";
/// if (capturedPhoto != null) {
/// try {
/// // note: we set a maxSize to perform a faster rotation
/// int maxSize = CN.convertToPixels(50);
/// Image img = Image.exifRotation(capturedPhoto, rotatedPhoto, maxSize);
/// imageLbl.setIcon(img);
/// hi.revalidate();
/// } catch (IOException ex) {
/// Log.e(ex);
/// }
/// try {
/// // note: we set a maxSize to perform a faster rotation
/// int maxSize = CN.convertToPixels(50);
/// Image img = Image.exifRotation(capturedPhoto, rotatedPhoto, maxSize);
/// imageLbl.setIcon(img);
/// hi.revalidate();
/// } catch (IOException ex) {
/// Log.e(ex);
/// }
/// };
/// };
/// cameraBtn.addActionListener(a -> Capture.capturePhoto(l -> {
/// if (l != null && l.getSource() != null) {
/// callback.onSucess((String) l.getSource());
/// callback.onSucess((String) l.getSource());
/// }
/// }));
/// galleryBtn.addActionListener(a -> CN.openGallery(l -> {
/// if (l != null && l.getSource() != null) {
/// callback.onSucess((String) l.getSource());
/// callback.onSucess((String) l.getSource());
/// }
/// }, CN.GALLERY_IMAGE));
/// ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import java.lang.ref.SoftReference;
import java.lang.reflect.Method;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.Vector;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
Expand Down Expand Up @@ -563,11 +564,11 @@ private static Map<String,String> splitQuery(String urlencodeQueryString) {
public String getStackTrace(Thread parentThread, Throwable t) {
System.out.println("CN1SS:ERR:Invoking getStackTrace in AndroidImplementation");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintWriter w = new PrintWriter(bos);
PrintWriter w = new PrintWriter(new OutputStreamWriter(bos, StandardCharsets.UTF_8));
t.printStackTrace(w);
w.close();
System.out.println("CN1SS:ERR:AndroidImplementation getStackTrace completed");
return bos.toString();
return new String(bos.toByteArray(), StandardCharsets.UTF_8);
}

public static void initPushContent(String message, String image, String messageType, String category, Context context) {
Expand Down Expand Up @@ -6538,7 +6539,7 @@ private String[] getStorageDirectories() {
BufferedReader bufReader = null;

try {
bufReader = new BufferedReader(new FileReader("/proc/mounts"));
bufReader = new BufferedReader(new InputStreamReader(new FileInputStream("/proc/mounts"), StandardCharsets.UTF_8));
ArrayList<String> list = new ArrayList<String>();
String line;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -32,7 +33,7 @@ public class FridaDetectionUtil {
public static boolean isFridaProcessRunning() {
try {
Process process = Runtime.getRuntime().exec("ps");
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8));
String line;
while ((line = reader.readLine()) != null) {
for (String processName : FRIDA_PROCESSES) {
Expand All @@ -54,7 +55,7 @@ public static boolean isFridaLibraryLoaded() {
BufferedReader reader = null;
try {
FileInputStream fis = new FileInputStream(new File("/proc/self/maps"));
reader = new BufferedReader(new InputStreamReader(fis));
reader = new BufferedReader(new InputStreamReader(fis, StandardCharsets.UTF_8));
String line;
while ((line = reader.readLine()) != null) {
for (String lib : FRIDA_LIBRARIES) {
Expand Down
8 changes: 5 additions & 3 deletions Ports/Android/src/com/codename1/impl/android/util/Base64.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
* @version 1.3
*/

import java.nio.charset.StandardCharsets;

/**
* Base64 converter class. This code is not a complete MIME encoder;
* it simply converts binary data to base64 data and back.
Expand Down Expand Up @@ -283,7 +285,7 @@ public static String encode(byte[] source, int off, int len, byte[] alphabet,
outLen -= 1;
}

return new String(outBuff, 0, outLen);
return new String(outBuff, 0, outLen, StandardCharsets.UTF_8);
}

/**
Expand Down Expand Up @@ -416,7 +418,7 @@ private static int decode4to3(byte[] source, int srcOffset,
* @since 1.4
*/
public static byte[] decode(String s) throws Base64DecoderException {
byte[] bytes = s.getBytes();
byte[] bytes = s.getBytes(StandardCharsets.UTF_8);
return decode(bytes, 0, bytes.length);
}

Expand All @@ -428,7 +430,7 @@ public static byte[] decode(String s) throws Base64DecoderException {
* @return the decoded data
*/
public static byte[] decodeWebSafe(String s) throws Base64DecoderException {
byte[] bytes = s.getBytes();
byte[] bytes = s.getBytes(StandardCharsets.UTF_8);
return decodeWebSafe(bytes, 0, bytes.length);
}

Expand Down
Loading
Loading