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

Commit 4e665fde authored by Jack Nudelman's avatar Jack Nudelman Committed by Gerrit Code Review
Browse files

Merge changes from topics "VOIMS_OPT_IN", "d2d"

* changes:
  Implement set D2D sharing status API in SubscriptionController.
  Prevent GsmCdmaPhoneTest breaking by permission issue
  Add voims_opt_in_status column in sim info table
parents 4983ffa2 51ee0085
Loading
Loading
Loading
Loading
+39 −1
Original line number Diff line number Diff line
@@ -239,6 +239,17 @@ public class GsmCdmaPhone extends Phone {
        }
    }

    /**
     * Used to create ImsManager instances, which may be injected during testing.
     */
    @VisibleForTesting
    public interface ImsManagerFactory {
        /**
         * Create a new instance of ImsManager for the specified phoneId.
         */
        ImsManager create(Context context, int phoneId);
    }

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private IccSmsInterfaceManager mIccSmsInterfaceManager;

@@ -251,6 +262,8 @@ public class GsmCdmaPhone extends Phone {

    private final SettingsObserver mSettingsObserver;

    private final ImsManagerFactory mImsManagerFactory;

    // Constructors

    public GsmCdmaPhone(Context context, CommandsInterface ci, PhoneNotifier notifier, int phoneId,
@@ -261,12 +274,23 @@ public class GsmCdmaPhone extends Phone {
    public GsmCdmaPhone(Context context, CommandsInterface ci, PhoneNotifier notifier,
                        boolean unitTestMode, int phoneId, int precisePhoneType,
                        TelephonyComponentFactory telephonyComponentFactory) {
        this(context, ci, notifier,
                unitTestMode, phoneId, precisePhoneType,
                telephonyComponentFactory,
                ImsManager::getInstance);
    }

    public GsmCdmaPhone(Context context, CommandsInterface ci, PhoneNotifier notifier,
            boolean unitTestMode, int phoneId, int precisePhoneType,
            TelephonyComponentFactory telephonyComponentFactory,
            ImsManagerFactory imsManagerFactory) {
        super(precisePhoneType == PhoneConstants.PHONE_TYPE_GSM ? "GSM" : "CDMA",
                notifier, context, ci, unitTestMode, phoneId, telephonyComponentFactory);

        // phone type needs to be set before other initialization as other objects rely on it
        mPrecisePhoneType = precisePhoneType;
        mVoiceCallSessionStats = new VoiceCallSessionStats(mPhoneId, this);
        mImsManagerFactory = imsManagerFactory;
        initOnce(ci);
        initRatSpecific(precisePhoneType);
        // CarrierSignalAgent uses CarrierActionAgent in construction so it needs to be created
@@ -4616,4 +4640,18 @@ public class GsmCdmaPhone extends Phone {
                loge("Invalid cdma_roaming_mode settings: " + config_cdma_roaming_mode);
        }
    }

    /**
     * Determines if IMS is enabled for call.
     *
     * @return {@code true} if IMS calling is enabled.
     */
    public boolean isImsUseEnabled() {
        ImsManager imsManager = mImsManagerFactory.create(mContext, mPhoneId);
        boolean imsUseEnabled = ((imsManager.isVolteEnabledByPlatform()
                && imsManager.isEnhanced4gLteModeSettingEnabledByUser())
                || (imsManager.isWfcEnabledByPlatform() && imsManager.isWfcEnabledByUser())
                && imsManager.isNonTtyOrTtyOnVolteEnabled());
        return imsUseEnabled;
    }
}
+0 −14
Original line number Diff line number Diff line
@@ -4364,20 +4364,6 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        mCi.unregisterForRadioCapabilityChanged(this);
    }

    /**
     * Determines if  IMS is enabled for call.
     *
     * @return {@code true} if IMS calling is enabled.
     */
    public boolean isImsUseEnabled() {
        ImsManager imsManager = ImsManager.getInstance(mContext, mPhoneId);
        boolean imsUseEnabled = ((imsManager.isVolteEnabledByPlatform()
                && imsManager.isEnhanced4gLteModeSettingEnabledByUser())
                || (imsManager.isWfcEnabledByPlatform() && imsManager.isWfcEnabledByUser())
                && imsManager.isNonTtyOrTtyOnVolteEnabled());
        return imsUseEnabled;
    }

    /**
     * Determines if the connection to IMS services are available yet.
     * @return {@code true} if the connection to IMS services are available.
+40 −0
Original line number Diff line number Diff line
@@ -2101,6 +2101,43 @@ public class SubscriptionController extends ISub.Stub {
        }
    }

    /**
     * Set device to device status sharing preference
     * @param sharing the sharing preference to set
     * @param subId
     * @return the number of records updated
     */
    @Override
    public int setDeviceToDeviceStatusSharing(int sharing, int subId) {
        if (DBG) logd("[setDeviceToDeviceStatusSharing]- sharing:" + sharing + " subId:" + subId);

        enforceModifyPhoneState("setDeviceToDeviceStatusSharing");

        // Now that all security checks passes, perform the operation as ourselves.
        final long identity = Binder.clearCallingIdentity();
        try {
            validateSubId(subId);
            if (sharing < 0) {
                if (DBG) logd("[setDeviceToDeviceStatusSharing]- fail");
                return -1;
            }
            ContentValues value = new ContentValues(1);
            value.put(SubscriptionManager.D2D_STATUS_SHARING, sharing);
            if (DBG) logd("[setDeviceToDeviceStatusSharing]- sharing:" + sharing + " set");

            int result = updateDatabase(value, subId, true);

            // Refresh the Cache of Active Subscription Info List
            refreshCachedActiveSubscriptionInfoList();

            notifySubscriptionInfoChanged();

            return result;
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
    }

    public void syncGroupedSetting(int refSubId) {
        logd("syncGroupedSetting");
        try (Cursor cursor = mContext.getContentResolver().query(
@@ -3039,6 +3076,7 @@ public class SubscriptionController extends ISub.Stub {
            case SubscriptionManager.WFC_IMS_ROAMING_ENABLED:
            case SubscriptionManager.IMS_RCS_UCE_ENABLED:
            case SubscriptionManager.CROSS_SIM_CALLING_ENABLED:
            case SubscriptionManager.VOIMS_OPT_IN_STATUS:
                value.put(propKey, Integer.parseInt(propValue));
                break;
            case SubscriptionManager.ALLOWED_NETWORK_TYPES:
@@ -3116,6 +3154,8 @@ public class SubscriptionController extends ISub.Stub {
                        case SubscriptionManager.GROUP_UUID:
                        case SubscriptionManager.DATA_ENABLED_OVERRIDE_RULES:
                        case SubscriptionManager.ALLOWED_NETWORK_TYPES:
                        case SubscriptionManager.VOIMS_OPT_IN_STATUS:
                        case SubscriptionManager.D2D_STATUS_SHARING:
                            resultValue = cursor.getString(0);
                            break;
                        default:
+2 −1
Original line number Diff line number Diff line
@@ -115,7 +115,8 @@ public class FakeTelephonyProvider extends MockContentProvider {
                    + Telephony.SimInfo.COLUMN_ALLOWED_NETWORK_TYPES + " BIGINT DEFAULT -1,"
                    + Telephony.SimInfo.COLUMN_IMS_RCS_UCE_ENABLED + " INTEGER DEFAULT 0, "
                    + Telephony.SimInfo.COLUMN_RCS_CONFIG + " BLOB,"
                    + Telephony.SimInfo.COLUMN_ALLOWED_NETWORK_TYPES_FOR_REASONS + " TEXT"
                    + Telephony.SimInfo.COLUMN_ALLOWED_NETWORK_TYPES_FOR_REASONS + " TEXT,"
                    + Telephony.SimInfo.COLUMN_D2D_STATUS_SHARING + " INTEGER DEFAULT 0"
                    + ");";
        }

+4 −2
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ import android.testing.TestableLooper;

import androidx.test.filters.FlakyTest;

import com.android.ims.ImsManager;
import com.android.internal.telephony.test.SimulatedCommands;
import com.android.internal.telephony.test.SimulatedCommandsVerifier;
import com.android.internal.telephony.uicc.IccCardApplicationStatus;
@@ -133,9 +134,10 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        super.setUp(getClass().getSimpleName());

        doReturn(false).when(mSST).isDeviceShuttingDown();
        doReturn(true).when(mImsManager).isVolteEnabledByPlatform();

        mPhoneUT = new GsmCdmaPhone(mContext, mSimulatedCommands, mNotifier, true, 0,
            PhoneConstants.PHONE_TYPE_GSM, mTelephonyComponentFactory);
            PhoneConstants.PHONE_TYPE_GSM, mTelephonyComponentFactory, (c, p) -> mImsManager);
        mPhoneUT.setVoiceCallSessionStats(mVoiceCallSessionStats);
        ArgumentCaptor<Integer> integerArgumentCaptor = ArgumentCaptor.forClass(Integer.class);
        verify(mUiccController).registerForIccChanged(eq(mPhoneUT), integerArgumentCaptor.capture(),
@@ -998,7 +1000,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        };

        Phone phone = new GsmCdmaPhone(mContext, sc, mNotifier, true, 0,
                PhoneConstants.PHONE_TYPE_GSM, mTelephonyComponentFactory);
                PhoneConstants.PHONE_TYPE_GSM, mTelephonyComponentFactory, (c, p) -> mImsManager);
        phone.setVoiceCallSessionStats(mVoiceCallSessionStats);
        ArgumentCaptor<Integer> integerArgumentCaptor = ArgumentCaptor.forClass(Integer.class);
        verify(mUiccController).registerForIccChanged(eq(phone), integerArgumentCaptor.capture(),