[DEV][Thinktank][NO-OFFTOPIC HERE!]Porting Z3 camera to previous Xperia devices

Search This thread

olokos

Recognized Developer
Oct 16, 2011
2,945
2,494
Warsaw
We are trying to get Z3 Camera software fully working here. Please contribute to [DEV] thread if you actually have something helpful for us. If you don't then head over to Discussion thread here
Any off-topic posts in this thread instead of Q&A thread will slow-down the development and may put-off some people to work on this.
This port is somewhat a continuation of this one.
We hope to get all camera features from Z3 like 12000 ISO and pause recording, but at this point we can't tell if it will work at all.

XDA:DevDB Information
Z3 camera port for more Xperia Devices, App for all devices (see above for details)

Contributors
olokos, tomascus, Riyal, lagalaga, slowlyshah

Version Information
Status: Testing

Created 2014-10-06
Last Updated 2014-10-06
 

olokos

Recognized Developer
Oct 16, 2011
2,945
2,494
Warsaw
Reserved

Here are some files that @tomascus have uploaded for us to test. I made it flashable. Don't bother about what the updater-script says. I just took it from my other zip.
It breaks video recording for now, but that's a good place to start.
http://d-h.st/GYg
Use this thread as a reference of what's done so far. It's cluttered, but something useful might still be there.
 
Last edited:

tomascus

Recognized Developer
Jun 5, 2012
1,904
2,650
Melbourne
Reserved for future use

Hehe, good start. We might also need more brainpower. @Chocolatetrain, I take back what I said about giving this up, you can help us if you want :p

Anyway, something a little more on topic :

