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

Commit 6a4e9d87 authored by Sailesh Nepal's avatar Sailesh Nepal
Browse files

Remove Lollipop support for InCallUI

This CL removes support for running dialer on Android L MR1.
The change allows us to switch from the system SDK to the public SDK.

This is useful for the following reasons:
  - makes it easier to switch to gradle
  - makes it easier to migrate GoogleDialer to google3
  - reduces maintenance overhead for unused code

Currently there's no plan to release Dialer on Lollipop. If or when
we decide to support Lollipop we can consider switching back to the
system SDK and restoring the comapatiblity code.

Bug: 26676586
Change-Id: Idac9e6e19f1d21c9261c1b0d0ff3e3ca4aab980b
parent ff1528ec
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -64,9 +64,7 @@ LOCAL_PRIVILEGED_MODULE := true

LOCAL_PROGUARD_FLAG_FILES := proguard.flags $(incallui_dir)/proguard.flags

# Uncomment the following line to build against the current SDK
# This is required for building an unbundled app.
LOCAL_SDK_VERSION := system_current
LOCAL_SDK_VERSION := current

include $(BUILD_PACKAGE)

+9 −99
Original line number Diff line number Diff line
@@ -19,9 +19,9 @@ package com.android.incallui;
import android.content.Context;
import android.hardware.camera2.CameraCharacteristics;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Trace;
import android.telecom.Call.Details;
import android.telecom.Connection;
import android.telecom.DisconnectCause;
import android.telecom.GatewayInfo;
@@ -37,8 +37,6 @@ import com.android.contacts.common.compat.SdkVersionOverride;
import com.android.contacts.common.compat.telecom.TelecomManagerCompat;
import com.android.contacts.common.testing.NeededForTesting;
import com.android.dialer.util.IntentUtil;
import com.android.incallui.compat.telecom.DetailsCompat;
import com.android.incallui.compat.telecom.VideoProfileCompat;
import com.android.incallui.util.TelecomCallUtil;

