Merge changes I00d6980a,I814221b4,Id88603a5
* changes: CameraBrowser: Launch itself when a camera is attached to USB. Send Intents when PTP compatible devices are connected/disconnected to USB Give system server permission to access USB.
This commit is contained in:
committed by
Android (Google) Code Review
commit
03a545e5ed
@@ -24,6 +24,7 @@ import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.UEventObserver;
|
||||
import android.provider.Mtp;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
@@ -147,8 +148,43 @@ class UsbObserver extends UEventObserver {
|
||||
}
|
||||
}
|
||||
|
||||
private native void monitorUsbHostBus();
|
||||
|
||||
// called from JNI in monitorUsbHostBus()
|
||||
private void usbCameraAdded(int deviceID) {
|
||||
Intent intent = new Intent(Usb.ACTION_USB_CAMERA_ATTACHED,
|
||||
Mtp.Device.getContentUri(deviceID));
|
||||
Log.d(TAG, "usbCameraAdded, sending " + intent);
|
||||
mContext.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
// called from JNI in monitorUsbHostBus()
|
||||
private void usbCameraRemoved(int deviceID) {
|
||||
Intent intent = new Intent(Usb.ACTION_USB_CAMERA_DETACHED,
|
||||
Mtp.Device.getContentUri(deviceID));
|
||||
Log.d(TAG, "usbCameraRemoved, sending " + intent);
|
||||
mContext.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
private void initHostSupport() {
|
||||
// Create a thread to call into native code to wait for USB host events.
|
||||
// This thread will call us back on usbCameraAdded and usbCameraRemoved.
|
||||
Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
monitorUsbHostBus();
|
||||
}
|
||||
};
|
||||
new Thread(null, runnable, "UsbObserver host thread").start();
|
||||
}
|
||||
|
||||
void systemReady() {
|
||||
synchronized (this) {
|
||||
if (mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_hasUsbHostSupport)) {
|
||||
// start monitoring for connected USB devices
|
||||
initHostSupport();
|
||||
}
|
||||
|
||||
update();
|
||||
mSystemReady = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user