Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1a29c07 authored by zachh's avatar zachh Committed by android-build-merger
Browse files

Merge "Added "clearData" to CallLogDataSource and PhoneLookup interfaces."

am: 0f2cfb47

Change-Id: Ic6581cdaae5980c2b166231b6d27190135fcca07
parents 73573d40 0f2cfb47
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.dialer.glidephotomanager.GlidePhotoManagerComponent;
import com.android.dialer.main.MainComponent;
import com.android.dialer.metrics.MetricsComponent;
import com.android.dialer.phonelookup.PhoneLookupComponent;
import com.android.dialer.phonelookup.database.PhoneLookupDatabaseComponent;
import com.android.dialer.phonenumbergeoutil.PhoneNumberGeoUtilComponent;
import com.android.dialer.precall.PreCallComponent;
import com.android.dialer.preferredsim.suggestion.SimSuggestionComponent;
@@ -47,7 +48,8 @@ import com.android.voicemail.VoicemailComponent;
 * from this component.
 */
public interface BaseDialerRootComponent
    extends CallLocationComponent.HasComponent,
    extends BubbleComponent.HasComponent,
        CallLocationComponent.HasComponent,
        CallLogComponent.HasComponent,
        CallLogDatabaseComponent.HasComponent,
        CallLogUiComponent.HasComponent,
@@ -61,8 +63,8 @@ public interface BaseDialerRootComponent
        MainComponent.HasComponent,
        MapsComponent.HasComponent,
        MetricsComponent.HasComponent,
        BubbleComponent.HasComponent,
        PhoneLookupComponent.HasComponent,
        PhoneLookupDatabaseComponent.HasComponent,
        PhoneNumberGeoUtilComponent.HasComponent,
        PreCallComponent.HasComponent,
        SimSuggestionComponent.HasComponent,
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.dialer.calllog;

import com.android.dialer.calllog.database.CallLogDatabaseModule;
import com.android.dialer.calllog.datasources.CallLogDataSource;
import com.android.dialer.calllog.datasources.DataSources;
import com.android.dialer.calllog.datasources.phonelookup.PhoneLookupDataSource;
@@ -26,7 +27,7 @@ import dagger.Module;
import dagger.Provides;

/** Dagger module which satisfies call log dependencies. */
@Module
@Module(includes = CallLogDatabaseModule.class)
public abstract class CallLogModule {

  @Provides
+2 −7
Original line number Diff line number Diff line
@@ -45,12 +45,7 @@ import java.util.Arrays;
/** {@link ContentProvider} for the annotated call log. */
public class AnnotatedCallLogContentProvider extends ContentProvider {

  /**
   * We sometimes run queries where we potentially pass every ID into a where clause using the
   * (?,?,?,...) syntax. The maximum number of host parameters is 999, so that's the maximum size
   * this table can be. See https://www.sqlite.org/limits.html for more details.
   */
  private static final int MAX_ROWS = 999;


  private static final int ANNOTATED_CALL_LOG_TABLE_CODE = 1;
  private static final int ANNOTATED_CALL_LOG_TABLE_ID_CODE = 2;
@@ -87,7 +82,7 @@ public class AnnotatedCallLogContentProvider extends ContentProvider {

  @Override
  public boolean onCreate() {
    databaseHelper = new AnnotatedCallLogDatabaseHelper(getContext(), MAX_ROWS);
    databaseHelper = CallLogDatabaseComponent.get(getContext()).annotatedCallLogDatabaseHelper();

    // Note: As this method is called before Application#onCreate, we must *not* initialize objects
    // that require preparation work done in Application#onCreate.
+32 −3
Original line number Diff line number Diff line
@@ -22,15 +22,34 @@ import android.database.sqlite.SQLiteOpenHelper;
import android.provider.CallLog.Calls;
import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.AnnotatedCallLog;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor;
import com.android.dialer.inject.ApplicationContext;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import java.util.Locale;
import javax.inject.Inject;
import javax.inject.Singleton;

/** {@link SQLiteOpenHelper} for the AnnotatedCallLog database. */
class AnnotatedCallLogDatabaseHelper extends SQLiteOpenHelper {
@Singleton
public class AnnotatedCallLogDatabaseHelper extends SQLiteOpenHelper {

  private static final String FILENAME = "annotated_call_log.db";

  private final Context appContext;
  private final int maxRows;
  private final ListeningExecutorService backgroundExecutor;

  @Inject
  public AnnotatedCallLogDatabaseHelper(
      @ApplicationContext Context appContext,
      @AnnotatedCallLogMaxRows int maxRows,
      @BackgroundExecutor ListeningExecutorService backgroundExecutor) {
    super(appContext, FILENAME, null, 1);

  AnnotatedCallLogDatabaseHelper(Context appContext, int maxRows) {
    super(appContext, "annotated_call_log.db", null, 1);
    this.appContext = appContext;
    this.maxRows = maxRows;
    this.backgroundExecutor = backgroundExecutor;
  }

  private static final String CREATE_TABLE_SQL =
@@ -127,4 +146,14 @@ class AnnotatedCallLogDatabaseHelper extends SQLiteOpenHelper {

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {}

  /** Closes the database and deletes it. */
  public ListenableFuture<Void> delete() {
    return backgroundExecutor.submit(
        () -> {
          close();
          appContext.deleteDatabase(FILENAME);
          return null;
        });
  }
}
+22 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */
package com.android.dialer.calllog.database;

import javax.inject.Qualifier;

/** Annotation for the max number of rows in the AnnotatedCallLog. */
@Qualifier
public @interface AnnotatedCallLogMaxRows {}
Loading