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: I3b54529865e16b7e1640b0adda7f7edb9d1a41f7
This commit is contained in:
Salvador Martinez
2017-08-07 10:22:37 -07:00
parent 8d3bfd62e1
commit 52da8a79b9

View File

@@ -88,8 +88,7 @@ public class TetherPreferenceController extends AbstractPreferenceController imp
public TetherPreferenceController(Context context, Lifecycle lifecycle) { public TetherPreferenceController(Context context, Lifecycle lifecycle) {
super(context); super(context);
mBluetoothPan = new AtomicReference<>(); mBluetoothPan = new AtomicReference<>();
mAdminDisallowedTetherConfig = checkIfRestrictionEnforced( mAdminDisallowedTetherConfig = isTetherConfigDisallowed(context);
mContext, DISALLOW_CONFIG_TETHERING, UserHandle.myUserId()) != null;
mConnectivityManager = mConnectivityManager =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
@@ -170,6 +169,11 @@ public class TetherPreferenceController extends AbstractPreferenceController imp
} }
} }
public static boolean isTetherConfigDisallowed(Context context) {
return checkIfRestrictionEnforced(
context, DISALLOW_CONFIG_TETHERING, UserHandle.myUserId()) != null;
}
@VisibleForTesting @VisibleForTesting
void updateSummary() { void updateSummary() {
if (mPreference == null) { if (mPreference == null) {