[Q] Galaxy S2 Bluetooth Logcat Problem. - T-Mobile Samsung Galaxy S II SGH-T989

Hi,
I am running the recently released stock ROM version 4.1.2 downloaded via Kies.
I am trying to debug a Bluetooth problem. However, I cannot see Bluetooth messages when I run the following script using command 'sh btlog' on my android from a terminal:
#!/system/bin/sh
su
print START
# logcat -c
# logcat -v time |grep ".*[bB]luetooth.*"
logcat -v time | grep Bluetooth
print END
It will only output:
START
And, if I run 'logcat | grep Bluetooth' from a terminal session on the android I do not get any output.
But if I run 'sh btlog' from an adb shell I do see the Bluetooth messages, and if I run 'logcat | grep Bluetooth' from an adb shell I also get the expected output.
Can anyone help?
Thanks

Brushborder said:
Hi,
First,I hope this is posted in the right place. I have not been here in ages!
I am running the stock ROM and ICS 4.1.2
I am trying to figure out a problem with my S2 and how it randomly disconnects from some Bluetooth devices. However, I cannot see Bluetooth messages when I run my script using command 'sh btlog' on my android from a terminal:
#!/system/bin/sh
print START
# logcat -c
# logcat -v time |grep ".*[bB]luetooth.*"
logcat -v time | grep Bluetooth
print END
It will only output:
START
And, if I run 'logcat | grep Bluetooth' from a terminal session on the android I do not get any output.
But if I run 'sh btlog' from an adb shell I do see the Bluetooth messages, and if I run 'logcat | grep Bluetooth' from an adb shell I also get the expected output.
Can anyone help?
Thanks
Click to expand...
Click to collapse
get on stock 4.1.2, it was released for our device a while back it might solve your issue
imo ics is dead now

JesusWazBlack said:
get on stock 4.1.2, it was released for our device a while back it might solve your issue
imo ics is dead now
Click to expand...
Click to collapse
Maybe I misspoke. I'm on the stock 4.1.2. Downloaded via kies last week or so, but it is still causing problem. Better, but still disconnects and does not allow reset which is why I am trying to look at log. Thx

Brushborder said:
Hi,
I am running the recently released stock ROM version 4.1.2 downloaded via Kies.
I am trying to debug a Bluetooth problem. However, I cannot see Bluetooth messages when I run the following script using command 'sh btlog' on my android from a terminal:
#!/system/bin/sh
su
print START
# logcat -c
# logcat -v time |grep ".*[bB]luetooth.*"
logcat -v time | grep Bluetooth
print END
It will only output:
START
And, if I run 'logcat | grep Bluetooth' from a terminal session on the android I do not get any output.
But if I run 'sh btlog' from an adb shell I do see the Bluetooth messages, and if I run 'logcat | grep Bluetooth' from an adb shell I also get the expected output.
Can anyone help?
Thanks
Click to expand...
Click to collapse
Well, I fixed the code problem. Basically, I am executing this script as a task when bluetooth starts. I have to make sure the task manager is executing this as super user. Not in the script itself, but calling from super. Now my logger works, now to debug the exceptions.

Related

[SOLVED] Shell scripting problem: unexpected "fi"

SOLVED: The file had Windows EOL formatting. *nix no likely that.
In the init script there are several instances of if statements like this:
Code:
testvar=1
if [ "$testvar" = "1" ] ; then
echo "Testvar is equal to one"
fi
Yet, when I put if statements exactly like this into a shell script and execute them in an adb shell (or connectbox shell), I get the following error:
line 4: syntax error: unexpected "fi" (expecting "then")
I've also taken if statements directly from init and they throw the same error.
Any busybox gurus here know what's up with this?
toadlife said:
In the init script there are several instances of if statements like this:
Code:
testvar=1
if [ "$testvar" = "1" ] ; then
echo "Testvar is equal to one"
fi
Yet, when I put if statements exactly like this into a shell script and execute them in an adb shell (or connectbox shell), I get the following error:
line 4: syntax error: unexpected "fi" (expecting "then")
I've also taken if statements directly from init and they throw the same error.
Any busybox gurus here know what's up with this?
Click to expand...
Click to collapse
Remove the ; and enter the then
Code:
testvar=1
if [ "$testvar" = "1" ]
then
echo "Testvar is equal to one"
fi
Nope. Still throws the same error.
This is driving me nuts. What I'm doing is editing the /init script. The loops work just fine when executed at bootup in / init, but remounting the filesystem, editing /init and rebooting just the test a change takes forever.
For now I've got my changes to init working, but it would be nice to be able to test before editing /init
I just realized that I forgot to put `#!/bin/sh` at the top of my script. But doing so doesn't seem to help. Instead I get not found error.
Weird!
toadlife said:
Nope. Still throws the same error.
This is driving me nuts. What I'm doing is editing the /init script. The loops work just fine when executed at bootup in / init, but remounting the filesystem, editing /init and rebooting just the test a change takes forever.
For now I've got my changes to init working, but it would be nice to be able to test before editing /init
Click to expand...
Click to collapse
Code:
testvar=1
if [ $testvar = `1` ] (`=~ key)
then
echo "Testvar is equal to one"
fi
[/QUOTE]
It gives the echo, but also 1: not found.
Here is the actual code I put into my init:
(this works)
Code:
#Super cool battery thingy
RUNSCBS=`/bin/grep -o "run.scbs=.*" /proc/cmdline | /bin/sed -e "s/.*run.scbs=//g" -e "s/ .*//g"`
if [ "$RUNSCBS" = "1" ] ; then
dev=$(cat /sys/class/scbs/0/dev | sed -e "s/:/ /g")
mknod /dev/scbs0 c $dev
scbs -d -co /sdcard/scbs.conf
fi
# Debug logs
TAKELOGS=`/bin/grep -o "take.logs=.*" /proc/cmdline | /bin/sed -e "s/.*take.logs=//g" -e "s/ .*//g"`
if [ "$TAKELOGS" = "1" ] ; then
logfiledate=`expr substr \`date -Iseconds|tr -d :|tr -d \+|tr -d \-|tr -d T\` 1 14`
tar -cz -f "$card"/debuglogs_"$logfiledate".tar.gz "$card"/debuglogs_*.txt
cat /proc/kmsg>"$card"/debuglogs_kmsg_"$logfiledate".txt &
logcat -v time >"$card"/debuglogs_logcat_time_"$logfiledate".txt &
logcat -v time -b radio>"$card"/debuglogs_logcat_time_radio_"$logfiledate".txt &
fi
Ooooo I really like the idea of having logging running from init. Does that work well? Do the logs ever 'loop' and you end up missing things, or do they just keep on churnin?
arrrghhh said:
Ooooo I really like the idea of having logging running from init. Does that work well? Do the logs ever 'loop' and you end up missing things, or do they just keep on churnin?
Click to expand...
Click to collapse
AFAIK, they go forever. I started doing it last night by just putting the static command in the /init and the logging was still going when I got up this morning.
This morning wanted to see if I could make logging and scbs triggerable by an option in the command line.
Both are working for me now.
Know if where talking about scripts, i have a question too.
This is my RIL logs script:
Code:
#! /system/bin/sh
i="0"
while [ $i -lt 2 ]
do
date=`date +%Y%m%d%H%M`
if [ -d /sdcard/logs/ril/$date/ ]
then
echo "/sdcard/logs/ril/$date/ exists!"
else
mkdir /sdcard/logs/ril/$date/
echo " Made direction /sdcard/logs/ril/$date!"
fi
logcat -v time > /sdcard/logs/ril/$date/logcat-time.txt &
logcat -v time -b radio > /sdcard/logs/ril/$date/logcat-time.txt &
sleep 18000 && kill -0 $! && kill $!
cd /sdcard/logs/ril/
tar -czf ril$date.tar.gz $date
rm -r $date
cd /
done
The thing, i believe, is that only the logcat -v time -b radio is killed and when it's sleeping it's not doing that in the background.
Sleeping for 18000 seconds (5h), because if it's running for a day the logcat log will be more than 10 mb or so.
lol.
Your date string...
Code:
date +%Y%m%d%H%M
...is a bit simpler than mine...
Code:
expr substr `date -Iseconds|tr -d :|tr -d \+|tr -d \-|tr -d T` 1 14
(I couldn't figure out the `date` syntax)
Christiaan91 said:
Know if where talking about scripts, i have a question too.
This is my RIL logs script:
Code:
#! /system/bin/sh
i="0"
while [ $i -lt 2 ]
do
date=`date +%Y%m%d%H%M`
if [ -d /sdcard/logs/ril/$date/ ]
then
echo "/sdcard/logs/ril/$date/ exists!"
else
mkdir /sdcard/logs/ril/$date/
echo " Made direction /sdcard/logs/ril/$date!"
fi
logcat -v time > /sdcard/logs/ril/$date/logcat-time.txt &
logcat -v time -b radio > /sdcard/logs/ril/$date/logcat-time.txt &
sleep 18000 && kill -0 $! && kill $!
cd /sdcard/logs/ril/
tar -czf ril$date.tar.gz $date
rm -r $date
cd /
done
The thing, i believe, is that only the logcat -v time -b radio is killed and when it's sleeping it's not doing that in the background.
Sleeping for 18000 seconds (5h), because if it's running for a day the logcat log will be more than 10 mb or so.
Click to expand...
Click to collapse
Hmm. I haven't set up gscript myself yet, but you might need to nohup the logcats to get them to stay once gscript shuts down.
arrrghhh said:
Ooooo I really like the idea of having logging running from init. Does that work well? Do the logs ever 'loop' and you end up missing things, or do they just keep on churnin?
Click to expand...
Click to collapse
I have found one issue. It's seems that whenever scbs runs, locat fails to open the log devices. I just disabled scbs and logcat worked. I'm going to try swapping the code around so scbs runs after the logging starts.
It seems scbs blows up logcat, even when it is triggered after logging starts. Ughhh.
Entropy512 said:
Hmm. I haven't set up gscript myself yet, but you might need to nohup the logcats to get them to stay once gscript shuts down.
Click to expand...
Click to collapse
logcat will be going, even when you close the terminal, but when you deleted the files they stop. So that's not a problem, cuz i won't delete.
BTW: is it possible to silently run scripts? Like this one?
./pathtoscript1 & ./pathtoscript2 & ./pathtoscript3
Christiaan91 said:
logcat will be going, even when you close the terminal, but when you deleted the files they stop. So that's not a problem, cuz i won't delete.
BTW: is it possible to silently run scripts? Like this one?
./pathtoscript1 & ./pathtoscript2 & ./pathtoscript3
Click to expand...
Click to collapse
What do you mean "silently run" - do you mean disable any printing to stdout?
./pathtoscript1 &>/dev/null & ; ./pathtoscript2 &>/dev/null &
should do the trick The &>/dev/null routes all output to /dev/null
Man, you guys go way overboard on this stuff. This is my gscript logging script.
Code:
cd /sdcard
mv logg.txt logg.0.txt
mv logr.txt logr.0.txt
nohup logcat -v time > logg.txt &
nohup logcat -v time -b radio > logr.txt &
nohup klogd > klog.txt
highlandsun said:
Man, you guys go way overboard on this stuff. This is my gscript logging script.
Code:
cd /sdcard
mv logg.txt logg.0.txt
mv logr.txt logr.0.txt
nohup logcat -v time > logg.txt &
nohup logcat -v time -b radio > logr.txt &
nohup klogd > klog.txt
Click to expand...
Click to collapse
Yeah, well we don't all have kung-fu coding ablities like you, so we go overboard with what we can overboard with.
Besides, I think it might be beneficial to put something like the code I wrote into the official init, so noobs can more easily provide debug logs.
One thing to keep in mind, busybox = /bin/sh, statically compiled sh is /system/bin/sh. I got tired of not having arrow key support whenever I su'ed (since /bin/su spawns a root /system/bin/sh regardless of what's in /etc/passwd) so I bind mounted /bin/sh (which is a symlink to busybox) over the one in /system in my user.conf. I haven't come across any ill effect, but if you feel that the shell difference may be causing issues, you could try that route, since it's very easy to undo.
-- Starfox
Starfox said:
One thing to keep in mind, busybox = /bin/sh, statically compiled sh is /system/bin/sh. I got tired of not having arrow key support whenever I su'ed (since /bin/su spawns a root /system/bin/sh regardless of what's in /etc/passwd) so I bind mounted /bin/sh (which is a symlink to busybox) over the one in /system in my user.conf. I haven't come across any ill effect, but if you feel that the shell difference may be causing issues, you could try that route, since it's very easy to undo.
-- Starfox
Click to expand...
Click to collapse
Thanks for the tip. I'll give that a shot.
LOL. I'm an idiot
Figured out what the problem was. The file had Windows EOL formatting.
That's what I get for using Windows to edit shell scripts.

