yashsingh1/xdaforums huggingface dataset:
[Nexus 4 Original Android Development] sga999:
I updated apktool and aapt. And everything ran perfectly. Most people who had not updated yet said it failed somehow, then after updating, it worked. But I updated the tools first, never got errors, so I think it's creating the update.zip properly. So I'll ask this one more time, and if you don't want to or can't do this, please let me know. Can you create the framework-res.apk zip file for the stock rom for me? Maybe I would then be able to compare my update.zip to yours and see what went wrong.

If I already have your kernel installed, can I just bring up twrp recovery and flash the single update.zip for the framework? Or is it more complicated than that? I'm thinking I must be missing something about how to flash the update.zip.

Can you tell me how to see logs that show the overload and other issues? Again, please just let me know, and if you don't want to answer this, I'll stop asking.

I appreciate all that you've done, and I certainly don't want to ask you too much. I just need to know if you're missing the questions or don't want to answer...which is fine.
[Nexus 4 Original Android Development] MWBehr:
Sounds like the update script is fine, the problem is with your framework. Either it's not being recompiled properly or the changes you're making are causing problems. What versions of the tools are you using?
[Nexus 4 Original Android Development] hp420:
So if this requires external power, would an external hdd with external power source work, in theory? Or does the USB itself need to carry a current to make it work?
[Nexus 4 Original Android Development] sga999:
I've tried it with no changes at all, i.e. decompile and recompile with no changes (my post #11 describes this in more detail). So as you said, the recompile must not be working.

My versions are:

aapt.exe v0.2

apktool.jar 1.5.2 but unfortunalely, frameworkflasher's runme.bat always does "echo version 1.4.3" (this threw me off for a while!)

I only replaced aapt.exe and apktool.jar. Are there other .exe or .dll files that need to be replaced also? Maybe I'm just doing an incomplete job of updating the files.

Thanks for your help.
[Nexus 4 Original Android Development] ziddey:
Upload your framework-res.apk and I'll try to mod it. Not sure why it's not working for you though.

I haven't combed through the logs to look for when it's mounted, but since you created vold.fstab, it shouldn't be an issue. Maybe it didn't affect the stock rom anyway. If it did mount at /mnt/shell/emulated/0, internal storage would no longer be accessible. I had issues even opening Android settings, nevermind storage. Of course, you could simply check your mounts with the mount command, or use df to see mounts / disk space.

In theory, yes. However, I'm imagining that a powered external hdd isn't going to be sending power out the usb port, and since the charger type is currently used to force host mode, it won't switch automatically. This could be a potential reason for the debug /sys/kernel/debug/msm_otg/mode, so I'll enable it in the next build. Unfortunately, I'm imagining that it still won't work though, seeing how it'd get stuck in a_idle. However, it does give me some ideas for trying to trace the root issue, or at least figuring out another workaround.
[Nexus 4 Original Android Development] sga999:
ziddey, here are links to my framework-res.apk and the update.zip. They are unmodified stock, i.e. I let framework flasher decompile, recompile without any changes, sign, etc. You may have no interest in the update.zip, but if what you create "matches" mine (not sure if a byte by byte compare will work), I don't think it will help for you to give yours to me. But again, just ignore that .zip if you want to.

I'm not very familiar with uploading, so if I'm not supposed to put direct links here, let me know.

http://www.mediafire.com/?wxcnozb2e5u8wps

http://www.mediafire.com/?visp1jzai8aqisp

What I mean about the log is that I don't know what log you look at. I know there's logcat, dmesg, maybe others, but I've never looked at them. So I wanted to learn a little more by looking at the same thing you look at when you notice various errors.

Thanks for your help.
[Nexus 4 Original Android Development] ziddey:
edit: DO NOT DOWNLOAD. Tested by sga999 and does not work.

http://d-h.st/Z2s md5sum: 2b07609be9c462a0f4ba54c141dc2e88

your update.zip db087c101a8c07aa3606102128c96051

mine 19642b12da5a6fd372280c3e33fa8247

Report if that works. May be of interest to others. Is that stock 4.2.2 JDQ39?
[Nexus 4 Original Android Development] sga999:
Yours fails also! I have given it about 6 minutes, and it's stuck on the 'X'. I've waited longer than that before, maybe 10 minutes, but I don't ever think it should take more than a couple of minutes, right? UPDATE: I've now waited 11 minutes.

