Hi, I've rooted my Samsung S8 SM-G950F and installed TeamWin Recovery. I've also installed a couple of apps. I will be giving the phone as a present to someone and want them to think it is utterly new, I don't want them to realise I've been on it!
So I need to re-enable the startup wizard on next load...
I've enabled developer options, enabled OEM unlock and USB debugging. I've successfully connected through WINDOWS via USB using Android Studio ADB terminal.
I have once managed to do what I'm asking, so I know i'ts possible - but as I was testing it, I went back through and completed the wizard thinking I'll just redo what I did but now I can't for the life of me replicate what I did to re-enable it!!
These are the commands I entered via ADB, in the order I think I did them:
adb shell
su
pm enable com.sec.android.app.SecSetupWizard/.SecSetupWizardActivity
-> resulted in: Component {com.sec.android.app.SecSetupWizard/com.sec.android.app.SecSetupWizard.SecSetupWizardActivity} new state: enabled
pm enable com.sec.android.app.SecSetupWizard/.SecureInterceptActivity
-> resulted in: Component {com.sec.android.app.SecSetupWizard/com.sec.android.app.SecSetupWizard.SecureInterceptActivity} new state: enabled
am start -n com.sec.android.app.SecSetupWizard/.SecureInterceptActivity
-> resulted in: Starting: Intent { cmp=com.sec.android.app.SecSetupWizard/.SecureInterceptActivity launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } }
am start -n com.sec.android.app.SecSetupWizard/.SecSetupWizardActivity
-> resulted in: Starting: Intent { cmp=com.sec.android.app.SecSetupWizard/.SecSetupWizardActivity launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } }
pm enable com.google.android.setupwizard/.SetupWizardActivity
-> resulted in: Component {com.google.android.setupwizard/com.google.android.setupwizard.SetupWizardActivity} new state: enabled
am start -n com.google.android.setupwizard/.SetupWizardActivity
-> resulted in: Starting: Intent { cmp=com.google.android.setupwizard/.SetupWizardActivity launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } }
reboot
I ran this while screen was locked and avoided interacting with the screen at any point.
Why don't you reinstall the software with odin?
The apps I install need configuring once installed..
I did it..
adb shell am start -a android.intent.action.MAIN -n com.google.android.setupwizard/.SetupWizardTestActivity
I then entered:
reboot
and there it was! So I just turned the phone off.
Related
Hi
I'm trying to get a reboot application working.
It should get root through "su" and then execute "reboot".
It does, but nothing happens (su request shows up)
I used several ways to execute the commands.
The ShellInterface classs from MarketEnabler and this snippet http://www.anddev.org/root_access_snippet-t8384.html
"su" then "reboot" -> nothing
"su -c reboot" -> nothing...
Always the same, it looks like it worked but the device is still up
adb logcat says nothing about.
What's wrong?
I'm running it directly on HTC Hero rooted of course
I've had this issue on several ROMs. I guess some just don't support the command.. *shrug*
It should work...
The reboot binary is present
Hello out there. Looks like you just have a tiny error with your code.
"su -c reboot" needs to look like so: "su -c 'reboot'" -- the actual command to be executed has to be in quotes.
That sould work without the quotes
Still can't find the problem.
I chowned and chmodded the reboot binary like the su binary still no change
how does adbd do it without root permission?
the adb daemon on the device has to be able to do it to be able to respond to 'adb reboot' on a non-rooted phone. Anybody know how it is able to perform the reboot?
Try this, i can confirm it works fine
Code:
try {
Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
{
os.writeBytes("reboot\n");
os.flush();
process.waitFor();
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
Meltus said:
Try this, i can confirm it works fine
Code:
try {
Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
{
os.writeBytes("reboot\n");
os.flush();
process.waitFor();
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
Click to expand...
Click to collapse
This requires a rooted phone. How does adbd reboot on a non rooted phone?
Meltus said:
Try this, i can confirm it works fine
Code:
try {
Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
{
os.writeBytes("reboot\n");
os.flush();
process.waitFor();
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
Click to expand...
Click to collapse
It works on some, doesn't work on others. Seems to be something with how the phone is rooted, or how permissions are set, not exactly sure. Either way, just because it works for you doesn't mean it will work for everyone, however the code up there is probably a very good example for an implementation.
Some apps like ROM Manager have their reboot written using the NDK, so that may be a reason why they can reboot whereas other apps which try to reboot fail.
Meltus said:
Try this, i can confirm it works fine
Code:
process.waitFor();
Click to expand...
Click to collapse
asdfasdf
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
Hello I am desperately trying to run a shell script from my java app.
I tried to use http://developer.android.com/reference/java/lang/Runtime.html#exec%28java.lang.String%29 Runtime Exec to run it and it works except nothing really happens and the script is not executed.
My command was "/system/bin/sh /data/local/test.sh", of course properly chmodded. I tried running the test.sh directly, even tried opening a SH instance and pushing commands to the console via output buffer - nothing works.
When I try to run SU for example using any of these methods, I get prompted for superuser access, so it does work, just doesn't work like I want.
Anybody has any idea what's wrong? Or alternative way to run a script post-boot? (init.d executes too early in the startup process for my needs)
Are you capturing the error stream, or just the output stream?
This is everything I tried:
Code:
String[] str = { "/system/bin/sh", "/data/local/test.sh" };
Process p = Runtime.getRuntime().exec(str);
p.waitFor();
Code:
Process p2 = Runtime.getRuntime().exec("/system/bin/sh /data/local/test.sh");
p2.waitFor();
Code:
Runtime runtime = Runtime.getRuntime();
Process p = runtime.exec("/system/bin/sh");
OutputStream os = p.getOutputStream();
String str = "/data/local/test.sh";
byte[] cmds = str.getBytes();
os.write(cmds);
os.flush();
os.close();
calling just "/system/bin/sh" or "su" works - it actually waits indefinitely in each approach but once I try to execute a script it won't budge. I also attempted to run other parametrized commands like "setprop persist.sys.use_dithering 0" and it also failed. I'll try to intercept the error stream, good point.
nik3r said:
This is everything I tried:
Code:
String[] str = { "/system/bin/sh", "/data/local/test.sh" };
Process p = Runtime.getRuntime().exec(str);
p.waitFor();
Click to expand...
Click to collapse
You need the "-c" option to execute a script:
Sorry I missed that in your first post.
Code:
String[] str = { "/system/bin/sh", [COLOR="Red"]"-c",[/COLOR] "/data/local/test.sh" };
Process p = Runtime.getRuntime().exec(str);
p.waitFor();
nope, this is what I have
Code:
String[] str = { "/system/bin/sh", "-c", "/data/local/test.sh" };
Process p = Runtime.getRuntime().exec(str);
p.waitFor();
still no effect, the /data/local/test.sh is 0777 and only contains
Code:
echo "success" > /data/local/testresult.txt
The same command works from ADB even without the -c switch but with the exec command nothing happens.
finally progress
Update: according to the error output the file gets executed BUT it doesn't have permission to write in /data/local/ same problem if I try to write to this dir with java API.
My script needs to write there so I have only one question - is there a permission that would allow me to execute a script with access right to /data partition without root?
I want to modify the userdata partition after first boot of the ROM but I can't ask the user for root, I want to execute my tweaks and reboot the device before even the android login wizard appears so asking for root that has a prompt with timeout is not an option.
I know of an alternative way to do it but it's even more hacky than this and I would like to avoid someone vomiting over my code
Does it need to be /data/local? /data/local/tmp is world-writable on most devices.
In the end it needs to be /data/data/ actually, I want to mess with default settings of apps, system settings database for example... does that mean I need root or game over? Is there no permission for app to get access to the userdata partition?
As far as I know, the Dalvik system was set up that way on purpose to prevent errant apps from causing any problems elsewhere, and to maintain decent security (look how out of control Windows has become), so to answer your question, Yes, I believe you will need root.
nik3r said:
In the end it needs to be /data/data/ actually, I want to mess with default settings of apps, system settings database for example... does that mean I need root or game over? Is there no permission for app to get access to the userdata partition?
Click to expand...
Click to collapse
No, you can't write to /data/data without root (as that would be a major security risk).
Ok thanks guys I will try my dirty workaround
Hi All,
Things I am trying to do:
1. Connect to remote system
2. Run perl command and get the output on screen.
Could you please guide me on the process where in I can connect to a remote windows/unix machine and run build commands.
Any examples?
Thanks for your help.
Thanks,
Kino
Hi!
I've made something similar - An App that runs some shell scripts on an Ubuntu server over SSH.
Here are some code snippets, hope this helps you
Code:
JSch jsch = new JSch();
Session session = jsch.getSession([I]'ssh-username'[/I],IP, [I]'ssh-port'[/I]);
session.setPassword(SW); // SW ... password ssh-user (for me it's the same pw, ssh-user = su)
Properties prop = new Properties();
prop.put("StrictHostKeyChecking", "no");
session.setConfig(prop);
session.connect();
Channel channel = session.openChannel("exec");
Code:
if(SU) // If Command should run as SU
{
sudoCommand = "sudo -S -p '' " + command;
}
else
{
sudoCommand = command;
}
((ChannelExec) channel).setCommand(sudoCommand);
((ChannelExec) channel).setPty(true);
channel.connect();
OutputStream out = channel.getOutputStream();
ByteArrayOutputStream responseStream = new ByteArrayOutputStream();
channel.setOutputStream(responseStream);
if(SU)
{
out.write((SW + "\n").getBytes());
out.flush();
}
Thread.sleep(1000);
out.write(("logout" + "\n").getBytes());
out.flush();
Thread.sleep(500);
out.write(("exit" + "\n").getBytes());
out.flush();
out.close();
session.disconnect();
channel.disconnect();
Thank you LinuxForce. Thats helpful. I am trying to work on this.
LinuxForce said:
Hi!
I've made something similar - An App that runs some shell scripts on an Ubuntu server over SSH.
Here are some code snippets, hope this helps you
Click to expand...
Click to collapse
Hi
I have a problem debugging applications using my new OnePlus 2. Once the debugging starts the application is blacked out and unresponsive. After some time the black screen disappears and I can see my app but it is unresponsive. The Android Development Studio shows it is still in debugging mode but obviously I am not stuck on a breakpoint. The application gets responsive only when I stop the debugging session from within the ADS.
My phone is a stock OnePlus 2 A2003 running Android 5.1.1, kernel 3.10.49 and Oxygen OS 2.1.1. The phone is detected by the ADB and is set to USB debugging mode. The same issue happens no matter the options I set in Developer settings section (choosing the app being debugged or changing 'do not attach debugger' option). Just running the application works without problems.
I am using the newest Android Development Studio version available. I should not have any other software communicating with the phone (never had Eclipse installed). Only one adb process is running. I work from Windows 10 64bit.
Restarting the phone, ADB, PC or ADS does not help.
The same application can be debugged with no problem by my HTC One M7 running Android 5.0.
Can you give me any hints to what may be causing the problem? I am a novice in Android app development.
This is the debug console log I have:
Code:
The session was restarted
Target device: oneplus-one_a2003-6b306066
Uploading file
local path: D:\QuasarSpectrum\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.kp.quasarspectrum
No apk changes detected.
Skipping file upload, force stopping package instead.
DEVICE SHELL COMMAND: am force-stop com.kp.quasarspectrum
Launching application: com.kp.quasarspectrum/com.kp.quasarspectrum.MainActivity.
DEVICE SHELL COMMAND: am start -D -n "com.kp.quasarspectrum/com.kp.quasarspectrum.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.kp.quasarspectrum/.MainActivity }
[COLOR="Red"]Warning: debug info can be unavailable. Please close other application using ADB: Monitor, DDMS, Eclipse
[/COLOR]Waiting for process: com.kp.quasarspectrum
Connected to the target VM, address: 'localhost:8600', transport: 'socket'
This is the build.gradle file content:
Code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.kp.quasarspectrum"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.+'
compile files('libs/mpandroidchartlibrary-2-1-5.jar')
}