Search in sources :

Example 1 with ActiveSubscriptionInfo

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());
    }
}
Also used : ActiveSubscriptionInfo(com.android.internal.telephony.nano.TelephonyProto.ActiveSubscriptionInfo) ArrayList(java.util.ArrayList) ActiveSubscriptionInfo(com.android.internal.telephony.nano.TelephonyProto.ActiveSubscriptionInfo) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 2 with ActiveSubscriptionInfo

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;
}
Also used : ActiveSubscriptionInfo(com.android.internal.telephony.nano.TelephonyProto.ActiveSubscriptionInfo)

Example 3 with ActiveSubscriptionInfo

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;
}
Also used : TelephonyLog(com.android.internal.telephony.nano.TelephonyProto.TelephonyLog) TelephonyHistogram(android.telephony.TelephonyHistogram) ActiveSubscriptionInfo(com.android.internal.telephony.nano.TelephonyProto.ActiveSubscriptionInfo) TelephonyProto(com.android.internal.telephony.nano.TelephonyProto) BatteryStatsManager(android.os.BatteryStatsManager)

Aggregations

ActiveSubscriptionInfo (com.android.internal.telephony.nano.TelephonyProto.ActiveSubscriptionInfo)3 BatteryStatsManager (android.os.BatteryStatsManager)1 SubscriptionInfo (android.telephony.SubscriptionInfo)1 TelephonyHistogram (android.telephony.TelephonyHistogram)1 TelephonyProto (com.android.internal.telephony.nano.TelephonyProto)1 TelephonyLog (com.android.internal.telephony.nano.TelephonyProto.TelephonyLog)1 ArrayList (java.util.ArrayList)1