예제 #1
0
        public static void AddSaveInfo(Parser parser, FillResponse.Builder responseBuilder, FieldCollection fields)
        {
            // Docs state that password fields cannot be reliably saved in Compat mode since they will show as
            // masked values.
            var compatBrowser = CompatBrowsers.Contains(parser.PackageName);

            if (compatBrowser && fields.SaveType == SaveDataType.Password)
            {
                return;
            }

            var requiredIds = fields.GetRequiredSaveFields();

            if (fields.SaveType == SaveDataType.Generic || requiredIds.Length == 0)
            {
                return;
            }

            var saveBuilder = new SaveInfo.Builder(fields.SaveType, requiredIds);
            var optionalIds = fields.GetOptionalSaveIds();

            if (optionalIds.Length > 0)
            {
                saveBuilder.SetOptionalIds(optionalIds);
            }
            if (compatBrowser)
            {
                saveBuilder.SetFlags(SaveFlags.SaveOnAllViewsInvisible);
            }
            responseBuilder.SetSaveInfo(saveBuilder.Build());
        }
        public FillResponse BuildResponse(IntentSender sender, RemoteViews remoteViews)
        {
            FillResponse.Builder responseBuilder = new FillResponse.Builder();
            int saveType = mClientViewMetadata.mSaveType;

            AutofillId[] autofillIds = mClientViewMetadata.mFocusedIds;
            if (autofillIds != null && autofillIds.Length > 0)
            {
                SaveInfo saveInfo = new SaveInfo.Builder((SaveDataType)saveType, autofillIds).Build();
                responseBuilder.SetSaveInfo(saveInfo);
                responseBuilder.SetAuthentication(autofillIds, sender, remoteViews);
                return(responseBuilder.Build());
            }
            return(null);
        }
        /**
         * Wraps autofill data in a Response object (essentially a series of Datasets) which can then
         * be sent back to the client View.
         */
        public FillResponse BuildResponse(Dictionary <string, FieldTypeWithHeuristics> fieldTypesByAutofillHint,
                                          List <DatasetWithFilledAutofillFields> datasets, bool datasetAuth)
        {
            FillResponse.Builder responseBuilder = new FillResponse.Builder();
            if (datasets != null)
            {
                foreach (var datasetWithFilledAutofillFields in datasets)
                {
                    if (datasetWithFilledAutofillFields != null)
                    {
                        Dataset dataset;
                        String  datasetName = datasetWithFilledAutofillFields.autofillDataset.GetDatasetName();
                        if (datasetAuth)
                        {
                            IntentSender intentSender = AuthActivity.GetAuthIntentSenderForDataset(
                                mContext, datasetName);
                            RemoteViews remoteViews = RemoteViewsHelper.ViewsWithAuth(
                                mPackageName, datasetName);
                            dataset = mDatasetAdapter.BuildDataset(fieldTypesByAutofillHint,
                                                                   datasetWithFilledAutofillFields, remoteViews, intentSender);
                        }
                        else
                        {
                            RemoteViews remoteViews = RemoteViewsHelper.ViewsWithNoAuth(
                                mPackageName, datasetName);
                            dataset = mDatasetAdapter.BuildDataset(fieldTypesByAutofillHint,
                                                                   datasetWithFilledAutofillFields, remoteViews);
                        }
                        if (dataset != null)
                        {
                            responseBuilder.AddDataset(dataset);
                        }
                    }
                }
            }
            int saveType = 0;

            AutofillId[] autofillIds = mClientViewMetadata.mFocusedIds;
            if (autofillIds != null && autofillIds.Length > 0)
            {
                SaveInfo saveInfo = new SaveInfo.Builder((SaveDataType)saveType, autofillIds).Build();
                responseBuilder.SetSaveInfo(saveInfo);
                return(responseBuilder.Build());
            }
            return(null);
        }
예제 #4
0
        public static void AddSaveInfo(FillResponse.Builder responseBuilder, FieldCollection fields)
        {
            var requiredIds = fields.GetRequiredSaveFields();

            if (fields.SaveType == SaveDataType.Generic || requiredIds.Length == 0)
            {
                return;
            }

            var saveBuilder = new SaveInfo.Builder(fields.SaveType, requiredIds);
            var optionalIds = fields.GetOptionalSaveIds();

            if (optionalIds.Length > 0)
            {
                saveBuilder.SetOptionalIds(optionalIds);
            }
            responseBuilder.SetSaveInfo(saveBuilder.Build());
        }
예제 #5
0
        public static void AddSaveInfo(Parser parser, FillRequest fillRequest, FillResponse.Builder responseBuilder,
                                       FieldCollection fields)
        {
            // Docs state that password fields cannot be reliably saved in Compat mode since they will show as
            // masked values.
            bool?compatRequest = null;

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Q && fillRequest != null)
            {
                // Attempt to automatically establish compat request mode on Android 10+
                compatRequest = (fillRequest.Flags | FillRequest.FlagCompatibilityModeRequest) == fillRequest.Flags;
            }
            var compatBrowser = compatRequest ?? CompatBrowsers.Contains(parser.PackageName);

            if (compatBrowser && fields.SaveType == SaveDataType.Password)
            {
                return;
            }

            var requiredIds = fields.GetRequiredSaveFields();

            if (fields.SaveType == SaveDataType.Generic || requiredIds.Length == 0)
            {
                return;
            }

            var saveBuilder = new SaveInfo.Builder(fields.SaveType, requiredIds);
            var optionalIds = fields.GetOptionalSaveIds();

            if (optionalIds.Length > 0)
            {
                saveBuilder.SetOptionalIds(optionalIds);
            }
            if (compatBrowser)
            {
                saveBuilder.SetFlags(SaveFlags.SaveOnAllViewsInvisible);
            }
            responseBuilder.SetSaveInfo(saveBuilder.Build());
        }