Don't dismiss adb authorization prompt upon USB disconnect.
adbd expects a reply from system_server for authorization: normally there's a reply of "OK" or "NO", but when the prompt is dismissed because of USB disconnect, no response is sent, and we can't prompt for user authorization until system_server or adbd is restarted. Dismissing the authorization prompt on USB disconnect is also wrong: the request might not be coming in over USB. Bug: http://b/145814587 Test: unplugged a device with authorization dialog open Change-Id: I5a9925b917a7169213256daa557637b770583058
This commit is contained in:
@@ -22,8 +22,6 @@ import com.android.systemui.ForegroundServicesDialog;
|
||||
import com.android.systemui.keyguard.WorkLockActivity;
|
||||
import com.android.systemui.settings.BrightnessDialog;
|
||||
import com.android.systemui.tuner.TunerActivity;
|
||||
import com.android.systemui.usb.UsbDebuggingActivity;
|
||||
import com.android.systemui.usb.UsbDebuggingSecondaryUserActivity;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
@@ -58,17 +56,4 @@ public abstract class DefaultActivityBinder {
|
||||
@IntoMap
|
||||
@ClassKey(BrightnessDialog.class)
|
||||
public abstract Activity bindBrightnessDialog(BrightnessDialog activity);
|
||||
|
||||
/** Inject into UsbDebuggingActivity. */
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(UsbDebuggingActivity.class)
|
||||
public abstract Activity bindUsbDebuggingActivity(UsbDebuggingActivity activity);
|
||||
|
||||
/** Inject into UsbDebuggingSecondaryUserActivity. */
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(UsbDebuggingSecondaryUserActivity.class)
|
||||
public abstract Activity bindUsbDebuggingSecondaryUserActivity(
|
||||
UsbDebuggingSecondaryUserActivity activity);
|
||||
}
|
||||
|
||||
@@ -16,19 +16,13 @@
|
||||
|
||||
package com.android.systemui.usb;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.debug.IAdbManager;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemProperties;
|
||||
import android.util.EventLog;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -42,25 +36,14 @@ import android.widget.Toast;
|
||||
import com.android.internal.app.AlertActivity;
|
||||
import com.android.internal.app.AlertController;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class UsbDebuggingActivity extends AlertActivity
|
||||
implements DialogInterface.OnClickListener {
|
||||
private static final String TAG = "UsbDebuggingActivity";
|
||||
|
||||
private CheckBox mAlwaysAllow;
|
||||
private UsbDisconnectedReceiver mDisconnectedReceiver;
|
||||
private final BroadcastDispatcher mBroadcastDispatcher;
|
||||
private String mKey;
|
||||
|
||||
@Inject
|
||||
public UsbDebuggingActivity(BroadcastDispatcher broadcastDispatcher) {
|
||||
super();
|
||||
mBroadcastDispatcher = broadcastDispatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
Window window = getWindow();
|
||||
@@ -70,10 +53,6 @@ public class UsbDebuggingActivity extends AlertActivity
|
||||
|
||||
super.onCreate(icicle);
|
||||
|
||||
if (SystemProperties.getInt("service.adb.tcp.port", 0) == 0) {
|
||||
mDisconnectedReceiver = new UsbDisconnectedReceiver(this);
|
||||
}
|
||||
|
||||
Intent intent = getIntent();
|
||||
String fingerprints = intent.getStringExtra("fingerprints");
|
||||
mKey = intent.getStringExtra("key");
|
||||
@@ -126,40 +105,6 @@ public class UsbDebuggingActivity extends AlertActivity
|
||||
super.onWindowAttributesChanged(params);
|
||||
}
|
||||
|
||||
private class UsbDisconnectedReceiver extends BroadcastReceiver {
|
||||
private final Activity mActivity;
|
||||
public UsbDisconnectedReceiver(Activity activity) {
|
||||
mActivity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context content, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (!UsbManager.ACTION_USB_STATE.equals(action)) {
|
||||
return;
|
||||
}
|
||||
boolean connected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false);
|
||||
if (!connected) {
|
||||
mActivity.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
IntentFilter filter = new IntentFilter(UsbManager.ACTION_USB_STATE);
|
||||
mBroadcastDispatcher.registerReceiver(mDisconnectedReceiver, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
if (mDisconnectedReceiver != null) {
|
||||
mBroadcastDispatcher.unregisterReceiver(mDisconnectedReceiver);
|
||||
}
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
boolean allow = (which == AlertDialog.BUTTON_POSITIVE);
|
||||
|
||||
@@ -16,41 +16,19 @@
|
||||
|
||||
package com.android.systemui.usb;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import com.android.internal.app.AlertActivity;
|
||||
import com.android.internal.app.AlertController;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class UsbDebuggingSecondaryUserActivity extends AlertActivity
|
||||
implements DialogInterface.OnClickListener {
|
||||
private UsbDisconnectedReceiver mDisconnectedReceiver;
|
||||
private final BroadcastDispatcher mBroadcastDispatcher;
|
||||
|
||||
@Inject
|
||||
public UsbDebuggingSecondaryUserActivity(BroadcastDispatcher broadcastDispatcher) {
|
||||
mBroadcastDispatcher = broadcastDispatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
if (SystemProperties.getInt("service.adb.tcp.port", 0) == 0) {
|
||||
mDisconnectedReceiver = new UsbDisconnectedReceiver(this);
|
||||
}
|
||||
|
||||
final AlertController.AlertParams ap = mAlertParams;
|
||||
ap.mTitle = getString(R.string.usb_debugging_secondary_user_title);
|
||||
ap.mMessage = getString(R.string.usb_debugging_secondary_user_message);
|
||||
@@ -60,40 +38,6 @@ public class UsbDebuggingSecondaryUserActivity extends AlertActivity
|
||||
setupAlert();
|
||||
}
|
||||
|
||||
private class UsbDisconnectedReceiver extends BroadcastReceiver {
|
||||
private final Activity mActivity;
|
||||
public UsbDisconnectedReceiver(Activity activity) {
|
||||
mActivity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context content, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (UsbManager.ACTION_USB_STATE.equals(action)) {
|
||||
boolean connected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false);
|
||||
if (!connected) {
|
||||
mActivity.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
IntentFilter filter = new IntentFilter(UsbManager.ACTION_USB_STATE);
|
||||
mBroadcastDispatcher.registerReceiver(mDisconnectedReceiver, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
if (mDisconnectedReceiver != null) {
|
||||
mBroadcastDispatcher.unregisterReceiver(mDisconnectedReceiver);
|
||||
}
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finish();
|
||||
|
||||
Reference in New Issue
Block a user