Skip to content
This repository has been archived by the owner on Apr 8, 2022. It is now read-only.

Commit

Permalink
Fix some memory leaks from static views variables
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisk44 committed Nov 12, 2019
1 parent 7cb9b25 commit 701bf91
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 24 deletions.
3 changes: 1 addition & 2 deletions app/src/main/java/com/hijacker/CrackFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import static com.hijacker.MainActivity.notification;
import static com.hijacker.MainActivity.path;
import static com.hijacker.MainActivity.progress;
import static com.hijacker.MainActivity.refreshDrawer;
import static com.hijacker.MainActivity.stop;
import static com.hijacker.MainActivity.wl_path;

Expand Down Expand Up @@ -234,7 +233,7 @@ public boolean accept(File file, String s){
public void onResume() {
super.onResume();
currentFragment = FRAGMENT_CRACK;
refreshDrawer();
((MainActivity)getActivity()).refreshDrawer();

//Console text is saved/restored on pause/resume
consoleView.setText(console_text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import static com.hijacker.MainActivity.actions_path;
import static com.hijacker.MainActivity.currentFragment;
import static com.hijacker.MainActivity.mFragmentManager;
import static com.hijacker.MainActivity.refreshDrawer;

public class CustomActionEditorFragment extends Fragment{
View fragmentView;
Expand Down Expand Up @@ -194,6 +193,6 @@ public void onResume(){
save_btn.setEnabled(true);
}

refreshDrawer();
((MainActivity)getActivity()).refreshDrawer();
}
}
3 changes: 1 addition & 2 deletions app/src/main/java/com/hijacker/CustomActionFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import static com.hijacker.MainActivity.mFragmentManager;
import static com.hijacker.MainActivity.notification;
import static com.hijacker.MainActivity.progress;
import static com.hijacker.MainActivity.refreshDrawer;
import static com.hijacker.Shell.runOne;

public class CustomActionFragment extends Fragment{
Expand Down Expand Up @@ -115,7 +114,7 @@ public void onClick(View view){
public void onResume(){
super.onResume();
currentFragment = FRAGMENT_CUSTOM;
refreshDrawer();
((MainActivity)getActivity()).refreshDrawer();

//Console text is saved/restored on pause/resume
consoleView.setText(console_text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import static com.hijacker.MainActivity.currentFragment;
import static com.hijacker.MainActivity.custom_action_adapter;
import static com.hijacker.MainActivity.mFragmentManager;
import static com.hijacker.MainActivity.refreshDrawer;

public class CustomActionManagerFragment extends Fragment{
@Override
Expand Down Expand Up @@ -98,6 +97,6 @@ public void onClick(View view){
public void onResume(){
super.onResume();
currentFragment = FRAGMENT_CUSTOM;
refreshDrawer();
((MainActivity)getActivity()).refreshDrawer();
}
}
3 changes: 1 addition & 2 deletions app/src/main/java/com/hijacker/DevOptionsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import static com.hijacker.MainActivity.FRAGMENT_SETTINGS;
import static com.hijacker.MainActivity.NETHUNTER_BOOTKALI_BASH;
import static com.hijacker.MainActivity.bootkali_init_bin;
import static com.hijacker.MainActivity.refreshDrawer;
import static com.hijacker.MainActivity.currentFragment;
import static com.hijacker.ReaverFragment.get_chroot_env;

Expand Down Expand Up @@ -89,7 +88,7 @@ public boolean onPreferenceClick(Preference preference) {
public void onResume() {
super.onResume();
currentFragment = FRAGMENT_SETTINGS;
refreshDrawer();
((MainActivity)getActivity()).refreshDrawer();
fragmentView = getView();
}
}
3 changes: 1 addition & 2 deletions app/src/main/java/com/hijacker/IsolatedFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import static com.hijacker.MainActivity.isolate;
import static com.hijacker.MainActivity.mFragmentManager;
import static com.hijacker.MainActivity.menu;
import static com.hijacker.MainActivity.refreshDrawer;
import static com.hijacker.MainActivity.runInHandler;
import static com.hijacker.MainActivity.wpa_thread;

Expand Down Expand Up @@ -100,7 +99,7 @@ public void run(){
public void onResume() {
super.onResume();
currentFragment = FRAGMENT_AIRODUMP;
refreshDrawer();
((MainActivity)getActivity()).refreshDrawer();
thread = new Thread(runnable);
thread.start();
((Button)fragmentView.findViewById(R.id.crack)).setText(wpa_thread.isAlive() ? R.string.stop : R.string.crack);
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/hijacker/MDKFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import static com.hijacker.MainActivity.PROCESS_MDK_DOS;
import static com.hijacker.MainActivity.currentFragment;
import static com.hijacker.MainActivity.mFragmentManager;
import static com.hijacker.MainActivity.refreshDrawer;
import static com.hijacker.MainActivity.runInHandler;
import static com.hijacker.MainActivity.startAdos;
import static com.hijacker.MainActivity.startBeaconFlooding;
Expand Down Expand Up @@ -138,7 +137,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked){
tkip_cb.setOnCheckedChangeListener(listener);
aes_cb.setChecked(aes);
aes_cb.setOnCheckedChangeListener(listener);
refreshDrawer();
((MainActivity)getActivity()).refreshDrawer();
}
@Override
public void onPause(){
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/java/com/hijacker/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.concurrent.Semaphore;

import javax.net.ssl.HttpsURLConnection;

Expand Down Expand Up @@ -126,8 +125,6 @@ public class MainActivity extends AppCompatActivity{
static ProgressBar progress;
static Toolbar toolbar;
static View rootView;
static DrawerLayout mDrawerLayout;
static NavigationView navigationView;
static SparseArray<String> navTitlesMap = new SparseArray<>(); //SparseArray to map fragment IDs to their respective navigation titles
static Drawable[] overflow = {null, null, null, null, null, null, null, null}; //Drawables to use for overflow button icon
static ImageView[] status = {null, null, null, null, null}; //Icons in TestDialog, set in TestDialog class
Expand Down Expand Up @@ -168,6 +165,8 @@ public class MainActivity extends AppCompatActivity{
ReaverFragment reaverFragment = new ReaverFragment();
CrackFragment crackFragment = new CrackFragment();
CustomActionFragment customActionFragment = new CustomActionFragment();
DrawerLayout mDrawerLayout;
NavigationView navigationView;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -1589,7 +1588,7 @@ static void refreshState(){
progress.setProgress(deauthWait);
}
}
static void refreshDrawer(){
void refreshDrawer(){
navigationView.getMenu().findItem(currentFragment).setChecked(true);
actionBar.setTitle(navTitlesMap.get(currentFragment));
}
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/hijacker/MyListFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import android.widget.ListView;
import static com.hijacker.MainActivity.FRAGMENT_AIRODUMP;
import static com.hijacker.MainActivity.currentFragment;
import static com.hijacker.MainActivity.refreshDrawer;

public class MyListFragment extends ListFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Expand All @@ -42,6 +41,6 @@ public void onListItemClick(ListView l, final View v, int position, long id){
public void onResume(){
super.onResume();
currentFragment = FRAGMENT_AIRODUMP;
refreshDrawer();
((MainActivity)getActivity()).refreshDrawer();
}
}
3 changes: 1 addition & 2 deletions app/src/main/java/com/hijacker/ReaverFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
import static com.hijacker.MainActivity.prefix;
import static com.hijacker.MainActivity.progress;
import static com.hijacker.MainActivity.reaver_dir;
import static com.hijacker.MainActivity.refreshDrawer;
import static com.hijacker.MainActivity.runInHandler;
import static com.hijacker.MainActivity.stop;

Expand Down Expand Up @@ -234,7 +233,7 @@ static void stopReaver(){
public void onResume() {
super.onResume();
currentFragment = FRAGMENT_REAVER;
refreshDrawer();
((MainActivity)getActivity()).refreshDrawer();

//Console text is saved/restored on pause/resume
consoleView.setText(console_text);
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/hijacker/SettingsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import static com.hijacker.MainActivity.isArchValid;
import static com.hijacker.MainActivity.mFragmentManager;
import static com.hijacker.MainActivity.pref_edit;
import static com.hijacker.MainActivity.refreshDrawer;
import static com.hijacker.MainActivity.versionName;
import static com.hijacker.MainActivity.watchdog;
import static com.hijacker.MainActivity.currentFragment;
Expand Down Expand Up @@ -166,7 +165,7 @@ public boolean onPreferenceClick(Preference preference){
public void onResume() {
super.onResume();
currentFragment = FRAGMENT_SETTINGS;
refreshDrawer();
((MainActivity)getActivity()).refreshDrawer();
listener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Expand Down

0 comments on commit 701bf91

Please sign in to comment.