public static FilledAutofillFieldCollection GetFilledAutofillFieldCollectionFromEntry(PwEntryOutput pwEntryOutput, Context context) { if (pwEntryOutput == null) { return(null); } FilledAutofillFieldCollection fieldCollection = new FilledAutofillFieldCollection(); var pwEntry = pwEntryOutput.Entry; foreach (string key in pwEntryOutput.OutputStrings.GetKeys()) { FilledAutofillField field = new FilledAutofillField { AutofillHints = GetCanonicalHintsFromKp2aField(key).ToArray(), TextValue = pwEntryOutput.OutputStrings.ReadSafe(key) }; fieldCollection.Add(field); } if (IsCreditCard(pwEntry, context) && pwEntry.Expires) { DateTime expTime = pwEntry.ExpiryTime; FilledAutofillField field = new FilledAutofillField { AutofillHints = new[] { View.AutofillHintCreditCardExpirationDate }, DateValue = (long)(1000 * TimeUtil.SerializeUnix(expTime)) }; fieldCollection.Add(field); field = new FilledAutofillField { AutofillHints = new[] { View.AutofillHintCreditCardExpirationDay }, TextValue = expTime.Day.ToString() }; fieldCollection.Add(field); field = new FilledAutofillField { AutofillHints = new[] { View.AutofillHintCreditCardExpirationMonth }, TextValue = expTime.Month.ToString() }; fieldCollection.Add(field); field = new FilledAutofillField { AutofillHints = new[] { View.AutofillHintCreditCardExpirationYear }, TextValue = expTime.Year.ToString() }; fieldCollection.Add(field); } fieldCollection.DatasetName = pwEntry.Strings.ReadSafe(PwDefs.TitleField); return(fieldCollection); }
public static FilledAutofillFieldCollection FilterForPartition(FilledAutofillFieldCollection autofillFields, int partitionIndex) { FilledAutofillFieldCollection filteredCollection = new FilledAutofillFieldCollection { DatasetName = autofillFields.DatasetName }; if (partitionIndex == -1) { return(filteredCollection); } foreach (var field in autofillFields.HintMap.Values.Distinct()) { foreach (var hint in field.AutofillHints) { if (GetPartitionIndex(hint) == partitionIndex) { filteredCollection.Add(field); break; } } } return(filteredCollection); }
public static FilledAutofillFieldCollection GetFakeFieldCollection(int partition, int seed) { var filledAutofillFieldCollection = new FilledAutofillFieldCollection(); foreach (var hint in sValidHints.Keys) { if (hint != null && sValidHints[hint].GetPartition() == partition) { var fakeField = GetFakeField(hint, seed); filledAutofillFieldCollection.Add(fakeField); } } return(filledAutofillFieldCollection); }
protected override FilledAutofillFieldCollection GetDataset(Intent data) { if (!App.Kp2a.GetDb().Loaded || (App.Kp2a.QuickLocked)) { return(null); } FilledAutofillFieldCollection fieldCollection = new FilledAutofillFieldCollection(); var pwEntry = App.Kp2a.GetDb().LastOpenedEntry.Entry; foreach (string key in pwEntry.Strings.GetKeys()) { FilledAutofillField field = new FilledAutofillField { AutofillHints = new[] { GetCanonicalHintFromKp2aField(pwEntry, key) }, TextValue = pwEntry.Strings.ReadSafe(key), Protected = pwEntry.Strings.Get(key).IsProtected }; fieldCollection.Add(field); } if (IsCreditCard(pwEntry) && pwEntry.Expires) { DateTime expTime = pwEntry.ExpiryTime; FilledAutofillField field = new FilledAutofillField { AutofillHints = new[] { View.AutofillHintCreditCardExpirationDate }, DateValue = (long)(1000 * TimeUtil.SerializeUnix(expTime)), Protected = false }; fieldCollection.Add(field); field = new FilledAutofillField { AutofillHints = new[] { View.AutofillHintCreditCardExpirationDay }, TextValue = expTime.Day.ToString(), Protected = false }; fieldCollection.Add(field); field = new FilledAutofillField { AutofillHints = new[] { View.AutofillHintCreditCardExpirationMonth }, TextValue = expTime.Month.ToString(), Protected = false }; fieldCollection.Add(field); field = new FilledAutofillField { AutofillHints = new[] { View.AutofillHintCreditCardExpirationYear }, TextValue = expTime.Year.ToString(), Protected = false }; fieldCollection.Add(field); } fieldCollection.DatasetName = pwEntry.Strings.ReadSafe(PwDefs.TitleField); return(fieldCollection); }
private void ParseLocked(bool forFill, AssistStructure.ViewNode viewNode, StringBuilder validWebDomain) { var webDomain = viewNode.WebDomain; if (webDomain != null) { if (CommonUtil.DEBUG) { Log.Debug(CommonUtil.TAG, "child web domain: " + webDomain); } if (validWebDomain.Length() > 0) { if (webDomain != validWebDomain.ToString()) { throw new SecurityException("Found multiple web domains: valid= " + validWebDomain + ", child=" + webDomain); } } else { validWebDomain.Append(webDomain); } } if (viewNode.GetAutofillHints() != null) { var filteredHints = AutofillHints.FilterForSupportedHints( viewNode.GetAutofillHints()); if (filteredHints != null && filteredHints.Length > 0) { if (forFill) { mAutofillFields.Add(new AutofillFieldMetadata(viewNode)); } else { var filledAutofillField = new FilledAutofillField(viewNode.GetAutofillHints()); AutofillValue autofillValue = viewNode.AutofillValue; if (autofillValue.IsText) { // Using toString of AutofillValue.getTextValue in order to save it to // SharedPreferences. filledAutofillField.SetTextValue(autofillValue.TextValue); } else if (autofillValue.IsDate) { filledAutofillField.SetDateValue(autofillValue.DateValue); } else if (autofillValue.IsList) { filledAutofillField.SetListValue(viewNode.GetAutofillOptions(), autofillValue.ListValue); } mFilledAutofillFieldCollection.Add(filledAutofillField); } } } int childrenSize = viewNode.ChildCount; if (childrenSize > 0) { for (int i = 0; i < childrenSize; i++) { ParseLocked(forFill, viewNode.GetChildAt(i), validWebDomain); } } }