Clean up MobileNetworkInfoEntity unused fields

It's safe since MobileNetworkDatabase is in memory only.

Bug: 348118234
Flag: EXEMPT clean up
Test: manual - check Mobile Settings
Change-Id: I25141a87b9afb42b85d73cbcd7307b899b3f0a3b
This commit is contained in:
Chaohui Wang
2024-06-27 17:30:19 +08:00
parent af053aa3cc
commit b8ad25f8bd
2 changed files with 9 additions and 29 deletions

View File

@@ -41,7 +41,6 @@ import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.LifecycleOwner;
import com.android.internal.telephony.flags.Flags; import com.android.internal.telephony.flags.Flags;
import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.mobile.dataservice.MobileNetworkDatabase; import com.android.settingslib.mobile.dataservice.MobileNetworkDatabase;
@@ -435,7 +434,7 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
mMetricsFeatureProvider.action(mContext, mMetricsFeatureProvider.action(mContext,
SettingsEnums.ACTION_MOBILE_NETWORK_DB_INSERT_SUB_INFO, subId); SettingsEnums.ACTION_MOBILE_NETWORK_DB_INSERT_SUB_INFO, subId);
insertUiccInfo(subId, telephonyManager); insertUiccInfo(subId, telephonyManager);
insertMobileNetworkInfo(context, subId, telephonyManager); insertMobileNetworkInfo(subId, telephonyManager);
} }
} else if (DEBUG) { } else if (DEBUG) {
Log.d(TAG, "Can not insert subInfo, the entity is null"); Log.d(TAG, "Can not insert subInfo, the entity is null");
@@ -517,20 +516,13 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
} }
} }
private void insertMobileNetworkInfo(Context context, int subId, private void insertMobileNetworkInfo(int subId, TelephonyManager telephonyManager) {
TelephonyManager telephonyManager) { MobileNetworkInfoEntity mobileNetworkInfoEntity =
MobileNetworkInfoEntity mobileNetworkInfoEntity = convertToMobileNetworkInfoEntity(context, convertToMobileNetworkInfoEntity(subId, telephonyManager);
subId, telephonyManager);
Log.d(TAG, "insertMobileNetworkInfo, mobileNetworkInfoEntity = " Log.d(TAG, "insertMobileNetworkInfo, mobileNetworkInfoEntity = "
+ mobileNetworkInfoEntity); + mobileNetworkInfoEntity);
if (mobileNetworkInfoEntity == null) {
return;
}
if (!sCacheMobileNetworkInfoEntityMap.containsKey(subId) if (!sCacheMobileNetworkInfoEntityMap.containsKey(subId)
|| !sCacheMobileNetworkInfoEntityMap.get(subId).equals(mobileNetworkInfoEntity)) { || !sCacheMobileNetworkInfoEntityMap.get(subId).equals(mobileNetworkInfoEntity)) {
sCacheMobileNetworkInfoEntityMap.put(subId, mobileNetworkInfoEntity); sCacheMobileNetworkInfoEntityMap.put(subId, mobileNetworkInfoEntity);
@@ -540,7 +532,7 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
} }
} }
private MobileNetworkInfoEntity convertToMobileNetworkInfoEntity(Context context, int subId, private MobileNetworkInfoEntity convertToMobileNetworkInfoEntity(int subId,
TelephonyManager telephonyManager) { TelephonyManager telephonyManager) {
boolean isDataEnabled = false; boolean isDataEnabled = false;
if (telephonyManager != null) { if (telephonyManager != null) {
@@ -549,18 +541,8 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
Log.d(TAG, "TelephonyManager is null, subId = " + subId); Log.d(TAG, "TelephonyManager is null, subId = " + subId);
} }
return new MobileNetworkInfoEntity(String.valueOf(subId), return new MobileNetworkInfoEntity(String.valueOf(subId), isDataEnabled,
MobileNetworkUtils.isContactDiscoveryEnabled(context, subId), SubscriptionUtil.showToggleForPhysicalSim(mSubscriptionManager)
MobileNetworkUtils.isContactDiscoveryVisible(context, subId),
isDataEnabled,
MobileNetworkUtils.isCdmaOptions(context, subId),
MobileNetworkUtils.isGsmOptions(context, subId),
MobileNetworkUtils.isWorldMode(context, subId),
MobileNetworkUtils.shouldDisplayNetworkSelectOptions(context, subId),
MobileNetworkUtils.isTdscdmaSupported(context, subId),
MobileNetworkUtils.activeNetworkIsCellular(context),
SubscriptionUtil.showToggleForPhysicalSim(mSubscriptionManager),
/* deprecated isDataRoamingEnabled = */ false
); );
} }
@@ -681,8 +663,7 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
public void onUserMobileDataStateChanged(boolean enabled) { public void onUserMobileDataStateChanged(boolean enabled) {
Log.d(TAG, "onUserMobileDataStateChanged enabled " + enabled + " on SUB " + mSubId); Log.d(TAG, "onUserMobileDataStateChanged enabled " + enabled + " on SUB " + mSubId);
sExecutor.execute(() -> { sExecutor.execute(() -> {
insertMobileNetworkInfo(mContext, mSubId, insertMobileNetworkInfo(mSubId, getTelephonyManagerBySubId(mContext, mSubId));
getTelephonyManagerBySubId(mContext, mSubId));
}); });
} }
} }

View File

@@ -131,8 +131,7 @@ public class MobileDataPreferenceControllerTest {
private MobileNetworkInfoEntity setupMobileNetworkInfoEntity(String subId, private MobileNetworkInfoEntity setupMobileNetworkInfoEntity(String subId,
boolean isDatEnabled) { boolean isDatEnabled) {
return new MobileNetworkInfoEntity(subId, false, false, isDatEnabled, false, false, false, return new MobileNetworkInfoEntity(subId, isDatEnabled, false);
false, false, false, false, false);
} }
@Test @Test