Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f9ab99d authored by Manish Kumar's avatar Manish Kumar Committed by Natiq Ahmed
Browse files

Compilation fix

Change-Id: Ief9813978bbb2a5a321b3264d222bfd26dcc7b38
parent 66c99aea
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -1366,8 +1366,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
        final Context context = getActivity();
        if (hasReadyMobileRadio(context)) {
            final TelephonyManager tele = TelephonyManager.from(context);
			return false;
            //return mPolicyEditor.isMobilePolicySplit(getActiveSubscriberId(context));
            return mPolicyEditor.isMobilePolicySplit(getActiveSubscriberId(context));
        } else {
            return false;
        }
@@ -1378,7 +1377,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
        final Context context = getActivity();
        if (hasReadyMobileRadio(context)) {
            final TelephonyManager tele = TelephonyManager.from(context);
            //mPolicyEditor.setMobilePolicySplit(getActiveSubscriberId(context), split);
            mPolicyEditor.setMobilePolicySplit(getActiveSubscriberId(context), split);
        }
    }

+3 −2
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public class DateTimeSettings extends SettingsPreferenceFragment
    private SwitchPreference mAutoTimeZonePref;
    private Preference mTimeZone;
    private Preference mDatePref;
    private ListPreference mDateFormat;

    @Override
    public void onCreate(Bundle icicle) {
@@ -127,7 +128,7 @@ public class DateTimeSettings extends SettingsPreferenceFragment
        String [] formattedDates = new String[dateFormats.length];

        // Prevents duplicated values on date format selector.
/*        mDummyDate.set(mDummyDate.get(Calendar.YEAR), mDummyDate.DECEMBER, 31, 13, 0, 0);
        mDummyDate.set(mDummyDate.get(Calendar.YEAR), mDummyDate.DECEMBER, 31, 13, 0, 0);

        for (int i = 0; i < formattedDates.length; i++) {
            String formatted =
@@ -143,7 +144,7 @@ public class DateTimeSettings extends SettingsPreferenceFragment
        }

        mDateFormat.setEntries(formattedDates);
        mDateFormat.setEntryValues(R.array.date_format_values);*/
        mDateFormat.setEntryValues(R.array.date_format_values);

        mTimePref.setEnabled(!autoTimeEnabled);
        mDatePref.setEnabled(!autoTimeEnabled);
+2 −2
Original line number Diff line number Diff line
@@ -16,10 +16,10 @@ public class HotspotOffReceiver extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent) {
        if (WifiManager.WIFI_AP_STATE_CHANGED_ACTION.equals(intent.getAction())) {
            WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
            /*if (wifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_DISABLED) {
            if (wifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_DISABLED) {
                // The hotspot has been turned off, we don't need to recheck tethering.
                TetherService.cancelRecheckAlarmIfNecessary(context, TetherSettings.WIFI_TETHERING);
            }*/
            }
        }
    }
}
+93 −0
Original line number Diff line number Diff line
@@ -20,7 +20,12 @@ import static android.net.NetworkPolicy.CYCLE_NONE;
import static android.net.NetworkPolicy.LIMIT_DISABLED;
import static android.net.NetworkPolicy.SNOOZE_NEVER;
import static android.net.NetworkPolicy.WARNING_DISABLED;
import static android.net.NetworkTemplate.MATCH_MOBILE_3G_LOWER;
import static android.net.NetworkTemplate.MATCH_MOBILE_4G;
import static android.net.NetworkTemplate.MATCH_WIFI;
import static android.net.NetworkTemplate.buildTemplateMobile3gLower;
import static android.net.NetworkTemplate.buildTemplateMobile4g;
import static android.net.NetworkTemplate.buildTemplateMobileAll;
import static com.android.internal.util.Preconditions.checkNotNull;

import android.net.NetworkPolicy;
@@ -34,6 +39,7 @@ import android.text.format.Time;
import com.google.android.collect.Lists;

import java.util.ArrayList;
import java.util.Objects;

/**
 * Utility class to modify list of {@link NetworkPolicy}. Specifically knows
@@ -233,6 +239,93 @@ public class NetworkPolicyEditor {
        if (modified) writeAsync();
    }


    @Deprecated
    public boolean isMobilePolicySplit(String subscriberId) {
        boolean has3g = false;
        boolean has4g = false;
        for (NetworkPolicy policy : mPolicies) {
            final NetworkTemplate template = policy.template;
            if (Objects.equals(subscriberId, template.getSubscriberId())) {
                switch (template.getMatchRule()) {
                    case MATCH_MOBILE_3G_LOWER:
                        has3g = true;
                        break;
                    case MATCH_MOBILE_4G:
                        has4g = true;
                        break;
                }
            }
        }
        return has3g && has4g;
    }

    @Deprecated
    public void setMobilePolicySplit(String subscriberId, boolean split) {
        if (setMobilePolicySplitInternal(subscriberId, split)) {
            writeAsync();
        }
    }

    /**
     * Mutate {@link NetworkPolicy} for given subscriber, combining or splitting
     * the policy as requested.
     *
     * @return {@code true} when any {@link NetworkPolicy} was mutated.
     */
    @Deprecated
    private boolean setMobilePolicySplitInternal(String subscriberId, boolean split) {
        final boolean beforeSplit = isMobilePolicySplit(subscriberId);

        final NetworkTemplate template3g = buildTemplateMobile3gLower(subscriberId);
        final NetworkTemplate template4g = buildTemplateMobile4g(subscriberId);
        final NetworkTemplate templateAll = buildTemplateMobileAll(subscriberId);

        if (split == beforeSplit) {
            // already in requested state; skip
            return false;

        } else if (beforeSplit && !split) {
            // combine, picking most restrictive policy
            final NetworkPolicy policy3g = getPolicy(template3g);
            final NetworkPolicy policy4g = getPolicy(template4g);

            NetworkPolicy restrictive = null;
            if ((policy3g == null) && (policy4g == null)) {
                return false;
            } else if (policy3g == null) {
                restrictive = policy4g;
            } else if (policy4g == null) {
                restrictive = policy3g;
            } else {
                restrictive = policy3g.compareTo(policy4g) < 0 ? policy3g : policy4g;
            }
            mPolicies.remove(policy3g);
            mPolicies.remove(policy4g);
            mPolicies.add(new NetworkPolicy(templateAll, restrictive.cycleDay,
                    restrictive.cycleTimezone, restrictive.warningBytes, restrictive.limitBytes,
                    SNOOZE_NEVER, SNOOZE_NEVER, restrictive.metered, restrictive.inferred));
            return true;

        } else if (!beforeSplit && split) {
            // duplicate existing policy into two rules
            final NetworkPolicy policyAll = getPolicy(templateAll);
            if (policyAll == null) {
                return false;
            }
            mPolicies.remove(policyAll);
            mPolicies.add(new NetworkPolicy(template3g, policyAll.cycleDay, policyAll.cycleTimezone,
                    policyAll.warningBytes, policyAll.limitBytes, SNOOZE_NEVER, SNOOZE_NEVER,
                    policyAll.metered, policyAll.inferred));
            mPolicies.add(new NetworkPolicy(template4g, policyAll.cycleDay, policyAll.cycleTimezone,
                    policyAll.warningBytes, policyAll.limitBytes, SNOOZE_NEVER, SNOOZE_NEVER,
                    policyAll.metered, policyAll.inferred));
            return true;
        } else {
            return false;
        }
    }

    /**
     * Build a revised {@link NetworkTemplate} that matches the same rule, but
     * with an unquoted {@link NetworkTemplate#getNetworkId()}. Used to work