[adb-wireless] Add Wireless Debugging Switch in Developer options.

Bug: 111434128
Bug: 119492574

Test: make RunSettingsRoboTests ROBOTEST_FILTER=WirelessDebugging
Change-Id: I188badb43035172642cf235bb27e56d3a1dea169
This commit is contained in:
Joshua Duong
2018-11-08 06:56:45 -08:00
parent 235f07f95e
commit 85a65e2dc6
24 changed files with 2869 additions and 0 deletions

View File

@@ -0,0 +1,95 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.development;
import android.content.Context;
import android.debug.PairDevice;
import android.os.Bundle;
import android.view.View;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
/**
* An AP preference for the currently connected AP
*/
public class AdbPairedDevicePreference extends Preference {
private static final String TAG = "AdbPairedDevicePref";
private PairDevice mPairedDevice;
// Extract using getSerializable(PAIRED_DEVICE_EXTRA)
public static final String PAIRED_DEVICE_EXTRA = "paired_device";
public AdbPairedDevicePreference(PairDevice pairedDevice, Context context) {
super(context);
mPairedDevice = pairedDevice;
setWidgetLayoutResource(getWidgetLayoutResourceId());
refresh();
}
protected int getWidgetLayoutResourceId() {
return R.layout.preference_widget_gear_optional_background;
}
/**
* Refreshes the preference bound to the paired device previously passed in.
*/
public void refresh() {
setTitle(this, mPairedDevice);
}
public void setPairedDevice(PairDevice pairedDevice) {
mPairedDevice = pairedDevice;
}
public PairDevice getPairedDevice() {
return mPairedDevice;
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
final View gear = holder.findViewById(R.id.settings_button);
final View gearNoBg = holder.findViewById(R.id.settings_button_no_background);
gear.setVisibility(View.INVISIBLE);
gearNoBg.setVisibility(View.VISIBLE);
}
static void setTitle(AdbPairedDevicePreference preference,
PairDevice pairedDevice) {
preference.setTitle(pairedDevice.getDeviceName());
preference.setSummary(pairedDevice.isConnected()
? preference.getContext().getText(R.string.adb_wireless_device_connected_summary)
: "");
}
/**
* Writes the paired devices bound to this preference to the bundle.
*
* @param bundle the bundle to write the paired device to
*/
public void savePairedDeviceToExtras(Bundle bundle) {
bundle.putParcelable(PAIRED_DEVICE_EXTRA, mPairedDevice);
}
}