[q]reboot tasker - Android Q&A, Help & Troubleshooting

Hi!
I want to stop and start tasker by itself via a bashscript since I see no other way to do so. This works if you put in terminal line by line:
Code:
am force-stop net.dinglisch.android.taskerm
am start -a android.intent.action.MAIN -n net.dinglisch.android.taskerm/net.dinglisch.android.taskerm.Tasker
killall net.dinglisch.android.taskerm
But now I'm stock
My guess was that it would have to work if i put in a file "kst.sh" and run
Code:
sh ./kst.sh
as root. But it doesn't work and it seems to ignore the linebreaks in the file.
So here I am, knowing the commands and need to run them with one call. How do I do that?
Many thanks!!

C0qRouge said:
... it seems to ignore the linebreaks in the file...
Click to expand...
Click to collapse
That error is caused by the windows linebreaks, you need to use any word editor that let you change the linebreak style to Unix (Notepad++ is a popular choice), or write your script from your device directly (any editor for android should work).

Related

ADB Push Nautilus Script?

Is there an ADB push nautilus script out there?
That'll be handy, but i'm no scripting expert. I suspect it'll be bit tricky since adb is terminal only, I'm sure someone will have to figure out a way to pipe the output from terminal to GUI pop up dialog box to display progress bar, with success or failure message.
this one seem to work but no progress bar or success/fail message tho. YMMV
Code:
#/bin/sh
adb push $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS /sdcard
save this as adb_push.sh
be sure to set this file with permission:
Code:
chmod a+x adb_push.sh
think of this as rough draft, not perfect. Above code will push straight to sdcard. Suppose you could create few scripts like this..
ADB - Push to System APP
Code:
#/bin/sh
adb remount
adb push $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS /system/app
ADB - Install APK
Code:
#/bin/sh
adb install $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
EDIT: Forgot to mention this, it'll work only if you've already set path to Android's SDK tools folder in .bashrc
awesome, thanks! I'll test it in a minute
Simple scrip to push files to your android device.
Just put it in your Nautilus script dir (HOME/.gnome2/nautilus-scripts) and make it executable (chmod +x Push\ sdcard). also set path for ADB inside script (ADB=...)
I did something similar a while back for both Konqueror and Dolphin in KDE, but I realized, I just don't use a file manager since I prefer the command line instead. I had a working ADB zsh completion script, but somehow forgot to back it up before my previous hard drive failure.
https://code.google.com/p/send-to-android/
this is interesting

Java on Weptop Firefox

