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

Commit 1e4ef187 authored by erfanian's avatar erfanian Committed by Copybara-Service
Browse files

A few more interface updates.

Bug: 73773964
Test: none
PiperOrigin-RevId: 200079809
Change-Id: I1c505c4f63a17b34ed9fb062c9f9e1b1e16c3832
parent 128ecd2b
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver {
  public static final String ACTION_TURN_ON_SPEAKER = "com.android.incallui.ACTION_TURN_ON_SPEAKER";
  public static final String ACTION_TURN_OFF_SPEAKER =
      "com.android.incallui.ACTION_TURN_OFF_SPEAKER";
  public static final String ACTION_ANSWER_SPEAKEASY_CALL =
      "com.android.incallui.ACTION_ANSWER_SPEAKEASY_CALL";

  @RequiresApi(VERSION_CODES.N_MR1)
  public static final String ACTION_PULL_EXTERNAL_CALL =
@@ -81,6 +83,9 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver {
      answerIncomingCall(VideoProfile.STATE_BIDIRECTIONAL, context);
    } else if (action.equals(ACTION_ANSWER_VOICE_INCOMING_CALL)) {
      answerIncomingCall(VideoProfile.STATE_AUDIO_ONLY, context);
    } else if (action.equals(ACTION_ANSWER_SPEAKEASY_CALL)) {
      markIncomingCallAsSpeakeasyCall();
      answerIncomingCall(VideoProfile.STATE_AUDIO_ONLY, context);
    } else if (action.equals(ACTION_DECLINE_INCOMING_CALL)) {
      Logger.get(context)
          .logImpression(DialerImpression.Type.REJECT_INCOMING_CALL_FROM_NOTIFICATION);
@@ -146,6 +151,19 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver {
    }
  }

  private void markIncomingCallAsSpeakeasyCall() {
    CallList callList = InCallPresenter.getInstance().getCallList();
    if (callList == null) {
      LogUtil.e(
          "NotificationBroadcastReceiver.markIncomingCallAsSpeakeasyCall", "call list is empty");
    } else {
      DialerCall call = callList.getIncomingCall();
      if (call != null) {
        call.setIsSpeakEasyCall(true);
      }
    }
  }

  private void answerIncomingCall(int videoState, @NonNull Context context) {
    CallList callList = InCallPresenter.getInstance().getCallList();
    if (callList == null) {
+43 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.incallui;
import static android.telecom.Call.Details.PROPERTY_HIGH_DEF_AUDIO;
import static com.android.contacts.common.compat.CallCompat.Details.PROPERTY_ENTERPRISE_CALL;
import static com.android.incallui.NotificationBroadcastReceiver.ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST;
import static com.android.incallui.NotificationBroadcastReceiver.ACTION_ANSWER_SPEAKEASY_CALL;
import static com.android.incallui.NotificationBroadcastReceiver.ACTION_ANSWER_VIDEO_INCOMING_CALL;
import static com.android.incallui.NotificationBroadcastReceiver.ACTION_ANSWER_VOICE_INCOMING_CALL;
import static com.android.incallui.NotificationBroadcastReceiver.ACTION_DECLINE_INCOMING_CALL;
@@ -57,6 +58,7 @@ import android.telecom.VideoProfile;
import android.text.BidiFormatter;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextDirectionHeuristics;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
@@ -90,7 +92,9 @@ import com.android.incallui.call.state.DialerCallState;
import com.android.incallui.ringtone.DialerRingtoneManager;
import com.android.incallui.ringtone.InCallTonePlayer;
import com.android.incallui.ringtone.ToneGeneratorFactory;
import com.android.incallui.speakeasy.SpeakEasyComponent;
import com.android.incallui.videotech.utils.SessionModificationState;
import com.google.common.base.Optional;
import java.util.Objects;

/** This class adds Notifications to the status bar for the in-call experience. */
@@ -451,6 +455,7 @@ public class StatusBarNotifier
        addVideoCallAction(builder);
      } else {
        addAnswerAction(builder);
        addSpeakeasyAnswerAction(builder);
      }
    }
  }
@@ -869,6 +874,44 @@ public class StatusBarNotifier
            .build());
  }

  private void addSpeakeasyAnswerAction(Notification.Builder builder) {
    if (!ConfigProviderComponent.get(context)
        .getConfigProvider()
        .getBoolean("enable_speakeasy_notification_button", false)) {
      return;
    }

    if (!SpeakEasyComponent.get(context).speakEasyCallManager().isAvailable(context)) {
      return;
    }

    Optional<Integer> buttonText = SpeakEasyComponent.get(context).speakEasyTextResource();
    if (!buttonText.isPresent()) {
      return;
    }

    LogUtil.d("StatusBarNotifier.addSpeakeasyAnswerAction", "showing button");
    PendingIntent answerVoicePendingIntent =
        createNotificationPendingIntent(context, ACTION_ANSWER_SPEAKEASY_CALL);

    Spannable spannable = new SpannableString(context.getText(buttonText.get()));
    // TODO(erfanian): Migrate these color values to somewhere more permanent in subsequent
    // implementation.
    spannable.setSpan(
        new ForegroundColorSpan(
            context.getColor(R.color.DO_NOT_USE_OR_I_WILL_BREAK_YOU_text_span_tertiary_button)),
        0,
        spannable.length(),
        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    builder.addAction(
        new Notification.Action.Builder(
                Icon.createWithResource(context, R.drawable.quantum_ic_call_white_24),
                spannable,
                answerVoicePendingIntent)
            .build());
  }

  private void addDismissAction(Notification.Builder builder) {
    LogUtil.d(
        "StatusBarNotifier.addDismissAction",
+19 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ 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
  -->
<resources>
  <color name="DO_NOT_USE_OR_I_WILL_BREAK_YOU_text_span_tertiary_button">#1A73E8</color>
</resources>
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -32,4 +32,8 @@ public final class Annotations {
  /** A Speakeasy chip */
  @Qualifier
  public @interface SpeakEasyChipResourceId {}

  /** A Speakeasy text resource */
  @Qualifier
  public @interface SpeakEasyTextResourceId {}
}
+3 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import com.android.dialer.inject.HasRootComponent;
import com.android.incallui.speakeasy.Annotations.SpeakEasyChipResourceId;
import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsFragment;
import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsObject;
import com.android.incallui.speakeasy.Annotations.SpeakEasyTextResourceId;
import com.google.common.base.Optional;
import dagger.Subcomponent;

@@ -38,6 +39,8 @@ public abstract class SpeakEasyComponent {

  public abstract @SpeakEasyChipResourceId Optional<Integer> speakEasyChip();

  public abstract @SpeakEasyTextResourceId Optional<Integer> speakEasyTextResource();

  public static SpeakEasyComponent get(Context context) {
    return ((SpeakEasyComponent.HasComponent)
            ((HasRootComponent) context.getApplicationContext()).component())
Loading