It seems all the magic is in the main lib files in system/lib, (the ones that don't work), hopefully I'll get to doing some debugging tomorrow and checking it oitm
 

olokos

Recognized Developer
Oct 16, 2011
2,945
2,494
Warsaw
Here are some logcats I took. That's a good place to start. I'll investigate this later.

EDIT
Our first priority should be getting Z3 camera recording working so it would be usable on a daily basis for now. We're really close I feel. At least to get recording. There's a problem with startvideometadata function of cameraextension.
There's a log for that. Check out the attachment as I might be missing something.
 

Attachments

  • logcats_06.10.2014.zip
    4.8 KB · Views: 54
Last edited:

tomascus

Recognized Developer
Jun 5, 2012
1,904
2,650
Melbourne
Here are some logcats I took. That's a good place to start. I'll investigate this later.

EDIT
Our first priority should be getting Z3 camera recording working so it would be usable on a daily basis for now. We're really close I feel. At least to get recording. There's a problem with startvideometadata function of cameraextension.
There's a log for that. Check out the attachment as I might be missing something.

Fixed, will upload updated apk later. btw, what's your google account so i can add you as editor?

https://drive.google.com/folderview?id=0B3bfLXY54yW-eUphbUoxVHduZlU&usp=drive_web

edit: video recording now works in the files on above link.
Time for SuperVideoCamera.apk?
 
Last edited:

olokos

Recognized Developer
Oct 16, 2011
2,945
2,494
Warsaw
Fixed, will upload updated apk later. btw, what's your google account so i can add you as editor?

https://drive.google.com/folderview?id=0B3bfLXY54yW-eUphbUoxVHduZlU&usp=drive_web

edit: video recording now works in the files on above link.
Time for SuperVideoCamera.apk?

Nice one.
I've sent you a PM with my e-mail.
Works great!

BTW. What have you done to get it to work?
Probably yeah. It's great that you got this working so we can use it everyday now and get all the issues on the go.
 
Last edited:

tomascus

Recognized Developer
Jun 5, 2012
1,904
2,650
Melbourne
Getting it to work:

Nice one.
I've sent you a PM with my e-mail.
Works great!

BTW. What have you done to get it to work?
Probably yeah. It's great that you got this working so we can use it everyday now and get all the issues on the go.

1. Logcat points to some java files i.e Cameradevice.java in this case, so we can search for string 'videometadata' in the smali file
2. found it:

Code:
.method public startVideoMetadata()V
    .locals 3

   .prologue
   .line 3267
    iget-object v0, p0, Lcom/sonyericsson/android/camera/device/CameraDevice;->mCameraExtension:Lcom/sonyericsson/cameraextension/CameraExtension;
	
    if-eqz v0, :cond_0

    .line 3268
    iget-object v0, p0, Lcom/sonyericsson/android/camera/device/CameraDevice;->mCameraExtension:Lcom/sonyericsson/cameraextension/CameraExtension;

    invoke-virtual {v0}, Lcom/sonyericsson/cameraextension/CameraExtension;->startVideoMetadata()V

    .line 3269
    new-instance v0, Lcom/sonyericsson/cameracommon/status/EachCameraStatusPublisher;

    iget-object v1, p0, Lcom/sonyericsson/android/camera/device/CameraDevice;->mCameraActivity:Lcom/sonyericsson/android/camera/CameraActivity;

    iget v2, p0, Lcom/sonyericsson/android/camera/device/CameraDevice;->mCameraId:I

    invoke-direct {v0, v1, v2}, Lcom/sonyericsson/cameracommon/status/EachCameraStatusPublisher;-><init>(Landroid/content/Context;I)V

    new-instance v1, Lcom/sonyericsson/cameracommon/status/eachcamera/Metadata;

    sget-object v2, Lcom/sonyericsson/cameracommon/status/eachcamera/Metadata$Value;->ON:Lcom/sonyericsson/cameracommon/status/eachcamera/Metadata$Value;

    invoke-direct {v1, v2}, Lcom/sonyericsson/cameracommon/status/eachcamera/Metadata;-><init>(Lcom/sonyericsson/cameracommon/status/eachcamera/Metadata$Value;)V

    invoke-virtual {v0, v1}, Lcom/sonyericsson/cameracommon/status/EachCameraStatusPublisher;->put(Lcom/sonyericsson/cameracommon/status/CameraStatusValue;)Lcom/sonyericsson/cameracommon/status/CameraStatusPublisher;

    move-result-object v0

    invoke-virtual {v0}, Lcom/sonyericsson/cameracommon/status/CameraStatusPublisher;->publish()V

    .line 3273
    :cond_0
    return-void

3. For this one, I compared method against same Z2 file and didn't find it
4. Looked up purpose of videometadata
5. Figured it was pointless, so might as well not run all that code at all
6. Edit smali file, make it move straight to :cond_0 by adding making that if-eqz v0 always true, make v0 have value of 0, therefore statement always true. Also hashed out lines I didn't want it to run.
7. Also there was a 'stopVideoMetadata' method, so I basically did the same thing for that.

Code:
.method public startVideoMetadata()V
    .locals 3

 #   .prologue
  # .line 3267
   # iget-object v0, p0, Lcom/sonyericsson/android/camera/device/CameraDevice;->mCameraExtension:Lcom/sonyericsson/cameraextension/CameraExtension;

    [B]const/4 v0, 0x0 #0 into register v0[/B]
	
    if-eqz v0, :cond_0 [B]#This statement will always be true, therefore move to cond_0[/B]

   # .line 3268
    #iget-object v0, p0, Lcom/sonyericsson/android/camera/device/CameraDevice;->mCameraExtension:Lcom/sonyericsson/cameraextension/CameraExtension;

    #invoke-virtual {v0}, Lcom/sonyericsson/cameraextension/CameraExtension;->startVideoMetadata()V

    #.line 3269
    #new-instance v0, Lcom/sonyericsson/cameracommon/status/EachCameraStatusPublisher;

    #iget-object v1, p0, Lcom/sonyericsson/android/camera/device/CameraDevice;->mCameraActivity:Lcom/sonyericsson/android/camera/CameraActivity;

    #iget v2, p0, Lcom/sonyericsson/android/camera/device/CameraDevice;->mCameraId:I

    #invoke-direct {v0, v1, v2}, Lcom/sonyericsson/cameracommon/status/EachCameraStatusPublisher;-><init>(Landroid/content/Context;I)V

    #new-instance v1, Lcom/sonyericsson/cameracommon/status/eachcamera/Metadata;

    #sget-object v2, Lcom/sonyericsson/cameracommon/status/eachcamera/Metadata$Value;->ON:Lcom/sonyericsson/cameracommon/status/eachcamera/Metadata$Value;

    #invoke-direct {v1, v2}, Lcom/sonyericsson/cameracommon/status/eachcamera/Metadata;-><init>(Lcom/sonyericsson/cameracommon/status/eachcamera/Metadata$Value;)V

    #invoke-virtual {v0, v1}, Lcom/sonyericsson/cameracommon/status/EachCameraStatusPublisher;->put(Lcom/sonyericsson/cameracommon/status/CameraStatusValue;)Lcom/sonyericsson/cameracommon/status/CameraStatusPublisher;

    #move-result-object v0

    #invoke-virtual {v0}, Lcom/sonyericsson/cameracommon/status/CameraStatusPublisher;->publish()V

    .line 3273
    :cond_0 [B]#End here[/B]
    return-void

.end method

OR YOU could delete all that code and just end it with return-void probably.
 
Last edited:

olokos

Recognized Developer
Oct 16, 2011
2,945
2,494
Warsaw
Thanks a ton. Makes perfect sense although it could be used with other functions of the camera, not in SEMCCameraUI.apk, but we'll figure it out later on. I'll be going to school in 20 minutes so I'll try to do something else later on.
My first guess about this function is pause/start recording feature of Z3, but I might be wrong. Where is this Z3 feature anyway? I mean we have SEMCCameraUI.apk, but I've got no idea why this feature is not there on recording :/
I also saw that there's an issue with the "rec" img when recording, could it be that?
@showlyshah @lagalaga
Take a look at this thread :)