Yes, I gave you /system/framework/framework-res.apk from stock 4.2.2 JDQ39. That's what I'm running.

I have the unsigned and signed apk's saved from the various steps of Framework Flasher. It would be interesting to know where it goes wrong. I'm pretty sure the signed apk has the same problem, but I can't be sure I installed it properly (I read various posts about putting it in /system, fixing properties, cut/paste into /system/framework). It reboots immediately after I do the paste.

I would guess that the recompile is somehow not working. I suppose I could try to go through the individual steps on my own...but I sure had hoped to use this tool, just like you did!

Thanks for creating it for me...at least it's not something I was doing wrong with the tool!
[Nexus 4 Original Android Development] ziddey:
root@android:/ # ls -la /storage
dr-xr-xr-x root root 2013-04-05 23:57 emulated
lrwxrwxrwx root root 2013-04-05 23:57 sdcard0 -> /storage/emulated/legacy
d---rwxr-x system [b][color=red]sdcard_rw[/color][/b] 1969-12-31 19:00 usbdisk0
[Nexus 4 Original Android Development] sga999:
My 1st and 3rd lines differ. In the 1st line, instead of root, it has sdcard_r. In the 3rd line, instead of sdcard_rw, it has media_rw.

EDIT: Also, the permissions on my 1st line are d---r-x---.
[Nexus 4 Original Android Development] DesignGrits:
Just found this, sounds like it might work in combination with this mod, any thoughts?

http://www.kickstarter.com/projects...r-android-smartphones-and-ta?ref=home_popular
[Nexus 4 Original Android Development] ziddey:
2013.04.07 0355ET: ziddey-otg-04070355.zip Now modifies /system/etc/permissions/platform.xml to allow app write access to usb storage (thanks garyd9 for script code). Kernel build number reverted to 105 to match Franco's M1 build number.

md5sum 68bf9e71bb082781d8d22a70953e8b46

Chainfire has a good article about the write permission issues for secondary storage (e.g. usb drives): http://www.chainfire.eu/articles/113/Is_Google_blocking_apps_writing_to_SD_cards_/

I tried to set android:storageDescription in storage_list.xml as a hard string "USB storage" instead of "@string/storage_usb" but for some reason, that causes a force close. For the time being, it looks like the description will only be valid for newer CM10.1 builds. Should just be a cosmetic issue for users of other roms.
[Nexus 4 Original Android Development] HearthC0re:
You will still need external power.
[Nexus 4 Original Android Development] baltac:
According to my experience on three different roms and this thread feedbacks, it's seem to be only a cosmetic issue... An important task to do in future, would be to create some kind of autopatcher to merge your mod to any kernel, if it's possibile. What do you think about?

I'm just throwing an idea in the arena, for anyone who want to try achieve the quest, since I'm not so skilled to do it for you, atm....
[Nexus 4 Original Android Development] adidas007:
I read some one earlier say that the phone doesn't charge when pendrive / mouse is being used.

For me my phone is charging as well as the pendrive and mouse are working perfectly!

ROM : PA 3.15
[Nexus 4 Original Android Development] DrunkFuX666:
Its written in the FAQ and I quote...

" Will it work on Nexus 4?

No. Currently USB-OTG is not supported on Nexus 4. Seems there is some hardware issue preventing that, and most likely software alone can't fix it."

Sent from my Nexus⁴
[Nexus 4 Original Android Development] SetiroN:
Ziddey, could you add support for USB audio?
[Nexus 4 Original Android Development] sga999:
ziddey, with your latest, Titanium Backup with backup folder on my micro sd card works perfectly now. Thanks very much.

EDIT: FYI, this may be uninteresting to you. The ls -la /storage command still shows exactly the same 3 lines for me, so this change to platform.xml fixes my "permission problem" but does not change the output of that command.
[Nexus 4 Original Android Development] ritchea:
Holy Cow! You miss the forum for 24 hours and all the problems are fixed. Great work, ziddey (and sga999). TB is backing up to USB as I type. I'm not sure I understand. Was the "media_rw" label assigned to the usb storage the problem--not having permissions for it? (while "sdcard_rw" was already being granted permissions in platform.xml?)

---------- Post added at 07:57 PM ---------- Previous post was at 07:52 PM ----------

Same for me--and ES File Explorer is reporting same as before update. But, hey, it works!
[Nexus 4 Original Android Development] ziddey:
Chainfire's article describes the issue pretty well (don't be alarmed by the the tiny size of the scrollbar. the bulk of the page is user comments).

