diff options
author | Eric Erfanian <erfanian@google.com> | 2018-04-29 05:32:38 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-04-29 05:32:38 +0000 |
commit | eac73f3067acefffaa8eec7b7a9d8b3cc176e674 (patch) | |
tree | b0856f5ceba502b88d8e8970cd6cf9295fc83561 /java/com/android/incallui/call | |
parent | c28ed7444c25d52fd3996f8edf076a1d740d4e05 (diff) | |
parent | 16b77d4d484dca3d4a070709cfb046c6fba8c993 (diff) |
Merge changes I7be0efad,I4d6fb104,Idc15d873,I6b3241bc,If8c6e798, ...
* changes:
Updated logic on showing voice/video/sms options in favorites menus.
Implemented remove starred contact from speed dial fragment.
Remove audio change behavior for background calling.
Move DialerCall.State to an independent package.
Logging for background calling and HFP device support.
HFP device support change.
Handle missing permission.READ_CALL_LOG when initializing the badge for missed calls.
Diffstat (limited to 'java/com/android/incallui/call')
-rw-r--r-- | java/com/android/incallui/call/CallList.java | 62 | ||||
-rw-r--r-- | java/com/android/incallui/call/DialerCall.java | 128 | ||||
-rw-r--r-- | java/com/android/incallui/call/state/DialerCallState.java | 99 |
3 files changed, 154 insertions, 135 deletions
diff --git a/java/com/android/incallui/call/CallList.java b/java/com/android/incallui/call/CallList.java index 6b17962de..5d9db32d9 100644 --- a/java/com/android/incallui/call/CallList.java +++ b/java/com/android/incallui/call/CallList.java @@ -42,7 +42,7 @@ import com.android.dialer.shortcuts.ShortcutUsageReporter; import com.android.dialer.spam.Spam; import com.android.dialer.spam.SpamComponent; import com.android.dialer.telecom.TelecomCallUtil; -import com.android.incallui.call.DialerCall.State; +import com.android.incallui.call.state.DialerCallState; import com.android.incallui.latencyreport.LatencyReport; import com.android.incallui.videotech.utils.SessionModificationState; import java.util.Collection; @@ -155,8 +155,8 @@ public class CallList implements DialerCallDelegate { @Override public void onComplete(boolean isSpam) { boolean isIncomingCall = - call.getState() == DialerCall.State.INCOMING - || call.getState() == DialerCall.State.CALL_WAITING; + call.getState() == DialerCallState.INCOMING + || call.getState() == DialerCallState.CALL_WAITING; if (isSpam) { if (!isIncomingCall) { LogUtil.i( @@ -211,8 +211,8 @@ public class CallList implements DialerCallDelegate { call.getCountryIso()); Trace.endSection(); - if (call.getState() == DialerCall.State.INCOMING - || call.getState() == DialerCall.State.CALL_WAITING) { + if (call.getState() == DialerCallState.INCOMING + || call.getState() == DialerCallState.CALL_WAITING) { if (call.isActiveRttCall()) { Logger.get(context) .logCallImpression( @@ -233,7 +233,7 @@ public class CallList implements DialerCallDelegate { notifyGenericListeners(); } - if (call.getState() != State.INCOMING) { + if (call.getState() != DialerCallState.INCOMING) { // Only report outgoing calls ShortcutUsageReporter.onOutgoingCallAdded(context, call.getNumber()); } @@ -444,46 +444,46 @@ public class CallList implements DialerCallDelegate { /** A call that is waiting for {@link PhoneAccount} selection */ public DialerCall getWaitingForAccountCall() { - return getFirstCallWithState(DialerCall.State.SELECT_PHONE_ACCOUNT); + return getFirstCallWithState(DialerCallState.SELECT_PHONE_ACCOUNT); } public DialerCall getPendingOutgoingCall() { - return getFirstCallWithState(DialerCall.State.CONNECTING); + return getFirstCallWithState(DialerCallState.CONNECTING); } public DialerCall getOutgoingCall() { - DialerCall call = getFirstCallWithState(DialerCall.State.DIALING); + DialerCall call = getFirstCallWithState(DialerCallState.DIALING); if (call == null) { - call = getFirstCallWithState(DialerCall.State.REDIALING); + call = getFirstCallWithState(DialerCallState.REDIALING); } if (call == null) { - call = getFirstCallWithState(DialerCall.State.PULLING); + call = getFirstCallWithState(DialerCallState.PULLING); } return call; } public DialerCall getActiveCall() { - return getFirstCallWithState(DialerCall.State.ACTIVE); + return getFirstCallWithState(DialerCallState.ACTIVE); } public DialerCall getSecondActiveCall() { - return getCallWithState(DialerCall.State.ACTIVE, 1); + return getCallWithState(DialerCallState.ACTIVE, 1); } public DialerCall getBackgroundCall() { - return getFirstCallWithState(DialerCall.State.ONHOLD); + return getFirstCallWithState(DialerCallState.ONHOLD); } public DialerCall getDisconnectedCall() { - return getFirstCallWithState(DialerCall.State.DISCONNECTED); + return getFirstCallWithState(DialerCallState.DISCONNECTED); } public DialerCall getDisconnectingCall() { - return getFirstCallWithState(DialerCall.State.DISCONNECTING); + return getFirstCallWithState(DialerCallState.DISCONNECTING); } public DialerCall getSecondBackgroundCall() { - return getCallWithState(DialerCall.State.ONHOLD, 1); + return getCallWithState(DialerCallState.ONHOLD, 1); } public DialerCall getActiveOrBackgroundCall() { @@ -495,9 +495,9 @@ public class CallList implements DialerCallDelegate { } public DialerCall getIncomingCall() { - DialerCall call = getFirstCallWithState(DialerCall.State.INCOMING); + DialerCall call = getFirstCallWithState(DialerCallState.INCOMING); if (call == null) { - call = getFirstCallWithState(DialerCall.State.CALL_WAITING); + call = getFirstCallWithState(DialerCallState.CALL_WAITING); } return call; @@ -512,7 +512,7 @@ public class CallList implements DialerCallDelegate { result = getOutgoingCall(); } if (result == null) { - result = getFirstCallWithState(DialerCall.State.ACTIVE); + result = getFirstCallWithState(DialerCallState.ACTIVE); } if (result == null) { result = getDisconnectingCall(); @@ -592,9 +592,9 @@ public class CallList implements DialerCallDelegate { */ public boolean hasNonParentActiveOrBackgroundCall() { for (DialerCall call : callById.values()) { - if ((call.getState() == State.ACTIVE - || call.getState() == State.ONHOLD - || call.getState() == State.CONFERENCED) + if ((call.getState() == DialerCallState.ACTIVE + || call.getState() == DialerCallState.ONHOLD + || call.getState() == DialerCallState.CONFERENCED) && !call.wasParentCall()) { return true; } @@ -611,11 +611,11 @@ public class CallList implements DialerCallDelegate { public void clearOnDisconnect() { for (DialerCall call : callById.values()) { final int state = call.getState(); - if (state != DialerCall.State.IDLE - && state != DialerCall.State.INVALID - && state != DialerCall.State.DISCONNECTED) { + if (state != DialerCallState.IDLE + && state != DialerCallState.INVALID + && state != DialerCallState.DISCONNECTED) { - call.setState(DialerCall.State.DISCONNECTED); + call.setState(DialerCallState.DISCONNECTED); call.setDisconnectCause(new DisconnectCause(DisconnectCause.UNKNOWN)); updateCallInMap(call); } @@ -688,7 +688,7 @@ public class CallList implements DialerCallDelegate { boolean updated = false; - if (call.getState() == DialerCall.State.DISCONNECTED) { + if (call.getState() == DialerCallState.DISCONNECTED) { // update existing (but do not add!!) disconnected calls if (callById.containsKey(call.getId())) { // For disconnected calls, we want to keep them alive for a few seconds so that the @@ -718,7 +718,7 @@ public class CallList implements DialerCallDelegate { } private int getDelayForDisconnect(DialerCall call) { - if (call.getState() != DialerCall.State.DISCONNECTED) { + if (call.getState() != DialerCallState.DISCONNECTED) { throw new IllegalStateException(); } @@ -748,7 +748,7 @@ public class CallList implements DialerCallDelegate { private boolean isCallDead(DialerCall call) { final int state = call.getState(); - return DialerCall.State.IDLE == state || DialerCall.State.INVALID == state; + return DialerCallState.IDLE == state || DialerCallState.INVALID == state; } /** Sets up a call for deletion and notifies listeners of change. */ @@ -756,7 +756,7 @@ public class CallList implements DialerCallDelegate { if (pendingDisconnectCalls.contains(call)) { pendingDisconnectCalls.remove(call); } - call.setState(DialerCall.State.IDLE); + call.setState(DialerCallState.IDLE); updateCallInMap(call); notifyGenericListeners(); } diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java index da05b9d2a..d57de15e5 100644 --- a/java/com/android/incallui/call/DialerCall.java +++ b/java/com/android/incallui/call/DialerCall.java @@ -81,6 +81,7 @@ import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.theme.R; import com.android.dialer.util.PermissionsUtil; import com.android.incallui.audiomode.AudioModeProvider; +import com.android.incallui.call.state.DialerCallState; import com.android.incallui.latencyreport.LatencyReport; import com.android.incallui.speakeasy.runtime.Constraints; import com.android.incallui.videotech.VideoTech; @@ -146,7 +147,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa private boolean isSpeakEasyCall; private boolean isEmergencyCall; private Uri handle; - private int state = State.INVALID; + private int state = DialerCallState.INVALID; private DisconnectCause disconnectCause; private boolean hasShownLteToWiFiHandoverToast; @@ -200,7 +201,8 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa /** * Whether the call is put on hold by remote party. This is different than the {@link - * State#ONHOLD} state which indicates that the call is being held locally on the device. + * DialerCallState#ONHOLD} state which indicates that the call is being held locally on the + * device. */ private boolean isRemotelyHeld; @@ -427,25 +429,25 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa switch (state) { case Call.STATE_NEW: case Call.STATE_CONNECTING: - return DialerCall.State.CONNECTING; + return DialerCallState.CONNECTING; case Call.STATE_SELECT_PHONE_ACCOUNT: - return DialerCall.State.SELECT_PHONE_ACCOUNT; + return DialerCallState.SELECT_PHONE_ACCOUNT; case Call.STATE_DIALING: - return DialerCall.State.DIALING; + return DialerCallState.DIALING; case Call.STATE_PULLING_CALL: - return DialerCall.State.PULLING; + return DialerCallState.PULLING; case Call.STATE_RINGING: - return DialerCall.State.INCOMING; + return DialerCallState.INCOMING; case Call.STATE_ACTIVE: - return DialerCall.State.ACTIVE; + return DialerCallState.ACTIVE; case Call.STATE_HOLDING: - return DialerCall.State.ONHOLD; + return DialerCallState.ONHOLD; case Call.STATE_DISCONNECTED: - return DialerCall.State.DISCONNECTED; + return DialerCallState.DISCONNECTED; case Call.STATE_DISCONNECTING: - return DialerCall.State.DISCONNECTING; + return DialerCallState.DISCONNECTING; default: - return DialerCall.State.INVALID; + return DialerCallState.INVALID; } } @@ -570,7 +572,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa videoTech = null; // We want to potentially register a video call callback here. updateFromTelecomCall(); - if (oldState != getState() && getState() == DialerCall.State.DISCONNECTED) { + if (oldState != getState() && getState() == DialerCallState.DISCONNECTED) { for (DialerCallListener listener : listeners) { listener.onDialerCallDisconnect(); } @@ -596,7 +598,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa videoTechManager.dispatchCallStateChanged(telecomCall.getState(), getAccountHandle()); final int translatedState = translateState(telecomCall.getState()); - if (state != State.BLOCKED) { + if (state != DialerCallState.BLOCKED) { setState(translatedState); setDisconnectCause(telecomCall.getDetails().getDisconnectCause()); } @@ -805,7 +807,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa public void blockCall() { telecomCall.reject(false, null); - setState(State.BLOCKED); + setState(DialerCallState.BLOCKED); } @Nullable @@ -846,7 +848,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa public int getState() { if (telecomCall != null && telecomCall.getParent() != null) { - return State.CONFERENCED; + return DialerCallState.CONFERENCED; } else { return state; } @@ -857,9 +859,9 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa } public void setState(int state) { - if (state == State.INCOMING) { + if (state == DialerCallState.INCOMING) { logState.isIncoming = true; - } else if (state == State.DISCONNECTED) { + } else if (state == DialerCallState.DISCONNECTED) { long newDuration = getConnectTimeMillis() == 0 ? 0 : System.currentTimeMillis() - getConnectTimeMillis(); if (this.state != state) { @@ -927,7 +929,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa /** Returns call disconnect cause, defined by {@link DisconnectCause}. */ public DisconnectCause getDisconnectCause() { - if (state == State.DISCONNECTED || state == State.IDLE) { + if (state == DialerCallState.DISCONNECTED || state == DialerCallState.IDLE) { return disconnectCause; } @@ -1146,7 +1148,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa .setCallInitiationType(CallInitiationType.Type.EXTERNAL_INITIATION) .build(); } - if (getState() == State.INCOMING) { + if (getState() == DialerCallState.INCOMING) { logState.callSpecificAppData = logState .callSpecificAppData @@ -1169,7 +1171,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa "[%s, %s, %s, %s, children:%s, parent:%s, " + "conferenceable:%s, videoState:%s, mSessionModificationState:%d, CameraDir:%s]", id, - State.toString(getState()), + DialerCallState.toString(getState()), Details.capabilitiesToString(telecomCall.getDetails().getCallCapabilities()), Details.propertiesToString(telecomCall.getDetails().getCallProperties()), childCallIds, @@ -1366,7 +1368,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa public void disconnect() { LogUtil.i("DialerCall.disconnect", ""); - setState(DialerCall.State.DISCONNECTING); + setState(DialerCallState.DISCONNECTING); for (DialerCallListener listener : listeners) { listener.onDialerCallUpdate(); } @@ -1686,88 +1688,6 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa @Retention(RetentionPolicy.SOURCE) public @interface CallHistoryStatus {} - /* Defines different states of this call */ - public static class State { - - public static final int INVALID = 0; - public static final int NEW = 1; /* The call is new. */ - public static final int IDLE = 2; /* The call is idle. Nothing active */ - public static final int ACTIVE = 3; /* There is an active call */ - public static final int INCOMING = 4; /* A normal incoming phone call */ - public static final int CALL_WAITING = 5; /* Incoming call while another is active */ - public static final int DIALING = 6; /* An outgoing call during dial phase */ - public static final int REDIALING = 7; /* Subsequent dialing attempt after a failure */ - public static final int ONHOLD = 8; /* An active phone call placed on hold */ - public static final int DISCONNECTING = 9; /* A call is being ended. */ - public static final int DISCONNECTED = 10; /* State after a call disconnects */ - public static final int CONFERENCED = 11; /* DialerCall part of a conference call */ - public static final int SELECT_PHONE_ACCOUNT = 12; /* Waiting for account selection */ - public static final int CONNECTING = 13; /* Waiting for Telecom broadcast to finish */ - public static final int BLOCKED = 14; /* The number was found on the block list */ - public static final int PULLING = 15; /* An external call being pulled to the device */ - public static final int CALL_PENDING = 16; /* A call is pending on a long process to finish */ - - public static boolean isConnectingOrConnected(int state) { - switch (state) { - case ACTIVE: - case INCOMING: - case CALL_WAITING: - case CONNECTING: - case DIALING: - case PULLING: - case REDIALING: - case ONHOLD: - case CONFERENCED: - return true; - default: - return false; - } - } - - public static boolean isDialing(int state) { - return state == DIALING || state == PULLING || state == REDIALING; - } - - public static String toString(int state) { - switch (state) { - case INVALID: - return "INVALID"; - case NEW: - return "NEW"; - case IDLE: - return "IDLE"; - case ACTIVE: - return "ACTIVE"; - case INCOMING: - return "INCOMING"; - case CALL_WAITING: - return "CALL_WAITING"; - case DIALING: - return "DIALING"; - case PULLING: - return "PULLING"; - case REDIALING: - return "REDIALING"; - case ONHOLD: - return "ONHOLD"; - case DISCONNECTING: - return "DISCONNECTING"; - case DISCONNECTED: - return "DISCONNECTED"; - case CONFERENCED: - return "CONFERENCED"; - case SELECT_PHONE_ACCOUNT: - return "SELECT_PHONE_ACCOUNT"; - case CONNECTING: - return "CONNECTING"; - case BLOCKED: - return "BLOCKED"; - default: - return "UNKNOWN"; - } - } - } - /** Camera direction constants */ public static class CameraDirection { public static final int CAMERA_DIRECTION_UNKNOWN = -1; diff --git a/java/com/android/incallui/call/state/DialerCallState.java b/java/com/android/incallui/call/state/DialerCallState.java new file mode 100644 index 000000000..266d6d6f7 --- /dev/null +++ b/java/com/android/incallui/call/state/DialerCallState.java @@ -0,0 +1,99 @@ +/* + * 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.incallui.call.state; + +/** Defines different states of {@link com.android.incallui.call.DialerCall} */ +public class DialerCallState { + + public static final int INVALID = 0; + public static final int NEW = 1; /* The call is new. */ + public static final int IDLE = 2; /* The call is idle. Nothing active */ + public static final int ACTIVE = 3; /* There is an active call */ + public static final int INCOMING = 4; /* A normal incoming phone call */ + public static final int CALL_WAITING = 5; /* Incoming call while another is active */ + public static final int DIALING = 6; /* An outgoing call during dial phase */ + public static final int REDIALING = 7; /* Subsequent dialing attempt after a failure */ + public static final int ONHOLD = 8; /* An active phone call placed on hold */ + public static final int DISCONNECTING = 9; /* A call is being ended. */ + public static final int DISCONNECTED = 10; /* State after a call disconnects */ + public static final int CONFERENCED = 11; /* DialerCall part of a conference call */ + public static final int SELECT_PHONE_ACCOUNT = 12; /* Waiting for account selection */ + public static final int CONNECTING = 13; /* Waiting for Telecom broadcast to finish */ + public static final int BLOCKED = 14; /* The number was found on the block list */ + public static final int PULLING = 15; /* An external call being pulled to the device */ + public static final int CALL_PENDING = 16; /* A call is pending on a long process to finish */ + + public static boolean isConnectingOrConnected(int state) { + switch (state) { + case ACTIVE: + case INCOMING: + case CALL_WAITING: + case CONNECTING: + case DIALING: + case PULLING: + case REDIALING: + case ONHOLD: + case CONFERENCED: + return true; + default: + return false; + } + } + + public static boolean isDialing(int state) { + return state == DIALING || state == PULLING || state == REDIALING; + } + + public static String toString(int state) { + switch (state) { + case INVALID: + return "INVALID"; + case NEW: + return "NEW"; + case IDLE: + return "IDLE"; + case ACTIVE: + return "ACTIVE"; + case INCOMING: + return "INCOMING"; + case CALL_WAITING: + return "CALL_WAITING"; + case DIALING: + return "DIALING"; + case PULLING: + return "PULLING"; + case REDIALING: + return "REDIALING"; + case ONHOLD: + return "ONHOLD"; + case DISCONNECTING: + return "DISCONNECTING"; + case DISCONNECTED: + return "DISCONNECTED"; + case CONFERENCED: + return "CONFERENCED"; + case SELECT_PHONE_ACCOUNT: + return "SELECT_PHONE_ACCOUNT"; + case CONNECTING: + return "CONNECTING"; + case BLOCKED: + return "BLOCKED"; + default: + return "UNKNOWN"; + } + } +} |