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

Commit 771c4e9e authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10929702 from f3a6e1ba to 24Q1-release

Change-Id: I67fcb8b17dbd5dc46fd4cf7e0f6f332010988120
parents 1b4069d6 f3a6e1ba
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ android_app {
    static_libs: [
        "androidx.annotation_annotation",
        "androidx.core_core",
        "telecom_flags-lib",
        "telecom_flags_core_java_lib",
    ],
    libs: [
        "services",
@@ -62,7 +62,7 @@ android_test {
        "androidx.fragment_fragment",
        "androidx.test.ext.junit",
        "platform-compat-test-rules",
        "telecom_flags-lib",
        "telecom_flags_core_java_lib",
    ],
    srcs: [
        "tests/src/**/*.java",
+0 −5
Original line number Diff line number Diff line
@@ -31,8 +31,3 @@ aconfig_declarations {
      "telecom_callaudioroutestatemachine_flags.aconfig"
    ],
}

java_aconfig_library {
    name: "telecom_flags-lib",
    aconfig_declarations: "telecom_flags"
}
 No newline at end of file
+7 −0
Original line number Diff line number Diff line
package: "com.android.server.telecom.flags"

flag {
  name: "only_update_telephony_on_valid_sub_ids"
  namespace: "telecom"
  description: "For testing purposes, only update Telephony when the default calling subId is non-zero"
  bug: "234846282"
}

flag {
  name: "telephony_has_default_but_telecom_does_not"
  namespace: "telecom"
+47 −10
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.XmlUtils;
import com.android.modules.utils.ModifiedUtf8;
import com.android.server.telecom.flags.Flags;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -389,10 +390,28 @@ public class PhoneAccountRegistrar {
                            account.getGroupId()));
        }

        // Potentially update the default voice subid in SubscriptionManager.
        // Potentially update the default voice subid in SubscriptionManager so that Telephony and
        // Telecom are in sync.
        int newSubId = accountHandle == null ? SubscriptionManager.INVALID_SUBSCRIPTION_ID :
                getSubscriptionIdForPhoneAccount(accountHandle);
        if (Flags.onlyUpdateTelephonyOnValidSubIds()) {
            if (shouldUpdateTelephonyDefaultVoiceSubId(accountHandle, isSimAccount, newSubId)) {
                updateDefaultVoiceSubId(newSubId, accountHandle);
            } else {
                Log.i(this, "setUserSelectedOutgoingPhoneAccount: %s is not a sub", accountHandle);
            }
        } else {
            if (isSimAccount || accountHandle == null) {
                updateDefaultVoiceSubId(newSubId, accountHandle);
            } else {
                Log.i(this, "setUserSelectedOutgoingPhoneAccount: %s is not a sub", accountHandle);
            }
        }
        write();
        fireDefaultOutgoingChanged();
    }

    private void updateDefaultVoiceSubId(int newSubId, PhoneAccountHandle accountHandle){
        int currentVoiceSubId = mSubscriptionManager.getDefaultVoiceSubscriptionId();
        if (newSubId != currentVoiceSubId) {
            Log.i(this, "setUserSelectedOutgoingPhoneAccount: update voice sub; "
@@ -401,12 +420,30 @@ public class PhoneAccountRegistrar {
        } else {
            Log.i(this, "setUserSelectedOutgoingPhoneAccount: no change to voice sub");
        }
        } else {
            Log.i(this, "setUserSelectedOutgoingPhoneAccount: %s is not a sub", accountHandle);
    }

        write();
        fireDefaultOutgoingChanged();
    // This helper is important for CTS testing.  [PhoneAccount]s created by Telecom in CTS are
    // assigned a  subId value of INVALID_SUBSCRIPTION_ID (-1) by Telephony.  However, when
    // Telephony has a default outgoing calling voice account of -1, that translates to no default
    // account (user should be prompted to select an acct when making MOs).  In order to avoid
    // Telephony clearing out the newly changed default [PhoneAccount] in Telecom, Telephony should
    // not be updated. This situation will never occur in production since [PhoneAccount]s in
    // production are assigned non-negative subId values.
    private boolean shouldUpdateTelephonyDefaultVoiceSubId(PhoneAccountHandle phoneAccountHandle,
            boolean isSimAccount, int newSubId) {
        // user requests no call preference
        if (phoneAccountHandle == null) {
            return true;
        }
        // do not update Telephony if the newSubId is invalid
        if (newSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
            Log.w(this, "shouldUpdateTelephonyDefaultVoiceSubId: "
                            + "invalid subId scenario, not updating Telephony. "
                            + "phoneAccountHandle=[%s], isSimAccount=[%b], newSubId=[%s]",
                    phoneAccountHandle, isSimAccount, newSubId);
            return false;
        }
        return isSimAccount;
    }

    boolean isUserSelectedSmsPhoneAccount(PhoneAccountHandle accountHandle) {