I was originally hesitant to implement the workaround, since the original setup was "by-the-book." That and I didn't realize Cyanogenmod already incorporated a fix, so I didn't see the problem firsthand. But as Chainfire describes, the platform.xml approach is actually used by Samsung, so I figure it's okay ;).

By Android specification, only the primary storage (EXTERNAL_STORAGE) is assigned the sdcard_rw group. Apps have sdcard_rw permissions via WRITE_EXTERNAL_STORAGE and therefore have write access. Secondary storage (MEDIA_STORAGE) is assigned media_rw, with apps explicitly not able to be granted WRITE_MEDIA_STORAGE permissions.

The CM approach simply causes secondary storage to be assigned sdcard_rw as well, and so everything works as it should. The "Samsung approach" adds the media_rw group to WRITE_EXTERNAL_STORAGE, so that apps have the required permissions. USB drives are still mounted with media_rw group, but that's fine now.
[Nexus 4 Original Android Development] sga999:
ritchea, it seems like adding media_rw for WRITE_EXTERNAL_STORAGE is the solution, nothing about other permissions that we were looking at. But I can't explain any of it...just like you said, I'm glad it's working! The chainfire article is interesting, but it is pretty old. I wonder if anything else was ever learned about this. If so, he may have info in some other thread about it, but I don't know.

EDIT: Sorry, ziddey, I responded before seeing your response. ritchea, read what he says instead of mine!
[Nexus 4 Original Android Development] ziddey:
That's not possible and is the reason why we have kernel modules today. Unfortunately, msm_otg is built into the kernel, and there's no way to overload it with a kernel module.

I don't have any experience on this, but have come across a lot of threads discussing this. As far as the kernel is concerned, it was already being built with usb audio support, so perhaps it's out of the scope of usb otg itself, and requires whatever other rom-level tweaks to get working.
[Nexus 4 Original Android Development] sga999:
Does anyone else have a problem with "Available" space not showing in Settings - Storage - USB STORAGE? Mine shows the word "Available", then below that, instead of showing the space available, it has "Available" in smaller font. The same micro sd card shows the available space correctly when connecting it to another device.

I've seen ziddey's and ritchea's screens in this thread, both showing the available space, as expected. But I don't think either are running stock, rooted, deodexed 4.2.2. So maybe it's only a problem for the stock rom? I hope someone else can tell me if they have the same problem.
[Nexus 4 Original Android Development] ziddey:
Are you using a storage_list.xml compiled for your specific framework-res.apk or mine?

The storage_list.xml in the current release was compiled for a recent CM10.1's framework-res.apk, so at the least, I'm imagining the description would be invalid.
[Nexus 4 Original Android Development] sga999:
I'm compiling my own. I haven't been able to get your zip file to update framework-res.apk with any of the recoveries (cwm 6.0.2.3 and several twrp versions).

My description works fine, i.e. it says USB STORAGE. The bar below that even seems to indicate that most of the storage is available, but it just won't tell me how much (I know I have over 26GB out of 29.71GB available). Is there something in the storage_list.xml that should change since you posted the "source" a few weeks ago? I mean, I copied that, and I've been using that for my compile. So is there something you have changed in that "source" that I may not have included?

Here's what I have:

<?xml version="1.0" encoding="utf-8"?>

<StorageList

xmlns:android="http://schemas.android.com/apk/res/android">

<storage android:storageDescription="@string/storage_internal" android:emulated="true" android:mtpReserve="100" />

<storage android:mountPoint="/storage/usbdisk0" android:storageDescription="@string/storage_usb" android:primary="false" android:removable="true" />

</StorageList>

EDIT: That's supposed to say android colon primary but for some reason an emoticon is showing in my post on top of the colon p!
[Nexus 4 Original Android Development] Gia90:
I've made a powered otg cable by modifing a normal otg cable.

I've tested it with this kernel and it sometimes works and sometimes not..

When i use a mouse, it works but sometimes the cursor stops moving for some secs and then it works again..

Mass storages are detected but after some secs they become not accessible...

I don't know if it is due to my bad cable or not, anyway if you have any suggestion i'd be glad to be helped by you...

Thank you.
[Nexus 4 Original Android Development] ritchea:
I'm pretty sure I came across the same problem when Toshiba thrive updated to HC 3.2.
[Nexus 4 Original Android Development] SetiroN:
I think you also need to include ALSA support besides USB Audio; audio devices are being detected, but sound isn't being re-routed to them (not even after a reboot), as if there was no audio device priority logic, which I believe is included in ALSA.

