Home | History | Annotate | Download | only in source
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package com.example.android.autofill.service.data.source;
     17 
     18 import com.example.android.autofill.service.data.DataCallback;
     19 import com.example.android.autofill.service.model.DatasetWithFilledAutofillFields;
     20 import com.example.android.autofill.service.model.FieldType;
     21 import com.example.android.autofill.service.model.FieldTypeWithHeuristics;
     22 import com.example.android.autofill.service.model.FilledAutofillField;
     23 import com.example.android.autofill.service.model.ResourceIdHeuristic;
     24 
     25 import java.util.HashMap;
     26 import java.util.List;
     27 
     28 public interface AutofillDataSource {
     29 
     30     /**
     31      * Asynchronously gets saved list of {@link DatasetWithFilledAutofillFields} that contains some
     32      * objects that can autofill fields with these {@code autofillHints}.
     33      */
     34     void getAutofillDatasets(List<String> allAutofillHints,
     35             DataCallback<List<DatasetWithFilledAutofillFields>> datasetsCallback);
     36 
     37     void getAllAutofillDatasets(
     38             DataCallback<List<DatasetWithFilledAutofillFields>> datasetsCallback);
     39 
     40     /**
     41      * Asynchronously gets a saved {@link DatasetWithFilledAutofillFields} for a specific
     42      * {@code datasetName} that contains some objects that can autofill fields with these
     43      * {@code autofillHints}.
     44      */
     45     void getAutofillDataset(List<String> allAutofillHints,
     46             String datasetName, DataCallback<DatasetWithFilledAutofillFields> datasetsCallback);
     47 
     48     /**
     49      * Stores a collection of Autofill fields.
     50      */
     51     void saveAutofillDatasets(List<DatasetWithFilledAutofillFields>
     52             datasetsWithFilledAutofillFields);
     53 
     54     void saveResourceIdHeuristic(ResourceIdHeuristic resourceIdHeuristic);
     55 
     56     /**
     57      * Gets all autofill field types.
     58      */
     59     void getFieldTypes(DataCallback<List<FieldTypeWithHeuristics>> fieldTypesCallback);
     60 
     61     /**
     62      * Gets all autofill field types.
     63      */
     64     void getFieldType(String typeName, DataCallback<FieldType> fieldTypeCallback);
     65 
     66     void getFieldTypeByAutofillHints(
     67             DataCallback<HashMap<String, FieldTypeWithHeuristics>> fieldTypeMapCallback);
     68 
     69     void getFilledAutofillField(String datasetId, String fieldTypeName, DataCallback<FilledAutofillField> fieldCallback);
     70 
     71     /**
     72      * Clears all data.
     73      */
     74     void clear();
     75 }
     76