DO NOT MERGE - Merge pi-platform-release (PPRL.190205.001) into stage-aosp-master
Bug: 124234733 Change-Id: Ia72f271ae01966c235400ed9d582bf6d7d31a1dd
This commit is contained in:
@@ -97,6 +97,11 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater
|
||||
if (DBG) {
|
||||
Log.d(TAG, "isFilterMatched() current audio profile : " + currentAudioProfile);
|
||||
}
|
||||
// If device is Hearing Aid, it is compatible with HFP and A2DP.
|
||||
// It would show in Available Devices group.
|
||||
if (cachedDevice.isConnectedHearingAidDevice()) {
|
||||
return true;
|
||||
}
|
||||
// According to the current audio profile type,
|
||||
// this page will show the bluetooth device that have corresponding profile.
|
||||
// For example:
|
||||
|
@@ -97,6 +97,11 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater {
|
||||
if (DBG) {
|
||||
Log.d(TAG, "isFilterMatched() current audio profile : " + currentAudioProfile);
|
||||
}
|
||||
// If device is Hearing Aid, it is compatible with HFP and A2DP.
|
||||
// It would not show in Connected Devices group.
|
||||
if (cachedDevice.isConnectedHearingAidDevice()) {
|
||||
return false;
|
||||
}
|
||||
// According to the current audio profile type,
|
||||
// this page will show the bluetooth device that doesn't have corresponding profile.
|
||||
// For example:
|
||||
|
@@ -16,9 +16,14 @@
|
||||
|
||||
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;
|
||||
@@ -39,11 +44,18 @@ 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
|
||||
@@ -103,9 +115,37 @@ public class UsbDefaultFragment extends RadioButtonPickerFragment {
|
||||
@Override
|
||||
protected boolean setDefaultKey(String key) {
|
||||
long functions = UsbBackend.usbFunctionsFromString(key);
|
||||
mPreviousFunctions = mUsbBackend.getCurrentFunctions();
|
||||
if (!Utils.isMonkeyRunning()) {
|
||||
mUsbBackend.setDefaultUsbFunctions(functions);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
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,8 +16,13 @@
|
||||
|
||||
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;
|
||||
@@ -46,10 +51,18 @@ 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
|
||||
@@ -96,9 +109,28 @@ public class UsbDetailsFunctionsController extends UsbDetailsController
|
||||
|
||||
@Override
|
||||
public void onRadioButtonClicked(RadioButtonPreference preference) {
|
||||
long function = UsbBackend.usbFunctionsFromString(preference.getKey());
|
||||
if (function != mUsbBackend.getCurrentFunctions() && !Utils.isMonkeyRunning()) {
|
||||
mUsbBackend.setCurrentFunctions(function);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,4 +143,15 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,12 +22,12 @@ import android.text.TextUtils;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
/**
|
||||
* Helper class to get feature persistent flag information.
|
||||
*/
|
||||
|
@@ -21,6 +21,7 @@ import android.util.Log;
|
||||
|
||||
import androidx.preference.SwitchPreference;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
|
||||
public class FeatureFlagPreference extends SwitchPreference {
|
||||
|
||||
|
@@ -16,7 +16,9 @@
|
||||
|
||||
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;
|
||||
@@ -27,6 +29,7 @@ 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;
|
||||
@@ -35,6 +38,8 @@ 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 {
|
||||
@@ -51,7 +56,33 @@ public abstract class DevelopmentTiles extends TileService {
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
getQsTile().setState(isEnabled() ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
|
||||
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().updateTile();
|
||||
}
|
||||
|
||||
@@ -242,4 +273,4 @@ public abstract class DevelopmentTiles extends TileService {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -150,13 +150,21 @@ public class BrightnessLevelPreferenceController extends AbstractPreferenceContr
|
||||
return (value - min) / (max - min);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
IVrManager safeGetVrManager() {
|
||||
return IVrManager.Stub.asInterface(ServiceManager.getService(
|
||||
Context.VR_SERVICE));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isInVrMode() {
|
||||
try {
|
||||
return IVrManager.Stub.asInterface(ServiceManager.getService(Context.VR_SERVICE))
|
||||
.getVrModeState();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to check vr mode!", e);
|
||||
IVrManager vrManager = safeGetVrManager();
|
||||
if (vrManager != null) {
|
||||
try {
|
||||
return vrManager.getVrModeState();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to check vr mode!", e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -69,7 +69,7 @@ public class CurrentDreamPreferenceController extends AbstractPreferenceControll
|
||||
private void launchScreenSaverSettings() {
|
||||
Optional<DreamInfo> info = getActiveDreamInfo();
|
||||
if (!info.isPresent()) return;
|
||||
mBackend.launchSettings(info.get());
|
||||
mBackend.launchSettings(mContext, info.get());
|
||||
}
|
||||
|
||||
private Optional<DreamInfo> getActiveDreamInfo() {
|
||||
|
Reference in New Issue
Block a user