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

Commit e0f10817 authored by Bonian Chen's avatar Bonian Chen
Browse files

[Settings] IMS feature checking before accessing VT IMS API

Check IMS feature before accessing VT IMS API.o

Bug: 231248315
Test: local
Change-Id: I01b438cc79bb91ca05ba6bf57c7e38eb06e51a98
parent a82a1ff8
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.settings.network.telephony;

import android.content.Context;
import android.content.pm.PackageManager;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
@@ -129,6 +130,12 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
        return queryImsState(mSubId).isEnabledByUser();
    }

    @VisibleForTesting
    protected boolean isImsSupported() {
        return mContext.getPackageManager().hasSystemFeature(
                PackageManager.FEATURE_TELEPHONY_IMS);
    }

    public VideoCallingPreferenceController init(int subId) {
        mSubId = subId;

@@ -154,7 +161,7 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
            return false;
        }

        return queryImsState(subId).isReadyToVideoCall();
        return isImsSupported() && queryImsState(subId).isReadyToVideoCall();
    }

    @Override
+1 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ public class VideoCallingPreferenceControllerTest {
        mController.init(SUB_ID);
        doReturn(mQueryImsState).when(mController).queryImsState(anyInt());
        doReturn(mQueryVoLteState).when(mController).queryVoLteState(anyInt());
        doReturn(true).when(mController).isImsSupported();
        mPreference.setKey(mController.getPreferenceKey());

        mQueryImsState.setIsEnabledByPlatform(true);