I finally managed to get java to work with firefox. I test out runescape and it works great on minimum graphics setting may be able set higher.
Im on 4.1.8.3 with full ubuntu mod. HAS NOT BEEN VERIFIED WITH AN UNMODDED WEBTOP
Here a little guide that I wrote. It should work
Basically
Google Java arm and click Java Embedded
Download ARMv7 Linux - Headful from there
Extract the ejre1.6.0_25 folder and move to phone
Copy the ejre1.6.0_25 folder to
/usr/lib/
Ingore this code if you are running from lxterminal
Code:
su
/usr/bin/sudo -u adas bash
In lxterminal or whatever terminal
Code:
sudo ln -s /usr/lib/ejre1.6.0_25/lib/arm/libnpjp2.so /usr/lib/firefox-addons/plugins/libnpjp2.so
sudo chmod 755 /usr/lib/ejre1.6.0_25/bin/java
sudo chmod 755 /usr/lib/ejre1.6.0_25/bin/java_vm
sudo chmod 755 /usr/lib/ejre1.6.0_25/bin/javaws
sudo chmod 755 /usr/lib/ejre1.6.0_25/bin/keytool
If you get "link failed File exists" run this. then run the ln command
Code:
sudo rm /usr/lib/firefox-addons/plugins/libnpjp2.so
You can also use root explorer to set permission for the files
Set to this:
read write execute
X --- X----- X
X ---------- X
X ---------- X
Then it should work
I attach a screenshot of runescape running
I'd like more information if you would regarding the installation of java as I am a diehard runescape fan myself. I've downloaded the Java embed but it was version _25 and not _21, not sure if it matters. And also, do I have to be rooted or not?
If you come pm me or reply here, that would be great.
I tried this and was able to get the plugin to load, but all I get is black boxes where the applets are. Any ideas? The java plugin shows under plugins. I'm using 1.6.0_25.
I'd like to know how you exactly got it to work? I cant get the lxterminal to run on my webtop, I'm really new and found out basically everything else but how to install the plugin. Thanks for the info.
And according to a thread on xda, cant remember which - the lxterminal was removed from the phone on the most recent update... so how would I get around that?
I did all the commands using Android Terminal Emulator from the Market.
Are you fully updated on your phone? as in 4.1.8.3
because ive tried more than once to get it to work. and no avail.
exactly what commands did you do anyway? because that could quite possibly solve my problems.
I'm on 4.1.83. I used the commands that are in the OP, changing out ejre-1.6.0_21 with ejre1.6.0_25 (which is the folder name for the version I downloaded). Make sure you do not have a folder in a folder. I never got it fully working, just black boxes on the web pages. The plugin does show to be installed though.
OHHHHHHHHHHHHHHHHH, thats why.
actually, nvm ... my files are in the exact location his are. >_<
Should I type the lines 1 at a time? I've been copy and pasting them all at once.
I did one at a time.
?.?
Ok this is my situation as of yet, I currently have rooted atrix, running newest version. I open terminal emulator from market, type in the first line "ln -s /usr/lib/ejre-1.6.0_25/lib/arm/libnpjp2.so /usr/lib/firefox-addons/plugins/libnpjp2.so" and it returns "link failed File exists, so im guessing i've already placed it into the plugins folder.
So far so good, now onto second line -
"chmod 755 /usr/lib/ejre-1.6.0_25/bin/java"
and my return being
-unable to chmod /usr/lib/ejre-1.6.0_25/bin/java: No such file or directory
I would type the rest but i'm sure they would return the same
My files are in the correct location /usr/lib/ejre-1.6.0_25/
any suggestions?
Well I have the full ubuntu mod on my phone. I have not test it doing it though anything other than lxterminal
If you see the plugin in firefox that is good. Im betting the permission are not set properly
you can use root explorer to set the permission on the files that are chmod. Make sure all check boxs under execute are selected.
Check what you copied to the phone and make sure you don't have two ejre-1.6.0_25 folders (one within the other) from when you extracted it.
I extracted it to my sd card then moved the folder, so my locations are exactly what he lists. nothing different aside from the _25 instead of _21 which i change in what I type. I just tried to allow permissions, lets see if this changes anything...*crosses fingers*
Edit: When I type the first line, I get
link failed Permission denied
Stephen Who said:
I extracted it to my sd card then moved the folder, so my locations are exactly what he lists. nothing different aside from the _25 instead of _21 which i change in what I type. I just tried to allow permissions, lets see if this changes anything...*crosses fingers*
Edit: When I type the first line, I get
link failed Permission denied
Click to expand...
Click to collapse
Do you have root?
I have root, plugin shows in firefox, permissions are correct, but all applets just show as a black box. I'm running stock. Do you think it only works with the ubunto mod?
Ok I edited the OP so the commands can be run from android terminal or adb.
Im not sure why it doesnt work for you must be the full ubuntu mod.
I might try downloading a new version of java see if it works
Update
I tried the the 25 version and it worked. I updated the commands. I was able to get it to work using adb.
password for adas:?
edit: and yes, I'm rooted. It's asking for a password when I type the second command line. :|

[Q] Read commands' output inside su process

