Loading services/core/java/com/android/server/camera/CameraServiceProxy.java +40 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ import android.hardware.camera2.CaptureRequest; import android.hardware.devicestate.DeviceStateManager; import android.hardware.devicestate.DeviceStateManager.FoldStateListener; import android.hardware.display.DisplayManager; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbManager; import android.media.AudioManager; import android.nfc.INfcAdapter; import android.os.Binder; Loading Loading @@ -335,6 +337,16 @@ public class CameraServiceProxy extends SystemService switchUserLocked(mLastUser); } break; case UsbManager.ACTION_USB_DEVICE_ATTACHED: case UsbManager.ACTION_USB_DEVICE_DETACHED: synchronized (mLock) { UsbDevice device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); if (device != null) { notifyUsbDeviceHotplugLocked(device, action.equals(UsbManager.ACTION_USB_DEVICE_ATTACHED)); } } break; default: break; // do nothing } Loading Loading @@ -645,6 +657,8 @@ public class CameraServiceProxy extends SystemService filter.addAction(Intent.ACTION_USER_INFO_CHANGED); filter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED); filter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED); filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); mContext.registerReceiver(mIntentReceiver, filter); publishBinderService(CAMERA_SERVICE_PROXY_BINDER_NAME, mCameraServiceProxy); Loading Loading @@ -963,6 +977,32 @@ public class CameraServiceProxy extends SystemService return true; } private boolean notifyUsbDeviceHotplugLocked(@NonNull UsbDevice device, boolean attached) { // Only handle external USB camera devices if (device.getHasVideoCapture()) { // Forward the usb hotplug event to the native camera service running in the // cameraserver // process. ICameraService cameraService = getCameraServiceRawLocked(); if (cameraService == null) { Slog.w(TAG, "Could not notify cameraserver, camera service not available."); return false; } try { int eventType = attached ? ICameraService.EVENT_USB_DEVICE_ATTACHED : ICameraService.EVENT_USB_DEVICE_DETACHED; mCameraServiceRaw.notifySystemEvent(eventType, new int[]{device.getDeviceId()}); } catch (RemoteException e) { Slog.w(TAG, "Could not notify cameraserver, remote exception: " + e); // Not much we can do if camera service is dead. return false; } return true; } return false; } private void updateActivityCount(CameraSessionStats cameraState) { String cameraId = cameraState.getCameraId(); int newCameraState = cameraState.getNewCameraState(); Loading Loading
services/core/java/com/android/server/camera/CameraServiceProxy.java +40 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ import android.hardware.camera2.CaptureRequest; import android.hardware.devicestate.DeviceStateManager; import android.hardware.devicestate.DeviceStateManager.FoldStateListener; import android.hardware.display.DisplayManager; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbManager; import android.media.AudioManager; import android.nfc.INfcAdapter; import android.os.Binder; Loading Loading @@ -335,6 +337,16 @@ public class CameraServiceProxy extends SystemService switchUserLocked(mLastUser); } break; case UsbManager.ACTION_USB_DEVICE_ATTACHED: case UsbManager.ACTION_USB_DEVICE_DETACHED: synchronized (mLock) { UsbDevice device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); if (device != null) { notifyUsbDeviceHotplugLocked(device, action.equals(UsbManager.ACTION_USB_DEVICE_ATTACHED)); } } break; default: break; // do nothing } Loading Loading @@ -645,6 +657,8 @@ public class CameraServiceProxy extends SystemService filter.addAction(Intent.ACTION_USER_INFO_CHANGED); filter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED); filter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED); filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); mContext.registerReceiver(mIntentReceiver, filter); publishBinderService(CAMERA_SERVICE_PROXY_BINDER_NAME, mCameraServiceProxy); Loading Loading @@ -963,6 +977,32 @@ public class CameraServiceProxy extends SystemService return true; } private boolean notifyUsbDeviceHotplugLocked(@NonNull UsbDevice device, boolean attached) { // Only handle external USB camera devices if (device.getHasVideoCapture()) { // Forward the usb hotplug event to the native camera service running in the // cameraserver // process. ICameraService cameraService = getCameraServiceRawLocked(); if (cameraService == null) { Slog.w(TAG, "Could not notify cameraserver, camera service not available."); return false; } try { int eventType = attached ? ICameraService.EVENT_USB_DEVICE_ATTACHED : ICameraService.EVENT_USB_DEVICE_DETACHED; mCameraServiceRaw.notifySystemEvent(eventType, new int[]{device.getDeviceId()}); } catch (RemoteException e) { Slog.w(TAG, "Could not notify cameraserver, remote exception: " + e); // Not much we can do if camera service is dead. return false; } return true; } return false; } private void updateActivityCount(CameraSessionStats cameraState) { String cameraId = cameraState.getCameraId(); int newCameraState = cameraState.getNewCameraState(); Loading