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

Commit 6adc5ab3 authored by Yomna Nasser's avatar Yomna Nasser
Browse files

Add metrics to Enable2gPreferenceController.

Test: m & atest -c Enable2gPreferenceControllerTest & statsd_testdrive 97
Bug: b/181699391
Change-Id: I1ad860937cec7594c482706cadd853b115436594
parent 4d5a03da
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.settings.network.telephony;

import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
@@ -22,6 +23,9 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;

import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;

/**
 * Preference controller for "Enable 2G"
 */
@@ -34,6 +38,8 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
                | TelephonyManager.NETWORK_TYPE_BITMASK_CDMA
                | TelephonyManager.NETWORK_TYPE_BITMASK_1xRTT;

    private final MetricsFeatureProvider mMetricsFeatureProvider;

    private CarrierConfigManager mCarrierConfigManager;
    private TelephonyManager mTelephonyManager;

@@ -46,6 +52,7 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
    public Enable2gPreferenceController(Context context, String key) {
        super(context, key);
        mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
        mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
    }

    /**
@@ -98,6 +105,8 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
        }
        mTelephonyManager.setAllowedNetworkTypesForReason(
                mTelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G, newAllowedNetworkTypes);
        mMetricsFeatureProvider.action(
                mContext, SettingsEnums.ACTION_2G_ENABLED, isChecked);
        return true;
    }
}