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

Commit b2226765 authored by SongFerng Wang's avatar SongFerng Wang Committed by Android (Google) Code Review
Browse files

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

parents 96dc223f 6f4ceba6
Loading
Loading
Loading
Loading
+18 −3
Original line number Original line Diff line number Diff line
@@ -27,7 +27,6 @@ import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.PersistableBundle;
import android.provider.Telephony;
import android.provider.Telephony;
import android.telephony.CarrierConfigManager;
import android.telephony.CarrierConfigManager;
import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
@@ -1025,7 +1024,7 @@ public class ApnEditor extends SettingsPreferenceFragment
                bearerBitmask = 0;
                bearerBitmask = 0;
                break;
                break;
            } else {
            } else {
                bearerBitmask |= ServiceState.getBitmaskForTech(Integer.parseInt(bearer));
                bearerBitmask |= getBitmaskForTech(Integer.parseInt(bearer));
            }
            }
        }
        }
        callUpdate = setIntValueAndCheckIfDiff(values,
        callUpdate = setIntValueAndCheckIfDiff(values,
@@ -1037,7 +1036,7 @@ public class ApnEditor extends SettingsPreferenceFragment
        int bearerVal;
        int bearerVal;
        if (bearerBitmask == 0 || mBearerInitialVal == 0) {
        if (bearerBitmask == 0 || mBearerInitialVal == 0) {
            bearerVal = 0;
            bearerVal = 0;
        } else if (ServiceState.bitmaskHasTech(bearerBitmask, mBearerInitialVal)) {
        } else if (bitmaskHasTech(bearerBitmask, mBearerInitialVal)) {
            bearerVal = mBearerInitialVal;
            bearerVal = mBearerInitialVal;
        } else {
        } else {
            // bearer field was being used but bitmask has changed now and does not include the
            // bearer field was being used but bitmask has changed now and does not include the
@@ -1329,4 +1328,20 @@ public class ApnEditor extends SettingsPreferenceFragment
            return (String) mData[index];
            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;
    }
}
}