Ok so I just bought an A500 on ebay, and I've done enough unbricking, unlocking, rooting, and flashing to be able to solve most issues I think. I'm 90% sure i can fix this thing too if i can figure out how to get the CPUID from it.
Problem is that it's stuck at the acer logo screen I've been reading about. I'm going through the EUUS tool and need to enter the CPUID which is where I'm stuck. (doing the full reflash through APX mode)
Is there any way to get the CPUID that I havent read about? Most seem to need a bootable tablet. (still reading too so I'll keep up to date)
I've got the serial number off the sd card flap, and I can pull the case open if it's somewhere on one of the boards (doubtful but I thought I'd ask)
update:
currently trying the unsoftbrick through AfterOTA 1.09, it's been on "[2/3] flashing recovery..." for a long time now.... Whenever I've done recovery flashes they never took more than a minute or two
found a possible solution to getting the CPUID and thus the way back into this poor devil here:
http://forum.xda-developers.com/showthread.php?t=1751978
Problem I'm coming up with is during the process of running the compiled script I get "Error: Faled to open device!"
It is a brand new computer, running linux Mint 14 x64
lsusb is showing the device as "0955:7820 NVidia Corp." so i know its being recognized even under APX mode
Pyr0ball said:
Problem I'm coming up with is during the process of running the compiled script I get "Error: Faled to open device!"
Click to expand...
Click to collapse
Are you running as root or have changed the device permissions so that your user are allowed to read/write to the device?
eppeP said:
Are you running as root or have changed the device permissions so that your user are allowed to read/write to the device?
Click to expand...
Click to collapse
I'm running as root (su)
Pyr0ball said:
I'm running as root (su)
Click to expand...
Click to collapse
In that case I don't have any direct ideas...
You can add
Code:
libusb_set_debug(ctx, 3);
between
Code:
libusb_init(&ctx);
and
Code:
dev_handle = libusb_open_device_with_vid_pid(ctx, 0x0955, 0x7820);
and see if that prints any usefull hints.
Otherwise you can try tracing using strace.
eppeP said:
In that case I don't have any direct ideas...
You can add
Code:
libusb_set_debug(ctx, 3);
between
Code:
libusb_init(&ctx);
and
Code:
dev_handle = libusb_open_device_with_vid_pid(ctx, 0x0955, 0x7820);
and see if that prints any usefull hints.
Otherwise you can try tracing using strace.
Click to expand...
Click to collapse
ok I'll give this a try and post the output in a bit
Pyr0ball said:
ok I'll give this a try and post the output in a bit
Click to expand...
Click to collapse
this is what im getting:
Segmentation fault (core dumped)
Just to be sure, this is the code I compiled:
Code:
#include <libusb-1.0/libusb.h>
#include <stdio.h>
#include <stdint.h>
int main(void)
{
unsigned char data[64];
int received_length;
int r = 1;
libusb_context* ctx = NULL;
libusb_set_debug(ctx, 3);
libusb_device_handle* dev_handle = NULL;
libusb_init(&ctx);
dev_handle = libusb_open_device_with_vid_pid(ctx, 0x0955, 0x7820);
if(dev_handle)
{
r = libusb_bulk_transfer(dev_handle, 0x81, data, sizeof(data), &received_length, 10000);
if (r == 0)
{
if(received_length == 8)
{
printf("uid: %#016lx\n", *(uint64_t*)data);
}
else
{
r = 1;
printf("Error: We got %d bytes of data instead of the 8 bytes we expected...\n", received_length);
}
}
else
{
printf("Error: USB read failed!\n");
}
libusb_release_interface(dev_handle, 0);
}
else
{
printf("Error: Failed to open device!\n");
}
libusb_exit(ctx);
return r;
}
Pyr0ball said:
this is what im getting:
Segmentation fault (core dumped)
Just to be sure, this is the code I compiled:
Click to expand...
Click to collapse
Yes, that is to be expected consiedring the change you made.
That is however not the change I told you to make, try to read the part where I described where to add libusb_set_debug line.
is this still alive??? i need help, stuck in the getting the cpuid stage
Related
Hi, i am trying to run adb and su commands in onclicklistener of my button of android app and here is my code
Code:
btnCheckSu.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Process p; String[] st = new String[3];
try {
st[0]="/system/bin/su";
st[1]="-c";
st[2]="reboot";
p = Runtime.getRuntime().exec(st);
Toast.makeText(SUCheck.this, "Rebooting...", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
I do get the prompt for su but then phone does not reboot...any help please
thanks
Well im not sure about the su commands but the reboot intent is restricted to processes signed with the same key as the platform you are using (essentially the key used to sign the rom you are using)
It could be the same with using su to reboot. Not sure though
--------
I tried it on the terminal emulator and it worked after entering the command twice for some reason
From something awesome
Try your commands via adb root shell first. If they work then u know the condemns are good and can try something else. All so without capturing process output there it's no way to know what's going on.
Sent from my MB860 using Tapatalk
Why not use the standard android api?
Code:
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
pm.reboot("");
You'll need the REBOOT permission though.
HomerSp said:
Why not use the standard android api?
Code:
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
pm.reboot("");
You'll need the REBOOT permission though.
Click to expand...
Click to collapse
Because as i said before the reboot permission is only valid on system apps signed with the platform key
From something awesome
killersnowman said:
Because as i said before the reboot permission is only valid on system apps signed with the platform key
From something awesome
Click to expand...
Click to collapse
You're right, sorry.
Try this instead, it worked fine for me.
Code:
Runtime.getRuntime().exec("su -c /system/bin/reboot");
i guys
thanks for the above replies...
but none of the above suggestion has worked for me...any other clues please
thanks
.../me repeats himself...
CAPTURE UR OUTPUT, without it we cant know what is going wrong.
Try your commands via adb shell first, if they work there they will also work via your phone.
yup, great.... adb working through my pc shell
capturing output...i have to work that out how...cheers
hisheeraz said:
yup, great.... adb working through my pc shell
capturing output...i have to work that out how...cheers
Click to expand...
Click to collapse
from your process create datastreams for your process.getInputStream() and process.getErrorStream(). After execution dump streams to file/logcat/w/e.
hisheeraz said:
yup, great.... adb working through my pc shell
capturing output...i have to work that out how...cheers
Click to expand...
Click to collapse
Try this:
Code:
btnCheckSu.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Process p; String[] st = new String[3];
try {
st[0]="/system/bin/su";
st[1]="-c";
st[2]="reboot";
p = Runtime.getRuntime().exec(st);
[COLOR="Red"] String s;
DataInputStream is=new DataInputStream(p.getInputStream());
DataInputStream er=new DataInputStream(p.getErrorStream());
Log.i("MyApp","stdout:\n");
while((s=is.readLine())!=null){
Log.i("MyApp",s+"\n");
}
Log.i("MyApp","stderr:\n");
while((s=er.readLine())!=null){
Log.i("MyApp",s+"\n");
}
[/COLOR]
Toast.makeText(SUCheck.this, "Rebooting...", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
sorry for being such a pain but my Log.i is empty there is absolutely nothing there
even after reinstalling the app in my phone nothing is in Log.i
help please...
EDIT:1
HERE IS THE LOG.I
sdtout:
stderr:
not permitted!
also i am using REBOOT permission in my manifest...i donot think i need it but just in case
hisheeraz said:
sorry for being such a pain but my Log.i is empty there is absolutely nothing there
even after reinstalling the app in my phone nothing is in Log.i
help please...
EDIT:1
HERE IS THE LOG.I
sdtout:
stderr:
not permitted!
Click to expand...
Click to collapse
bla,
try without -c. then also try...
reboot
reboot -f
busybox reboot
busybox reboot -f
hey thanks
/system/bin/su
-c
busybox reboot -f
is working...but
busybox reboot recovery -f
of
busybox reboot recovery
is not working. thanks for your effort and help,
i will dig into this tomorrow and will post you my feed back, it is really late here in AU :O
regards
I flashed Lightspeed_4_beta3 after that came out and I finally made the time to try and update to the newest version 4.3 today, but I can't get into recovery, I have Acer Recovery app and I re-installed CWM but it still wont load recovery... any ideas why? and how to fix it?
Go to market and get the app called "Rebooter". It gives the option to boot into recovery, dowload, reboot or power down. This needs root to work though...
I know how to boot into recovery, that's not the problem, the problem is it wont load CWM recovery at all, it says loading recovery and it should only take a few seconds but I left it for 5 minutes and still said the same thing.
GloriousDJ said:
I know how to boot into recovery, that's not the problem, the problem is it wont load CWM recovery at all, it says loading recovery and it should only take a few seconds but I left it for 5 minutes and still said the same thing.
Click to expand...
Click to collapse
Welcome to corrupted data. You know how to use ADB? You might be able to push a recovery image, but you'll need to format the devblk first I suspect.
Hope you have a backup copy of your UID number. I think you will probably need it.
I;ll say, go back to stock. Run Timmy Deans tools. It'l put a rooted stock 3.2, then install acer recovery with thor.
In the future, I would install RA Recovery. You can flash it from CWM.
Moscow Desire said:
Welcome to corrupted data. You know how to use ADB? You might be able to push a recovery image, but you'll need to format the devblk first I suspect.
Hope you have a backup copy of your UID number. I think you will probably need it.
I;ll say, go back to stock. Run Timmy Deans tools. It'l put a rooted stock 3.2, then install acer recovery with thor.
In the future, I would install RA Recovery. You can flash it from CWM.
Click to expand...
Click to collapse
I have used ADB for my phone before, I'll look and see if I can push RA Recovery on without going back to stock, because I don't think I have my UID number anymore. Thanks for the idea, I guess I can try that see if I can get it working that way.
GloriousDJ said:
I have used ADB for my phone before, I don't have a copy of my UID number but the I can still get on the beta3 so its not stuck in a boot loop or something so I think I could get it. Thanks for the idea, I guess I can try that see if I can get it working that way.
Click to expand...
Click to collapse
I believe Thor has instructions for pushing the CWM image on his site at tegraowners. As now you cannot flash an install.
I also suppose, you might try AcerREcovery from the market, and see if it would flash CWM again. Might be a little easier.
Moscow Desire said:
I believe Thor has instructions for pushing the CWM image on his site at tegraowners. As now you cannot flash an install.
I also suppose, you might try AcerREcovery from the market, and see if it would flash CWM again. Might be a little easier.
Click to expand...
Click to collapse
Ok I'll try that first. Thanks for your help
Moscow Desire said:
In the future, I would install RA Recovery. You can flash it from CWM.
Click to expand...
Click to collapse
I got Acer Recovery app to install the RA Recovery and was able to boot into that, for whatever reason thor's wasn't working anymore. Thanks for your help
Moscow Desire said:
Hope you have a backup copy of your UID number. I think you will probably need it.
Click to expand...
Click to collapse
Unless I have misinterpreted something, this should not be that much of a problem. Maybe a bit inconvenient if you don't know USB programming though.
If you can get the device into APX mode it will answer the first read request with the UID.
So if you open the device (955:7820) and initiate a bulk transfer on endpoint 0x81 and you should get 8 bytes that is the UID.
Something like:
Code:
#include <libusb-1.0/libusb.h>
#include <stdio.h>
#include <stdint.h>
int main(void)
{
unsigned char data[64];
int received_length;
int r = 1;
libusb_context* ctx = NULL;
libusb_device_handle* dev_handle = NULL;
libusb_init(&ctx);
dev_handle = libusb_open_device_with_vid_pid(ctx, 0x0955, 0x7820);
if(dev_handle)
{
r = libusb_bulk_transfer(dev_handle, 0x81, data, sizeof(data), &received_length, 10000);
if (r == 0)
{
if(received_length == 8)
{
printf("uid: %#016lx\n", *(uint64_t*)data);
}
else
{
r = 1;
printf("Error: We got %d bytes of data insetad of the 8 bytes we expected...\n", received_length);
}
}
else
{
printf("Error: USB read failed!\n");
}
libusb_release_interface(dev_handle, 0);
}
else
{
printf("Error: Failed to open device!\n");
}
libusb_exit(ctx);
return r;
}
I have been sooo fustrated trying to get my iconia rollback from the ics leak.
I tried SEVERAL methods including this one http://forum.xda-developers.com/show...2#post23850482 in a thread i just posted.
But still no luck =( Every time i try to boot into recovery mode i get "Recovery verified failed" in read text and it just sits there and wont boot into recovery.
Can someone PLEASE tell me how to fix this or a way to get rid of this error. I dont care if i have to go back to stock i will.
Thanks guys
GloriousDJ said:
I flashed Lightspeed_4_beta3 after that came out and I finally made the time to try and update to the newest version 4.3 today, but I can't get into recovery, I have Acer Recovery app and I re-installed CWM but it still wont load recovery... any ideas why? and how to fix it?
Click to expand...
Click to collapse
Had you ever flashed the stock ics leak? It sounds like you may have the ics bootloader. Does it say "0.03.11-ICS" in the upper left corner when you boot up? If so, that may be whey thor recovery wasn't booting. (just checking)
eppeP said:
Unless I have misinterpreted something, this should not be that much of a problem. Maybe a bit inconvenient if you don't know USB programming though.
If you can get the device into APX mode it will answer the first read request with the UID.
So if you open the device (955:7820) and initiate a bulk transfer on endpoint 0x81 and you should get 8 bytes that is the UID.
Something like:
Code:
#include <libusb-1.0/libusb.h>
#include <stdio.h>
#include <stdint.h>
int main(void)
{
unsigned char data[64];
int received_length;
int r = 1;
libusb_context* ctx = NULL;
libusb_device_handle* dev_handle = NULL;
libusb_init(&ctx);
dev_handle = libusb_open_device_with_vid_pid(ctx, 0x0955, 0x7820);
if(dev_handle)
{
r = libusb_bulk_transfer(dev_handle, 0x81, data, sizeof(data), &received_length, 10000);
if (r == 0)
{
if(received_length == 8)
{
printf("uid: %#016lx\n", *(uint64_t*)data);
}
else
{
r = 1;
printf("Error: We got %d bytes of data insetad of the 8 bytes we expected...\n", received_length);
}
}
else
{
printf("Error: USB read failed!\n");
}
libusb_release_interface(dev_handle, 0);
}
else
{
printf("Error: Failed to open device!\n");
}
libusb_exit(ctx);
return r;
}
Click to expand...
Click to collapse
First thanks
having a hard time compiling in ubuntu
output is:
[email protected]:~/a500$ gcc -Wall -W -Werror apx.c -o apx
/tmp/ccNiYNxr.o: In function `main':
apx.c.text+0x36): undefined reference to `libusb_init'
apx.c.text+0x4c): undefined reference to `libusb_open_device_with_vid_pid'
apx.c.text+0x82): undefined reference to `libusb_bulk_transfer'
apx.c.text+0xec): undefined reference to `libusb_release_interface'
apx.c.text+0x104): undefined reference to `libusb_exit'
collect2: ld returned 1 exit status
any ideas for me?
liftman- said:
First thanks
having a hard time compiling in ubuntu
output is:
[email protected]:~/a500$ gcc -Wall -W -Werror apx.c -o apx
/tmp/ccNiYNxr.o: In function `main':
apx.c.text+0x36): undefined reference to `libusb_init'
apx.c.text+0x4c): undefined reference to `libusb_open_device_with_vid_pid'
apx.c.text+0x82): undefined reference to `libusb_bulk_transfer'
apx.c.text+0xec): undefined reference to `libusb_release_interface'
apx.c.text+0x104): undefined reference to `libusb_exit'
collect2: ld returned 1 exit status
any ideas for me?
Click to expand...
Click to collapse
Try linking against libusb-1.0:
Code:
gcc apx.c -o apx -lusb-1.0
lcd047 said:
Try linking against libusb-1.0:
Code:
gcc apx.c -o apx -lusb-1.0
Click to expand...
Click to collapse
That should work, -Wall -pedantic -lusb-1.0 is what I used when I tested it.
thanks for the help!
got it
eppeP said:
Unless I have misinterpreted something, this should not be that much of a problem. Maybe a bit inconvenient if you don't know USB programming though.
If you can get the device into APX mode it will answer the first read request with the UID.
So if you open the device (955:7820) and initiate a bulk transfer on endpoint 0x81 and you should get 8 bytes that is the UID.
Something like:
Code:
#include <libusb-1.0/libusb.h>
#include <stdio.h>
#include <stdint.h>
int main(void)
{
unsigned char data[64];
int received_length;
int r = 1;
libusb_context* ctx = NULL;
libusb_device_handle* dev_handle = NULL;
libusb_init(&ctx);
dev_handle = libusb_open_device_with_vid_pid(ctx, 0x0955, 0x7820);
if(dev_handle)
{
r = libusb_bulk_transfer(dev_handle, 0x81, data, sizeof(data), &received_length, 10000);
if (r == 0)
{
if(received_length == 8)
{
printf("uid: %#016lx\n", *(uint64_t*)data);
}
else
{
r = 1;
printf("Error: We got %d bytes of data insetad of the 8 bytes we expected...\n", received_length);
}
}
else
{
printf("Error: USB read failed!\n");
}
libusb_release_interface(dev_handle, 0);
}
else
{
printf("Error: Failed to open device!\n");
}
libusb_exit(ctx);
return r;
}
Click to expand...
Click to collapse
Hi, eppeP,
I downloaded the drivers for lib Usb and installed, I am missing something definately as I dont know how to read the CPUID after installing the drivers
Please help....
I just did this in ubuntu with no problem. with tablet in APX mode, start an elevated command prompt (Run as admin) then run the EXE file.
it will spit back an error or the UID.
Very simple.
jecee said:
Hi, eppeP,
I downloaded the drivers for lib Usb and installed, I am missing something definately as I dont know how to read the CPUID after installing the drivers
Please help....
Click to expand...
Click to collapse
Since you write drivers I assume you are using windows.
In that case you want the libusb 0.1 version, the quoted code is for libusb 1.0 which is not available for windows.
Code and a visual studio project can be found here. This thread may be of use as well.
If using Linux (or any other platform for which libusb 1.0 exist) you should be able to build the quoted code as described earlier in this thread.
Thanks so Much!!!
Thanks so Much!!!
THIS WORKED GREAT!!!!!!!
Hi,
Question why (955:7820) ?? Should we modify it according to our device?
Hi,
what is the command to reboot in recovery bootloader ecc?
I will insert in my app through this library
rampo said:
Hi,
what is the command to reboot in recovery bootloader ecc?
I will insert in my app through this library
Click to expand...
Click to collapse
The command for rebooting is
Code:
reboot
Use that to reboot into recovery:
Code:
reboot recovery
For bootloader you need to use adb:
Code:
adb reboot-bootloader
Runtime.getRuntime().exec(new String[]{"su","-c","reboot bootloader"});
Sent from my HTC One using xda premium
Not permitted
Not permitted!
Click to expand...
Click to collapse
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
pinpong said:
Runtime.getRuntime().exec(new String[]{"su","-c","reboot bootloader"});
Sent from my HTC One using xda premium
Click to expand...
Click to collapse
He wants to use RootTools.
For that use:
Code:
Command command = new Command(0, "reboot bootloader") {
[user=439709]@override[/user]
public void output(int id, String line) {
//TODO: Do something with the output here
}
};
RootTools.getShell(true).add(command).waitForFinish();
EDIT: @override: The first letter needs to be upper case (Doesn't let me as it thinks of it as a mentioning function.)
---------- Post added at 10:02 PM ---------- Previous post was at 10:00 PM ----------
rampo said:
Click to expand...
Click to collapse
First you need to be a root user.
Type "su" as the first command.
If you use RootTools you can execute commands as root without having to type "su" the way I gave you above.
Second adb commands must be launched from your computer.
nikwen said:
He wants to use RootTools.
For that use:
Code:
Command command = new Command(0, "reboot bootloader") {
[user=439709]@override[/user]
public void output(int id, String line) {
//TODO: Do something with the output here
}
};
RootTools.getShell(true).add(command).waitForFinish();
Click to expand...
Click to collapse
Same logcat : "Not permited!"
First you need to be a root user.
Click to expand...
Click to collapse
Don't warry man
Type "su" as the first command.
Click to expand...
Click to collapse
Already done.
If you use RootTools you can execute commands as root without having to type "su" the way I gave you above.
Click to expand...
Click to collapse
Ok, thanks.
Second adb commands must be launched from your computer.
Click to expand...
Click to collapse
Yes, i know, but i've tried
pinpong said:
Runtime.getRuntime().exec(new String[]{"su","-c","reboot bootloader"});
Sent from my HTC One using xda premium
Click to expand...
Click to collapse
Same "Not permited!"
rampo said:
Same logcat : "Not permited!"
Don't warry man
Already done.
Click to expand...
Click to collapse
In the screenshot you did not.
Ok, thanks.
Yes, i know, but i've tried
Click to expand...
Click to collapse
If I type "su", then press enter and then "reboot recovery", everything works fine.
Look at this for rebooting into bootloader: http://www.androidcentral.com/android-201-10-basic-terminal-commands-you-should-know
EDIT: You can see whether you typed "su" by looking at the last character of one line. If it is a # instead of a $, you typed "su".
EDIT: You can see whether you typed "su" by looking at the last character of one line. If it is a # instead of a $, you typed "su".
Click to expand...
Click to collapse
There is a "#"
If I type "su", then press enter and then "reboot recovery", everything works fine.
Click to expand...
Click to collapse
.
Not for me, i said this in my second post
HTC One, stock rooted ROM
rampo said:
There is a "#"
.
Not for me, i said this in my second post
HTC One, stock rooted ROM
Click to expand...
Click to collapse
Then it is because of the implementation of the reboot command of your ROM. On my Samsung Galaxy Ace with AOKP it is working fine.
Maybe you could compile your own busybox and include the reboot command. Then copy it into the data directory of your app and run the commands by typing their full path like this:
Code:
/data/data/com.example.app/files/busybox reboot recovery
Maybe you could compile your own busybox and include the reboot command. Then copy it into the data directory of your app and run the commands by typing their full path like this:
Click to expand...
Click to collapse
Mmm, if i add this myself-compiled busybox version to my app, this will work with all devices?
Because as you can read in the first post, the command should be written in the app I'm working on.
Or there is a universal another command or another way to do it?
rampo said:
Mmm, if i add this myself-compiled busybox version to my app, this will work with all devices?
Because as you can read in the first post, the command should be written in the app I'm working on.
Or there is a universal another command or another way to do it?
Click to expand...
Click to collapse
I really thought that you could use the "reboot recovery" on every device.
However, this is one of the best examples for different implementations on different devices. For example on some phones the "ls" command is linked to "ls -l" (Source). That is why busybox is always the better way. It is working the same on all devices and ROMs.
You need to compile it yourself because the one which is installed by this app does not include the reboot command.
I think that there is no other way as the "universal" did not work on your device. Maybe anotherone has a better idea, but I do not think so.
I really thought that you could use the "reboot recovery" on every device.
However, this is one of the best examples for different implementations on different devices. For example on some phones the "ls" command is linked to "ls -l" (Source). That is why busybox is always the better way. It is working the same on all devices and ROMs.
Click to expand...
Click to collapse
Thanks man, I've tried
Code:
su
reboot recovery
and
Code:
su
reboot bootloader
in my Galaxy Nexus, it works.
I will develop and test the app on Nexus, pure Google software
You could grab the reboot binary (I attached mine from the nexus 7), put it in /system/xbin then do this in terminal :
Code:
su
chmod 775 /system/xbin/reboot
After which, reboot/reboot-recovery/reboot-bootloader should work.
If this works, you can include the binary in the assets folder of your app, then copy it to /system/xbin and chmod it in your code.
Code:
File sdCard = Environment.getExternalStorageDirectory().toString();
File update = new File( sdCard + "reboot");
if (update.exists()) {
System.out.println("reboot binary already exists on sdcard");
} else {
try {
update.createNewFile();
System.out.println("File created successfully");
InputStream is = getAssets().open("reboot");
FileOutputStream fos = new FileOutputStream(update);
byte[] buffer = new byte[1024];
int length = 0;
while ((length = is.read(buffer)) > 0) {
fos.write(buffer, 0, length);
}
System.out.println("reboot binary successfully moved to sdcard");
// Close the streams
fos.flush();
fos.close();
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Process process = null;
process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(
process.getOutputStream());
os.writeBytes("busybox mount -o remount,rw /system"+"\n");
os.writeBytes("cp -f " + sdCard + "/reboot /system/xbin/reboot" + "\n");
os.writeBytes("chmod 775 /system/xbin/reboot" + "\n");
os.writeBytes("rm -f " + sdCard + "/reboot " + "\n");
os.writeBytes("busybox mount -o remount,ro /system"+"\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
private void rebootToRecovery() {
Process process = null;
process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(
process.getOutputStream());
os.writeBytes("reboot recovery"+"\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
}
Damn, we really need syntax highlighting and indentation in the code forum tags...
Androguide.fr said:
You could grab the reboot binary (I attached mine from the nexus 7), put it in /system/xbin then do this in terminal :
Code:
su
chmod 775 /system/xbin/reboot
After which, reboot/reboot-recovery/reboot-bootloader should work.
If this works, you can include the binary in the assets folder of your app, then copy it to /system/xbin and chmod it in your code.
Code:
File sdCard = Environment.getExternalStorageDirectory();
sdCard.toString();
File update = new File( sdCard + "reboot");
if (update.exists()) {
System.out.println("reboot binary already exists on sdcard");
} else {
try {
update.createNewFile();
System.out.println("File created successfully");
InputStream is = getAssets().open("xbin");
FileOutputStream fos = new FileOutputStream(update);
byte[] buffer = new byte[1024];
int length = 0;
while ((length = is.read(buffer)) > 0) {
fos.write(buffer, 0, length);
}
System.out.println("reboot binary successfully moved to sdcard");
// Close the streams
fos.flush();
fos.close();
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Process process = null;
process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(
process.getOutputStream());
os.writeBytes("busybox mount -o remount,rw /system"+"\n");
os.writeBytes("cp -f " + sdCard + "/reboot /system/xbin/reboot" + "\n");
os.writeBytes("chmod 775 /system/xbin/reboot");
os.writeBytes("busybox mount -o remount,ro /system"+"\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
private void rebootToRecovery() {
Process process = null;
process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(
process.getOutputStream());
os.writeBytes("reboot recovery"+"\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
}
Damn, we really need syntax highlighting and indentation in the code forum tags...
Click to expand...
Click to collapse
Genial
And there is a command for SafeMode reboot?
rampo said:
Genial
And there is a command for SafeMode reboot?
Click to expand...
Click to collapse
What do you mean by SafeMode ?
Androguide.fr said:
You could grab the reboot binary (I attached mine from the nexus 7), put it in /system/xbin then do this in terminal :
Code:
su
chmod 775 /system/xbin/reboot
After which, reboot/reboot-recovery/reboot-bootloader should work.
If this works, you can include the binary in the assets folder of your app, then copy it to /system/xbin and chmod it in your code.
Code:
File sdCard = Environment.getExternalStorageDirectory();
sdCard.toString();
File update = new File( sdCard + "reboot");
if (update.exists()) {
System.out.println("reboot binary already exists on sdcard");
} else {
try {
update.createNewFile();
System.out.println("File created successfully");
InputStream is = getAssets().open("xbin");
FileOutputStream fos = new FileOutputStream(update);
byte[] buffer = new byte[1024];
int length = 0;
while ((length = is.read(buffer)) > 0) {
fos.write(buffer, 0, length);
}
System.out.println("reboot binary successfully moved to sdcard");
// Close the streams
fos.flush();
fos.close();
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Process process = null;
process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(
process.getOutputStream());
os.writeBytes("busybox mount -o remount,rw /system"+"\n");
os.writeBytes("cp -f " + sdCard + "/reboot /system/xbin/reboot" + "\n");
os.writeBytes("chmod 775 /system/xbin/reboot" + "\n");
os.writeBytes("rm -f " + sdCard + "/reboot " + "\n");
os.writeBytes("busybox mount -o remount,ro /system"+"\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
private void rebootToRecovery() {
Process process = null;
process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(
process.getOutputStream());
os.writeBytes("reboot recovery"+"\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
}
Damn, we really need syntax highlighting and indentation in the code forum tags...
Click to expand...
Click to collapse
Really great idea. :good: Respect!
Just one thing I would do another way: I would copy the reboot binary to the data folder of the app so that the system is not modyfied.
If the default reboot binary has some additional functions which the system needs, there could go something wrong.
rampo said:
Click to expand...
Click to collapse
Simply type
Code:
su
reboot
PhAkEer said:
Simply type
Code:
su
reboot
Click to expand...
Click to collapse
nikwen said:
Really great idea. :good: Respect!
Just one thing I would do another way: I would copy the reboot binary to the data folder of the app so that the system is not modyfied.
If the default reboot binary has some additional functions which the system needs, there could go something wrong.
Click to expand...
Click to collapse
Yeah you're definitely right, would be better practice :good:
PhAkEer said:
Simply type
Code:
su
reboot
Click to expand...
Click to collapse
Dude, just read the thread...
Hello,
As the title states, I'm receiving an error that says "Cannot convert from element type Object to Bluetooth Device. The following is the highlighted code:
Code:
if (pairedDevices.size() > 0) {
findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);//make title viewable
for (BluetoothDevice device : pairedDevices) {
mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
} else {
mPairedDevicesArrayAdapter.add("no devices paired");
}
I have a feeling it has something to do with java generics, but I'm not quite sure how to fix it. Would anyone be able to offer help?
Thanks
theBasher91 said:
Code:
for (BluetoothDevice device : pairedDevices)
Click to expand...
Click to collapse
Well I would suspect that pairedDevices is a list or array of type Object? Not sure as you dont post the actual error or line numbers... but cast within the for loop if this is the case
Code:
for (Object item : pairedDevices)
{
BluetoothDevice device = (BluetoothDevice) item;
}
Just a thought
Or, assuming that pairedDevices is an ArrayList or other type that implements the collections interface, you're best bet would be to ensure that it is parameterized correctly.
For example:
Code:
ArrayList<BluetoothDevice> = new ArrayList()<BluetoothDevice>
I wrote a simple application that needs to run external programs as superuser. I run this piece of code in a periodic task: the code is contained in a Runnable that runs periodically by using a ScheduledThreadPoolExecutor. The code works well for a while, but after some times it stops to work randomly. To do that I used the following code. By debugging the application I found the problem is in the line Process process = builder.start();
I mean that when the problem happens the execution wait the return of this method forever.
Code:
//Code in run() Method of a class that implemnst Runnable:
ArrayList<String> results = new ArrayList<String>();
try {
ProcessBuilder builder = new ProcessBuilder("su");
builder.redirectErrorStream(true);
Process process = builder.start();
DataOutputStream os = new DataOutputStream(
process.getOutputStream());
BufferedReader bRes = new BufferedReader(new InputStreamReader(
process.getInputStream()));
os.writeBytes("busybox ifconfig | busybox grep 'eth'; echo done_done\n"); //<-- this is my command for now
os.flush();
String r;
long curr = System.currentTimeMillis();
while ((r = bRes.readLine()).equals("done_done") == false){
results.add(r);
}
os.writeBytes("exit\n");
os.flush();
process.waitFor();
} catch (Exception e) {
//...
}
Any suggestions? I can't figure out what kind of problems produce this situation. I used this code in past without problems. Can the command line "busybox ifconfig | busybox grep 'eth'; echo done_done\n" not return and works forever? I don't think so..
Thank you, Nico