mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 18:08:26 +03:00
remove log spam
This commit is contained in:
parent
1a99bbb040
commit
9b8bdb0639
1 changed files with 1 additions and 47 deletions
|
@ -128,7 +128,6 @@ namespace Bit.Android
|
||||||
var notificationManager = (NotificationManager)GetSystemService(NotificationService);
|
var notificationManager = (NotificationManager)GetSystemService(NotificationService);
|
||||||
var cancelNotification = true;
|
var cancelNotification = true;
|
||||||
|
|
||||||
LogInfo(e.PackageName + " fires event " + e.EventType);
|
|
||||||
switch(e.EventType)
|
switch(e.EventType)
|
||||||
{
|
{
|
||||||
case EventTypes.ViewFocused:
|
case EventTypes.ViewFocused:
|
||||||
|
@ -156,40 +155,31 @@ namespace Bit.Android
|
||||||
}
|
}
|
||||||
else if(_appSettings.AutofillPasswordField && AutofillActivity.LastCredentials == null)
|
else if(_appSettings.AutofillPasswordField && AutofillActivity.LastCredentials == null)
|
||||||
{
|
{
|
||||||
LogInfo("1");
|
|
||||||
if(string.IsNullOrWhiteSpace(_lastNotificationUri))
|
if(string.IsNullOrWhiteSpace(_lastNotificationUri))
|
||||||
{
|
{
|
||||||
LogInfo("2");
|
|
||||||
CancelNotification(notificationManager);
|
CancelNotification(notificationManager);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("3");
|
|
||||||
var uri = GetUri(root);
|
var uri = GetUri(root);
|
||||||
LogInfo("4");
|
|
||||||
if(uri != _lastNotificationUri)
|
if(uri != _lastNotificationUri)
|
||||||
{
|
{
|
||||||
LogInfo("5");
|
|
||||||
CancelNotification(notificationManager);
|
CancelNotification(notificationManager);
|
||||||
}
|
}
|
||||||
else if(uri.StartsWith(App.Constants.AndroidAppProtocol))
|
else if(uri.StartsWith(App.Constants.AndroidAppProtocol))
|
||||||
{
|
{
|
||||||
LogInfo("6");
|
|
||||||
CancelNotification(notificationManager, 30000);
|
CancelNotification(notificationManager, 30000);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("7");
|
|
||||||
if(e.PackageName == BitwardenPackage)
|
if(e.PackageName == BitwardenPackage)
|
||||||
{
|
{
|
||||||
LogInfo("8");
|
|
||||||
CancelNotification(notificationManager);
|
CancelNotification(notificationManager);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("9");
|
|
||||||
if(_appSettings.AutofillPersistNotification)
|
if(_appSettings.AutofillPersistNotification)
|
||||||
{
|
{
|
||||||
var uri = GetUri(root);
|
var uri = GetUri(root);
|
||||||
|
@ -223,13 +213,11 @@ namespace Bit.Android
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogInfo("10");
|
|
||||||
cancelNotification = ScanAndAutofill(root, e, notificationManager, cancelNotification);
|
cancelNotification = ScanAndAutofill(root, e, notificationManager, cancelNotification);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cancelNotification)
|
if(cancelNotification)
|
||||||
{
|
{
|
||||||
LogInfo("11");
|
|
||||||
CancelNotification(notificationManager);
|
CancelNotification(notificationManager);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -237,27 +225,12 @@ namespace Bit.Android
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("12");
|
|
||||||
notificationManager?.Dispose();
|
notificationManager?.Dispose();
|
||||||
root.Dispose();
|
root.Dispose();
|
||||||
e.Dispose();
|
e.Dispose();
|
||||||
}
|
}
|
||||||
// Suppress exceptions so that service doesn't crash
|
// Suppress exceptions so that service doesn't crash
|
||||||
catch(Exception ex)
|
catch { }
|
||||||
{
|
|
||||||
LogError(ex.Message);
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LogInfo(string msg)
|
|
||||||
{
|
|
||||||
global::Android.Util.Log.Info("bw_access", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LogError(string msg)
|
|
||||||
{
|
|
||||||
global::Android.Util.Log.Error("bw_access", msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnInterrupt()
|
public override void OnInterrupt()
|
||||||
|
@ -268,9 +241,7 @@ namespace Bit.Android
|
||||||
public bool ScanAndAutofill(AccessibilityNodeInfo root, AccessibilityEvent e,
|
public bool ScanAndAutofill(AccessibilityNodeInfo root, AccessibilityEvent e,
|
||||||
NotificationManager notificationManager, bool cancelNotification)
|
NotificationManager notificationManager, bool cancelNotification)
|
||||||
{
|
{
|
||||||
LogInfo("13");
|
|
||||||
var passwordNodes = GetWindowNodes(root, e, n => n.Password, false);
|
var passwordNodes = GetWindowNodes(root, e, n => n.Password, false);
|
||||||
LogInfo("500000000000");
|
|
||||||
if(passwordNodes.Count > 0)
|
if(passwordNodes.Count > 0)
|
||||||
{
|
{
|
||||||
var uri = GetUri(root);
|
var uri = GetUri(root);
|
||||||
|
@ -278,18 +249,15 @@ namespace Bit.Android
|
||||||
{
|
{
|
||||||
if(NeedToAutofill(AutofillActivity.LastCredentials, uri))
|
if(NeedToAutofill(AutofillActivity.LastCredentials, uri))
|
||||||
{
|
{
|
||||||
LogInfo("14");
|
|
||||||
var allEditTexts = GetWindowNodes(root, e, n => EditText(n), false);
|
var allEditTexts = GetWindowNodes(root, e, n => EditText(n), false);
|
||||||
var usernameEditText = allEditTexts.TakeWhile(n => !n.Password).LastOrDefault();
|
var usernameEditText = allEditTexts.TakeWhile(n => !n.Password).LastOrDefault();
|
||||||
FillCredentials(usernameEditText, passwordNodes);
|
FillCredentials(usernameEditText, passwordNodes);
|
||||||
|
|
||||||
LogInfo("15");
|
|
||||||
allEditTexts.Dispose();
|
allEditTexts.Dispose();
|
||||||
usernameEditText.Dispose();
|
usernameEditText.Dispose();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogInfo("16");
|
|
||||||
NotifyToAutofill(uri, notificationManager);
|
NotifyToAutofill(uri, notificationManager);
|
||||||
cancelNotification = false;
|
cancelNotification = false;
|
||||||
}
|
}
|
||||||
|
@ -299,17 +267,13 @@ namespace Bit.Android
|
||||||
}
|
}
|
||||||
else if(AutofillActivity.LastCredentials != null)
|
else if(AutofillActivity.LastCredentials != null)
|
||||||
{
|
{
|
||||||
LogInfo("17");
|
|
||||||
System.Threading.Tasks.Task.Run(async () =>
|
System.Threading.Tasks.Task.Run(async () =>
|
||||||
{
|
{
|
||||||
LogInfo("18");
|
|
||||||
await System.Threading.Tasks.Task.Delay(1000);
|
await System.Threading.Tasks.Task.Delay(1000);
|
||||||
LogInfo("19");
|
|
||||||
AutofillActivity.LastCredentials = null;
|
AutofillActivity.LastCredentials = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("20");
|
|
||||||
passwordNodes.Dispose();
|
passwordNodes.Dispose();
|
||||||
return cancelNotification;
|
return cancelNotification;
|
||||||
}
|
}
|
||||||
|
@ -476,7 +440,6 @@ namespace Bit.Android
|
||||||
private NodeList GetWindowNodes(AccessibilityNodeInfo n, AccessibilityEvent e,
|
private NodeList GetWindowNodes(AccessibilityNodeInfo n, AccessibilityEvent e,
|
||||||
Func<AccessibilityNodeInfo, bool> condition, bool disposeIfUnused, NodeList nodes = null, int j = 0)
|
Func<AccessibilityNodeInfo, bool> condition, bool disposeIfUnused, NodeList nodes = null, int j = 0)
|
||||||
{
|
{
|
||||||
LogInfo("51");
|
|
||||||
if(nodes == null)
|
if(nodes == null)
|
||||||
{
|
{
|
||||||
nodes = new NodeList();
|
nodes = new NodeList();
|
||||||
|
@ -484,34 +447,25 @@ namespace Bit.Android
|
||||||
|
|
||||||
if(n != null)
|
if(n != null)
|
||||||
{
|
{
|
||||||
LogInfo("52: " + n.ChildCount + ", " + n.WindowId + ", " + n.ViewIdResourceName + ", " + n.Password + ", " + j);
|
|
||||||
var dispose = disposeIfUnused;
|
var dispose = disposeIfUnused;
|
||||||
if(n.WindowId == e.WindowId && !(n.ViewIdResourceName?.StartsWith(SystemUiPackage) ?? false) && condition(n))
|
if(n.WindowId == e.WindowId && !(n.ViewIdResourceName?.StartsWith(SystemUiPackage) ?? false) && condition(n))
|
||||||
{
|
{
|
||||||
LogInfo("53");
|
|
||||||
dispose = false;
|
dispose = false;
|
||||||
nodes.Add(n);
|
nodes.Add(n);
|
||||||
LogInfo("53.1: " + nodes.Count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("54: " + n.ChildCount);
|
|
||||||
for(var i = 0; i < n.ChildCount; i++)
|
for(var i = 0; i < n.ChildCount; i++)
|
||||||
{
|
{
|
||||||
LogInfo("55.1");
|
|
||||||
var c = n.GetChild(i);
|
var c = n.GetChild(i);
|
||||||
LogInfo("55.2");
|
|
||||||
GetWindowNodes(c, e, condition, true, nodes, j++);
|
GetWindowNodes(c, e, condition, true, nodes, j++);
|
||||||
LogInfo("55.3: " + i + ", " + n.ChildCount + ", " + n.WindowId + ", " + n.ViewIdResourceName + ", " + n.Password + ", " + j);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dispose)
|
if(dispose)
|
||||||
{
|
{
|
||||||
LogInfo("56");
|
|
||||||
n.Dispose();
|
n.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("57: " + nodes.Count);
|
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue