33 * LICENSE: http://git.io/vki47 | TERMS: http://git.io/vki4o
44 * -----------------------------------------------------------
55 */
6- package com .SecUpwN .AIMSICD .fragments ;
6+ package com .SecUpwN .AIMSICD .activities ;
77
8- import android .app .Activity ;
9- import android .content .Context ;
108import android .os .Bundle ;
119import android .os .Handler ;
1210import android .os .Looper ;
3735import io .freefair .android .injection .annotation .Inject ;
3836import io .freefair .android .injection .annotation .InjectView ;
3937import io .freefair .android .injection .annotation .XmlLayout ;
40- import io .freefair .android .injection .app .InjectionFragment ;
38+ import io .freefair .android .injection .app .InjectionAppCompatActivity ;
4139import io .freefair .android .util .logging .Logger ;
4240
4341
6361 * [ ] Need a "no" timeout to watch output for while, or let's make it 10 minutes.
6462 * Perhaps with a manual stop?
6563 */
66- @ XmlLayout (R .layout .at_command_fragment )
67- public class AtCommandFragment extends InjectionFragment {
64+ @ XmlLayout (R .layout .activity_at_command )
65+ public class AtCommandActivity extends InjectionAppCompatActivity {
6866
6967 @ Inject
7068 private Logger log ;
@@ -76,7 +74,6 @@ public class AtCommandFragment extends InjectionFragment {
7674 private static final int BUSYBOX_UNAVAILABLE = 103 ;
7775 private static final List <String > mSerialDevices = new ArrayList <>();
7876
79- private Context mContext ;
8077 private String mSerialDevice ;
8178 private int mTimeout ;
8279
@@ -110,8 +107,8 @@ public class AtCommandFragment extends InjectionFragment {
110107 private Button atCommandExecute ;
111108
112109 @ Override
113- public void onViewCreated ( View view , Bundle savedInstanceState ) {
114- super .onViewCreated ( view , savedInstanceState );
110+ protected void onCreate ( Bundle savedInstanceState ) {
111+ super .onCreate ( savedInstanceState );
115112 atCommandExecute .setOnClickListener (new btnClick ());
116113 mSerialDeviceSpinner .setOnItemSelectedListener (new spinnerListener ());
117114 timeoutSpinner .setOnItemSelectedListener (new timeoutSpinnerListener ());
@@ -170,12 +167,6 @@ public void onNothingSelected(AdapterView<?> parentView) {
170167 }
171168 }
172169
173- @ Override
174- public void onAttach (Activity activity ) {
175- super .onAttach (activity );
176- mContext = activity .getBaseContext ();
177- }
178-
179170 @ Override
180171 public void onDestroy () {
181172 super .onDestroy ();
@@ -195,16 +186,16 @@ public void onResume() {
195186 mAtCommandLayout .setVisibility (View .VISIBLE );
196187 break ;
197188 case ROOT_UNAVAILABLE :
198- mAtCommandError .setText (mContext . getString ( R .string .unable_to_acquire_root_access ) );
189+ mAtCommandError .setText (R .string .unable_to_acquire_root_access );
199190 break ;
200191 case BUSYBOX_UNAVAILABLE :
201- mAtCommandError .setText (mContext . getString ( R .string .unable_to_detect_busybox ) );
192+ mAtCommandError .setText (R .string .unable_to_detect_busybox );
202193 break ;
203194 case SERIAL_INIT_ERROR :
204- mAtCommandError .setText (mContext . getString ( R .string .unknown_error_trying_to_acquire_serial_device ) );
195+ mAtCommandError .setText (R .string .unknown_error_trying_to_acquire_serial_device );
205196 break ;
206197 default :
207- mAtCommandError .setText (mContext . getString ( R .string .unknown_error_initialising_at_command_injector ) );
198+ mAtCommandError .setText (R .string .unknown_error_initialising_at_command_injector );
208199 break ;
209200 }
210201
@@ -270,7 +261,7 @@ private int initSerialDevice() {
270261 // THIS IS A BAD IDEA TODO: Consider removing
271262 // Use RIL Serial Device details from the System Property
272263 try {
273- String rilDevice = Helpers .getSystemProp (mContext , "rild.libargs" , "UNKNOWN" );
264+ String rilDevice = Helpers .getSystemProp (this , "rild.libargs" , "UNKNOWN" );
274265 mSerialDevice = ("UNKNOWN" .equals (rilDevice ) ? rilDevice : rilDevice .substring (3 ));
275266
276267 if (!"UNKNOWN" .equals (mSerialDevice )) {
@@ -341,7 +332,7 @@ public void commandOutput(int id, String line) {
341332 if (!mSerialDevices .isEmpty ()) {
342333 String [] entries = new String [mSerialDevices .size ()];
343334 entries = mSerialDevices .toArray (entries );
344- ArrayAdapter <String > spinnerAdapter = new ArrayAdapter <>(mContext ,
335+ ArrayAdapter <String > spinnerAdapter = new ArrayAdapter <>(this ,
345336 android .R .layout .simple_spinner_item , entries );
346337 mSerialDeviceSpinner .setAdapter (spinnerAdapter );
347338 mSerialDeviceSpinner .setVisibility (View .VISIBLE );
@@ -447,4 +438,4 @@ private void commandWait(Shell shell, Command cmd) throws Exception {
447438 }
448439 }
449440 }
450- }
441+ }
0 commit comments