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.preferredsim.suggestion; 18 19 import android.content.Context; 20 import android.support.annotation.NonNull; 21 import android.support.annotation.WorkerThread; 22 import android.telecom.PhoneAccountHandle; 23 import com.android.dialer.common.Assert; 24 import com.google.common.base.Optional; 25 26 /** Provides hints to the user when selecting a SIM to make a call. */ 27 public interface SuggestionProvider { 28 29 /** The reason the suggestion is made. */ 30 enum Reason { 31 UNKNOWN, 32 // The SIM has the same carrier as the callee. 33 INTRA_CARRIER, 34 // The user has selected the SIM for the callee multiple times. 35 FREQUENT, 36 // The user has select the SIM for this category of calls (contacts from certain accounts, 37 // etc.). 38 USER_SET, 39 // The user has selected the SIM for all contacts on the account. 40 ACCOUNT, 41 // Unspecified reason. 42 OTHER, 43 } 44 45 /** The suggestion. */ 46 class Suggestion { 47 @NonNull public final PhoneAccountHandle phoneAccountHandle; 48 @NonNull public final Reason reason; 49 public final boolean shouldAutoSelect; 50 51 public Suggestion( 52 @NonNull PhoneAccountHandle phoneAccountHandle, 53 @NonNull Reason reason, 54 boolean shouldAutoSelect) { 55 this.phoneAccountHandle = Assert.isNotNull(phoneAccountHandle); 56 this.reason = Assert.isNotNull(reason); 57 this.shouldAutoSelect = shouldAutoSelect; 58 } 59 } 60 61 @WorkerThread 62 @NonNull 63 Optional<Suggestion> getSuggestion(@NonNull Context context, @NonNull String number); 64 65 @WorkerThread 66 void reportUserSelection( 67 @NonNull Context context, 68 @NonNull String number, 69 @NonNull PhoneAccountHandle phoneAccountHandle, 70 boolean rememberSelection); 71 72 @WorkerThread 73 void reportIncorrectSuggestion( 74 @NonNull Context context, @NonNull String number, @NonNull PhoneAccountHandle newAccount); 75 } 76