EDIT
From what Z3 firmware have you used those files? Leaked firmware or official release?
 
Last edited:

tomascus

Recognized Developer
Jun 5, 2012
1,904
2,650
Melbourne
Thanks a ton. Makes perfect sense although it could be used with other functions of the camera, not in SEMCCameraUI.apk, but we'll figure it out later on. I'll be going to school in 20 minutes so I'll try to do something else later on.
My first guess about this function is pause/start recording feature of Z3, but I might be wrong. Where is this Z3 feature anyway? I mean we have SEMCCameraUI.apk, but I've got no idea why this feature is not there on recording :/
I also saw that there's an issue with the "rec" img when recording, could it be that?
@showlyshah @lagalaga
Take a look at this thread :)

EDIT
From what Z3 firmware have you used those files? Leaked firmware or official release?

leaked http://xdaforums.com/crossdevice-dev/sony/dump-xperia-z3-dump-t2867886
 

olokos

Recognized Developer
Oct 16, 2011
2,945
2,494
Warsaw
I was worried about that. I'm at school atm, but I'll try swmccameraui from .314 Z3 fw as there could be some big changes compared to the leak.
 

tomascus

Recognized Developer
Jun 5, 2012
1,904
2,650
Melbourne
I was worried about that. I'm at school atm, but I'll try swmccameraui from .314 Z3 fw as there could be some big changes compared to the leak.

Ahhh, education first my man :laugh:

Anyway, just an update, here's the stack trace I always get from changing the camera libs :

Code:
W/dalvikvm(13756): Exception Ljava/lang/NullPointerException; thrown while initializing Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize;
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
W/dalvikvm(13756): VFY: unable to find class referenced in signature (Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize;)
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
W/dalvikvm(13756): VFY: 'this' arg 'Ljava/lang/Object;' not instance of 'Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize;'
W/dalvikvm(13756): VFY:  rejecting opcode 0x6e at 0x0002
W/dalvikvm(13756): VFY:  rejected Lcom/sonyericsson/android/camera/view/CameraWindow;.setVideoSize (Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize;)V
W/dalvikvm(13756): Verifier rejected class Lcom/sonyericsson/android/camera/view/CameraWindow;
D/AndroidRuntime(13756): Shutting down VM
W/dalvikvm(13756): threadid=1: thread exiting with uncaught exception (group=0x41653d88)
 
  • Like
Reactions: Chocolatetrain

olokos

Recognized Developer
Oct 16, 2011
2,945
2,494
Warsaw
Xda is also education :D

I'm not sure what you're trying to do here, but IMO something passes video size zero.
May I ask you to try .314 swmccameraui apk from Z3 or at least send me one so I could decompile it in a few hours when my IT class starts? Because that leaked apk can be far from stock z3 apk. :-\

EDIT We've also had this issue with porting Z2 camera AFAIK. Maybe it's still there, just buried deep down the thread. There also are Linux commands to check apk file dependencies in that thread. That's worth trying.
 

lagalaga

Senior Member
Oct 11, 2010
127
174
Ahhh, education first my man :laugh:

Anyway, just an update, here's the stack trace I always get from changing the camera libs :

Code:
W/dalvikvm(13756): Exception Ljava/lang/NullPointerException; thrown while initializing Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize;
(...)
W/dalvikvm(13756): VFY: unable to find class referenced in signature (Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize;)
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0
I/dalvikvm(13756): Rejecting re-init on previously-failed class Lcom/sonyericsson/android/camera/configuration/parameters/VideoSize; v=0x0



