Merge "DO NOT MERGE - Merge pi-dev@5234907 into stage-aosp-master" into stage-aosp-master
This commit is contained in:
@@ -19,9 +19,10 @@ package com.android.settings.bluetooth;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.preference.PreferenceFragment;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
|
@@ -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,13 +16,8 @@
|
||||
|
||||
package com.android.settings.connecteddevice.usb;
|
||||
|
||||
import static android.net.ConnectivityManager.TETHERING_USB;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.net.ConnectivityManager;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import android.hardware.usb.UsbPort;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,9 +16,7 @@
|
||||
|
||||
package com.android.settings.development.qstile;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.os.RemoteException;
|
||||
@@ -29,7 +27,6 @@ import android.service.quicksettings.Tile;
|
||||
import android.service.quicksettings.TileService;
|
||||
import android.sysprop.DisplayProperties;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import android.util.EventLog;
|
||||
import android.util.Log;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.ThreadedRenderer;
|
||||
@@ -38,8 +35,6 @@ import android.view.WindowManagerGlobal;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.internal.app.LocalePicker;
|
||||
import com.android.internal.statusbar.IStatusBarService;
|
||||
import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
import com.android.settingslib.development.SystemPropPoker;
|
||||
|
||||
public abstract class DevelopmentTiles extends TileService {
|
||||
@@ -56,33 +51,7 @@ public abstract class DevelopmentTiles extends TileService {
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
final int state;
|
||||
if (!DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(this)) {
|
||||
// Reset to disabled state if dev option is off.
|
||||
if (isEnabled()) {
|
||||
setIsEnabled(false);
|
||||
SystemPropPoker.getInstance().poke();
|
||||
}
|
||||
final ComponentName cn = new ComponentName(getPackageName(), getClass().getName());
|
||||
try {
|
||||
getPackageManager().setComponentEnabledSetting(
|
||||
cn, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
final IStatusBarService statusBarService = IStatusBarService.Stub.asInterface(
|
||||
ServiceManager.checkService(Context.STATUS_BAR_SERVICE));
|
||||
if (statusBarService != null) {
|
||||
EventLog.writeEvent(0x534e4554, "117770924"); // SaftyNet
|
||||
statusBarService.remTile(cn);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to modify QS tile for component " +
|
||||
cn.toString(), e);
|
||||
}
|
||||
state = Tile.STATE_UNAVAILABLE;
|
||||
} else {
|
||||
state = isEnabled() ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
|
||||
}
|
||||
getQsTile().setState(state);
|
||||
getQsTile().setState(isEnabled() ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
|
||||
getQsTile().updateTile();
|
||||
}
|
||||
|
||||
@@ -273,4 +242,4 @@ public abstract class DevelopmentTiles extends TileService {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user