1

My aim is to clear the RAM..For tat my idea is to reboot the phone..I got this code to do tat..

 public static void rebootSU() 
    { 
        Runtime runtime = Runtime.getRuntime(); 
        Process proc = null; 
        OutputStreamWriter osw = null;    
        StringBuilder sbstdOut = new StringBuilder();   
        StringBuilder sbstdErr = new StringBuilder(); 
        String command="/system/bin/reboot";    
        try { 
            // Run Script    
            proc = runtime.exec("su");   
            osw = new OutputStreamWriter(proc.getOutputStream());  
            osw.write(command);   
            osw.flush();     
            osw.close();     
            } catch (IOException ex) { 
                ex.printStackTrace();   
                } finally {       
                    if (osw != null) {     
                        try {      
                            osw.close();   
                            } catch (IOException e) { 
                                e.printStackTrace(); 
                                }      
                            }    
                    }   
                try {     
                    if (proc != null)    
                        proc.waitFor();  
                    } catch (InterruptedException e) {  
                        e.printStackTrace(); 
                        }   
                    //sbstdOut.append(ReadBufferedReader(new InputStreamReader(proc.getInputStream()))); 
                    //sbstdErr.append(ReadBufferedReader(new InputStreamReader(proc.getErrorStream()))); 
                    if (proc.exitValue() != 0) 
                    {    

                    }        
                    } 

When I executed this code, following warning is shown in the logcat..I gave REBOOT permission also..When I searched about this they are telling like signing with some firmware key and all..But I am not at all aware of that..Any help would be appreciated.

In Logcat

04-14 10:37:13.526: WARN/PackageManager(58): Not granting permission android.permission.REBOOT to package com.RebootTest (protectionLevel=3 flags=0x8446)
Mithun Sreedharan
  • 49,883
  • 70
  • 181
  • 236
Prijin Koshy Alex
  • 1,837
  • 3
  • 14
  • 17

1 Answers1

1

A similar question was asked and answered here. You can't reboot an unrooted phone until you have the firmware-key to sign it.

Community
  • 1
  • 1
dst
  • 1,770
  • 13
  • 26
  • Why would you even want to clear the RAM? The android platform does this on it's own and it's good - so why interfere? – dst Apr 14 '11 at 12:15
  • to strengthen the security..ok..reboot through code is not possible i think..nw my idea is to tel the user to manually switch on switch off their phone..then my reboot thing cleared...but after that it should start my application..ie, from boot up...any idea about tat???? – Prijin Koshy Alex Apr 16 '11 at 04:15
  • 1
    Strengthen the security because there are sensible data in the RAM? Apps can be registered to the broadcast-action ACTION_BOOT_COMPLETED. – dst Apr 16 '11 at 05:08
  • ya.. i did that app also..ie when i switch off and switch on the phone my activity starts..ok..nw my aim is tat,(First part) when user clicks on app icon,one activity should come saying"PLEASE SWITCH OFF AND SWITCH ON YOUR PHONE".(Second part) When user did tat,another activity shud come,on start up..Second part i did..pls suggest some idea for the first part – Prijin Koshy Alex Apr 16 '11 at 05:44