77import android .view .MenuItem ;
88import android .view .View ;
99import android .widget .Button ;
10+ import android .widget .EditText ;
11+ import android .widget .TextView ;
12+
13+ import java .io .BufferedReader ;
14+ import java .io .BufferedWriter ;
15+ import java .io .File ;
16+ import java .io .IOException ;
17+ import java .io .InputStreamReader ;
18+ import java .io .OutputStreamWriter ;
19+ import java .util .ArrayList ;
1020
1121/*
1222The page that allows gives the user below functionalities
1828public class PostLogin extends Activity {
1929 // The Button that handles the transfer activity
2030 Button transfer_button ;
31+ // The Textview that handles the root status display
32+ TextView root_status ;
2133 // The Button that handles the view transaction history activity
2234 Button statement_button ;
2335 // The Button that handles the change password activity
@@ -30,6 +42,13 @@ protected void onCreate(Bundle savedInstanceState) {
3042 setContentView (R .layout .activity_post_login );
3143 Intent intent = getIntent ();
3244 uname = intent .getStringExtra ("uname" );
45+
46+ root_status =(TextView ) findViewById (R .id .rootStatus );
47+ // Display root status
48+ showRootStatus ();
49+
50+
51+
3352 transfer_button = (Button ) findViewById (R .id .trf_button );
3453 transfer_button .setOnClickListener (new View .OnClickListener () {
3554
@@ -63,9 +82,51 @@ public void onClick(View v) {
6382 });
6483 }
6584
66- /*
67- The page that allows the user to allow password change for the logged in user
68- */
85+ void showRootStatus () {
86+ boolean isrooted = doesSuperuserApkExist ("/system/app/Superuser.apk" )||
87+ doesSUexist ();
88+ if (isrooted ==true )
89+ {
90+ root_status .setText ("Rooted Device!!" );
91+ }
92+ else
93+ {
94+ root_status .setText ("Device not Rooted!!" );
95+ }
96+ }
97+
98+ private boolean doesSUexist () {
99+ Process process = null ;
100+ try {
101+ process = Runtime .getRuntime ().exec (new String [] { "/system/xbin/which" , "su" });
102+ BufferedReader in = new BufferedReader (new InputStreamReader (process .getInputStream ()));
103+ if (in .readLine () != null ) return true ;
104+ return false ;
105+ } catch (Throwable t ) {
106+ return false ;
107+ } finally {
108+ if (process != null ) process .destroy ();
109+ }
110+
111+ }
112+
113+ private boolean doesSuperuserApkExist (String s ) {
114+
115+ File rootFile = new File ("/system/app/Superuser.apk" );
116+ Boolean doesexist = rootFile .exists ();
117+ if (doesexist == true )
118+ {
119+ return (true );
120+ }
121+ else
122+ {
123+ return (false );
124+ }
125+ }
126+
127+ /*
128+ The page that allows the user to allow password change for the logged in user
129+ */
69130 protected void changePasswd () {
70131 // TODO Auto-generated method stub
71132 Intent cP = new Intent (getApplicationContext (), ChangePassword .class );
0 commit comments