Hello, maybe here someone will help me
I'm writing a file manager app and I want to allow it for browsing with root permissions.
All I have so far is creation of a Process object using Runtime.exec("su"). Then I get output stream from it and write "ls" command. And here goes the question. How to read the output of the "ls"? Getting the input stream from the process gives me stdout of the "su" which is useless.
glodos said:
Hello, maybe here someone will help me
I'm writing a file manager app and I want to allow it for browsing with root permissions.
All I have so far is creation of a Process object using Runtime.exec("su"). Then I get output stream from it and write "ls" command. And here goes the question. How to read the output of the "ls"? Getting the input stream from the process gives me stdout of the "su" which is useless.
Click to expand...
Click to collapse
Use the -c option of su:
Code:
su -c 'ls -l /system/'
I think I'm closer, but still it doesn't work
I have this:
Code:
p = Runtime.getRuntime().exec("/system/bin/su -c 'ls -d -1 "+directory.getAbsolutePath()+"/*'");
So the command for a directory /data will be:
Code:
/system/bin/su -c 'ls -d -1 /data/*'
But it gives me:
Code:
W/su (13979): request rejected (0->0 'ls)
I have tried putting the command's parts into array but then system asks for su permission on every command. For ex. ls /data needs permission and ls /system needs another permission beacuse the command is different.
Not much I can think of to do about that. I had a similar issue once upon a time and I dealt with it by using a script that read its commands from a data file. I'd write the datafile to my program's designated directory (no special permissions required), then run a single command with su and that script would read the datafile to know what to do, otherwise, I had a ****load of su requests bothering the user.
You've got a point there, but making it work with a file manager, where the commands are related to user interaction would be very difficult. Anyway I will put it into my consideration.
I wonder how all these root explorers are made but none of the developers, which I asked so far, were so kind to give me some tips
glodos said:
You've got a point there, but making it work with a file manager, where the commands are related to user interaction would be very difficult. Anyway I will put it into my consideration.
I wonder how all these root explorers are made but none of the developers, which I asked so far, were so kind to give me some tips
Click to expand...
Click to collapse
Well, I suppose you could keep a process open to a shell with root permissions and once open, keep input and output pipes routed to it and send and receive commands as needed.
Gene Poole said:
Well, I suppose you could keep a process open to a shell with root permissions and once open, keep input and output pipes routed to it and send and receive commands as needed.
Click to expand...
Click to collapse
Well, that's what I've tried to do, but as I mentioned in the first post, output pipe gives me stdout of the su process which doesn't write any output (but "ls" does).
glodos said:
Well, that's what I've tried to do, but as I mentioned in the first post, output pipe gives me stdout of the su process which doesn't write any output (but "ls" does).
Click to expand...
Click to collapse
No, I don't think you're following me. Just run su -c 'sh' and it should run a shell and keep it open. From there, you create an input stream, output stream and possibly an error stream, then write commands like "ls -l /system\n" (the \n triggers the shell to execute it) to the output stream, then read the results form the input stream. You keep doing this as needed and when you're done just send "exit\n".
Oh, I understand now. I'll try it ASAP.
Edit:
It works now, but I have problems with stopping the loop. Here is my piece of code:
Code:
String[] cmd = new String[]{"su", "-c", "/system/bin/sh"};
console = Runtime.getRuntime().exec(cmd);
BufferedWriter stdin = new BufferedWriter(new OutputStreamWriter(console.getOutputStream()));
stdin.write("ls -d -1 "+directory.getAbsolutePath()+"/*\n");
BufferedReader stdout = new BufferedReader(new InputStreamReader(console.getInputStream()));
String read;
data1 = new String();
while((read=stdout.readLine())!=null){
data1+=read + "\n";
}
The problem is, that it hangs at some point on invocation of "stdout.readLine()". I have read that it waits for some data to come and it will never be null.
Furthermore if my ls command returns nothing (which can happen) it always hangs forever on readLine().
Anyway I'll try to do something with this. Maybe there is a workaround and reading will not block.
Thank you for your effort, it was really helpful.
glodos said:
The problem is, that it hangs at some point on invocation of "stdout.readLine()". I have read that it waits for some data to come and it will never be null.
Furthermore if my ls command returns nothing (which can happen) it always hangs forever on readLine().
Anyway I'll try to do something with this. Maybe there is a workaround and reading will not block.
Thank you for your effort, it was really helpful.
Click to expand...
Click to collapse
Sorry to ressurect such an old thread. I'd been having the same problem with reads blocking using BufferedReader, InputStream and other variants. Turns out BufferedReader has a ready() method which indicates whether a read() will block. This code works for me:
Code:
String outputStr;
BufferedReader reader = new BufferedReader(new InputStreamReader(suProcess.getInputStream()));
while (reader.ready()) {
outputStr += reader.readLine();
}
Hope it helps someone from the repeating the same frustrations. Heck I hope it helps me in the future in case I forget this

[Q] A command to change directory in ubuntu

Hi, if possible how can I change directory in a terminal window in ubuntu using a short command such as 'croot' instead of using 'cd ~/android/system' ??
wassupasian said:
Hi, if possible how can I change directory in a terminal window in ubuntu using a short command such as 'croot' instead of using 'cd ~/android/system' ??
Click to expand...
Click to collapse
not sure what "croot" is? You mean "chroot root:root /to/destination?" "cd ~/ take your logins home folder. You can always cd / for root or cd /etc /bin /sbin or whatever root subfolder from anywhere. but i am unaware of any true short cuts.
hope that helps,
dfl
If the bash stuff is equal to Ubuntu Desktop systems you can do something like this:
in terminal:
Code:
$ echo "alias croot='cd ~/android/system'" >> $HOME/.bash_aliases
logout -> login (reboot i guess)

How to duplicate what adb does to ad hoc open any given Activity on the Android phone?

I can ad hoc open any given Activity on the Android phone while connected over USB to adb on the Windows PC, but how do I DUPLICATE the SAME THING, but from the phone itself?
For example, how can I run this Activity, ad hoc, on the Android phone?
ACTION: "android.intent.action.MAIN"
PACKAGE: "com.google.android.gms"
CLASS: "com.google.android.gms.ads.settings.AdsSettingsActivity"
Click to expand...
Click to collapse
For illustrative purposes, below is a trivial example of ad hoc opening the "Reset Advertiser ID" Activity on the Android phone.
1. Install & test adb on your PC (I tested this only on Windows 10)
2. Connect your Android device over USB (mine is Samsung, Android 11)
3. Paste this command into a Windows command window:
C:\> adb shell am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity
That's just a trivial example where I can't yet figure out yet how to duplicate that popping up of a given Activity on the android phone for any given Activity, if all I know is the name of that given Activity (and which isn't already found in a static list inside of the shortcut creator apps).
Here are more examples I've tested for other Activities.
Code:
C:\> adb shell am start -n com.android.settings/.Settings
C:\> adb shell am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity
C:\> adb shell am start -n com.google.android.gms/.location.settings.LocationAccuracyActivity
C:\> adb shell am start -n com.android.settings/.applications.ManageApplications
C:\> adb shell am start -n com.google.android.gms/.update.SystemUpdateActivity
C:\> adb shell am start -n com.samsung.android.secsoundpicker/.SecSoundPickerActivity
C:\> adb shell am start -n com.android.settings/.Settings\$NotificationAppListActivity
C:\> adb shell am start -n com.android.settings/.Settings\$AppMemoryUsageActivity
C:\> adb shell am start -n com.android.settings/.Settings\$NotificationAppListActivity
C:\> adb shell am start -n com.android.settings/.Settings\$SecDisabledAppsActivity
C:\> adb shell am start -n com.android.settings/.Settings\$PowerUsageSummaryActivity
C:\> adb shell am start -n com.android.settings/.Settings\$AppAndNotificationDashboardActivity
C:\> adb shell am start -n com.google.android.gms/.app.settings.GoogleSettingsLink
C:\> adb shell am start -n com.google.android.gms/.app.settings.GoogleSettingsIALink
C:\> adb shell am start -n com.google.android.gms/co.g.Space
C:\> adb shell am start -n com.google.android.gms/.gcm.GcmDiagnostics
C:\> adb shell am start -n com.google.android.gms/.nearby.exposurenotification.settings.SettingsActivity
C:\> adb shell am start -n com.google.android.gms/.nearby.sharing.ContactSelectActivity
C:\> adb shell am start -n com.google.android.gms/.mdm.settings.AdmSettingsActivity
C:\> adb shell am start -n com.android.settings/.network.telephony.MobileNetworkActivity
After each command line above you can close the previous results using the adb command shown below (because you can't open an Android Settings Activity on top of an existing Android Settings Activity):
Code:
C:\> adb shell am force-stop com.android.settings
I'm well aware that we can create permanent homescreen shortcuts using shortcut creator applications; but this question is not about creating a homescreen shortcut for permanent access to Android Activities.
This question is how to instantly open ANY given Activity ad hoc (i.e., on a case-by-case basis) on Android whenever you want to - just from the name like we did above using adb (but without needing adb to do it).
Pack all the ADB commands listed in a Linux shell script ( means omitting "adb shell" part ), put this script into /data/local/tmp, make script executable and finally run this script in Terminal Emulator on phone.
jwoegerbauer said:
Pack all the ADB commands listed in a Linux shell script ( means omitting "adb shell" part ), put this script into /data/local/tmp, make script executable and finally run this script in Terminal Emulator on phone.
Click to expand...
Click to collapse
That worked! Thank you!
Below is my first testcase, which was the simple example of popping up the "Reset Advertising ID" Activity on Android when all you know is the unique name of the Activity.
This alias (which I named "resetadid") that worked first was:
$ alias resetadid='am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity'
This saves that alias into your bashrc file for safekeeping.
$ alias >> ~/.bashrc
To run that alias at the Android Termux command line, I just type:
$ resetadid
(which will pop up the named Activity on your phone)
Then I put that line into a shell script that I named "resetadid.sh"
$ am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity
And I put the following line into another shell script (named "closegms.sh") to close that gms (google mobile services) Activity.
$ adb shell am force-stop com.google.android.gms
Note for the shell scripts to work, I had to run these commands.
$ pkg install termux-exec
$ termux-fix-shebang ./resetadid.sh
Click to expand...
Click to collapse
This is the "./resetadid.sh" shell script that survives rebooting:
#!/data/data/com.termux/files/usr/bin/bash
am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity
To run that script at the Android Termux command line, I just type:
$ ./resetadid.sh
(that will pop up the named Activity on your phone)
Normally we won't need to close that Activity because resetting the advertising ID will close it when we hit the "reset" and "ok" buttons, but for now we need to close the Activity after we pop it up.
To that end is this temporary "closegms.sh" shell script.
#!/data/data/com.termux/files/usr/bin/bash
adb shell am force-stop com.google.android.gms
There are only two things left.
1. How to put that Termux command in a homescreen icon for free?
2. What to add to that shell script to actually press the "Reset" button?
Anyone know how to add a shell script to the Android homescreen?
Anyone know how to add a command to press the "reset" button?
Typically by long tapping on the home screen, you can create a shortcut to an existing script or add a live folder that contains all of your scripts.
BTW:
Termux is a Terminal Emulator what allows you to run ( Linux conformant ) Android Shell commands / scripts.
jwoegerbauer said:
Typically by long tapping on the home screen, you can create a shortcut to an existing script or add a live folder that contains all of your scripts.
Click to expand...
Click to collapse
Thanks for that advice which works to create, not a shortcut to a script, but a widget to a script (a shortcut would be nicer as it fits in homescreen folders).
It's not as simple as just long tapping because there is a ton of syntax involved, and the files have to be in critical directories, and even the version of Termux matters extremely greatly.
But it does work. Thanks.
So we can now create a homescreen widget that will bring up any given Activity if all we know is the Activity name!
I'll write it up in the next post.
jwoegerbauer said:
BTW:
Termux is a Terminal Emulator what allows you to run ( Linux conformant ) Android Shell commands / scripts.
Click to expand...
Click to collapse
The "right" Termux appears to be that on F-Droid and NOT the one on Google Play as documented elsewhere on the net, this being one link.
For this kind of shell scripts (to run Activities) do you think Andronix will help (Andronis is apparently Linux on top of Android along with Android without the need for rooting).
So we can now create a homescreen widget that will bring up any given Activity if all we know is the Activity name!
For anyone who reads this, may I ask that you please invest five minutes in testing this out and letting everyone here know how it works for you?
What I wrote below is designed so you can just follow the cookbook and you should end up with a widget on your homescreen which will open up to ANY named Activity (but I only give one example below) if all you know is the unique name of that Activity.
Install the F-Droid Termux
(Do not use the Google Play Termux!)
Install the F-Droid Termux:Widget
Start Termux on your Android device
All commands below are run on the Termux command line.
If you had to back out the Google Play Termux in favor of the F-Droid Termux, you'll want to re-create & re-test the alias to a simple Activity such as "Reset Ad ID" as explained earlier in this thread, just to test your syntax.
Re-create:
Code:
alias resetadid='am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity'
Re-test:
Code:
$ resetadid
Then re-create & re-test the shell script we previously described earlier in this thread.
Re-create:
Code:
#!/data/data/com.termux/files/usr/bin/bash
am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity
Re-test:
Code:
$ ./resetadid.sh
Now we're ready to put that command on your homescreen!
Create two directories which are defined in the Termux-Widget help.
Code:
$ mkdir -p $HOME/.shortcuts
$ mkdir -p $HOME/.shortcuts/tasks
Note I'm not sure what the "tasks" directory is for but Termux:Widget docs say to create it.
Move the shell script you created earlier into the $HOME/.shortcuts directory.
Code:
$mv ~/resetadid.sh $HOME/.shortcuts/.
Add the Termux Widget to your homescreen.
Long press your Android homescreen.
Select "Widgets"
Select "Termux:Widget"
Place that "Termux:Widget" on your Android homescreen
Click to expand...
Click to collapse
Depending on your Android version...
It will ask:
"Create widget and allow access?"
To which you press "Yes" to put your widget on the homescreen.
Click to expand...
Click to collapse
To interact with the now-running widget, just press the named entry showing up in that Termux Widget.
Code:
resetadid.sh
Depending on your Android version...
It may ask: "Termux requires "Display over other apps" permission
to start terminal sessions from background on Android >=10."
"Grants it from Settings -> Apps -> Termux -> Advanced" [sic]
Click to expand...
Click to collapse
If needed, grant Termux permission to display over other apps:
Code:
Android11:Settings > Apps > Your apps > Termux > Appear on top = (change off to on)
Now you can press the always running Termux:Widget icon on your homescreen to bring up the desired Activity.
Does this work for you to bring up the named Activity on Android with the only thing you know being the unique Activity name?
If so, here's what's left that I know of:
a. Figure out how to add a step to actually press the "Reset" button!
b. Figure out how to use a shortcut instead of an always-running widget (which can't be placed inside a homescreen folder)
c. Figure out how to run this automatically such as when there is a screen unlocking event.
--
Notes: Keep in mind the goal is to be able to interact with ANY known Android Activity using only freeware (so that everyone can do it); resetting the ad id is just one of the simplest examples.
Interested users can try this on the "Show Running Services" Activity (e.g., for implementing a "ps -aux|kill -9" shortcut).

Categories

Resources