From 0cd895282436a9291600890007ca866b672d84b4 Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 18 Sep 2024 11:15:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=80=9A=E8=BF=87base64?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E4=BC=A0=E9=80=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xypower/mpapp/BridgeProvider.java | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/xypower/mpapp/BridgeProvider.java b/app/src/main/java/com/xypower/mpapp/BridgeProvider.java index eaf54759..332c58dc 100644 --- a/app/src/main/java/com/xypower/mpapp/BridgeProvider.java +++ b/app/src/main/java/com/xypower/mpapp/BridgeProvider.java @@ -230,6 +230,23 @@ public class BridgeProvider extends ContentProvider { return res ? 1 : 0; } + private String stringFromBase64(String decoded) { + if (TextUtils.isEmpty(decoded)) { + return null; + } + + byte[] bytes = Base64.decode(decoded, Base64.DEFAULT); + + String str = null; + try { + str = new String(bytes, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } + + return str; + } + private int takePhoto(Uri uri, ContentValues values) { String path = values.containsKey("path") ? values.getAsString("path") : null; int channel = values.containsKey("channel") ? values.getAsInteger("channel").intValue() : 1; @@ -238,10 +255,10 @@ public class BridgeProvider extends ContentProvider { int width = values.containsKey("width") ? values.getAsInteger("width").intValue() : 0; int height = values.containsKey("height") ? values.getAsInteger("height").intValue() : 0; - String leftTopOsd = values.containsKey("leftTopOsd") ? values.getAsString("leftTopOsd") : null; - String rightTopOsd = values.containsKey("rightTopOsd") ? values.getAsString("rightTopOsd") : null; - String rightBottomOsd = values.containsKey("rightBottomOsd") ? values.getAsString("rightBottomOsd") : null; - String leftBottomOsd = values.containsKey("leftBottomOsd") ? values.getAsString("leftBottomOsd") : null; + String leftTopOsd = stringFromBase64(values.containsKey("leftTopOsd") ? values.getAsString("leftTopOsd") : null); + String rightTopOsd = stringFromBase64(values.containsKey("rightTopOsd") ? values.getAsString("rightTopOsd") : null); + String rightBottomOsd = stringFromBase64(values.containsKey("rightBottomOsd") ? values.getAsString("rightBottomOsd") : null); + String leftBottomOsd = stringFromBase64(values.containsKey("leftBottomOsd") ? values.getAsString("leftBottomOsd") : null); String appPath = MicroPhotoContext.buildMpAppDir(getContext()); File configFile = new File(appPath); @@ -315,10 +332,10 @@ public class BridgeProvider extends ContentProvider { long videoId = System.currentTimeMillis() / 1000; - String leftTopOsd = values.containsKey("leftTopOsd") ? values.getAsString("leftTopOsd") : null; - String rightTopOsd = values.containsKey("rightTopOsd") ? values.getAsString("rightTopOsd") : null; - String rightBottomOsd = values.containsKey("rightBottomOsd") ? values.getAsString("rightBottomOsd") : null; - String leftBottomOsd = values.containsKey("leftBottomOsd") ? values.getAsString("leftBottomOsd") : null; + String leftTopOsd = stringFromBase64(values.containsKey("leftTopOsd") ? values.getAsString("leftTopOsd") : null); + String rightTopOsd = stringFromBase64(values.containsKey("rightTopOsd") ? values.getAsString("rightTopOsd") : null); + String rightBottomOsd = stringFromBase64(values.containsKey("rightBottomOsd") ? values.getAsString("rightBottomOsd") : null); + String leftBottomOsd = stringFromBase64(values.containsKey("leftBottomOsd") ? values.getAsString("leftBottomOsd") : null); if (cameraId == -1) { cameraId = channel - 1;