I would do some tests myself but I don't have a linux partition right now.

Thanks for helping out!
[Nexus 4 Original Android Development] ziddey:
I wonder what the issue is with the script. I'm now running the latest TWRP and everything is still working. Does it create the .1 backups? Add the line to build.prop? It did change your platform.xml, so the script is running..

Not sure about the available storage, especially since you're compiling your own storage_list.xml.

Sounds like an intermittent bad connection to me. Hell, my microusb port is a whole lot looser now than it was a few weeks ago before I started fiddling with all this :(

ALSA support is also already included. I don't know off the top of my head, but I think you might need to do the rerouting yourself? Sorry I don't have a usb dac to test with.
[Nexus 4 Original Android Development] sga999:
ziddey, the .1 backup does get created, and build.prop is updated correctly.
[Nexus 4 Original Android Development] SetiroN:
You're right ziddey, everything is enabled in the kernel, I was erroneously assuming that because audio wasn't being re-routed after a restart (which is the usual behaviour so far on every device that has kernel but not framework support) something was missing from it. After manually checking that everything was in place, (no luck in trying to use the usual linux tools - aconf and alsaconf -) I realised that everything needs to be done at framework level on android. Luckily, the guys over at the Nexus 7 forums have already stumbled upon the same issue and developed a solution:

a windows-based services.jar patcher that includes plug&play support.

http://xdaforums.com/showthread.php?t=2029728

Although being developed with the N7 in mind, of course the relevant section and classes of services.jar are identical, thus the patch works handsomelyy on every AOSP-based jelly bean ROM.

You could put a link to that patch in the OP.

A cleaner solution would be to modify the source, Timur developed a very elegant solution (http://timur.mobi/img/usbhost_screenshot3b.png) but it would be up to ROM developers to include it.
[Nexus 4 Original Android Development] danba:
There are some very cheap USB DAC/headphone amplifiers: HDE 7.1 Channel USB External Sound Card Audio Adapter for example

http://www.amazon.com/s/ref=nb_sb_n...sb+sound+card&rh=i:aps,k:cm119+usb+sound+card

http://www.ebay.com/sch/i.html?_trk...&_nkw=cm119+usb+sound+card&_sacat=0&_from=R40
[Nexus 4 Original Android Development] sga999:
ziddey, I decided to flash the PA 3.15 rom. I have been content with stock for several months, but I was curious to see what would happen with another rom. I'm still using TWRP 2.4.4.0 (which had not "worked" when I was on the stock rom, i.e. framework-res.apk was not updated properly). So...I flashed your latest zip file, and it DOES update framework-res.apk. The "bad string" turns into "ISSUED ON:"

Unfortunately, the "Available" space problem is still exactly the same, i.e. smaller font below it with "Available". I can plug this same micro sd card into the OTG cable attached to a Samsung Galaxy Tab 2 7.0, and it works well. This is so strange.

(ASIDE: Oh, I just saw "disable smilies" in text below about options in sending messages....I could have done that to fix the colon p problem last night!).

EDIT: I recompiled framework-res.apk myself with the correct storage_list.xml, and installed it on the same setup as above, i.e. PA 3.15. Now the "bad string" is correct (now it says "USB STORAGE"), but I still have the "Available" problem.

I'm just going to ignore the "Available" problem for now. But about your 2 issues (usbdisk not working at all or a "bad string" displays), it must be that the .xml you're creating cannot be just inserted into the framework-res.apk. It's like there are some "unresolved linkages" (that's my terminology) in your file that only get resolved by actually recompiling all of the pieces and recreating the apk (I know you are already aware of this problem, but I'm just describing it in my own way) . Whenever I have recompiled, the apk has worked for all roms that I've tried....stock deodexed or odexed, or this new PA 3.15. It seems like compiling and recreating the apk is the only surefire way to get a good framework-res.apk.
[Nexus 4 Original Android Development] sga999:
ziddey, I just finished editing my prior post to give you a little more info, and then I decided to try one other thing. I decompiled YOUR framework-res.apk. This line shows in storage_list.xml:

<storage android:mountPoint="/storage/usbdisk0" android:storageDescription="@string/issued_on" android:removable="true" />

"Issued on:" was the string I was getting when flashing your zip on this PA rom. Maybe you were already aware that the decompile was showing this, and if so, just ignore this.

EDIT: I just noticed that the first line from the decompile of your apk is bad too. Here are both lines:

<storage android:storageDescription="@string/issued_by" android:emulated="true" android:mtpReserve="100" />

<storage android:mountPoint="/storage/usbdisk0" android:storageDescription="@string/issued_on" android:removable="true" />

If I decompile the original apk, that first line has "@string/storage_internal", which is what we expect.

What is even more strange is that my settings - storage screen shows "INTERNAL STORAGE" despite that bad string in the first line, but the 2nd line displays "ISSUED ON:". That really makes no sense.

These strings are in strings.xml. The PA strings file has more strings than the stock strings file, so the "index" to the string points further down in the stock rom strings file (19 lines?), so it must be choosing the wrong string. (In my particular files, the "issued by" does seem to be at about the right place to cause this problem).

I have no idea if this has any bearing, but when I was trying framework flasher weeks ago, I ran across some things I didn't understand.

1. Someone said to do this before decompiling an apk. They said it would install the device's framework to your system. (This is probably completely unrelated to the problems we're having).

apktool if framework-res.apk

2. Someone said that when creating an update.zip, META-INF/com/google/android/update-binary was rom dependent, and "You will need to pull this from a ROM or Theme.zip".

Are you using an update-binary from your specific rom? Again, I don't know what this all means, but maybe each of us would have to have the right one.
[Nexus 4 Original Android Development] simobile:
Slimport and Qualcomm PMIC chips on Nexus 4 support bus powered USBOTG. Even though Qualcomm blows and don't share their datasheets as they should. Information is available elsewhere and can easily be found with some extra digging.

The op here has done a great job in finding a way to get devices identified/connected and now let's get part two working. I don't want to hear that "its not possible". Everything is possible with enough time and patience. So, I'm sure there are many items that need to be looked into for USB bus power output but for now I have found this...

From: https://groups.google.com/forum/?fromgroups=#!topic/android-kernel/B8qgcWjN_G8

I can confirm that sys/bus/usb/devices/1-1:1.8/subsystem/drivers/usb/usb1/bmaxpower is set to 0ma. I don't have my Micro USBOTG here as Ieft it at work. However, i'll change that value and see what happens when I get a chance. I also have an Acer A500 tablet with a full size USB host port. That file is also labeled as 0ma but I think that is because that voltage is always being presented to the port with an on board regulator. It's not asking Android to enable anything. So Android see's the device as drawing 0ma from the power bus.

I'm no hacker or programmer but I'm more than happy to dig in as much as I can. Also, this is just a thought and it might mean nothing. I was bored and I know this can be solved.
[Nexus 4 Original Android Development] ziddey:
That's well beyond where the actual problem is. To start, take a look at msm_hsusb_vbus_power() in drivers/usb/otg/msm_otg.c. This function is responsible for actually enabling vbus power. If you look at the kernel messages, you'll see "vbus_otg is NULL." From here, it simply bails out of the function without actually enabling vbus_otg (obviously it can't and will crash since it doesn't exist). Because of lazy coding, it then just assumes that it is enabled and proceeds (good for us since it continues to enable host mode..).

Chasing the issue a little further "upstream", take a look at msm_otg_set_host(). There's a specific if condition of !machine_is_apq_8064_mako(). That is to say, specifically DON'T set vbus_otg for the Nexus 4.. Talk about hardcoding.. I've played around with removing the if condition, but then it's "Unable to get vbus_otg" and bails out hard, pretty much wrecking otg in its entirety (no peripheral mode, host mode, or hsic).

From here, I believe we need to go up to arch/arm/mach-msm/lge/mako/board-mako.c to see that there is no vbus_otg. It'd be worth comparing with j1 code (Optimus G): http://xdaforums.com/showthread.php?p=39019345#post39019345

It looks like the implementation was more in board-j1.c for the LGOG vs. in msm_otg.c itself for us.

I did try to simply boot the "OptimusNexus" kernel (http://xdaforums.com/showthread.php?t=2175663) but it's clearly incompatible and trashed something in /data that killed wifi. I'm going to make a backup of my /data and then try the whole OptimusNexus and see if that runs any differently. If not, we're probably barking up the wrong tree. So far, it still doesn't seem to be confirmed that host mode is indeed working for the LGOG. Somebody with that phone needs to try it..