>
|
|
209
|
+ bundle.putInt(EXTRA_STATUS_PART, MSG_CAMERA_NEW_PHOTO_FOUND);
|
|
|
210
|
+ bundle.putString(EXTRA_DATA_PART,filename);
|
|
|
211
|
+ sendCameraIntent(bundle);
|
|
|
212
|
+ }
|
|
|
213
|
+
|
|
|
214
|
+ @Override
|
|
|
215
|
+ public void onBulbStarted() {
|
|
|
216
|
+
|
|
|
217
|
+ }
|
|
|
218
|
+
|
|
|
219
|
+ @Override
|
|
|
220
|
+ public void onBulbExposureTime(int seconds) {
|
|
|
221
|
+
|
|
|
222
|
+ }
|
|
|
223
|
+
|
|
|
224
|
+ @Override
|
|
|
225
|
+ public void onBulbStopped() {
|
|
|
226
|
+
|
|
|
227
|
+ }
|
|
|
228
|
+
|
|
|
229
|
+ @Override
|
|
|
230
|
+ public void onFocusStarted() {
|
|
|
231
|
+
|
|
|
232
|
+ }
|
|
|
233
|
+
|
|
|
234
|
+ @Override
|
|
|
235
|
+ public void onFocusEnded(boolean hasFocused) {
|
|
|
236
|
+
|
|
|
237
|
+ }
|
|
|
238
|
+
|
|
|
239
|
+ @Override
|
|
|
240
|
+ public void onFocusPointsChanged() {
|
|
|
241
|
+
|
|
|
242
|
+ }
|
|
|
243
|
+
|
|
|
244
|
+ @Override
|
|
|
245
|
+ public void onObjectAdded(int handle) {
|
|
|
246
|
+
|
|
|
247
|
+ }
|
|
|
248
|
+
|
|
|
249
|
+ @Override
|
|
|
250
|
+ public void onLogMessage(String msg) {
|
|
|
251
|
+
|
|
|
252
|
+ }
|
|
|
253
|
+
|
|
|
254
|
+ @Override
|
|
|
255
|
+ public void onStorageFound(int handle, String label) {
|
|
|
256
|
+
|
|
|
257
|
+ }
|
|
|
258
|
+
|
|
|
259
|
+ @Override
|
|
|
260
|
+ public void onAllStoragesFound() {
|
|
|
261
|
+
|
|
|
262
|
+ }
|
|
|
263
|
+
|
|
|
264
|
+ @Override
|
|
|
265
|
+ public void onImageHandlesRetrieved(int[] handles) {
|
|
|
266
|
+ if(origin.length ==0){
|
|
|
267
|
+ origin = handles;
|
|
|
268
|
+ }else{
|
|
|
269
|
+ if(origin.length == handles.length){
|
|
|
270
|
+ return;
|
|
|
271
|
+ }
|
|
|
272
|
+ ArrayList<Integer> diff = new ArrayList<>();
|
|
|
273
|
+ for (int i = 0; i < handles.length; i++) {
|
|
|
274
|
+ boolean isMatch = false;
|
|
|
275
|
+ for (int j = 0; j < origin.length; j++) {
|
|
|
276
|
+ if (origin[j] == handles[i]) {
|
|
|
277
|
+ isMatch = true;
|
|
|
278
|
+ break;
|
|
|
279
|
+ }
|
|
220
|
280
|
}
|
|
221
|
|
- }else if(MSG_TYPE_CREATE_FILE_ERROR.equalsIgnoreCase(eventMsg)){
|
|
222
|
|
- Bundle bundle = new Bundle();
|
|
223
|
|
- bundle.putInt(EXTRA_STATUS_PART, MSG_SDCARD_ERROR);
|
|
224
|
|
- sendCameraIntent(bundle);
|
|
225
|
|
- }else{
|
|
226
|
|
- String sub = eventMsg.substring(0,1);
|
|
227
|
|
- if(TextUtils.isDigitsOnly(sub)){
|
|
228
|
|
- LogHelper.d("czy","CameraService fetchPhotoTask new photo found");
|
|
229
|
|
- Bundle bundle = new Bundle();
|
|
230
|
|
- bundle.putInt(EXTRA_STATUS_PART, MSG_CAMERA_NEW_PHOTO_FOUND);
|
|
231
|
|
- bundle.putString(EXTRA_DATA_PART,eventMsg);
|
|
232
|
|
- sendCameraIntent(bundle);
|
|
|
281
|
+ if (!isMatch) {
|
|
|
282
|
+ diff.add(handles[i]);
|
|
233
|
283
|
}
|
|
234
|
284
|
}
|
|
235
|
|
- }else{
|
|
236
|
|
- count++;
|
|
237
|
|
- if(count>=MAX_NO_PHOTO_COUNT){
|
|
238
|
|
- LogHelper.d("czy","CameraService fetchPhotoTask 太久没发现新照片了,重新连接试试");
|
|
239
|
|
- Bundle bundle = new Bundle();
|
|
240
|
|
- bundle.putInt(EXTRA_STATUS_PART, MSG_CAMERA_CONN_ERROR);
|
|
241
|
|
- sendCameraIntent(bundle);
|
|
242
|
|
- stopCameraService();
|
|
|
285
|
+ if(camera != null && diff.size() >0){
|
|
|
286
|
+ for(int k = 0; k< diff.size();k++){
|
|
|
287
|
+ camera.retrievePicture(diff.get(k));
|
|
|
288
|
+ }
|
|
243
|
289
|
}
|
|
|
290
|
+ origin = handles;
|
|
244
|
291
|
}
|
|
245
|
|
-
|
|
246
|
|
- isLastQueryReturned = true;
|
|
247
|
292
|
}
|
|
248
|
293
|
|
|
249
|
|
- private void sendCameraIntent(Bundle bundle){
|
|
250
|
|
- Intent intent = new Intent(ACTION_CAMERA_SERVICE_STATUS_CHANGE);
|
|
251
|
|
- intent.putExtras(bundle);
|
|
252
|
|
- sendBroadcast(intent);
|
|
|
294
|
+ @Override
|
|
|
295
|
+ public void onImageInfoRetrieved(int objectHandle, ObjectInfo objectInfo, Bitmap thumbnail) {
|
|
|
296
|
+
|
|
253
|
297
|
}
|
|
254
|
298
|
|
|
|
299
|
+
|
|
255
|
300
|
}
|
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+<?xml version="1.0" encoding="utf-8"?>
|
|
|
2
|
+<!-- Copyright (C) 2011 The Android Open Source Project
|
|
|
3
|
+
|
|
|
4
|
+ Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
5
|
+ you may not use this file except in compliance with the License.
|
|
|
6
|
+ You may obtain a copy of the License at
|
|
|
7
|
+
|
|
|
8
|
+ http://www.apache.org/licenses/LICENSE-2.0
|
|
|
9
|
+
|
|
|
10
|
+ Unless required by applicable law or agreed to in writing, software
|
|
|
11
|
+ distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
12
|
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13
|
+ See the License for the specific language governing permissions and
|
|
|
14
|
+ limitations under the License.
|
|
|
15
|
+-->
|
|
|
16
|
+<resources>
|
|
|
17
|
+ <!-- vendor and product ID for EOS 600D -->
|
|
|
18
|
+ <!-- usb-device vendor-id="1193" product-id="12824" -->
|
|
|
19
|
+ <!-- usb-device protocol="0" / -->
|
|
|
20
|
+ <usb-device class="6" subclass="1" protocol="1" />
|
|
|
21
|
+</resources>
|
|
|
|
@@ -101,7 +101,7 @@ public class PtpUsbService implements PtpService {
|
|
101
|
101
|
}
|
|
102
|
102
|
camera.shutdownHard();
|
|
103
|
103
|
}
|
|
104
|
|
- UsbDevice device = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
|
|
|
104
|
+ UsbDevice device = intent == null ? null :(UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
|
|
105
|
105
|
if (device != null) {
|
|
106
|
106
|
if (AppConfig.LOG) {
|
|
107
|
107
|
Log.i(TAG, "initialize: got device through intent");
|