Search in sources :

Example 1 with RecurrenceRule

use of android.util.RecurrenceRule in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DataUsageSummaryPreferenceController method refreshDataplanInfo.

// TODO(b/70950124) add test for this method once the robolectric shadow run script is
// completed (b/3526807)
private void refreshDataplanInfo(DataUsageController.DataUsageInfo info) {
    // reset data before overwriting
    mCarrierName = null;
    mDataplanCount = 0;
    mDataplanSize = -1L;
    mDataBarSize = mDataInfoController.getSummaryLimit(info);
    mDataplanUse = info.usageLevel;
    mCycleStart = info.cycleStart;
    mCycleEnd = info.cycleEnd;
    mSnapshotTime = -1L;
    SubscriptionInfo subInfo = mSubscriptionManager.getActiveSubscriptionInfo(mSubscriptionId);
    if (subInfo == null) {
        subInfo = mSubscriptionManager.getAllSubscriptionInfoList().stream().filter(i -> i.getSubscriptionId() == mSubscriptionId).findFirst().orElse(null);
    }
    if (subInfo != null && mHasMobileData) {
        mCarrierName = subInfo.getCarrierName();
        List<SubscriptionPlan> plans = mSubscriptionManager.getSubscriptionPlans(mSubscriptionId);
        final SubscriptionPlan primaryPlan = getPrimaryPlan(mSubscriptionManager, mSubscriptionId);
        if (primaryPlan != null) {
            mDataplanCount = plans.size();
            mDataplanSize = primaryPlan.getDataLimitBytes();
            if (unlimited(mDataplanSize)) {
                mDataplanSize = -1L;
            }
            mDataBarSize = mDataplanSize;
            mDataplanUse = primaryPlan.getDataUsageBytes();
            RecurrenceRule rule = primaryPlan.getCycleRule();
            if (rule != null && rule.start != null && rule.end != null) {
                mCycleStart = rule.start.toEpochSecond() * 1000L;
                mCycleEnd = rule.end.toEpochSecond() * 1000L;
            }
            mSnapshotTime = primaryPlan.getDataUsageTime();
        }
    }
    mManageSubscriptionIntent = mSubscriptionManager.createManageSubscriptionIntent(mSubscriptionId);
    Log.i(TAG, "Have " + mDataplanCount + " plans, dflt sub-id " + mSubscriptionId + ", intent " + mManageSubscriptionIntent);
}
Also used : Context(android.content.Context) PreferenceControllerMixin(com.android.settings.core.PreferenceControllerMixin) Intent(android.content.Intent) PreferenceFragmentCompat(androidx.preference.PreferenceFragmentCompat) SubscriptionManager(android.telephony.SubscriptionManager) BasePreferenceController(com.android.settings.core.BasePreferenceController) NetworkPolicyEditor(com.android.settingslib.NetworkPolicyEditor) RecurrenceRule(android.util.RecurrenceRule) Settings(android.provider.Settings) SubscriptionPlan(android.telephony.SubscriptionPlan) RecyclerView(androidx.recyclerview.widget.RecyclerView) SubscriptionInfo(android.telephony.SubscriptionInfo) Log(android.util.Log) CollectionUtils(com.android.internal.util.CollectionUtils) R(com.android.settings.R) NetworkPolicyManager(android.net.NetworkPolicyManager) LifecycleObserver(com.android.settingslib.core.lifecycle.LifecycleObserver) TextUtils(android.text.TextUtils) DataUsageController(com.android.settingslib.net.DataUsageController) Preference(androidx.preference.Preference) List(java.util.List) EntityHeaderController(com.android.settings.widget.EntityHeaderController) Activity(android.app.Activity) VisibleForTesting(androidx.annotation.VisibleForTesting) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) OnStart(com.android.settingslib.core.lifecycle.events.OnStart) NetworkTemplate(android.net.NetworkTemplate) RecurrenceRule(android.util.RecurrenceRule) SubscriptionPlan(android.telephony.SubscriptionPlan) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 2 with RecurrenceRule

