Revert "resolve merge conflicts of 7849607a7c to pi-dev-plus-aosp"
This reverts commit e81224d80c.
Reason for revert: broke pi-dev-plus-aosp
Change-Id: Ib45b96216017d01b6301a558a0cd27bf1071779c
Merged-In: I3d2ebad2879479a870bcdfe596bb88b83c424389
This commit is contained in:
@@ -16,14 +16,9 @@
|
||||
|
||||
package com.android.settings.connecteddevice.usb;
|
||||
|
||||
import static android.net.ConnectivityManager.TETHERING_USB;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
@@ -44,18 +39,11 @@ import java.util.List;
|
||||
public class UsbDefaultFragment extends RadioButtonPickerFragment {
|
||||
@VisibleForTesting
|
||||
UsbBackend mUsbBackend;
|
||||
@VisibleForTesting
|
||||
ConnectivityManager mConnectivityManager;
|
||||
@VisibleForTesting
|
||||
OnStartTetheringCallback mOnStartTetheringCallback = new OnStartTetheringCallback();
|
||||
@VisibleForTesting
|
||||
long mPreviousFunctions;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
mUsbBackend = new UsbBackend(context);
|
||||
mConnectivityManager = context.getSystemService(ConnectivityManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,37 +103,9 @@ public class UsbDefaultFragment extends RadioButtonPickerFragment {
|
||||
@Override
|
||||
protected boolean setDefaultKey(String key) {
|
||||
long functions = UsbBackend.usbFunctionsFromString(key);
|
||||
mPreviousFunctions = mUsbBackend.getCurrentFunctions();
|
||||
if (!Utils.isMonkeyRunning()) {
|
||||
if (functions == UsbManager.FUNCTION_RNDIS) {
|
||||
// We need to have entitlement check for usb tethering, so use API in
|
||||
// ConnectivityManager.
|
||||
mConnectivityManager.startTethering(TETHERING_USB, true /* showProvisioningUi */,
|
||||
mOnStartTetheringCallback);
|
||||
} else {
|
||||
mUsbBackend.setDefaultUsbFunctions(functions);
|
||||
}
|
||||
|
||||
mUsbBackend.setDefaultUsbFunctions(functions);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
final class OnStartTetheringCallback extends
|
||||
ConnectivityManager.OnStartTetheringCallback {
|
||||
|
||||
@Override
|
||||
public void onTetheringStarted() {
|
||||
super.onTetheringStarted();
|
||||
// Set default usb functions again to make internal data persistent
|
||||
mUsbBackend.setDefaultUsbFunctions(UsbManager.FUNCTION_RNDIS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTetheringFailed() {
|
||||
super.onTetheringFailed();
|
||||
mUsbBackend.setDefaultUsbFunctions(mPreviousFunctions);
|
||||
updateCandidates();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,14 +16,9 @@
|
||||
|
||||
package com.android.settings.connecteddevice.usb;
|
||||
|
||||
import static android.net.ConnectivityManager.TETHERING_USB;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.hardware.usb.UsbPort;
|
||||
import android.net.ConnectivityManager;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
@@ -51,18 +46,10 @@ public class UsbDetailsFunctionsController extends UsbDetailsController
|
||||
}
|
||||
|
||||
private PreferenceCategory mProfilesContainer;
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
@VisibleForTesting
|
||||
OnStartTetheringCallback mOnStartTetheringCallback;
|
||||
@VisibleForTesting
|
||||
long mPreviousFunction;
|
||||
|
||||
public UsbDetailsFunctionsController(Context context, UsbDetailsFragment fragment,
|
||||
UsbBackend backend) {
|
||||
super(context, fragment, backend);
|
||||
mConnectivityManager = context.getSystemService(ConnectivityManager.class);
|
||||
mOnStartTetheringCallback = new OnStartTetheringCallback();
|
||||
mPreviousFunction = mUsbBackend.getCurrentFunctions();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,28 +96,9 @@ public class UsbDetailsFunctionsController extends UsbDetailsController
|
||||
|
||||
@Override
|
||||
public void onRadioButtonClicked(RadioButtonPreference preference) {
|
||||
final long function = UsbBackend.usbFunctionsFromString(preference.getKey());
|
||||
final long previousFunction = mUsbBackend.getCurrentFunctions();
|
||||
if (function != previousFunction && !Utils.isMonkeyRunning()) {
|
||||
mPreviousFunction = previousFunction;
|
||||
|
||||
if (function == UsbManager.FUNCTION_RNDIS) {
|
||||
//Update the UI in advance to make it looks smooth
|
||||
final RadioButtonPreference prevPref =
|
||||
(RadioButtonPreference) mProfilesContainer.findPreference(
|
||||
UsbBackend.usbFunctionsToString(mPreviousFunction));
|
||||
if (prevPref != null) {
|
||||
prevPref.setChecked(false);
|
||||
preference.setChecked(true);
|
||||
}
|
||||
|
||||
// We need to have entitlement check for usb tethering, so use API in
|
||||
// ConnectivityManager.
|
||||
mConnectivityManager.startTethering(TETHERING_USB, true /* showProvisioningUi */,
|
||||
mOnStartTetheringCallback);
|
||||
} else {
|
||||
mUsbBackend.setCurrentFunctions(function);
|
||||
}
|
||||
long function = UsbBackend.usbFunctionsFromString(preference.getKey());
|
||||
if (function != mUsbBackend.getCurrentFunctions() && !Utils.isMonkeyRunning()) {
|
||||
mUsbBackend.setCurrentFunctions(function);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,15 +111,4 @@ public class UsbDetailsFunctionsController extends UsbDetailsController
|
||||
public String getPreferenceKey() {
|
||||
return "usb_details_functions";
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
final class OnStartTetheringCallback extends
|
||||
ConnectivityManager.OnStartTetheringCallback {
|
||||
|
||||
@Override
|
||||
public void onTetheringFailed() {
|
||||
super.onTetheringFailed();
|
||||
mUsbBackend.setCurrentFunctions(mPreviousFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user