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

Commit ecce3962 authored by SongFerng Wang's avatar SongFerng Wang Committed by Gerrit Code Review
Browse files

Merge "[mainline] Decouple ServiceState.bitmaskHasTech and getBitmaskForTech"

parents d1489d2f c13da874
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import android.os.Bundle;
import android.os.PersistableBundle;
import android.provider.Telephony;
import android.telephony.CarrierConfigManager;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -1000,7 +999,7 @@ public class ApnEditor extends SettingsPreferenceFragment
                bearerBitmask = 0;
                break;
            } else {
                bearerBitmask |= ServiceState.getBitmaskForTech(Integer.parseInt(bearer));
                bearerBitmask |= getBitmaskForTech(Integer.parseInt(bearer));
            }
        }
        callUpdate = setIntValueAndCheckIfDiff(values,
@@ -1012,7 +1011,7 @@ public class ApnEditor extends SettingsPreferenceFragment
        int bearerVal;
        if (bearerBitmask == 0 || mBearerInitialVal == 0) {
            bearerVal = 0;
        } else if (ServiceState.bitmaskHasTech(bearerBitmask, mBearerInitialVal)) {
        } else if (bitmaskHasTech(bearerBitmask, mBearerInitialVal)) {
            bearerVal = mBearerInitialVal;
        } else {
            // bearer field was being used but bitmask has changed now and does not include the
@@ -1304,4 +1303,20 @@ public class ApnEditor extends SettingsPreferenceFragment
            return (String) mData[index];
        }
    }

    private static int getBitmaskForTech(int radioTech) {
        if (radioTech >= 1) {
            return (1 << (radioTech - 1));
        }
        return 0;
    }

    private static boolean bitmaskHasTech(int bearerBitmask, int radioTech) {
        if (bearerBitmask == 0) {
            return true;
        } else if (radioTech >= 1) {
            return ((bearerBitmask & (1 << (radioTech - 1))) != 0);
        }
        return false;
    }
}