use of android.util.RecurrenceRule in project android_packages_apps_Settings by omnirom.

the class DataUsageSummaryPreferenceControllerTest method createTestDataPlan.

private void createTestDataPlan(long startTime, long endTime) {
    final RecurrenceRule recurrenceRule = new RecurrenceRule(Instant.ofEpochMilli(startTime).atZone(ZoneId.systemDefault()), Instant.ofEpochMilli(endTime).atZone(ZoneId.systemDefault()), null);
    doReturn(recurrenceRule).when(mSubscriptionPlan).getCycleRule();
    mSubscriptionPlans.add(mSubscriptionPlan);
}
Also used : RecurrenceRule(android.util.RecurrenceRule)

Example 3 with RecurrenceRule

use of android.util.RecurrenceRule in project android_packages_apps_Settings by omnirom.

the class DataUsageSummaryPreferenceController method refreshDataplanInfo.

// TODO(b/70950124) add test for this method once the robolectric shadow run script is
// completed (b/3526807)
private void refreshDataplanInfo(DataUsageController.DataUsageInfo info, SubscriptionInfo subInfo) {
    // reset data before overwriting
    mCarrierName = null;
    mDataplanCount = 0;
    mDataplanSize = -1L;
    mDataBarSize = mDataInfoController.getSummaryLimit(info);
    mDataplanUse = info.usageLevel;
    mCycleStart = info.cycleStart;
    mCycleEnd = info.cycleEnd;
    mSnapshotTime = -1L;
    if (subInfo != null && mHasMobileData) {
        mCarrierName = subInfo.getCarrierName();
        final List<SubscriptionPlan> plans = getSubscriptionPlans(mSubId);
        final SubscriptionPlan primaryPlan = getPrimaryPlan(plans);
        if (primaryPlan != null) {
            mDataplanCount = plans.size();
            mDataplanSize = primaryPlan.getDataLimitBytes();
            if (unlimited(mDataplanSize)) {
                mDataplanSize = -1L;
            }
            mDataBarSize = mDataplanSize;
            mDataplanUse = primaryPlan.getDataUsageBytes();
            RecurrenceRule rule = primaryPlan.getCycleRule();
            if (rule != null && rule.start != null && rule.end != null) {
                mCycleStart = rule.start.toEpochSecond() * 1000L;
                mCycleEnd = rule.end.toEpochSecond() * 1000L;
            }
            mSnapshotTime = primaryPlan.getDataUsageTime();
        }
    }
    // Temporarily return null, since no current users of SubscriptionPlan have this intent set.
    // TODO (b/170330084): Remove after refactoring 5G SubscriptionPlan logic.
    // mManageSubscriptionIntent = createManageSubscriptionIntent(mSubId);
    mManageSubscriptionIntent = null;
    Log.i(TAG, "Have " + mDataplanCount + " plans, dflt sub-id " + mSubId + ", intent " + mManageSubscriptionIntent);
}
Also used : RecurrenceRule(android.util.RecurrenceRule) SubscriptionPlan(android.telephony.SubscriptionPlan)

Aggregations

RecurrenceRule (android.util.RecurrenceRule)3 SubscriptionPlan (android.telephony.SubscriptionPlan)2 Activity (android.app.Activity)1 Context (android.content.Context)1 Intent (android.content.Intent)1 NetworkPolicyManager (android.net.NetworkPolicyManager)1 NetworkTemplate (android.net.NetworkTemplate)1 Settings (android.provider.Settings)1 SubscriptionInfo (android.telephony.SubscriptionInfo)1 SubscriptionManager (android.telephony.SubscriptionManager)1 TextUtils (android.text.TextUtils)1 Log (android.util.Log)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 Preference (androidx.preference.Preference)1 PreferenceFragmentCompat (androidx.preference.PreferenceFragmentCompat)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 CollectionUtils (com.android.internal.util.CollectionUtils)1 R (com.android.settings.R)1 BasePreferenceController (com.android.settings.core.BasePreferenceController)1 PreferenceControllerMixin (com.android.settings.core.PreferenceControllerMixin)1