Home | History | Annotate | Download | only in contacts
      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 
     17 package com.android.dialer.calllog.datasources.contacts;
     18 
     19 import android.content.ContentValues;
     20 import android.content.Context;
     21 import android.support.annotation.MainThread;
     22 import android.support.annotation.WorkerThread;
     23 import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.AnnotatedCallLog;
     24 import com.android.dialer.calllog.datasources.CallLogDataSource;
     25 import com.android.dialer.calllog.datasources.CallLogMutations;
     26 import com.android.dialer.calllog.datasources.util.RowCombiner;
     27 import com.android.dialer.common.Assert;
     28 import java.util.List;
     29 import javax.inject.Inject;
     30 
     31 /** Responsible for maintaining the contacts related columns in the annotated call log. */
     32 public final class ContactsDataSource implements CallLogDataSource {
     33 
     34   @Inject
     35   public ContactsDataSource() {}
     36 
     37   @WorkerThread
     38   @Override
     39   public boolean isDirty(Context appContext) {
     40     Assert.isWorkerThread();
     41 
     42     // TODO: Implementation.
     43     return false;
     44   }
     45 
     46   @WorkerThread
     47   @Override
     48   public void fill(
     49       Context appContext,
     50       CallLogMutations mutations) {
     51     Assert.isWorkerThread();
     52     // TODO: Implementation.
     53     for (ContentValues contentValues : mutations.getInserts().values()) {
     54       contentValues.put(AnnotatedCallLog.CONTACT_NAME, "Placeholder name");
     55     }
     56   }
     57 
     58   @Override
     59   public void onSuccessfulFill(Context appContext) {
     60     // TODO: Implementation.
     61   }
     62 
     63   @Override
     64   public ContentValues coalesce(List<ContentValues> individualRowsSortedByTimestampDesc) {
     65     // TODO: Implementation.
     66     return new RowCombiner(individualRowsSortedByTimestampDesc)
     67         .useSingleValueString(AnnotatedCallLog.CONTACT_NAME)
     68         .combine();
     69   }
     70 
     71   @MainThread
     72   @Override
     73   public void registerContentObservers(
     74       Context appContext, ContentObserverCallbacks contentObserverCallbacks) {
     75     // TODO: Guard against missing permissions during callback registration.
     76   }
     77 }
     78