import java.util.ArrayList;
@@ -291,18 +289,8 @@ public class Call {
    private static final String ID_PREFIX = Call.class.getSimpleName() + "_";
    private static int sIdCounter = 0;

    private Object mTelecomCallCallback = newTelecomCallCallback();

    private Object newTelecomCallCallback() {
        if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M) >= Build.VERSION_CODES.M) {
            return newMarshmallowTelecomCallCallback();
        }
        return newLollipopTelecomCallCallback();
    }

    private Object newMarshmallowTelecomCallCallback() {
        Log.i(this, "Using an android.telecom.Call$Callback");
        return new android.telecom.Call.Callback() {
    private final android.telecom.Call.Callback mTelecomCallCallback =
        new android.telecom.Call.Callback() {
            @Override
            public void onStateChanged(android.telecom.Call call, int newState) {
                Log.d(this, "TelecomCallCallback onStateChanged call=" + call + " newState="
@@ -368,80 +356,6 @@ public class Call {
                update();
            }
    };
    }

    private Object newLollipopTelecomCallCallback() {
        // This code only runs for Google Experience phones on the pre-M sdk since only the system
        // dialer can invoke the InCallUI code. This allows us to safely use the
        // android.telecom.Call.Listener interface
        Log.i(this, "Using an android.telecom.Call$Listener");
        return new android.telecom.Call.Listener() {
            @Override
            public void onStateChanged(android.telecom.Call call, int newState) {
                Log.d(this, "TelecomCallCallback onStateChanged call=" + call + " newState="
                        + newState);
                update();
            }

            @Override
            public void onParentChanged(android.telecom.Call call,
                    android.telecom.Call newParent) {
                Log.d(this, "TelecomCallCallback onParentChanged call=" + call + " newParent="
                        + newParent);
                update();
            }

            @Override
            public void onChildrenChanged(android.telecom.Call call,
                    List<android.telecom.Call> children) {
                update();
            }

            @Override
            public void onDetailsChanged(android.telecom.Call call,
                    android.telecom.Call.Details details) {
                Log.d(this, "TelecomCallCallback onStateChanged call=" + call + " details="
                        + details);
                update();
            }

            @Override
            public void onCannedTextResponsesLoaded(android.telecom.Call call,
                    List<String> cannedTextResponses) {
                Log.d(this, "TelecomCallCallback onStateChanged call=" + call
                        + " cannedTextResponses=" + cannedTextResponses);
                update();
            }

            @Override
            public void onPostDialWait(android.telecom.Call call,
                    String remainingPostDialSequence) {
                Log.d(this, "TelecomCallCallback onStateChanged call=" + call
                        + " remainingPostDialSequence=" + remainingPostDialSequence);
                update();
            }

            @Override
            public void onVideoCallChanged(android.telecom.Call call,
                    VideoCall videoCall) {
                Log.d(this, "TelecomCallCallback onStateChanged call=" + call + " videoCall="
                        + videoCall);
                update();
            }

            @Override
            public void onCallDestroyed(android.telecom.Call call) {
                Log.d(this, "TelecomCallCallback onStateChanged call=" + call);
                call.removeListener(this);
            }

            @Override
            public void onConferenceableCallsChanged(android.telecom.Call call,
                    List<android.telecom.Call> conferenceableCalls) {
                update();
            }
        };
    }

    private android.telecom.Call mTelecomCall;
    private boolean mIsEmergencyCall;
@@ -491,11 +405,7 @@ public class Call {

        updateFromTelecomCall();

        if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M) >= Build.VERSION_CODES.M) {
            mTelecomCall.registerCallback((android.telecom.Call.Callback) mTelecomCallCallback);
        } else {
            mTelecomCall.addListener((android.telecom.Call.Listener) mTelecomCallCallback);
        }
        mTelecomCall.registerCallback(mTelecomCallCallback);

        mTimeAddedMs = System.currentTimeMillis();
    }
@@ -750,7 +660,7 @@ public class Call {
    }

    public Bundle getIntentExtras() {
        return DetailsCompat.getIntentExtras(mTelecomCall.getDetails());
        return mTelecomCall.getDetails().getIntentExtras();
    }

    public Bundle getExtras() {
@@ -824,7 +734,7 @@ public class Call {
    }

    public boolean hasProperty(int property) {
        return DetailsCompat.hasProperty(mTelecomCall.getDetails(), property);
        return mTelecomCall.getDetails().hasProperty(property);
    }

    /** Gets the time when the call first became active. */
@@ -989,11 +899,11 @@ public class Call {
                "videoState:%s, mSessionModificationState:%d, VideoSettings:%s]",
                mId,
                State.toString(getState()),
                DetailsCompat.capabilitiesToString(mTelecomCall.getDetails().getCallCapabilities()),
                Details.capabilitiesToString(mTelecomCall.getDetails().getCallCapabilities()),
                mChildCallIds,
                getParentId(),
                this.mTelecomCall.getConferenceableCalls(),
                VideoProfileCompat.videoStateToString(mTelecomCall.getDetails().getVideoState()),
                VideoProfile.videoStateToString(mTelecomCall.getDetails().getVideoState()),
                mSessionModificationState,
                getVideoSettings());
    }
+1 −1
Original line number Diff line number Diff line
@@ -380,7 +380,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
                && call.can(android.telecom.Call.Details.CAPABILITY_HOLD);
        final boolean isCallOnHold = call.getState() == Call.State.ONHOLD;

        final boolean showAddCall = TelecomAdapter.getInstance().canAddCall(call)
        final boolean showAddCall = TelecomAdapter.getInstance().canAddCall()
                && UserManagerCompat.isUserUnlocked(ui.getContext());
        final boolean showMerge = call.can(
                android.telecom.Call.Details.CAPABILITY_MERGE_CONFERENCE);
+3 −4
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ import com.android.incallui.InCallPresenter.InCallEventListener;
import com.android.incallui.InCallPresenter.InCallState;
import com.android.incallui.InCallPresenter.InCallStateListener;
import com.android.incallui.InCallPresenter.IncomingCallListener;
import com.android.incallui.compat.telecom.DetailsCompat;
import com.android.incalluibind.ObjectFactory;

import java.lang.ref.WeakReference;
@@ -345,7 +344,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
        updatePrimaryCallState();

        if (call.can(Details.CAPABILITY_MANAGE_CONFERENCE) !=
                DetailsCompat.can(details, Details.CAPABILITY_MANAGE_CONFERENCE)) {
                details.can(Details.CAPABILITY_MANAGE_CONFERENCE)) {
            maybeShowManageConferenceCallButton();
        }
    }
@@ -1112,8 +1111,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
    }

    private static boolean hasCallSubject(Call call) {
        return !TextUtils.isEmpty(DetailsCompat.getIntentExtras(
                call.getTelecomCall().getDetails()).getString(TelecomManager.EXTRA_CALL_SUBJECT));
        return !TextUtils.isEmpty(call.getTelecomCall().getDetails().getIntentExtras()
                .getString(TelecomManager.EXTRA_CALL_SUBJECT));
    }

    public interface CallCardUi extends Ui {
+2 −4
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import com.android.contacts.common.compat.PhoneNumberUtilsCompat;
import com.android.contacts.common.preference.ContactsPreferences;
import com.android.contacts.common.util.ContactDisplayUtils;
import com.android.incallui.ContactInfoCache.ContactCacheEntry;
import com.android.incallui.compat.telecom.DetailsCompat;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -356,10 +355,9 @@ public class ConferenceParticipantListAdapter extends BaseAdapter {
                    new ContactLookupCallback(this));
        }

        boolean thisRowCanSeparate = mParentCanSeparate && DetailsCompat.can(
                call.getTelecomCall().getDetails(),
        boolean thisRowCanSeparate = mParentCanSeparate && call.getTelecomCall().getDetails().can(
                android.telecom.Call.Details.CAPABILITY_SEPARATE_FROM_CONFERENCE);
        boolean thisRowCanDisconnect = DetailsCompat.can(call.getTelecomCall().getDetails(),
        boolean thisRowCanDisconnect = call.getTelecomCall().getDetails().can(
                android.telecom.Call.Details.CAPABILITY_DISCONNECT_FROM_CONFERENCE);

        setCallerInfoForRow(result, contactCache.namePrimary,
Loading