Merge "Upgrade logging for UsbDeviceManager to narrow down bugs." into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6d3747ebe2
@@ -63,6 +63,7 @@ import java.io.IOException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -537,6 +538,7 @@ public class UsbDeviceManager {
|
|||||||
oldFunctions = UsbManager.USB_FUNCTION_NONE;
|
oldFunctions = UsbManager.USB_FUNCTION_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Slog.i(TAG, "Setting adb to " + String.valueOf(enable));
|
||||||
setEnabledFunctions(oldFunctions, true, mUsbDataUnlocked);
|
setEnabledFunctions(oldFunctions, true, mUsbDataUnlocked);
|
||||||
updateAdbNotification();
|
updateAdbNotification();
|
||||||
}
|
}
|
||||||
@@ -764,15 +766,16 @@ public class UsbDeviceManager {
|
|||||||
|
|
||||||
// send broadcast intent only if the USB state has changed
|
// send broadcast intent only if the USB state has changed
|
||||||
if (!isUsbStateChanged(intent)) {
|
if (!isUsbStateChanged(intent)) {
|
||||||
if (DEBUG) {
|
Slog.i(TAG, "skip broadcasting " + intent + " extras: " + intent.getExtras());
|
||||||
Slog.d(TAG, "skip broadcasting " + intent + " extras: " + intent.getExtras());
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG) Slog.d(TAG, "broadcasting " + intent + " extras: " + intent.getExtras());
|
|
||||||
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
|
|
||||||
mBroadcastedIntent = intent;
|
mBroadcastedIntent = intent;
|
||||||
|
|
||||||
|
Random rand = new Random();
|
||||||
|
intent.putExtra("random_tag", rand.nextInt(1000));
|
||||||
|
Slog.i(TAG, "broadcasting " + intent + " extras: " + intent.getExtras());
|
||||||
|
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
|
||||||
|
intent.removeExtra("random_tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateUsbFunctions() {
|
private void updateUsbFunctions() {
|
||||||
@@ -845,8 +848,10 @@ public class UsbDeviceManager {
|
|||||||
updateCurrentAccessory();
|
updateCurrentAccessory();
|
||||||
}
|
}
|
||||||
if (mBootCompleted) {
|
if (mBootCompleted) {
|
||||||
|
Slog.i(TAG, "update state " + mConnected + " " + mConfigured);
|
||||||
if (!mConnected) {
|
if (!mConnected) {
|
||||||
// restore defaults when USB is disconnected
|
// restore defaults when USB is disconnected
|
||||||
|
Slog.i(TAG, "Disconnect, setting usb functions to null");
|
||||||
setEnabledFunctions(null, false, false);
|
setEnabledFunctions(null, false, false);
|
||||||
}
|
}
|
||||||
updateUsbStateBroadcastIfNeeded(false);
|
updateUsbStateBroadcastIfNeeded(false);
|
||||||
@@ -880,6 +885,7 @@ public class UsbDeviceManager {
|
|||||||
break;
|
break;
|
||||||
case MSG_SET_CURRENT_FUNCTIONS:
|
case MSG_SET_CURRENT_FUNCTIONS:
|
||||||
String functions = (String) msg.obj;
|
String functions = (String) msg.obj;
|
||||||
|
Slog.i(TAG, "Getting setFunction command for " + functions);
|
||||||
setEnabledFunctions(functions, false, msg.arg1 == 1);
|
setEnabledFunctions(functions, false, msg.arg1 == 1);
|
||||||
break;
|
break;
|
||||||
case MSG_UPDATE_USER_RESTRICTIONS:
|
case MSG_UPDATE_USER_RESTRICTIONS:
|
||||||
@@ -887,6 +893,8 @@ public class UsbDeviceManager {
|
|||||||
final boolean forceRestart = mUsbDataUnlocked
|
final boolean forceRestart = mUsbDataUnlocked
|
||||||
&& isUsbDataTransferActive()
|
&& isUsbDataTransferActive()
|
||||||
&& !isUsbTransferAllowed();
|
&& !isUsbTransferAllowed();
|
||||||
|
Slog.i(TAG, "Updating user restrictions, force restart is "
|
||||||
|
+ String.valueOf(forceRestart));
|
||||||
setEnabledFunctions(
|
setEnabledFunctions(
|
||||||
mCurrentFunctions, forceRestart, mUsbDataUnlocked && !forceRestart);
|
mCurrentFunctions, forceRestart, mUsbDataUnlocked && !forceRestart);
|
||||||
break;
|
break;
|
||||||
@@ -901,6 +909,7 @@ public class UsbDeviceManager {
|
|||||||
updateUsbStateBroadcastIfNeeded(false);
|
updateUsbStateBroadcastIfNeeded(false);
|
||||||
mPendingBootBroadcast = false;
|
mPendingBootBroadcast = false;
|
||||||
}
|
}
|
||||||
|
Slog.i(TAG, "Boot complete, setting default functions");
|
||||||
setEnabledFunctions(null, false, false);
|
setEnabledFunctions(null, false, false);
|
||||||
if (mCurrentAccessory != null) {
|
if (mCurrentAccessory != null) {
|
||||||
getCurrentSettings().accessoryAttached(mCurrentAccessory);
|
getCurrentSettings().accessoryAttached(mCurrentAccessory);
|
||||||
@@ -918,6 +927,7 @@ public class UsbDeviceManager {
|
|||||||
Slog.v(TAG, "Current user switched to " + msg.arg1
|
Slog.v(TAG, "Current user switched to " + msg.arg1
|
||||||
+ "; resetting USB host stack for MTP or PTP");
|
+ "; resetting USB host stack for MTP or PTP");
|
||||||
// avoid leaking sensitive data from previous user
|
// avoid leaking sensitive data from previous user
|
||||||
|
Slog.i(TAG, "User Switched, kicking usb stack");
|
||||||
setEnabledFunctions(mCurrentFunctions, true, false);
|
setEnabledFunctions(mCurrentFunctions, true, false);
|
||||||
}
|
}
|
||||||
mCurrentUser = msg.arg1;
|
mCurrentUser = msg.arg1;
|
||||||
|
|||||||
Reference in New Issue
Block a user