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);
}
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);
}
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);
}
Aggregations