|
|
@@ -33,6 +33,7 @@ import android.telephony.TelephonyManager;
|
|
|
|
import android.telephony.UiccCardInfo;
|
|
|
|
import android.telephony.UiccCardInfo;
|
|
|
|
import android.telephony.UiccPortInfo;
|
|
|
|
import android.telephony.UiccPortInfo;
|
|
|
|
import android.telephony.UiccSlotInfo;
|
|
|
|
import android.telephony.UiccSlotInfo;
|
|
|
|
|
|
|
|
import android.util.ArrayMap;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
|
|
import com.android.settings.network.telephony.MobileNetworkUtils;
|
|
|
|
import com.android.settings.network.telephony.MobileNetworkUtils;
|
|
|
@@ -49,7 +50,7 @@ import com.android.settingslib.mobile.dataservice.UiccInfoEntity;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Optional;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -63,6 +64,7 @@ import androidx.lifecycle.Observer;
|
|
|
|
public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptionsChangedListener {
|
|
|
|
public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptionsChangedListener {
|
|
|
|
|
|
|
|
|
|
|
|
private static final String TAG = "MobileNetworkRepository";
|
|
|
|
private static final String TAG = "MobileNetworkRepository";
|
|
|
|
|
|
|
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
|
|
|
|
|
|
|
|
|
|
|
private final ExecutorService mExecutor = Executors.newSingleThreadExecutor();
|
|
|
|
private final ExecutorService mExecutor = Executors.newSingleThreadExecutor();
|
|
|
|
|
|
|
|
|
|
|
@@ -92,6 +94,7 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
|
|
|
private boolean mIsEuicc = false;
|
|
|
|
private boolean mIsEuicc = false;
|
|
|
|
private boolean mIsRemovable = false;
|
|
|
|
private boolean mIsRemovable = false;
|
|
|
|
private boolean mIsActive = false;
|
|
|
|
private boolean mIsActive = false;
|
|
|
|
|
|
|
|
private Map<Integer, SubscriptionInfo> mSubscriptionInfoMap = new ArrayMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
public static MobileNetworkRepository create(Context context,
|
|
|
|
public static MobileNetworkRepository create(Context context,
|
|
|
|
MobileNetworkCallback mobileNetworkCallback) {
|
|
|
|
MobileNetworkCallback mobileNetworkCallback) {
|
|
|
@@ -157,7 +160,6 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void removeRegister() {
|
|
|
|
public void removeRegister() {
|
|
|
|
mSubscriptionManager.removeOnSubscriptionsChangedListener(this);
|
|
|
|
|
|
|
|
mAirplaneModeObserver.unRegister(mContext);
|
|
|
|
mAirplaneModeObserver.unRegister(mContext);
|
|
|
|
mContext.getContentResolver().unregisterContentObserver(mAirplaneModeObserver);
|
|
|
|
mContext.getContentResolver().unregisterContentObserver(mAirplaneModeObserver);
|
|
|
|
if (mDataSubscriptionChangedReceiver != null) {
|
|
|
|
if (mDataSubscriptionChangedReceiver != null) {
|
|
|
@@ -234,15 +236,16 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
|
|
|
mIsActive = portInfo.isActive();
|
|
|
|
mIsActive = portInfo.isActive();
|
|
|
|
mPortIndex = portInfo.getPortIndex();
|
|
|
|
mPortIndex = portInfo.getPortIndex();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
} else if (DEBUG) {
|
|
|
|
Log.d(TAG,
|
|
|
|
Log.d(TAG,
|
|
|
|
"Can not get port index and physicalSlotIndex for subId " + mSubId);
|
|
|
|
"Can not get port index and physicalSlotIndex for subId "
|
|
|
|
|
|
|
|
+ mSubId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mPhysicalSlotIndex != SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
|
|
|
|
if (mPhysicalSlotIndex != SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else if (DEBUG) {
|
|
|
|
Log.d(TAG, "Can not get card state info");
|
|
|
|
Log.d(TAG, "Can not get card state info");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -257,8 +260,10 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
|
|
|
.filter(SubscriptionInfoEntity::isActiveSubscription)
|
|
|
|
.filter(SubscriptionInfoEntity::isActiveSubscription)
|
|
|
|
.filter(SubscriptionInfoEntity::isSubscriptionVisible)
|
|
|
|
.filter(SubscriptionInfoEntity::isSubscriptionVisible)
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
Log.d(TAG, "onAvailableSubInfoChanged, availableSubInfoEntityList = "
|
|
|
|
if (DEBUG) {
|
|
|
|
+ availableSubInfoEntityList);
|
|
|
|
Log.d(TAG, "onAvailableSubInfoChanged, availableSubInfoEntityList = "
|
|
|
|
|
|
|
|
+ availableSubInfoEntityList);
|
|
|
|
|
|
|
|
}
|
|
|
|
mCallback.onAvailableSubInfoChanged(availableSubInfoEntityList);
|
|
|
|
mCallback.onAvailableSubInfoChanged(availableSubInfoEntityList);
|
|
|
|
mMetricsFeatureProvider.action(mContext,
|
|
|
|
mMetricsFeatureProvider.action(mContext,
|
|
|
|
SettingsEnums.ACTION_MOBILE_NETWORK_DB_NOTIFY_SUB_INFO_IS_CHANGED);
|
|
|
|
SettingsEnums.ACTION_MOBILE_NETWORK_DB_NOTIFY_SUB_INFO_IS_CHANGED);
|
|
|
@@ -267,7 +272,10 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
|
|
|
|
|
|
|
|
|
|
|
private void setActiveSubInfoList(
|
|
|
|
private void setActiveSubInfoList(
|
|
|
|
List<SubscriptionInfoEntity> activeSubInfoEntityList) {
|
|
|
|
List<SubscriptionInfoEntity> activeSubInfoEntityList) {
|
|
|
|
Log.d(TAG, "onActiveSubInfoChanged, activeSubInfoEntityList = " + activeSubInfoEntityList);
|
|
|
|
if (DEBUG) {
|
|
|
|
|
|
|
|
Log.d(TAG,
|
|
|
|
|
|
|
|
"onActiveSubInfoChanged, activeSubInfoEntityList = " + activeSubInfoEntityList);
|
|
|
|
|
|
|
|
}
|
|
|
|
mCallback.onActiveSubInfoChanged(mActiveSubInfoEntityList);
|
|
|
|
mCallback.onActiveSubInfoChanged(mActiveSubInfoEntityList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -291,10 +299,11 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
|
|
|
SubscriptionInfoEntity subInfoEntity =
|
|
|
|
SubscriptionInfoEntity subInfoEntity =
|
|
|
|
convertToSubscriptionInfoEntity(context, info);
|
|
|
|
convertToSubscriptionInfoEntity(context, info);
|
|
|
|
if (subInfoEntity != null) {
|
|
|
|
if (subInfoEntity != null) {
|
|
|
|
|
|
|
|
mSubscriptionInfoMap.put(info.getSubscriptionId(), info);
|
|
|
|
mMobileNetworkDatabase.insertSubsInfo(subInfoEntity);
|
|
|
|
mMobileNetworkDatabase.insertSubsInfo(subInfoEntity);
|
|
|
|
mMetricsFeatureProvider.action(mContext,
|
|
|
|
mMetricsFeatureProvider.action(mContext,
|
|
|
|
SettingsEnums.ACTION_MOBILE_NETWORK_DB_INSERT_SUB_INFO);
|
|
|
|
SettingsEnums.ACTION_MOBILE_NETWORK_DB_INSERT_SUB_INFO);
|
|
|
|
} else {
|
|
|
|
} 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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@@ -322,7 +331,9 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
|
|
|
|
|
|
|
|
|
|
|
UiccSlotInfo[] uiccSlotInfos = mTelephonyManager.getUiccSlotsInfo();
|
|
|
|
UiccSlotInfo[] uiccSlotInfos = mTelephonyManager.getUiccSlotsInfo();
|
|
|
|
if (uiccSlotInfos == null || uiccSlotInfos.length == 0) {
|
|
|
|
if (uiccSlotInfos == null || uiccSlotInfos.length == 0) {
|
|
|
|
Log.d(TAG, "uiccSlotInfos = null or empty");
|
|
|
|
if (DEBUG) {
|
|
|
|
|
|
|
|
Log.d(TAG, "uiccSlotInfos = null or empty");
|
|
|
|
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
getUiccInfoBySubscriptionInfo(uiccSlotInfos, subInfo);
|
|
|
|
getUiccInfoBySubscriptionInfo(uiccSlotInfos, subInfo);
|
|
|
@@ -332,7 +343,9 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
|
|
|
context);
|
|
|
|
context);
|
|
|
|
SubscriptionInfo subscriptionOrDefault = SubscriptionUtil.getSubscriptionOrDefault(
|
|
|
|
SubscriptionInfo subscriptionOrDefault = SubscriptionUtil.getSubscriptionOrDefault(
|
|
|
|
context, mSubId);
|
|
|
|
context, mSubId);
|
|
|
|
Log.d(TAG, "convert subscriptionInfo to entity for subId = " + mSubId);
|
|
|
|
if(DEBUG){
|
|
|
|
|
|
|
|
Log.d(TAG, "convert subscriptionInfo to entity for subId = " + mSubId);
|
|
|
|
|
|
|
|
}
|
|
|
|
return new SubscriptionInfoEntity(String.valueOf(mSubId),
|
|
|
|
return new SubscriptionInfoEntity(String.valueOf(mSubId),
|
|
|
|
subInfo.getSimSlotIndex(),
|
|
|
|
subInfo.getSimSlotIndex(),
|
|
|
|
subInfo.getCarrierId(), subInfo.getDisplayName().toString(),
|
|
|
|
subInfo.getCarrierId(), subInfo.getDisplayName().toString(),
|
|
|
@@ -399,7 +412,9 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
|
|
|
private boolean isMultipleEnabledProfilesSupported() {
|
|
|
|
private boolean isMultipleEnabledProfilesSupported() {
|
|
|
|
List<UiccCardInfo> cardInfos = mTelephonyManager.getUiccCardsInfo();
|
|
|
|
List<UiccCardInfo> cardInfos = mTelephonyManager.getUiccCardsInfo();
|
|
|
|
if (cardInfos == null) {
|
|
|
|
if (cardInfos == null) {
|
|
|
|
Log.w(TAG, "UICC card info list is empty.");
|
|
|
|
if (DEBUG) {
|
|
|
|
|
|
|
|
Log.d(TAG, "UICC card info list is empty.");
|
|
|
|
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return cardInfos.stream().anyMatch(
|
|
|
|
return cardInfos.stream().anyMatch(
|
|
|
@@ -414,28 +429,27 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
|
|
|
private void insertAvailableSubInfoToEntity(List<SubscriptionInfo> availableInfoList) {
|
|
|
|
private void insertAvailableSubInfoToEntity(List<SubscriptionInfo> availableInfoList) {
|
|
|
|
if ((availableInfoList == null || availableInfoList.size() == 0)
|
|
|
|
if ((availableInfoList == null || availableInfoList.size() == 0)
|
|
|
|
&& mAvailableSubInfoEntityList.size() != 0) {
|
|
|
|
&& mAvailableSubInfoEntityList.size() != 0) {
|
|
|
|
Log.d(TAG, "availableSudInfoList from framework is empty, remove all subs");
|
|
|
|
if (DEBUG) {
|
|
|
|
|
|
|
|
Log.d(TAG, "availableSudInfoList from framework is empty, remove all subs");
|
|
|
|
|
|
|
|
}
|
|
|
|
for (SubscriptionInfoEntity info : mAvailableSubInfoEntityList) {
|
|
|
|
for (SubscriptionInfoEntity info : mAvailableSubInfoEntityList) {
|
|
|
|
deleteAllInfoBySubId(info.subId);
|
|
|
|
deleteAllInfoBySubId(info.subId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (availableInfoList != null) {
|
|
|
|
} else if (availableInfoList != null) {
|
|
|
|
for (SubscriptionInfo subInfo : availableInfoList) {
|
|
|
|
for (SubscriptionInfo subInfo : availableInfoList) {
|
|
|
|
if (availableInfoList.size() < mAvailableSubInfoEntityList.size()) {
|
|
|
|
mSubscriptionInfoMap.remove(subInfo.getSubscriptionId());
|
|
|
|
Optional<SubscriptionInfoEntity> infoEntity =
|
|
|
|
if (DEBUG) {
|
|
|
|
mAvailableSubInfoEntityList.stream().filter(
|
|
|
|
Log.d(TAG,
|
|
|
|
info -> subInfo.getSubscriptionId()
|
|
|
|
"insert sudInfo " + subInfo.getSubscriptionId() + " to subInfoEntity");
|
|
|
|
!= Integer.parseInt(info.subId)).findFirst();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (infoEntity.isPresent()) {
|
|
|
|
|
|
|
|
Log.d(TAG, "delete sudInfo " + infoEntity.get().subId
|
|
|
|
|
|
|
|
+ " from subInfoEntity");
|
|
|
|
|
|
|
|
deleteAllInfoBySubId(infoEntity.get().subId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, "insert sudInfo " + subInfo.getSubscriptionId() + " to subInfoEntity");
|
|
|
|
|
|
|
|
insertSubInfo(mContext, subInfo);
|
|
|
|
insertSubInfo(mContext, subInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!mSubscriptionInfoMap.isEmpty()) {
|
|
|
|
|
|
|
|
mSubscriptionInfoMap.forEach((key, value) -> {
|
|
|
|
|
|
|
|
deleteAllInfoBySubId(String.valueOf(key));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|