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

Commit 135619d4 authored by Salvador Martinez's avatar Salvador Martinez
Browse files

Refactor tether logic for reuse

Some logic related to permissions needs to be used elsewhere. This
CL refactors the relevant code into a method so that it stays in
sync in both places.

Test: robotests still pass
Bug: 64092292
Change-Id: If8191698023d1da90db99b518d9f770683b5c789
Merged-In: I3b54529865e16b7e1640b0adda7f7edb9d1a41f7
parent a8db5cce
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -88,8 +88,7 @@ public class TetherPreferenceController extends PreferenceController
    public TetherPreferenceController(Context context, Lifecycle lifecycle) {
        super(context);
        mBluetoothPan = new AtomicReference<>();
        mAdminDisallowedTetherConfig = checkIfRestrictionEnforced(
                context, DISALLOW_CONFIG_TETHERING, UserHandle.myUserId()) != null;
        mAdminDisallowedTetherConfig = isTetherConfigDisallowed(context);
        mConnectivityManager =
                (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
@@ -170,6 +169,11 @@ public class TetherPreferenceController extends PreferenceController
        }
    }

    public static boolean isTetherConfigDisallowed(Context context) {
        return checkIfRestrictionEnforced(
                context, DISALLOW_CONFIG_TETHERING, UserHandle.myUserId()) != null;
    }

    @VisibleForTesting
    void updateSummary() {
        if (mPreference == null) {