adb segmentation fault w/certain shell commands (D.I.R.T/RemICS-UX Port/ICS 4.0.4)

Hello all,
I recently rooted my phone and installed the RemICS-UX Port | ICS 4.0.4 by Team D.I.R.T. It's been great so far but I'm running into some issues running adb shell commands. For example:
Code:
$ adb shell
sh-3.2$ pm list packages
Segmentation fault
However, if I use su then I can run the commands:
Code:
sh-3.2$ su
sh-3.2# pm list packages
package:android
package:android.googleSearch.googleSearchWidget
package:com.anddoes.launcher
package:com.android.backupconfirm
...etc...
Has anyone run into a similar issue before? The IDE I use for Android development uses "pm install" and "am start" to deploy apps to the device. I really need to be able to run those commands without requesting superuser access. Any and all help is greatly appreciated.

Lauch App per adb (no root)

Hello,
I would like to start an app installed on a non rooted fire tv (generic solution, and as an example for xbmc) by adb. I found some examples, which all don't work... (I am able to start the adb shell and launch other commands...)
eg:
Code:
am start -a android.intent.action.MAIN -n org.xbmc.xbmc/android.app.NativeActivity
returns
Code:
Error type 3
Error: Activity class {org.xbmc.xbmc/android.app.NativeActivity} does not exist
.
Is this not possible on non rooted fire tv's?
Or do I just use a wrong syntax?
I am working on some remote conrtrol options, so launchers are not a solution for me.
Thanks for support.
adb shell am start -n org.xbmc.xbmc/.Splash
Kramar111 said:
adb shell am start -n org.xbmc.xbmc/.Splash
Click to expand...
Click to collapse
Works, thanks a lot!
Is there any way to get this for other apps out of the system?
eg: if I want to start netflix the same way, can I get the parameters from anywhre in the system or is "google my friend""?
with aapt (part of Android SDK):
run
Code:
aapt dump badging name.apk
and search line "launchable-activity"
or in GNU/Linux run
Code:
./aapt dump badging name.apk | grep "launchable-activity"
Kramar111 said:
with aapt (part of Android SDK):
run
Code:
aapt dump badging name.apk
and search line "launchable-activity"
or in GNU/Linux run
Code:
./aapt dump badging name.apk | grep "launchable-activity"
Click to expand...
Click to collapse
adb shell am start -n ir.hamgam.mobile/.Splash
for doesn't work plz help me

