Loading src/java/com/android/internal/telephony/LocaleTracker.java +1 −1 Original line number Diff line number Diff line Loading @@ -566,7 +566,7 @@ public class LocaleTracker extends Handler { } if (mFeatureFlags.oemEnabledSatelliteFlag()) { TelephonyCountryDetector.getInstance(mPhone.getContext()) TelephonyCountryDetector.getInstance(mPhone.getContext(), mFeatureFlags) .onNetworkCountryCodeChanged(mPhone, countryIso); } Intent intent = new Intent(TelephonyManager.ACTION_NETWORK_COUNTRY_CHANGED); Loading src/java/com/android/internal/telephony/TelephonyCountryDetector.java +38 −3 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.util.Pair; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.flags.FeatureFlags; import java.util.ArrayList; import java.util.HashMap; Loading Loading @@ -109,6 +110,10 @@ public class TelephonyCountryDetector extends Handler { private Map<String, Long> mOverriddenCachedNetworkCountryCodes = new HashMap<>(); @GuardedBy("mLock") private boolean mIsCountryCodesOverridden = false; private final RegistrantList mCountryCodeChangedRegistrants = new RegistrantList(); private FeatureFlags mFeatureFlags = null; @NonNull private final LocationListener mLocationListener = new LocationListener() { @Override public void onLocationChanged(Location location) { Loading Loading @@ -186,22 +191,26 @@ public class TelephonyCountryDetector extends Handler { @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) protected TelephonyCountryDetector(@NonNull Looper looper, @NonNull Context context, @NonNull LocationManager locationManager, @NonNull ConnectivityManager connectivityManager) { @NonNull ConnectivityManager connectivityManager, FeatureFlags featureFlags) { super(looper); mLocationManager = locationManager; mGeocoder = new Geocoder(context); mConnectivityManager = connectivityManager; mFeatureFlags = featureFlags; initialize(); } /** @return the singleton instance of the {@link TelephonyCountryDetector} */ public static synchronized TelephonyCountryDetector getInstance(@NonNull Context context) { public static synchronized TelephonyCountryDetector getInstance(@NonNull Context context, FeatureFlags featureFlags) { if (sInstance == null) { HandlerThread handlerThread = new HandlerThread("TelephonyCountryDetector"); handlerThread.start(); sInstance = new TelephonyCountryDetector(handlerThread.getLooper(), context, context.getSystemService(LocationManager.class), context.getSystemService(ConnectivityManager.class)); context.getSystemService(ConnectivityManager.class), featureFlags); } return sInstance; } Loading Loading @@ -473,6 +482,12 @@ public class TelephonyCountryDetector extends Handler { } } evaluateRequestingLocationUpdates(); if (mFeatureFlags.oemEnabledSatelliteFlag()) { logd("mCountryCodeChangedRegistrants.notifyRegistrants()"); mCountryCodeChangedRegistrants.notifyRegistrants(); } else { logd("mCountryCodeChangedRegistrants.notifyRegistrants() is not called"); } } private void handleEventWifiConnectivityStateChanged() { Loading Loading @@ -587,6 +602,26 @@ public class TelephonyCountryDetector extends Handler { || SystemProperties.getBoolean(BOOT_ALLOW_MOCK_MODEM_PROPERTY, false)); } /** * Register a callback for country code changed events * * @param h Handler to notify * @param what msg.what when the message is delivered * @param obj AsyncResult.userObj when the message is delivered */ public void registerForCountryCodeChanged(Handler h, int what, Object obj) { mCountryCodeChangedRegistrants.add(h, what, obj); } /** * Unregister a callback for country code changed events * * @param h Handler to notifyf */ public void unregisterForCountryCodeChanged(Handler h) { mCountryCodeChangedRegistrants.remove(h); } private static void logd(@NonNull String log) { Rlog.d(TAG, log); } Loading src/java/com/android/internal/telephony/satellite/SatelliteController.java +1 −1 Original line number Diff line number Diff line Loading @@ -570,7 +570,7 @@ public class SatelliteController extends Handler { // to the satellite service and HAL interface. mSatelliteModemInterface = SatelliteModemInterface.make( mContext, this, mFeatureFlags); mCountryDetector = TelephonyCountryDetector.getInstance(context); mCountryDetector = TelephonyCountryDetector.getInstance(context, mFeatureFlags); mCountryDetector.registerForWifiConnectivityStateChanged(this, EVENT_WIFI_CONNECTIVITY_STATE_CHANGED, null); mTelecomManager = mContext.getSystemService(TelecomManager.class); Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyCountryDetectorTest.java +12 −5 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ import android.util.Pair; import androidx.test.ext.junit.runners.AndroidJUnit4; import com.android.internal.annotations.GuardedBy; import com.android.internal.telephony.flags.FeatureFlags; import org.junit.After; import org.junit.Before; Loading @@ -76,6 +77,8 @@ public class TelephonyCountryDetectorTest extends TelephonyTest { LocaleTracker mMockLocaleTracker2; @Mock Location mMockLocation; @Mock Network mMockNetwork; @Mock private FeatureFlags mMockFeatureFlags; @Captor private ArgumentCaptor<LocationListener> mLocationListenerCaptor; Loading Loading @@ -118,8 +121,9 @@ public class TelephonyCountryDetectorTest extends TelephonyTest { when(mLocationManager.getProviders(true)).thenReturn(Arrays.asList("TEST_PROVIDER")); when(mMockFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(true); mCountryDetectorUT = new TestTelephonyCountryDetector( mLooper, mContext, mLocationManager, mConnectivityManager); mLooper, mContext, mLocationManager, mConnectivityManager, mMockFeatureFlags); if (isGeoCoderImplemented()) { verify(mLocationManager).requestLocationUpdates(anyString(), anyLong(), anyFloat(), mLocationListenerCaptor.capture()); Loading @@ -141,8 +145,10 @@ public class TelephonyCountryDetectorTest extends TelephonyTest { clearInvocations(mLocationManager); clearInvocations(mConnectivityManager); when(mMockLocaleTracker.getCurrentCountry()).thenReturn("US"); TelephonyCountryDetector inst1 = TelephonyCountryDetector.getInstance(mContext); TelephonyCountryDetector inst2 = TelephonyCountryDetector.getInstance(mContext); TelephonyCountryDetector inst1 = TelephonyCountryDetector .getInstance(mContext, mMockFeatureFlags); TelephonyCountryDetector inst2 = TelephonyCountryDetector .getInstance(mContext, mMockFeatureFlags); assertEquals(inst1, inst2); if (isGeoCoderImplemented()) { verify(mLocationManager, never()).requestLocationUpdates(anyString(), anyLong(), Loading Loading @@ -386,8 +392,9 @@ public class TelephonyCountryDetectorTest extends TelephonyTest { * @param locationManager The LocationManager instance. */ TestTelephonyCountryDetector(Looper looper, Context context, LocationManager locationManager, ConnectivityManager connectivityManager) { super(looper, context, locationManager, connectivityManager); LocationManager locationManager, ConnectivityManager connectivityManager, FeatureFlags featureFlags) { super(looper, context, locationManager, connectivityManager, featureFlags); } @Override Loading Loading
src/java/com/android/internal/telephony/LocaleTracker.java +1 −1 Original line number Diff line number Diff line Loading @@ -566,7 +566,7 @@ public class LocaleTracker extends Handler { } if (mFeatureFlags.oemEnabledSatelliteFlag()) { TelephonyCountryDetector.getInstance(mPhone.getContext()) TelephonyCountryDetector.getInstance(mPhone.getContext(), mFeatureFlags) .onNetworkCountryCodeChanged(mPhone, countryIso); } Intent intent = new Intent(TelephonyManager.ACTION_NETWORK_COUNTRY_CHANGED); Loading
src/java/com/android/internal/telephony/TelephonyCountryDetector.java +38 −3 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.util.Pair; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.flags.FeatureFlags; import java.util.ArrayList; import java.util.HashMap; Loading Loading @@ -109,6 +110,10 @@ public class TelephonyCountryDetector extends Handler { private Map<String, Long> mOverriddenCachedNetworkCountryCodes = new HashMap<>(); @GuardedBy("mLock") private boolean mIsCountryCodesOverridden = false; private final RegistrantList mCountryCodeChangedRegistrants = new RegistrantList(); private FeatureFlags mFeatureFlags = null; @NonNull private final LocationListener mLocationListener = new LocationListener() { @Override public void onLocationChanged(Location location) { Loading Loading @@ -186,22 +191,26 @@ public class TelephonyCountryDetector extends Handler { @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) protected TelephonyCountryDetector(@NonNull Looper looper, @NonNull Context context, @NonNull LocationManager locationManager, @NonNull ConnectivityManager connectivityManager) { @NonNull ConnectivityManager connectivityManager, FeatureFlags featureFlags) { super(looper); mLocationManager = locationManager; mGeocoder = new Geocoder(context); mConnectivityManager = connectivityManager; mFeatureFlags = featureFlags; initialize(); } /** @return the singleton instance of the {@link TelephonyCountryDetector} */ public static synchronized TelephonyCountryDetector getInstance(@NonNull Context context) { public static synchronized TelephonyCountryDetector getInstance(@NonNull Context context, FeatureFlags featureFlags) { if (sInstance == null) { HandlerThread handlerThread = new HandlerThread("TelephonyCountryDetector"); handlerThread.start(); sInstance = new TelephonyCountryDetector(handlerThread.getLooper(), context, context.getSystemService(LocationManager.class), context.getSystemService(ConnectivityManager.class)); context.getSystemService(ConnectivityManager.class), featureFlags); } return sInstance; } Loading Loading @@ -473,6 +482,12 @@ public class TelephonyCountryDetector extends Handler { } } evaluateRequestingLocationUpdates(); if (mFeatureFlags.oemEnabledSatelliteFlag()) { logd("mCountryCodeChangedRegistrants.notifyRegistrants()"); mCountryCodeChangedRegistrants.notifyRegistrants(); } else { logd("mCountryCodeChangedRegistrants.notifyRegistrants() is not called"); } } private void handleEventWifiConnectivityStateChanged() { Loading Loading @@ -587,6 +602,26 @@ public class TelephonyCountryDetector extends Handler { || SystemProperties.getBoolean(BOOT_ALLOW_MOCK_MODEM_PROPERTY, false)); } /** * Register a callback for country code changed events * * @param h Handler to notify * @param what msg.what when the message is delivered * @param obj AsyncResult.userObj when the message is delivered */ public void registerForCountryCodeChanged(Handler h, int what, Object obj) { mCountryCodeChangedRegistrants.add(h, what, obj); } /** * Unregister a callback for country code changed events * * @param h Handler to notifyf */ public void unregisterForCountryCodeChanged(Handler h) { mCountryCodeChangedRegistrants.remove(h); } private static void logd(@NonNull String log) { Rlog.d(TAG, log); } Loading
src/java/com/android/internal/telephony/satellite/SatelliteController.java +1 −1 Original line number Diff line number Diff line Loading @@ -570,7 +570,7 @@ public class SatelliteController extends Handler { // to the satellite service and HAL interface. mSatelliteModemInterface = SatelliteModemInterface.make( mContext, this, mFeatureFlags); mCountryDetector = TelephonyCountryDetector.getInstance(context); mCountryDetector = TelephonyCountryDetector.getInstance(context, mFeatureFlags); mCountryDetector.registerForWifiConnectivityStateChanged(this, EVENT_WIFI_CONNECTIVITY_STATE_CHANGED, null); mTelecomManager = mContext.getSystemService(TelecomManager.class); Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyCountryDetectorTest.java +12 −5 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ import android.util.Pair; import androidx.test.ext.junit.runners.AndroidJUnit4; import com.android.internal.annotations.GuardedBy; import com.android.internal.telephony.flags.FeatureFlags; import org.junit.After; import org.junit.Before; Loading @@ -76,6 +77,8 @@ public class TelephonyCountryDetectorTest extends TelephonyTest { LocaleTracker mMockLocaleTracker2; @Mock Location mMockLocation; @Mock Network mMockNetwork; @Mock private FeatureFlags mMockFeatureFlags; @Captor private ArgumentCaptor<LocationListener> mLocationListenerCaptor; Loading Loading @@ -118,8 +121,9 @@ public class TelephonyCountryDetectorTest extends TelephonyTest { when(mLocationManager.getProviders(true)).thenReturn(Arrays.asList("TEST_PROVIDER")); when(mMockFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(true); mCountryDetectorUT = new TestTelephonyCountryDetector( mLooper, mContext, mLocationManager, mConnectivityManager); mLooper, mContext, mLocationManager, mConnectivityManager, mMockFeatureFlags); if (isGeoCoderImplemented()) { verify(mLocationManager).requestLocationUpdates(anyString(), anyLong(), anyFloat(), mLocationListenerCaptor.capture()); Loading @@ -141,8 +145,10 @@ public class TelephonyCountryDetectorTest extends TelephonyTest { clearInvocations(mLocationManager); clearInvocations(mConnectivityManager); when(mMockLocaleTracker.getCurrentCountry()).thenReturn("US"); TelephonyCountryDetector inst1 = TelephonyCountryDetector.getInstance(mContext); TelephonyCountryDetector inst2 = TelephonyCountryDetector.getInstance(mContext); TelephonyCountryDetector inst1 = TelephonyCountryDetector .getInstance(mContext, mMockFeatureFlags); TelephonyCountryDetector inst2 = TelephonyCountryDetector .getInstance(mContext, mMockFeatureFlags); assertEquals(inst1, inst2); if (isGeoCoderImplemented()) { verify(mLocationManager, never()).requestLocationUpdates(anyString(), anyLong(), Loading Loading @@ -386,8 +392,9 @@ public class TelephonyCountryDetectorTest extends TelephonyTest { * @param locationManager The LocationManager instance. */ TestTelephonyCountryDetector(Looper looper, Context context, LocationManager locationManager, ConnectivityManager connectivityManager) { super(looper, context, locationManager, connectivityManager); LocationManager locationManager, ConnectivityManager connectivityManager, FeatureFlags featureFlags) { super(looper, context, locationManager, connectivityManager, featureFlags); } @Override Loading