Merge "Update the CDM device presence javadoc and overall logs"

This commit is contained in:
Guojing Yuan
2022-09-08 21:20:29 +00:00
committed by Android (Google) Code Review
21 changed files with 42 additions and 34 deletions

View File

@@ -43,7 +43,7 @@ public class BluetoothDeviceFilterUtils {
private BluetoothDeviceFilterUtils() {}
private static final boolean DEBUG = false;
private static final String LOG_TAG = "BluetoothDeviceFilterUtils";
private static final String LOG_TAG = "CDM_BluetoothDeviceFilterUtils";
@Nullable
static String patternToString(@Nullable Pattern p) {

View File

@@ -54,7 +54,7 @@ import java.util.regex.Pattern;
public final class BluetoothLeDeviceFilter implements DeviceFilter<ScanResult> {
private static final boolean DEBUG = false;
private static final String LOG_TAG = "BluetoothLeDeviceFilter";
private static final String LOG_TAG = "CDM_BluetoothLeDeviceFilter";
private static final int RENAME_PREFIX_LENGTH_LIMIT = 10;

View File

@@ -81,7 +81,7 @@ import java.util.function.Consumer;
public final class CompanionDeviceManager {
private static final boolean DEBUG = false;
private static final String LOG_TAG = "CompanionDeviceManager";
private static final String LOG_TAG = "CDM_CompanionDeviceManager";
/**
* The result code to propagate back to the originating activity, indicates the association
@@ -709,27 +709,29 @@ public final class CompanionDeviceManager {
/**
* Register to receive callbacks whenever the associated device comes in and out of range.
*
* The provided device must be {@link #associate associated} with the calling app before
* calling this method.
* <p>The provided device must be {@link #associate associated} with the calling app before
* calling this method.</p>
*
* Caller must implement a single {@link CompanionDeviceService} which will be bound to and
* <p>Caller must implement a single {@link CompanionDeviceService} which will be bound to and
* receive callbacks to {@link CompanionDeviceService#onDeviceAppeared} and
* {@link CompanionDeviceService#onDeviceDisappeared}.
* The app doesn't need to remain running in order to receive its callbacks.
* The app doesn't need to remain running in order to receive its callbacks.</p>
*
* Calling app must declare uses-permission
* {@link android.Manifest.permission#REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE}.
* <p>Calling app must declare uses-permission
* {@link android.Manifest.permission#REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE}.</p>
*
* Calling app must check for feature presence of
* {@link PackageManager#FEATURE_COMPANION_DEVICE_SETUP} before calling this API.
* <p>Calling app must check for feature presence of
* {@link PackageManager#FEATURE_COMPANION_DEVICE_SETUP} before calling this API.</p>
*
* For Bluetooth LE devices this is based on scanning for device with the given address.
* For Bluetooth classic devices this is triggered when the device connects/disconnects.
* WiFi devices are not supported.
* <p>For Bluetooth LE devices, this is based on scanning for device with the given address.
* The system will scan for the device when Bluetooth is ON or Bluetooth scanning is ON.</p>
*
* If a Bluetooth LE device wants to use a rotating mac address, it is recommended to use
* <p>For Bluetooth classic devices this is triggered when the device connects/disconnects.
* WiFi devices are not supported.</p>
*
* <p>If a Bluetooth LE device wants to use a rotating mac address, it is recommended to use
* Resolvable Private Address, and ensure the device is bonded to the phone so that android OS
* is able to resolve the address.
* is able to resolve the address.</p>
*
* @param deviceAddress a previously-associated companion device's address
*

View File

@@ -99,7 +99,7 @@ import java.util.concurrent.Executor;
*/
public abstract class CompanionDeviceService extends Service {
private static final String LOG_TAG = "CompanionDeviceService";
private static final String LOG_TAG = "CDM_CompanionDeviceService";
/**
* An intent action for a service to be bound whenever this app's companion device(s)

View File

@@ -84,7 +84,7 @@ import java.util.List;
public class CompanionDeviceActivity extends FragmentActivity implements
CompanionVendorHelperDialogFragment.CompanionVendorHelperDialogListener {
private static final boolean DEBUG = false;
private static final String TAG = CompanionDeviceActivity.class.getSimpleName();
private static final String TAG = "CDM_CompanionDeviceActivity";
// Keep the following constants in sync with
// frameworks/base/services/companion/java/

View File

@@ -39,7 +39,7 @@ import android.widget.TextView;
*/
public class CompanionDeviceDataTransferActivity extends Activity {
private static final String LOG_TAG = CompanionDeviceDataTransferActivity.class.getSimpleName();
private static final String LOG_TAG = "CDM_CompanionDeviceDataTransferActivity";
// Intent data keys from SystemDataTransferProcessor
private static final String EXTRA_PERMISSION_SYNC_REQUEST = "permission_sync_request";

View File

@@ -70,7 +70,7 @@ import java.util.Objects;
*/
public class CompanionDeviceDiscoveryService extends Service {
private static final boolean DEBUG = false;
private static final String TAG = CompanionDeviceDiscoveryService.class.getSimpleName();
private static final String TAG = "CDM_CompanionDeviceDiscoveryService";
private static final String SYS_PROP_DEBUG_TIMEOUT = "debug.cdm.discovery_timeout";
private static final long TIMEOUT_DEFAULT = 20_000L; // 20 seconds

View File

@@ -44,7 +44,7 @@ import androidx.fragment.app.DialogFragment;
* A fragmentDialog shows additional information about selfManaged devices
*/
public class CompanionVendorHelperDialogFragment extends DialogFragment {
private static final String TAG = CompanionVendorHelperDialogFragment.class.getSimpleName();
private static final String TAG = "CDM_CompanionVendorHelperDialogFragment";
private static final String ASSOCIATION_REQUEST_EXTRA = "association_request";
private CompanionVendorHelperDialogListener mListener;

View File

@@ -107,7 +107,7 @@ import java.util.Set;
*/
@SuppressLint("LongLogTag")
class AssociationRequestsProcessor {
private static final String TAG = "CompanionDevice_AssociationRequestsProcessor";
private static final String TAG = "CDM_AssociationRequestsProcessor";
private static final ComponentName ASSOCIATION_REQUEST_APPROVAL_ACTIVITY =
createRelative(COMPANION_DEVICE_DISCOVERY_PACKAGE_NAME, ".CompanionDeviceActivity");

View File

@@ -58,7 +58,7 @@ import java.util.StringJoiner;
@SuppressLint("LongLogTag")
class AssociationStoreImpl implements AssociationStore {
private static final boolean DEBUG = false;
private static final String TAG = "CompanionDevice_AssociationStore";
private static final String TAG = "CDM_AssociationStore";
private final Object mLock = new Object();

View File

@@ -66,7 +66,7 @@ import java.util.Map;
@SuppressLint("LongLogTag")
public class CompanionApplicationController {
static final boolean DEBUG = false;
private static final String TAG = "CompanionDevice_ApplicationController";
private static final String TAG = "CDM_CompanionApplicationController";
private static final long REBIND_TIMEOUT = 10 * 1000; // 10 sec
@@ -256,6 +256,9 @@ public class CompanionApplicationController {
return;
}
Log.i(TAG, "Calling onDeviceAppeared to userId=[" + userId + "] package=["
+ packageName + "] associationId=[" + association.getId() + "]");
primaryServiceConnector.postOnDeviceAppeared(association);
}
@@ -278,6 +281,9 @@ public class CompanionApplicationController {
return;
}
Log.i(TAG, "Calling onDeviceDisappeared to userId=[" + userId + "] package=["
+ packageName + "] associationId=[" + association.getId() + "]");
primaryServiceConnector.postOnDeviceDisappeared(association);
}

View File

@@ -124,7 +124,7 @@ import java.util.Set;
@SuppressLint("LongLogTag")
public class CompanionDeviceManagerService extends SystemService {
static final String TAG = "CompanionDeviceManagerService";
static final String TAG = "CDM_CompanionDeviceManagerService";
static final boolean DEBUG = false;
/** Range of Association IDs allocated for a user.*/

View File

@@ -43,7 +43,7 @@ import com.android.server.ServiceThread;
*/
@SuppressLint("LongLogTag")
class CompanionDeviceServiceConnector extends ServiceConnector.Impl<ICompanionDeviceService> {
private static final String TAG = "CompanionDevice_ServiceConnector";
private static final String TAG = "CDM_CompanionServiceConnector";
private static final boolean DEBUG = false;
/** Listener for changes to the state of the {@link CompanionDeviceServiceConnector} */

View File

@@ -26,7 +26,7 @@ import java.io.PrintWriter;
import java.util.List;
class CompanionDeviceShellCommand extends ShellCommand {
private static final String TAG = "CompanionDevice_ShellCommand";
private static final String TAG = "CDM_CompanionDeviceShellCommand";
private final CompanionDeviceManagerService mService;
private final AssociationStore mAssociationStore;

View File

@@ -37,7 +37,7 @@ import java.io.FileOutputStream;
* Util class for CDM data stores
*/
public final class DataStoreUtils {
private static final String TAG = "CompanionDevice_DataStoreUtils";
private static final String TAG = "CDM_DataStoreUtils";
/**
* Check if the parser pointer is at the start of the tag

View File

@@ -63,7 +63,7 @@ import java.util.concurrent.TimeUnit;
*/
public class SystemDataTransferProcessor {
private static final String LOG_TAG = SystemDataTransferProcessor.class.getSimpleName();
private static final String LOG_TAG = "CDM_SystemDataTransferProcessor";
// Values from UI to SystemDataTransferProcessor via ResultReceiver
private static final int RESULT_CODE_SYSTEM_DATA_TRANSFER_ALLOWED = 0;

View File

@@ -75,7 +75,7 @@ import java.util.concurrent.TimeoutException;
*/
public class SystemDataTransferRequestStore {
private static final String LOG_TAG = SystemDataTransferRequestStore.class.getSimpleName();
private static final String LOG_TAG = "CDM_SystemDataTransferRequestStore";
private static final String FILE_NAME = "companion_device_system_data_transfer_requests.xml";

View File

@@ -71,7 +71,7 @@ import java.util.Set;
@SuppressLint("LongLogTag")
class BleCompanionDeviceScanner implements AssociationStore.OnChangeListener {
private static final String TAG = "CompanionDevice_PresenceMonitor_BLE";
private static final String TAG = "CDM_BleCompanionDeviceScanner";
/**
* When using {@link ScanSettings#SCAN_MODE_LOW_POWER}, it usually takes from 20 seconds to

View File

@@ -40,7 +40,7 @@ import java.util.Map;
class BluetoothCompanionDeviceConnectionListener
extends BluetoothAdapter.BluetoothConnectionCallback
implements AssociationStore.OnChangeListener {
private static final String TAG = "CompanionDevice_PresenceMonitor_BT";
private static final String TAG = "CDM_BluetoothCompanionDeviceConnectionListener";
interface Callback {
void onBluetoothCompanionDeviceConnected(int associationId);

View File

@@ -57,7 +57,7 @@ import java.util.Set;
public class CompanionDevicePresenceMonitor implements AssociationStore.OnChangeListener,
BluetoothCompanionDeviceConnectionListener.Callback, BleCompanionDeviceScanner.Callback {
static final boolean DEBUG = false;
private static final String TAG = "CompanionDevice_PresenceMonitor";
private static final String TAG = "CDM_CompanionDevicePresenceMonitor";
/** Callback for notifying about changes to status of companion devices. */
public interface Callback {

View File

@@ -49,7 +49,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@SuppressLint("LongLogTag")
public class CompanionTransportManager {
private static final String TAG = "CompanionTransportManager";
private static final String TAG = "CDM_CompanionTransportManager";
// TODO: flip to false
private static final boolean DEBUG = true;