Looks like the libs depend on some framework changes?


Re the earlier StartVideometadata thing: there is a service that holds and publishes the camera status, eg resolution, fps and so on. It is basically just an sqlite database and a broadcastreceiver. I forgot where it lives, though. Is there such a thing as Cameracommon?

---------- Post added at 08:54 AM ---------- Previous post was at 08:53 AM ----------

@tomascus did you get all dependencies for the libs from ldd/objdump?
 

tomascus

Recognized Developer
Jun 5, 2012
1,904
2,650
Melbourne
Looks like the libs depend on some framework changes?


Re the earlier StartVideometadata thing: there is a service that holds and publishes the camera status, eg resolution, fps and so on. It is basically just an sqlite database and a broadcastreceiver. I forgot where it lives, though. Is there such a thing as Cameracommon?

---------- Post added at 08:54 AM ---------- Previous post was at 08:53 AM ----------

@tomascus did you get all dependencies for the libs from ldd/objdump?

Nope, a few random guesses. IDA and readelf shows the dependencies well though.
And there is a cameracommon jar in system/framework with videometadata but I was too lazy to try get it to work since I thought i'd be not so important

---------- Post added at 07:00 PM ---------- Previous post was at 06:03 PM ----------

Xda is also education :D

I'm not sure what you're trying to do here, but IMO something passes video size zero.
May I ask you to try .314 swmccameraui apk from Z3 or at least send me one so I could decompile it in a few hours when my IT class starts? Because that leaked apk can be far from stock z3 apk. :-\

EDIT We've also had this issue with porting Z2 camera AFAIK. Maybe it's still there, just buried deep down the thread. There also are Linux commands to check apk file dependencies in that thread. That's worth trying.

as far as I know, 23.0.A.2.93 is the latest version which the 'leak' was based on. The leak came from the official Sony site. I'll download 23.0.A.2.105 from the Z3c and check if any different
 
Last edited:

olokos

Recognized Developer
Oct 16, 2011
2,945
2,494
Warsaw
Nope, a few random guesses. IDA and readelf shows the dependencies well though.
And there is a cameracommon jar in system/framework with videometadata but I was too lazy to try get it to work since I thought i'd be not so important

---------- Post added at 07:00 PM ---------- Previous post was at 06:03 PM ----------



as far as I know, 23.0.A.2.93 is the latest version which the 'leak' was based on. The leak came from the official Sony site. I'll download 23.0.A.2.105 from the Z3c and check if any different
Please do post that dependecies list though so we would be sure we're not missing anything.
 

IgorEisberg

