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

Commit 04306a75 authored by twyen's avatar twyen Committed by Copybara-Service
Browse files

Update preferred SIM SuggestionProvider

"remember this SIM" checkbox state is reported to the provider.
The other SIM is reported to the provider when "change SIM" is used

Bug: 70503524
Test: Unit tests
PiperOrigin-RevId: 183308581
Change-Id: I3d097d14a503c759f130044c9a9c48c420eee19d
parent c1623fe2
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import com.android.dialer.logging.Logger;
import com.android.dialer.precall.PreCallAction;
import com.android.dialer.precall.PreCallCoordinator;
import com.android.dialer.precall.PreCallCoordinator.PendingAction;
import com.android.dialer.preferredsim.PreferredAccountUtil;
import com.android.dialer.preferredsim.PreferredSimFallbackContract;
import com.android.dialer.preferredsim.PreferredSimFallbackContract.PreferredSim;
import com.android.dialer.preferredsim.suggestion.SimSuggestionComponent;
@@ -483,7 +484,8 @@ public class CallingAccountSelector implements PreCallAction {
      if (number != null) {
        DialerExecutorComponent.get(coordinator.getActivity())
            .dialerExecutorFactory()
            .createNonUiTaskBuilder(new UserSelectionReporter(selectedAccountHandle, number))
            .createNonUiTaskBuilder(
                new UserSelectionReporter(selectedAccountHandle, number, setDefault))
            .build()
            .executeParallel(coordinator.getActivity());
      }
@@ -505,11 +507,13 @@ public class CallingAccountSelector implements PreCallAction {

    private final String number;
    private final PhoneAccountHandle phoneAccountHandle;
    private final boolean remember;

    public UserSelectionReporter(
        @NonNull PhoneAccountHandle phoneAccountHandle, @Nullable String number) {
        @NonNull PhoneAccountHandle phoneAccountHandle, @Nullable String number, boolean remember) {
      this.phoneAccountHandle = Assert.isNotNull(phoneAccountHandle);
      this.number = Assert.isNotNull(number);
      this.remember = remember;
    }

    @Nullable
@@ -517,7 +521,7 @@ public class CallingAccountSelector implements PreCallAction {
    public Void doInBackground(@NonNull Context context) throws Throwable {
      SimSuggestionComponent.get(context)
          .getSuggestionProvider()
          .reportUserSelection(context, number, phoneAccountHandle);
          .reportUserSelection(context, number, phoneAccountHandle, remember);
      return null;
    }
  }
+2 −2
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License
 */

package com.android.dialer.precall.impl;
package com.android.dialer.preferredsim;

import android.content.ComponentName;
import android.content.Context;
@@ -64,7 +64,7 @@ public class PreferredAccountUtil {
    return Optional.absent();
  }

  private static boolean isPhoneAccountValid(
  public static boolean isPhoneAccountValid(
      Context context, PhoneAccountHandle phoneAccountHandle) {
    if (VERSION.SDK_INT >= VERSION_CODES.O) {
      return context
+4 −2
Original line number Diff line number Diff line
@@ -62,8 +62,10 @@ public interface SuggestionProvider {
  void reportUserSelection(
      @NonNull Context context,
      @NonNull String number,
      @NonNull PhoneAccountHandle phoneAccountHandle);
      @NonNull PhoneAccountHandle phoneAccountHandle,
      boolean rememberSelection);

  @WorkerThread
  void reportIncorrectSuggestion(@NonNull Context context, @NonNull String number);
  void reportIncorrectSuggestion(
      @NonNull Context context, @NonNull String number, @NonNull PhoneAccountHandle newAccount);
}
+4 −2
Original line number Diff line number Diff line
@@ -40,8 +40,10 @@ public class StubSuggestionProvider implements SuggestionProvider {
  public void reportUserSelection(
      @NonNull Context context,
      @NonNull String number,
      @NonNull PhoneAccountHandle phoneAccountHandle) {}
      @NonNull PhoneAccountHandle phoneAccountHandle,
      boolean rememberSelection) {}

  @Override
  public void reportIncorrectSuggestion(@NonNull Context context, @NonNull String number) {}
  public void reportIncorrectSuggestion(
      @NonNull Context context, @NonNull String number, PhoneAccountHandle newAccount) {}
}
+1 −1
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ public class SwapSimWorker implements Worker<Void, Void>, DialerCallListener, Ca
    try {
      SimSuggestionComponent.get(context)
          .getSuggestionProvider()
          .reportIncorrectSuggestion(context, number);
          .reportIncorrectSuggestion(context, number, otherAccount);

      if (!PermissionsUtil.hasPhonePermissions(context)) {
        LogUtil.e("SwapSimWorker.doInBackground", "missing phone permission");