reduce logging verbosity of file provider

This commit is contained in:
Philipp Crocoll
2025-04-01 15:36:39 +02:00
parent 0567bfe645
commit e76f3999b6

View File

@@ -64,8 +64,6 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
@Override @Override
public boolean onCreate() { public boolean onCreate() {
Log.d("KP2A_FC_P", "onCreate");
BaseFileProviderUtils.registerProviderInfo(_ID, BaseFileProviderUtils.registerProviderInfo(_ID,
getAuthority()); getAuthority());
@@ -222,12 +220,12 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
try try
{ {
checkConnection(uri); checkConnection(uri);
Log.d("KP2A_FC_P", "checking connection for " + uri + " ok."); if (Utils.doLog()) Log.d("KP2A_FC_P", "checking connection for " + uri + " ok.");
return null; return null;
} }
catch (Exception e) catch (Exception e)
{ {
Log.d("KP2A_FC_P","Check connection failed with: " + e.toString()); if (Utils.doLog()) Log.d("KP2A_FC_P","Check connection failed with: " + e.toString());
MatrixCursor matrixCursor = new MatrixCursor(BaseFileProviderUtils.CONNECTION_CHECK_CURSOR_COLUMNS); MatrixCursor matrixCursor = new MatrixCursor(BaseFileProviderUtils.CONNECTION_CHECK_CURSOR_COLUMNS);
RowBuilder newRow = matrixCursor.newRow(); RowBuilder newRow = matrixCursor.newRow();
@@ -255,7 +253,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
} }
catch (FileNotFoundException ex) catch (FileNotFoundException ex)
{ {
Log.d("KP2A_FC_P","File not found. Ignore."); if (Utils.doLog()) Log.d("KP2A_FC_P","File not found. Ignore.");
return; return;
} }
@@ -277,7 +275,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
String lastPathSegment = uri.getLastPathSegment(); String lastPathSegment = uri.getLastPathSegment();
Log.d("KP2A_FC_P", "lastPathSegment:" + lastPathSegment); if (Utils.doLog()) Log.d("KP2A_FC_P", "lastPathSegment:" + lastPathSegment);
if (BaseFile.CMD_CANCEL.equals(lastPathSegment)) { if (BaseFile.CMD_CANCEL.equals(lastPathSegment)) {
int taskId = ProviderUtils.getIntQueryParam(uri, int taskId = ProviderUtils.getIntQueryParam(uri,
@@ -361,7 +359,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
} else if (BaseFile.CMD_CHECK_CONNECTION.equals(lastPathSegment)) } else if (BaseFile.CMD_CHECK_CONNECTION.equals(lastPathSegment))
{ {
Log.d("KP2A_FC_P","Check connection..."); if (Utils.doLog()) Log.d("KP2A_FC_P","Check connection...");
return getCheckConnectionCursor(uri); return getCheckConnectionCursor(uri);
} }
@@ -470,7 +468,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
String displayName = getFileEntryCached(dirName).displayName; String displayName = getFileEntryCached(dirName).displayName;
newRow.add(displayName); newRow.add(displayName);
Log.d(CLASSNAME, "Returning name " + displayName+" for " +dirName); if (Utils.doLog()) Log.d(CLASSNAME, "Returning name " + displayName+" for " +dirName);
} }
} }
@@ -690,7 +688,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
} }
catch (Exception e) catch (Exception e)
{ {
Log.d("KP2A_FC_P", "sortFiles() >> "+e); if (Utils.doLog()) Log.d("KP2A_FC_P", "sortFiles() >> "+e);
throw e; throw e;
} }
}// sortFiles() }// sortFiles()
@@ -777,14 +775,14 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
path = removeTrailingSlash(path); path = removeTrailingSlash(path);
if (path.indexOf("://") == -1) if (path.indexOf("://") == -1)
{ {
Log.d("KP2A_FC_P", "invalid path: " + path); if (Utils.doLog()) Log.d("KP2A_FC_P", "invalid path: " + path);
return null; return null;
} }
String pathWithoutProtocol = path.substring(path.indexOf("://") + 3); String pathWithoutProtocol = path.substring(path.indexOf("://") + 3);
int lastSlashPos = path.lastIndexOf("/"); int lastSlashPos = path.lastIndexOf("/");
if (pathWithoutProtocol.indexOf("/") == -1) if (pathWithoutProtocol.indexOf("/") == -1)
{ {
Log.d("KP2A_FC_P", "parent of " + path + " is null"); if (Utils.doLog()) Log.d("KP2A_FC_P", "parent of " + path + " is null");
return null; return null;
} }
else else
@@ -793,7 +791,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
if (params != null) { if (params != null) {
parent += params; parent += params;
} }
Log.d("KP2A_FC_P", "parent of " + path +" is " + parent); if (Utils.doLog()) Log.d("KP2A_FC_P", "parent of " + path +" is " + parent);
return parent; return parent;
} }
} }