Senior Member
Jul 6, 2009
1,834
3,966
www.audiobudget.com
OK, so for "Face in". It's either a kernel feature (most likely), or a feature associated with "libmedia.so" (even though the error is thrown by "libmedia_jni.iso", it's just the JNI for "libmedia.so", not the actual library). The feature is simple: enabling both back (primary, ID#0) and front (secondary, ID#1) cameras to open at the same time.
Decompile "Face in" (DualCamera.apk) and open "\com\sonymobile\android\addoncamera\dual\device\CameraDevicesManager.smali", comment out these lines and recompile it.
http://oi60.tinypic.com/eog2s.jpg
After commenting out the lines and recompiling it, this is what you get when the app treats the back camera both as front and back camera. (attached)

The key function here is this:
Code:
    #const/4 v1, 0x1
...
    #invoke-direct {v0, v1, v2}, Lcom/sonymobile/android/addoncamera/dual/device/CameraDeviceHandler;-><init>(ILandroid/hardware/Camera$PreviewCallback;)V
v1 is the Camera ID. which is saved by DeviceCameraHandler's constructor, like this:
Code:
iput p1, p0, Lcom/sonymobile/android/addoncamera/dual/device/CameraDeviceHandler;->mCameraDeviceId:I
Then (com\sonyericsson\cameracommon\activity\BaseExtendedActivity$StartUpGuardian.smali) calls:
Code:
Lcom/sonyericsson/cameracommon/activity/BaseActivity;->resumeAll()V
calls (DualCameraActivity.smali):
Code:
Lcom/sonymobile/android/addoncamera/dual/device/CameraDeviceHandler;->requestStartCameraOpen(Landroid/content/Context;)V
calls (device\CameraDeviceHandler.smali):
Code:
Lcom/sonymobile/android/addoncamera/dual/device/CameraDeviceHandler;->startCameraOpen(Landroid/content/Context;)V
calls (device\CameraDeviceHandler.smali):
Code:
invoke-static {}, Ljava/util/concurrent/Executors;->newSingleThreadExecutor()Ljava/util/concurrent/ExecutorService;
move-result-object v1
iget-object v2, p0, Lcom/sonymobile/android/addoncamera/dual/device/CameraDeviceHandler;->mOpenDeviceTask:Lcom/sonymobile/android/addoncamera/dual/device/CameraDeviceHandler$OpenDeviceTask;
invoke-interface {v1, v2}, Ljava/util/concurrent/ExecutorService;->submit(Ljava/util/concurrent/Callable;)Ljava/util/concurrent/Future;
internally calls:
Code:
Lcom/sonymobile/android/addoncamera/dual/device/CameraDeviceHandler$OpenDeviceTask;->call()Ljava/lang/Object;
calls (device/CameraDeviceHandler$OpenDeviceTask.smali):
Code:
Lcom/sonymobile/android/addoncamera/dual/device/CameraDeviceHandler$OpenDeviceTask;->call()Landroid/hardware/Camera;
calls (device/CameraDeviceHandler$OpenDeviceTask.smali):
Code:
Lcom/sonymobile/android/addoncamera/dual/device/CameraDeviceHandler$OpenDeviceTask;->openCamera()Z
calls (device/CameraDeviceHandler$OpenDeviceTask.smali):
Code:
invoke-static {v4}, Landroid/hardware/Camera;->open(I)Landroid/hardware/Camera;
while v4 is that "mCameraDeviceId" that was saved earlier.

The only solution I know is possible is, using only the back camera, and the moment you take a photo, take a photo with the back camera, turn off the back camera, turn on the front camera and take a photo, turn off the front camera and turn on the back camera again, and process the photo.
 

Attachments

  • IMG_20141007_154108.JPG
    IMG_20141007_154108.JPG
    60.7 KB · Views: 232
  • IMG_20141007_154131.JPG
    IMG_20141007_154131.JPG
    121.4 KB · Views: 195
  • IMG_20141007_154147.JPG
    IMG_20141007_154147.JPG
    55.7 KB · Views: 193
  • IMG_20141007_154201.JPG
    IMG_20141007_154201.JPG
    48.4 KB · Views: 188
  • IMG_20141007_154217.JPG
    IMG_20141007_154217.JPG
    43.3 KB · Views: 187
  • IMG_20141007_154232.JPG
    IMG_20141007_154232.JPG
    26.7 KB · Views: 190
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 18
    We are trying to get Z3 Camera software fully working here. Please contribute to [DEV] thread if you actually have something helpful for us. If you don't then head over to Discussion thread here
    Any off-topic posts in this thread instead of Q&A thread will slow-down the development and may put-off some people to work on this.
    This port is somewhat a continuation of this one.
    We hope to get all camera features from Z3 like 12000 ISO and pause recording, but at this point we can't tell if it will work at all.

    XDA:DevDB Information
    Z3 camera port for more Xperia Devices, App for all devices (see above for details)

    Contributors
    olokos, tomascus, Riyal, lagalaga, slowlyshah

    Version Information
    Status: Testing

    Created 2014-10-06
    Last Updated 2014-10-06
    6
    Here are some logcats I took. That's a good place to start. I'll investigate this later.

    EDIT
    Our first priority should be getting Z3 camera recording working so it would be usable on a daily basis for now. We're really close I feel. At least to get recording. There's a problem with startvideometadata function of cameraextension.
    There's a log for that. Check out the attachment as I might be missing something.

    Fixed, will upload updated apk later. btw, what's your google account so i can add you as editor?

    https://drive.google.com/folderview?id=0B3bfLXY54yW-eUphbUoxVHduZlU&usp=drive_web

    edit: video recording now works in the files on above link.
    Time for SuperVideoCamera.apk?
    4
    Reserved

    Here are some files that @tomascus have uploaded for us to test. I made it flashable. Don't bother about what the updater-script says. I just took it from my other zip.
    It breaks video recording for now, but that's a good place to start.
    http://d-h.st/GYg
    Use this thread as a reference of what's done so far. It's cluttered, but something useful might still be there.
    4
    Reserved for future use