Skip to content

Commit 2536854

Browse files
committed
reduce android debug logs
1 parent 9093a7d commit 2536854

6 files changed

Lines changed: 5 additions & 77 deletions

File tree

android/src/main/java/cn/reactnative/modules/update/BundledResourceCopier.java

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ private static final class ResolvedResourceSource {
3838
}
3939

4040
void copyFromResource(HashMap<String, ArrayList<File>> resToCopy) throws IOException {
41-
if (UpdateContext.DEBUG) {
42-
Log.d(UpdateContext.TAG, "copyFromResource called, resToCopy size: " + resToCopy.size());
43-
}
44-
4541
ArrayList<String> apkPaths = collectApkPaths();
4642
HashMap<String, ZipEntry> availableEntries = new HashMap<String, ZipEntry>();
4743
HashMap<String, SafeZipFile> zipFileMap = new HashMap<String, SafeZipFile>();
@@ -73,10 +69,6 @@ void copyFromResource(HashMap<String, ArrayList<File>> resToCopy) throws IOExcep
7369
new HashMap<String, ArrayList<File>>(resToCopy);
7470

7571
for (String fromPath : new ArrayList<String>(remainingFiles.keySet())) {
76-
if (UpdateContext.DEBUG) {
77-
Log.d(UpdateContext.TAG, "Processing fromPath: " + fromPath);
78-
}
79-
8072
ArrayList<File> targets = remainingFiles.get(fromPath);
8173
if (targets == null || targets.isEmpty()) {
8274
continue;
@@ -92,9 +84,6 @@ void copyFromResource(HashMap<String, ArrayList<File>> resToCopy) throws IOExcep
9284
if (actualEntry != null) {
9385
entry = availableEntries.get(actualEntry);
9486
actualSourcePath = actualEntry;
95-
if (UpdateContext.DEBUG) {
96-
Log.d(UpdateContext.TAG, "Normalized match: " + fromPath + " -> " + actualEntry);
97-
}
9887
}
9988
}
10089

@@ -111,9 +100,6 @@ void copyFromResource(HashMap<String, ArrayList<File>> resToCopy) throws IOExcep
111100

112101
File lastTarget = null;
113102
for (File target : targets) {
114-
if (UpdateContext.DEBUG) {
115-
Log.d(UpdateContext.TAG, "Copying from resource " + actualSourcePath + " to " + target);
116-
}
117103
try {
118104
if (lastTarget != null) {
119105
UpdateFileUtils.copyFile(lastTarget, target);
@@ -146,9 +132,10 @@ void copyFromResource(HashMap<String, ArrayList<File>> resToCopy) throws IOExcep
146132
}
147133

148134
if (!remainingFiles.isEmpty() && UpdateContext.DEBUG) {
149-
for (String fromPath : remainingFiles.keySet()) {
150-
Log.w(UpdateContext.TAG, "Resource not found and no fallback available: " + fromPath);
151-
}
135+
Log.w(
136+
UpdateContext.TAG,
137+
"Skipped " + remainingFiles.size() + " missing bundled resources"
138+
);
152139
}
153140
} finally {
154141
closeZipFiles(zipFileMap);
@@ -244,12 +231,6 @@ private ResolvedResourceSource resolveBundledResource(String resourcePath) {
244231
resources.getValue(resourceId, typedValue, true);
245232
}
246233
} catch (Resources.NotFoundException e) {
247-
if (UpdateContext.DEBUG) {
248-
Log.d(
249-
UpdateContext.TAG,
250-
"Failed to resolve resource value for " + resourcePath + ": " + e.getMessage()
251-
);
252-
}
253234
return null;
254235
}
255236

@@ -262,9 +243,6 @@ private ResolvedResourceSource resolveBundledResource(String resourcePath) {
262243
assetPath = assetPath.substring(1);
263244
}
264245

265-
if (UpdateContext.DEBUG) {
266-
Log.d(UpdateContext.TAG, "Resolved resource path " + resourcePath + " -> " + assetPath);
267-
}
268246
return new ResolvedResourceSource(resourceId, assetPath);
269247
}
270248

@@ -286,9 +264,6 @@ private ArrayList<String> collectApkPaths() {
286264
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && appInfo.splitSourceDirs != null) {
287265
for (String splitPath : appInfo.splitSourceDirs) {
288266
apkPaths.add(splitPath);
289-
if (UpdateContext.DEBUG) {
290-
Log.d(UpdateContext.TAG, "Found split APK: " + splitPath);
291-
}
292267
}
293268
}
294269
} catch (PackageManager.NameNotFoundException e) {

android/src/main/java/cn/reactnative/modules/update/DownloadTask.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ private void downloadFile() throws IOException {
7979
throw new IOException("Failed to replace existing file: " + writePath);
8080
}
8181

82-
if (UpdateContext.DEBUG) {
83-
Log.d(UpdateContext.TAG, "Downloading " + url);
84-
}
85-
8682
try (Response response = HTTP_CLIENT.newCall(request).execute()) {
8783
if (!response.isSuccessful()) {
8884
throw new IOException("Server error: " + response.code() + " " + response.message());
@@ -125,9 +121,6 @@ private void downloadFile() throws IOException {
125121
postProgress(received, contentLength);
126122
}
127123

128-
if (UpdateContext.DEBUG) {
129-
Log.d(UpdateContext.TAG, "Download finished");
130-
}
131124
}
132125

133126
private byte[] readBytes(InputStream input) throws IOException {
@@ -251,9 +244,6 @@ private void doFullPatch() throws IOException {
251244
}
252245
}
253246

254-
if (UpdateContext.DEBUG) {
255-
Log.d(UpdateContext.TAG, "Unzip finished");
256-
}
257247
}
258248

259249
private void doPatchFromApk() throws IOException, JSONException {
@@ -295,21 +285,7 @@ private void doPatchFromApk() throws IOException, JSONException {
295285
originBundleFile.delete();
296286
}
297287

298-
if (UpdateContext.DEBUG) {
299-
Log.d(UpdateContext.TAG, "copyList size: " + copyList.size());
300-
for (String from : copyList.keySet()) {
301-
Log.d(
302-
UpdateContext.TAG,
303-
"copyList entry: " + from + " -> " + copyList.get(from).size() + " targets"
304-
);
305-
}
306-
}
307-
308288
bundledResourceCopier.copyFromResource(copyList);
309-
310-
if (UpdateContext.DEBUG) {
311-
Log.d(UpdateContext.TAG, "Unzip finished");
312-
}
313289
}
314290

315291
private void doPatchFromPpk() throws IOException, JSONException {
@@ -337,15 +313,9 @@ private void doPatchFromPpk() throws IOException, JSONException {
337313
contents.deletes.toArray(new String[0])
338314
);
339315

340-
if (UpdateContext.DEBUG) {
341-
Log.d(UpdateContext.TAG, "Unzip finished");
342-
}
343316
}
344317

345318
private void doCleanUp() {
346-
if (UpdateContext.DEBUG) {
347-
Log.d(UpdateContext.TAG, "Start cleaning up");
348-
}
349319
cleanupOldEntries(
350320
params.unzipDirectory.getAbsolutePath(),
351321
params.hash,

android/src/main/java/cn/reactnative/modules/update/SafeZipFile.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package cn.reactnative.modules.update;
22

3-
import android.util.Log;
4-
53
import java.io.BufferedInputStream;
64
import java.io.BufferedOutputStream;
75
import java.io.File;
@@ -66,10 +64,6 @@ public void unzipToPath(ZipEntry ze, File targetPath) throws IOException {
6664
throw new SecurityException("Illegal name: " + name);
6765
}
6866

69-
if (UpdateContext.DEBUG) {
70-
Log.d(UpdateContext.TAG, "Unzipping " + name);
71-
}
72-
7367
if (ze.isDirectory()) {
7468
target.mkdirs();
7569
return;

android/src/main/java/cn/reactnative/modules/update/UpdateEventEmitter.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package cn.reactnative.modules.update;
22

3-
import android.util.Log;
43
import androidx.annotation.Nullable;
54
import com.facebook.react.bridge.ReactApplicationContext;
65
import com.facebook.react.modules.core.DeviceEventManagerModule;
@@ -26,9 +25,6 @@ private static synchronized ReactApplicationContext getReactContext() {
2625
static void sendEvent(String eventName, WritableMap params) {
2726
ReactApplicationContext reactContext = getReactContext();
2827
if (reactContext == null || !reactContext.hasActiveCatalystInstance()) {
29-
if (UpdateContext.DEBUG) {
30-
Log.d(UpdateContext.TAG, "Skipping event " + eventName + " because React context is unavailable");
31-
}
3228
return;
3329
}
3430

android/src/main/java/cn/reactnative/modules/update/UpdateFileUtils.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package cn.reactnative.modules.update;
22

3-
import android.util.Log;
43
import java.io.File;
54
import java.io.FileInputStream;
65
import java.io.FileOutputStream;
@@ -27,9 +26,6 @@ static void ensureParentDirectory(File file) throws IOException {
2726
}
2827

2928
static void removeDirectory(File file) throws IOException {
30-
if (UpdateContext.DEBUG) {
31-
Log.d(UpdateContext.TAG, "Removing " + file);
32-
}
3329
if (file.isDirectory()) {
3430
File[] files = file.listFiles();
3531
if (files != null) {

android/src/main/java/expo/modules/pushy/ExpoPushyPackage.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
package expo.modules.pushy;
22

33
import android.content.Context;
4-
import android.util.Log;
54
import androidx.annotation.Nullable;
65
import java.util.ArrayList;
7-
import java.util.HashMap;
86
import java.util.List;
9-
import java.util.Map;
107
import cn.reactnative.modules.update.UpdateContext;
118
import expo.modules.core.interfaces.Package;
129
import expo.modules.core.interfaces.ReactNativeHostHandler;
@@ -24,4 +21,4 @@ public String getJSBundleFile(boolean useDeveloperSupport) {
2421
});
2522
return handlers;
2623
}
27-
}
24+
}

0 commit comments

Comments
 (0)