@@ -142,23 +142,32 @@ |
||
| 142 | 142 |
android:label="@string/app_name" |
| 143 | 143 |
android:screenOrientation="portrait"/> |
| 144 | 144 |
|
| 145 |
- <service android:name=".service.UpgradeService" /> |
|
| 146 |
- |
|
| 147 |
- <service android:name=".service.UploadService" /> |
|
| 148 |
- |
|
| 149 |
- <service android:name=".service.OrderDealService"/> |
|
| 150 |
- |
|
| 151 |
- <service android:name=".dslr.CameraService" |
|
| 152 |
- android:process=":camera"> |
|
| 145 |
+ <activity |
|
| 146 |
+ android:name=".activities.RouteActivity" |
|
| 147 |
+ android:exported="true" |
|
| 148 |
+ android:screenOrientation="portrait" |
|
| 149 |
+ android:theme="@style/MyTransparentTheme"> |
|
| 150 |
+ <intent-filter> |
|
| 151 |
+ <action android:name="android.intent.action.MAIN" /> |
|
| 152 |
+ <category android:name="android.intent.category.DEFAULT" /> |
|
| 153 |
+ </intent-filter> |
|
| 153 | 154 |
<intent-filter> |
| 154 | 155 |
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /> |
| 155 | 156 |
</intent-filter> |
| 156 |
- |
|
| 157 | 157 |
<meta-data |
| 158 | 158 |
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" |
| 159 | 159 |
android:resource="@xml/device_filter" /> |
| 160 |
- </service> |
|
| 160 |
+ </activity> |
|
| 161 |
+ |
|
| 162 |
+ |
|
| 163 |
+ <service android:name=".service.UpgradeService" /> |
|
| 161 | 164 |
|
| 165 |
+ <service android:name=".service.UploadService" /> |
|
| 166 |
+ |
|
| 167 |
+ <service android:name=".service.OrderDealService"/> |
|
| 168 |
+ |
|
| 169 |
+ <service android:name=".dslr.CameraService" |
|
| 170 |
+ android:process=":camera"/> |
|
| 162 | 171 |
</application> |
| 163 | 172 |
|
| 164 | 173 |
</manifest> |
@@ -0,0 +1,20 @@ |
||
| 1 |
+package ai.pai.lensman.activities; |
|
| 2 |
+ |
|
| 3 |
+import android.app.Activity; |
|
| 4 |
+import android.content.Intent; |
|
| 5 |
+import android.os.Bundle; |
|
| 6 |
+ |
|
| 7 |
+import ai.pai.lensman.App; |
|
| 8 |
+import ai.pai.lensman.dslr.CameraService; |
|
| 9 |
+ |
|
| 10 |
+public class RouteActivity extends Activity {
|
|
| 11 |
+ |
|
| 12 |
+ @Override |
|
| 13 |
+ protected void onCreate(Bundle savedInstanceState) {
|
|
| 14 |
+ super.onCreate(savedInstanceState); |
|
| 15 |
+ Intent intent = new Intent(App.getAppContext(), CameraService.class); |
|
| 16 |
+ intent.putExtras(getIntent().getExtras()); |
|
| 17 |
+ App.getAppContext().startService(intent); |
|
| 18 |
+ finish(); |
|
| 19 |
+ } |
|
| 20 |
+} |
@@ -5,7 +5,9 @@ import android.app.Service; |
||
| 5 | 5 |
import android.content.Intent; |
| 6 | 6 |
import android.graphics.Bitmap; |
| 7 | 7 |
import android.os.Bundle; |
| 8 |
+import android.os.Handler; |
|
| 8 | 9 |
import android.os.IBinder; |
| 10 |
+import android.os.Message; |
|
| 9 | 11 |
import android.os.Process; |
| 10 | 12 |
|
| 11 | 13 |
import com.android.common.utils.LogHelper; |
@@ -16,14 +18,13 @@ import com.remoteyourcam.usb.ptp.model.LiveViewData; |
||
| 16 | 18 |
import com.remoteyourcam.usb.ptp.model.ObjectInfo; |
| 17 | 19 |
|
| 18 | 20 |
import java.util.ArrayList; |
| 19 |
-import java.util.Timer; |
|
| 20 |
-import java.util.TimerTask; |
|
| 21 | 21 |
|
| 22 | 22 |
import ai.pai.lensman.db.Preferences; |
| 23 | 23 |
|
| 24 |
-public class CameraService extends Service implements Camera.CameraListener, Camera.StorageInfoListener, Camera.RetrieveImageInfoListener{
|
|
| 24 |
+public class CameraService extends Service implements Handler.Callback, Camera.CameraListener, Camera.StorageInfoListener, Camera.RetrieveImageInfoListener{
|
|
| 25 | 25 |
|
| 26 |
- private Timer photoCaptureTimer; |
|
| 26 |
+ private Handler mainHandler; |
|
| 27 |
+ private final static int MSG_CHECK_STORAGE = 100; |
|
| 27 | 28 |
|
| 28 | 29 |
public static final String ACTION_CAMERA_SERVICE_STATUS_CHANGE = "action.ai.pai.lensman.dslr.cameraservice"; |
| 29 | 30 |
public static final String EXTRA_STATUS_PART = "status"; |
@@ -50,6 +51,7 @@ public class CameraService extends Service implements Camera.CameraListener, Ca |
||
| 50 | 51 |
public void onCreate() {
|
| 51 | 52 |
super.onCreate(); |
| 52 | 53 |
ptp = PtpService.Singleton.getInstance(this); |
| 54 |
+ mainHandler = new Handler(this); |
|
| 53 | 55 |
} |
| 54 | 56 |
|
| 55 | 57 |
@Override |
@@ -99,10 +101,7 @@ public class CameraService extends Service implements Camera.CameraListener, Ca |
||
| 99 | 101 |
} |
| 100 | 102 |
private void stopCamera(){
|
| 101 | 103 |
LogHelper.d("czy","CameraService stopCameraService ");
|
| 102 |
- if(photoCaptureTimer !=null){
|
|
| 103 |
- photoCaptureTimer.cancel(); |
|
| 104 |
- photoCaptureTimer = null; |
|
| 105 |
- } |
|
| 104 |
+ mainHandler.removeCallbacksAndMessages(null); |
|
| 106 | 105 |
ptp.setCameraListener(null); |
| 107 | 106 |
ptp.shutdown(); |
| 108 | 107 |
stopSelf(); |
@@ -113,23 +112,26 @@ public class CameraService extends Service implements Camera.CameraListener, Ca |
||
| 113 | 112 |
|
| 114 | 113 |
public void startCapture() {
|
| 115 | 114 |
stopCapture(); |
| 116 |
- photoCaptureTimer = new Timer(); |
|
| 117 |
- photoCaptureTimer.schedule(new TimerTask() {
|
|
| 118 |
- @Override |
|
| 119 |
- public void run() {
|
|
| 120 |
- camera.retrieveImageHandles(CameraService.this, 0xFFFFFFFF, PtpConstants.ObjectFormat.EXIF_JPEG); |
|
| 121 |
- } |
|
| 122 |
- },0, Preferences.getInstance().getCameraQueryInterval()); |
|
| 115 |
+ mainHandler.sendEmptyMessage(MSG_CHECK_STORAGE); |
|
| 123 | 116 |
} |
| 124 | 117 |
|
| 125 | 118 |
public void stopCapture(){
|
| 126 |
- if(photoCaptureTimer !=null){
|
|
| 127 |
- photoCaptureTimer.cancel(); |
|
| 128 |
- photoCaptureTimer = null; |
|
| 129 |
- } |
|
| 119 |
+ mainHandler.removeCallbacksAndMessages(null); |
|
| 130 | 120 |
origin = new int[0]; |
| 131 | 121 |
} |
| 132 | 122 |
|
| 123 |
+ @Override |
|
| 124 |
+ public boolean handleMessage(Message msg) {
|
|
| 125 |
+ if (msg.what == MSG_CHECK_STORAGE) {
|
|
| 126 |
+ if (camera != null) {
|
|
| 127 |
+ mainHandler.removeMessages(MSG_CHECK_STORAGE); |
|
| 128 |
+ camera.retrieveImageHandles(CameraService.this, 0xFFFFFFFF, PtpConstants.ObjectFormat.EXIF_JPEG); |
|
| 129 |
+ mainHandler.sendEmptyMessageDelayed(MSG_CHECK_STORAGE, Preferences.getInstance().getCameraQueryInterval()); |
|
| 130 |
+ } |
|
| 131 |
+ } |
|
| 132 |
+ return false; |
|
| 133 |
+ } |
|
| 134 |
+ |
|
| 133 | 135 |
private void sendCameraIntent(Bundle bundle){
|
| 134 | 136 |
Intent intent = new Intent(ACTION_CAMERA_SERVICE_STATUS_CHANGE); |
| 135 | 137 |
intent.putExtras(bundle); |
@@ -204,11 +206,7 @@ public class CameraService extends Service implements Camera.CameraListener, Ca |
||
| 204 | 206 |
public void onCapturedPictureReceived(int objectHandle, String filename, Bitmap thumbnail, Bitmap bitmap) {
|
| 205 | 207 |
|
| 206 | 208 |
LogHelper.d("czy","CameraService fetchPhotoTask new photo found");
|
| 207 |
- |
|
| 208 |
- Bundle bundle = new Bundle(); |
|
| 209 |
- bundle.putInt(EXTRA_STATUS_PART, MSG_CAMERA_NEW_PHOTO_FOUND); |
|
| 210 |
- bundle.putString(EXTRA_DATA_PART,filename); |
|
| 211 |
- sendCameraIntent(bundle); |
|
| 209 |
+ saveBmpAndNotify(objectHandle,filename,bitmap); |
|
| 212 | 210 |
} |
| 213 | 211 |
|
| 214 | 212 |
@Override |
@@ -243,7 +241,7 @@ public class CameraService extends Service implements Camera.CameraListener, Ca |
||
| 243 | 241 |
|
| 244 | 242 |
@Override |
| 245 | 243 |
public void onObjectAdded(int handle) {
|
| 246 |
- |
|
| 244 |
+ LogHelper.d("czy","CameraService onObjectAdded: "+ handle);
|
|
| 247 | 245 |
} |
| 248 | 246 |
|
| 249 | 247 |
@Override |
@@ -263,6 +261,8 @@ public class CameraService extends Service implements Camera.CameraListener, Ca |
||
| 263 | 261 |
|
| 264 | 262 |
@Override |
| 265 | 263 |
public void onImageHandlesRetrieved(int[] handles) {
|
| 264 |
+ LogHelper.d("czy","CameraService onImageHandlesRetrieved: "+ handles.length);
|
|
| 265 |
+ |
|
| 266 | 266 |
if(origin.length ==0){
|
| 267 | 267 |
origin = handles; |
| 268 | 268 |
}else{
|
@@ -284,7 +284,8 @@ public class CameraService extends Service implements Camera.CameraListener, Ca |
||
| 284 | 284 |
} |
| 285 | 285 |
if(camera != null && diff.size() >0){
|
| 286 | 286 |
for(int k = 0; k< diff.size();k++){
|
| 287 |
- camera.retrievePicture(diff.get(k)); |
|
| 287 |
+ LogHelper.d("czy","CameraService fetchPhotoTask new photo found: "+ diff.get(k));
|
|
| 288 |
+// camera.retrievePicture(diff.get(k)); |
|
| 288 | 289 |
} |
| 289 | 290 |
} |
| 290 | 291 |
origin = handles; |
@@ -296,5 +297,12 @@ public class CameraService extends Service implements Camera.CameraListener, Ca |
||
| 296 | 297 |
|
| 297 | 298 |
} |
| 298 | 299 |
|
| 300 |
+ private void saveBmpAndNotify(int objectHandle, String filename, Bitmap bmp){
|
|
| 301 |
+ |
|
| 302 |
+// Bundle bundle = new Bundle(); |
|
| 303 |
+// bundle.putInt(EXTRA_STATUS_PART, MSG_CAMERA_NEW_PHOTO_FOUND); |
|
| 304 |
+// bundle.putString(EXTRA_DATA_PART,filename); |
|
| 305 |
+// sendCameraIntent(bundle); |
|
| 306 |
+ } |
|
| 299 | 307 |
|
| 300 | 308 |
} |
@@ -1,4 +1,4 @@ |
||
| 1 |
-<resources> |
|
| 1 |
+<resources xmlns:tools="http://schemas.android.com/tools"> |
|
| 2 | 2 |
|
| 3 | 3 |
<!-- Base application theme. --> |
| 4 | 4 |
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> |
@@ -13,4 +13,22 @@ |
||
| 13 | 13 |
<item name="windowNoTitle">true</item> |
| 14 | 14 |
</style> |
| 15 | 15 |
|
| 16 |
+ <style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar"> |
|
| 17 |
+ <!-- Customize your theme here. --> |
|
| 18 |
+ <item name="android:selectableItemBackground">@null</item> |
|
| 19 |
+ <item name="android:selectableItemBackgroundBorderless" tools:targetApi="lollipop">@null |
|
| 20 |
+ </item> |
|
| 21 |
+ </style> |
|
| 22 |
+ |
|
| 23 |
+ <style name="MyTransparentTheme" parent="MyAppTheme"> |
|
| 24 |
+ <item name="android:windowBackground">@color/transparent</item> |
|
| 25 |
+ <item name="android:windowIsTranslucent">true</item> |
|
| 26 |
+ <item name="android:windowFrame">@null</item> |
|
| 27 |
+ <item name="android:windowContentOverlay">@null</item> |
|
| 28 |
+ <item name="android:windowAnimationStyle">@null</item> |
|
| 29 |
+ <item name="android:backgroundDimEnabled">false</item> |
|
| 30 |
+ <item name="android:windowIsFloating">false</item> |
|
| 31 |
+ <item name="windowNoTitle">true</item> |
|
| 32 |
+ </style> |
|
| 33 |
+ |
|
| 16 | 34 |
</resources> |
@@ -175,9 +175,9 @@ public class NikonCamera extends PtpCamera {
|
||
| 175 | 175 |
queue.add(new SimpleCommand(this, PtpConstants.Operation.NikonDeleteImagesInSdram, objectHandle)); |
| 176 | 176 |
} |
| 177 | 177 |
|
| 178 |
- public void onEventObjectAdded(int objectHandle) {
|
|
| 179 |
- queue.add(new RetrieveAddedObjectInfoAction(this, objectHandle)); |
|
| 180 |
- } |
|
| 178 |
+// public void onEventObjectAdded(int objectHandle) {
|
|
| 179 |
+// queue.add(new RetrieveAddedObjectInfoAction(this, objectHandle)); |
|
| 180 |
+// } |
|
| 181 | 181 |
|
| 182 | 182 |
public void onEventCaptureComplete() {
|
| 183 | 183 |
//TODO |
@@ -41,7 +41,6 @@ public class RetrieveAddedObjectInfoAction implements PtpAction {
|
||
| 41 | 41 |
if (getInfo.getObjectInfo() == null) {
|
| 42 | 42 |
return; |
| 43 | 43 |
} |
| 44 |
- |
|
| 45 | 44 |
camera.onEventObjectAdded(objectHandle); |
| 46 | 45 |
} |
| 47 | 46 |
|
@@ -72,7 +72,9 @@ public class NikonEventCheckCommand extends NikonCommand {
|
||
| 72 | 72 |
break; |
| 73 | 73 |
case Event.NikonObjectAddedInSdram: |
| 74 | 74 |
//libgphoto2 相关处理 |
| 75 |
- if (eventParam == 0) { eventParam = 0xffff001; }
|
|
| 75 |
+ if (eventParam == 0) {
|
|
| 76 |
+ eventParam = 0xffff0001; |
|
| 77 |
+ } |
|
| 76 | 78 |
camera.onEventObjectAdded(eventParam); |
| 77 | 79 |
break; |
| 78 | 80 |
} |