Rebooting a Nexus 7

joneden

Active Member
Licensed User
Longtime User
Hi All,

It's amazing isn't it how you can do the most fantastic stuff really easily yet when you go to do something that should be doable with a blindfold on it's really tricky.

I'm trying to reboot a Nexus 7 in my code. I've ensured that it is rooted but still can't do it.

I've tried the following two approaches and neither work

B4X:
' Method 1
   Dim objOperatingSystem As OperatingSystem : objOperatingSystem.Initialize("OS")
   objOperatingSystem.reboot("User requested reboot")
      
   ' Method 2
   Dim objPhone As Phone
   objPhone.Shell("reboot",Null,Null,Null)


The first method gives me an error about the user nor current process has reboot permissions (I added the reboot permission to the manifest).

The second method gives me an error that says reboot operation not permitted

Any suggestions would be very gratefully received!

Regards,

Jon
 

joneden

Active Member
Licensed User
Longtime User
Ah. So is there any fudge way to get a reboot to be performed - other than asking the user to do it manually?

Is it possible to register a service as a system service?

Regards,

Jon
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
Ouch.

Well I'm doing a Time and attendance application. I use the ZXing lib to get the user to show and have their barcode badge scanned. It works great but because sometimes I need to pull control back to the app (via a kiosk implementation) it seems that the ZXing lib isn't closing properly so I end up with memory leaks - that then slow the unit down. A reboot every few days would solve this.

So it looks like I need to focus on resolving the memory leak issue. I've tried killing the ZXing process but when I look for it it isn't in the process list. Exiting the app then shows the ZXing window so it is definitely running

I think that I ned to write some form of test app that will simplify the setup and allow me to do a more comprehensive test.

Regards

Jon
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
Hi Erel,

OK so I have cut the app right down to the bare minimum. When the app runs it has a clock in button, I press that, the ZXing screen shows up waiting for a barcode scan. When nothing happens for a few seconds my kiosk kicks in and pulls control back to the app.

At this stage the app finds the com.srowen.bs.android process which is the one for the commercial version of ZXing. I use objOperatingSystem.killBackgroundProcesses("com.srowen.bs.android") to try and kill it but on checking it is still running.

Then on closing my app I can see the ZXing window still running. If I had repeated the clock in and wait process 5 times, on exiting my app there would be 5 instances of the ZXing screen running.

Any ideas why the killBackgroundProcess isn't working?

Regards,

Jon
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
Hi again Erel

OK so I figured out what was happening, I think that I was calling the kill background process procedure too soon after exiting form the process. I put into the clock event on the unit and it keeps trying to kill the process every 500 ms till it's gone. Works a treat now. Hopefully that bit of info may help someone with the same issue in the future.


Back on the reboot question there must be a way to do it. I've used loads of apps that have a reboot option built into them. All the custom rom apps have it one way or another... Anyone have any ideas?

Regards

Jon
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
I just checked and taking Titanium backup as an example in the popup settings menu there is a reboot sub menu with two options, reboot device and reboot to recovery. Both work on my phone which runs 4.2.2 so the nexus should also do it.

Now if I only I could figure out why my phone won't display log data I could see what it's doing for the reboot!
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
Thanks Erel, I had tried that yesterday but using the su command, using rootCmd with reboot works.

For anyone else doing it there are two libs with the rootcmd, one of them requires a massive extra jar file that contains loads of samba stuff so go for the one by icefairy, taht one is small and works a treat.

Regards

Jon
 
Upvote 0
Top