use of com.android.internal.telephony.nano.TelephonyProto.ActiveSubscriptionInfo in project android_frameworks_opt_telephony by LineageOS.
the class TelephonyMetrics method updateActiveSubscriptionInfoList.
/**
* Update active subscription info list.
*/
public synchronized void updateActiveSubscriptionInfoList(List<SubscriptionInfo> subInfos) {
List<Integer> inActivePhoneList = new ArrayList<>();
for (int i = 0; i < mLastActiveSubscriptionInfos.size(); i++) {
inActivePhoneList.add(mLastActiveSubscriptionInfos.keyAt(i));
}
for (SubscriptionInfo info : subInfos) {
int phoneId = info.getSimSlotIndex();
inActivePhoneList.removeIf(value -> value.equals(phoneId));
ActiveSubscriptionInfo activeSubscriptionInfo = new ActiveSubscriptionInfo();
activeSubscriptionInfo.slotIndex = phoneId;
activeSubscriptionInfo.isOpportunistic = info.isOpportunistic() ? 1 : 0;
activeSubscriptionInfo.carrierId = info.getCarrierId();
if (info.getMccString() != null && info.getMncString() != null) {
activeSubscriptionInfo.simMccmnc = info.getMccString() + info.getMncString();
}
if (!MessageNano.messageNanoEquals(mLastActiveSubscriptionInfos.get(phoneId), activeSubscriptionInfo)) {
addTelephonyEvent(new TelephonyEventBuilder(phoneId).setActiveSubscriptionInfoChange(activeSubscriptionInfo).build());
mLastActiveSubscriptionInfos.put(phoneId, activeSubscriptionInfo);
}
}
for (int phoneId : inActivePhoneList) {
mLastActiveSubscriptionInfos.remove(phoneId);
addTelephonyEvent(new TelephonyEventBuilder(phoneId).setActiveSubscriptionInfoChange(makeInvalidSubscriptionInfo(phoneId)).build());
}
}
use of com.android.internal.telephony.nano.TelephonyProto.ActiveSubscriptionInfo in project android_frameworks_opt_telephony by LineageOS.
the class TelephonyMetrics method makeInvalidSubscriptionInfo.
private static ActiveSubscriptionInfo makeInvalidSubscriptionInfo(int phoneId) {
ActiveSubscriptionInfo invalidSubscriptionInfo = new ActiveSubscriptionInfo();
invalidSubscriptionInfo.slotIndex = phoneId;
invalidSubscriptionInfo.carrierId = -1;
invalidSubscriptionInfo.isOpportunistic = -1;
return invalidSubscriptionInfo;
}
use of com.android.internal.telephony.nano.TelephonyProto.ActiveSubscriptionInfo in project android_frameworks_opt_telephony by LineageOS.
the class TelephonyMetrics method buildProto.
/**
* Build the telephony proto
*
* @return Telephony proto
*/
private synchronized TelephonyLog buildProto() {
TelephonyLog log = new TelephonyLog();
// Build telephony events
log.events = new TelephonyEvent[mTelephonyEvents.size()];
mTelephonyEvents.toArray(log.events);
log.eventsDropped = mTelephonyEventsDropped;
// Build call sessions
log.callSessions = new TelephonyCallSession[mCompletedCallSessions.size()];
mCompletedCallSessions.toArray(log.callSessions);
// Build SMS sessions
log.smsSessions = new SmsSession[mCompletedSmsSessions.size()];
mCompletedSmsSessions.toArray(log.smsSessions);
// Build histogram. Currently we only support RIL histograms.
List<TelephonyHistogram> rilHistograms = RIL.getTelephonyRILTimingHistograms();
log.histograms = new TelephonyProto.TelephonyHistogram[rilHistograms.size()];
for (int i = 0; i < rilHistograms.size(); i++) {
log.histograms[i] = new TelephonyProto.TelephonyHistogram();
TelephonyHistogram rilHistogram = rilHistograms.get(i);
TelephonyProto.TelephonyHistogram histogramProto = log.histograms[i];
histogramProto.category = rilHistogram.getCategory();
histogramProto.id = rilHistogram.getId();
histogramProto.minTimeMillis = rilHistogram.getMinTime();
histogramProto.maxTimeMillis = rilHistogram.getMaxTime();
histogramProto.avgTimeMillis = rilHistogram.getAverageTime();
histogramProto.count = rilHistogram.getSampleCount();
histogramProto.bucketCount = rilHistogram.getBucketCount();
histogramProto.bucketEndPoints = rilHistogram.getBucketEndPoints();
histogramProto.bucketCounters = rilHistogram.getBucketCounters();
}
// Build modem power metrics
BatteryStatsManager batteryStatsManager = mContext == null ? null : (BatteryStatsManager) mContext.getSystemService(Context.BATTERY_STATS_SERVICE);
log.modemPowerStats = new ModemPowerMetrics(batteryStatsManager).buildProto();
// Log the hardware revision
log.hardwareRevision = SystemProperties.get("ro.boot.revision", "");
// Log the starting system time
log.startTime = new TelephonyProto.Time();
log.startTime.systemTimestampMillis = mStartSystemTimeMs;
log.startTime.elapsedTimestampMillis = mStartElapsedTimeMs;
log.endTime = new TelephonyProto.Time();
log.endTime.systemTimestampMillis = System.currentTimeMillis();
log.endTime.elapsedTimestampMillis = SystemClock.elapsedRealtime();
// Log the last active subscription information.
int phoneCount = TelephonyManager.getDefault().getPhoneCount();
ActiveSubscriptionInfo[] activeSubscriptionInfo = new ActiveSubscriptionInfo[phoneCount];
for (int i = 0; i < mLastActiveSubscriptionInfos.size(); i++) {
int key = mLastActiveSubscriptionInfos.keyAt(i);
activeSubscriptionInfo[key] = mLastActiveSubscriptionInfos.get(key);
}
for (int i = 0; i < phoneCount; i++) {
if (activeSubscriptionInfo[i] == null) {
activeSubscriptionInfo[i] = makeInvalidSubscriptionInfo(i);
}
}
log.lastActiveSubscriptionInfo = activeSubscriptionInfo;
return log;
}
Aggregations