CM7 for Samsung Epic 4G Touch?

Is there a CM7 for the Samsung Epic 4G Touch? The reason I'm looking for CM7 is because CM11 is really slow on my device and I want to see if using an older android version will improve performance. And before you tell me where the "Search" button is located, I have searched for CM7 and found nothing.
bump
I'm pretty sure that one would have to build it their selves.
https://wiki.cyanogenmod.org/w/Build_for_d710
Has instructions on how to do it, just replace cm-13.0 with cm-7 (you may need to type something else in) when initiating the repo. I configuring mine for marshmallow, so I can't do it, but feel free to do it yourself.
Were you using the latest official cm11 nightlies? If so, you can try manually trimming your flash storage and see if that helps. Until recently trim was disabled out of caution because of a potential brick bug but has been re-enabled by default several months ago. I have noticed an improvement after a manual trim and do not experience any slowness with cm11.
# on the phone in the terminal app:
su -c "fstrim -v /system; fstrim -v /data; fstrim -v /cache; fstrim -v /preload"
# on your PC if you are connected to the phone via adb:
adb shell su -c "fstrim -v /system; fstrim -v /data; fstrim -v /cache; fstrim -v /preload"
Click to expand...
Click to collapse
See here

Attempting to recover memory which then returns a O Byte file size for the mmcblk.

So when I try to scan my /dev/block via "# cat /proc/partitions" I get the correct sizes for all of the mmcblk variants. With the one I am trying to convert (mmcblk0p47) being stated to be at 11403264 Bits or 89.0 KB's.
When I then proceed to type this command in.
adb forward tcp:5555 tcp:5555
adb shell
su
/system/bin/busybox nc -l -p 5555 -e /system/bin/busybox dd if=/dev/block/mmcblk0p47
Click to expand...
Click to collapse
I get this as a result.
dd: writing 'standard output': Connection reset by peer
255+0 records in
254+0 records out
130048 bytes (127.0KB) copied, 0.093509 seconds, 1.3MB/s
Click to expand...
Click to collapse
So this is already showing an incorrect amount copied compared to what was shown via "# cat /proc/partitions".
Then when I finally type in.
adb forward tcp:5555 tcp:5555
cd /nexus
nc 127.0.0.1 5555 | pv -i 0.5 > mmcblk0p47.vhd
Click to expand...
Click to collapse
I get this returned to me.
"0 B 0:00:00 [ 0 B/s] [<=>"
Which as previously shown is wrong as it has been proven that it isn't 0 Bytes in size.
Then when I change the command slightly to .raw.
adb forward tcp:5555 tcp:5555
cd /nexus
nc 127.0.0.1 5555 | pv -i 0.5 > mmcblk0p47.raw
Click to expand...
Click to collapse
I get the exact same result.
I have absolutely no idea what is going on. Is it because I didn't put "su" before cd /nexus? Because this just seems silly how it isn't working.
Thanks.
Was also going to mention I've tried it again hoping that it would change but still getting the same issue.
Thought I would leave it a for a day.

Categories

Resources