Move callback anonymous classes out of constructor am: f58390a3cd

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15740838

Change-Id: Ic76e5fcc587df00672363413f5125c21e590456c
This commit is contained in:
Evan Laird
2021-09-24 23:32:11 +00:00
committed by Automerger Merge Worker

View File

@@ -108,8 +108,6 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
private Config mConfig;
@VisibleForTesting
boolean mInflateSignalStrengths = false;
private MobileStatusTracker.Callback mCallback;
private RegistrationCallback mRegistrationCallback;
private int mLastWwanLevel;
private int mLastWlanLevel;
private int mLastWlanCrossSimLevel;
@@ -121,6 +119,82 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
// Where to copy the next state into.
private int mMobileStatusHistoryIndex;
private final MobileStatusTracker.Callback mMobileCallback =
new MobileStatusTracker.Callback() {
private String mLastStatus;
@Override
public void onMobileStatusChanged(boolean updateTelephony,
MobileStatus mobileStatus) {
if (Log.isLoggable(mTag, Log.DEBUG)) {
Log.d(mTag, "onMobileStatusChanged="
+ " updateTelephony=" + updateTelephony
+ " mobileStatus=" + mobileStatus.toString());
}
String currentStatus = mobileStatus.toString();
if (!currentStatus.equals(mLastStatus)) {
mLastStatus = currentStatus;
String status = new StringBuilder()
.append(SSDF.format(System.currentTimeMillis())).append(",")
.append(currentStatus)
.toString();
recordLastMobileStatus(status);
}
updateMobileStatus(mobileStatus);
if (updateTelephony) {
updateTelephony();
} else {
notifyListenersIfNecessary();
}
}
};
private final RegistrationCallback mRegistrationCallback = new RegistrationCallback() {
@Override
public void onRegistered(ImsRegistrationAttributes attributes) {
Log.d(mTag, "onRegistered: " + "attributes=" + attributes);
int imsTransportType = attributes.getTransportType();
int registrationAttributes = attributes.getAttributeFlags();
if (imsTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
mImsType = IMS_TYPE_WWAN;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWwanLevel, /* isWifi= */false),
getCallStrengthDescription(mLastWwanLevel, /* isWifi= */false));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
} else if (imsTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WLAN) {
if (registrationAttributes == 0) {
mImsType = IMS_TYPE_WLAN;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWlanLevel, /* isWifi= */true),
getCallStrengthDescription(mLastWlanLevel, /* isWifi= */true));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
} else if (registrationAttributes
== ImsRegistrationAttributes.ATTR_EPDG_OVER_CELL_INTERNET) {
mImsType = IMS_TYPE_WLAN_CROSS_SIM;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWlanCrossSimLevel, /* isWifi= */false),
getCallStrengthDescription(
mLastWlanCrossSimLevel, /* isWifi= */false));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
}
}
}
@Override
public void onUnregistered(ImsReasonInfo info) {
Log.d(mTag, "onDeregistered: " + "info=" + info);
mImsType = IMS_TYPE_WWAN;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWwanLevel, /* isWifi= */false),
getCallStrengthDescription(mLastWwanLevel, /* isWifi= */false));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
}
};
// TODO: Reduce number of vars passed in, if we have the NetworkController, probably don't
// need listener lists anymore.
public MobileSignalController(
@@ -144,8 +218,8 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
mPhone = phone;
mDefaults = defaults;
mSubscriptionInfo = info;
mNetworkNameSeparator = getTextIfExists(R.string.status_bar_network_name_separator)
.toString();
mNetworkNameSeparator = getTextIfExists(
R.string.status_bar_network_name_separator).toString();
mNetworkNameDefault = getTextIfExists(
com.android.internal.R.string.lockscreen_carrier_default).toString();
mReceiverHandler = new Handler(receiverLooper);
@@ -165,83 +239,9 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
updateTelephony();
}
};
mCallback = new MobileStatusTracker.Callback() {
private String mLastStatus;
@Override
public void onMobileStatusChanged(boolean updateTelephony,
MobileStatus mobileStatus) {
if (Log.isLoggable(mTag, Log.DEBUG)) {
Log.d(mTag, "onMobileStatusChanged="
+ " updateTelephony=" + updateTelephony
+ " mobileStatus=" + mobileStatus.toString());
}
String currentStatus = mobileStatus.toString();
if (!currentStatus.equals(mLastStatus)) {
mLastStatus = currentStatus;
String status = new StringBuilder()
.append(SSDF.format(System.currentTimeMillis())).append(",")
.append(currentStatus)
.toString();
recordLastMobileStatus(status);
}
updateMobileStatus(mobileStatus);
if (updateTelephony) {
updateTelephony();
} else {
notifyListenersIfNecessary();
}
}
};
mRegistrationCallback = new RegistrationCallback() {
@Override
public void onRegistered(ImsRegistrationAttributes attributes) {
Log.d(mTag, "onRegistered: " + "attributes=" + attributes);
int imsTransportType = attributes.getTransportType();
int registrationAttributes = attributes.getAttributeFlags();
if (imsTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
mImsType = IMS_TYPE_WWAN;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWwanLevel, /* isWifi= */false),
getCallStrengthDescription(mLastWwanLevel, /* isWifi= */false));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
} else if (imsTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WLAN) {
if (registrationAttributes == 0) {
mImsType = IMS_TYPE_WLAN;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWlanLevel, /* isWifi= */true),
getCallStrengthDescription(mLastWlanLevel, /* isWifi= */true));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
} else if (registrationAttributes
== ImsRegistrationAttributes.ATTR_EPDG_OVER_CELL_INTERNET) {
mImsType = IMS_TYPE_WLAN_CROSS_SIM;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWlanCrossSimLevel, /* isWifi= */false),
getCallStrengthDescription(
mLastWlanCrossSimLevel, /* isWifi= */false));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
}
}
}
@Override
public void onUnregistered(ImsReasonInfo info) {
Log.d(mTag, "onDeregistered: " + "info=" + info);
mImsType = IMS_TYPE_WWAN;
IconState statusIcon = new IconState(
true,
getCallStrengthIcon(mLastWwanLevel, /* isWifi= */false),
getCallStrengthDescription(mLastWwanLevel, /* isWifi= */false));
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
}
};
mImsMmTelManager = ImsMmTelManager.createForSubscriptionId(info.getSubscriptionId());
mMobileStatusTracker = new MobileStatusTracker(mPhone, receiverLooper,
info, mDefaults, mCallback);
info, mDefaults, mMobileCallback);
mProviderModelBehavior = featureFlags.isCombinedStatusBarSignalIconsEnabled();
mProviderModelSetting = featureFlags.isProviderModelSettingEnabled();
}