uselessListener = new ArrayList<>(0);
176 | synchronized (wadbFailureListeners) {
177 | for (WadbFailureListener l : wadbFailureListeners) {
178 | try {
179 | failure.failure(l);
180 | } catch (Throwable t) {
181 | StandardUtils.printStack(t);
182 | uselessListener.add(l);
183 | }
184 | }
185 | wadbFailureListeners.removeAll(uselessListener);
186 | }
187 | }
188 |
189 | private static CommandsListener commandsListener = new CommandsListener();
190 |
191 | private static class CommandsListener implements Commands.CommandsListener {
192 |
193 | @Override
194 | public void onGetSUAvailable(boolean isAvailable) {
195 | if (!isAvailable) {
196 | Message message = Message.obtain();
197 | message.what = STATE_ROOT_PERMISSION_FAILURE;
198 | handler.sendMessage(message);
199 | }
200 | }
201 |
202 | @Override
203 | public void onGetAdbState(boolean isWadb, int port) {
204 | if (isWadb) {
205 | Message message = Message.obtain();
206 | message.what = STATE_START_WADB;
207 | message.arg1 = port;
208 | handler.sendMessage(message);
209 | } else {
210 | Message message = Message.obtain();
211 | message.what = STATE_STOP_WADB;
212 | handler.sendMessage(message);
213 | }
214 | }
215 |
216 | @Override
217 | public void onGetAdbStateFailure() {
218 | Message message = Message.obtain();
219 | message.what = STATE_GET_STATE_FAILURE;
220 | handler.sendMessage(message);
221 | }
222 |
223 | @Override
224 | public void onWadbStartListener(boolean isSuccess) {
225 | if (isSuccess) {
226 | Commands.getWadbState(this);
227 | } else {
228 | onOperateFailed();
229 | }
230 | }
231 |
232 | @Override
233 | public void onWadbStopListener(boolean isSuccess) {
234 | if (isSuccess) {
235 | Commands.getWadbState(this);
236 | } else {
237 | onOperateFailed();
238 | }
239 | }
240 |
241 | private void onOperateFailed() {
242 | Message message = Message.obtain();
243 | message.what = STATE_OPERATE_FAILED;
244 | handler.sendMessage(message);
245 | }
246 | }
247 |
248 | }
249 |
--------------------------------------------------------------------------------
/app/src/main/java/moe/haruue/wadb/ui/activity/LaunchActivity.java:
--------------------------------------------------------------------------------
1 | package moe.haruue.wadb.ui.activity;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Context;
5 | import android.content.pm.PackageManager;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 |
9 | import moe.haruue.util.StandardUtils;
10 | import moe.haruue.util.abstracts.HaruueActivity;
11 | import moe.haruue.wadb.BuildConfig;
12 | import moe.haruue.wadb.R;
13 |
14 | /**
15 | * @author Haruue Icymoon haruue@caoyue.com.cn
16 | */
17 |
18 | public class LaunchActivity extends RikkaActivity {
19 |
20 | @Override
21 | protected void onCreate(@Nullable Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | MainActivity.start(this);
24 | finish();
25 | }
26 |
27 | private static ComponentName getLaunchActivityComponentName() {
28 | return new ComponentName(BuildConfig.APPLICATION_ID, LaunchActivity.class.getName());
29 | }
30 |
31 | public static void hideLaunchIcon(Context context) {
32 | context.getPackageManager().setComponentEnabledSetting(
33 | getLaunchActivityComponentName(),
34 | PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
35 | PackageManager.DONT_KILL_APP
36 | );
37 | StandardUtils.toast(R.string.tip_on_hide_launch_icon);
38 | }
39 |
40 | public static void showLaunchIcon(Context context) {
41 | context.getPackageManager().setComponentEnabledSetting(
42 | getLaunchActivityComponentName(),
43 | PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
44 | PackageManager.DONT_KILL_APP
45 | );
46 | StandardUtils.toast(R.string.tip_on_show_launch_icon);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/moe/haruue/wadb/ui/activity/LicenseActivity.java:
--------------------------------------------------------------------------------
1 | package moe.haruue.wadb.ui.activity;
2 |
3 | import android.content.Context;
4 | import android.content.DialogInterface;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.annotation.RawRes;
9 | import android.support.v7.app.AlertDialog;
10 | import android.view.Window;
11 | import android.webkit.WebView;
12 |
13 | import java.io.InputStream;
14 | import java.io.InputStreamReader;
15 |
16 | import moe.haruue.util.StandardUtils;
17 | import moe.haruue.util.ThreadUtils;
18 | import moe.haruue.wadb.R;
19 |
20 | /**
21 | * @author Haruue Icymoon haruue@caoyue.com.cn
22 | */
23 |
24 | public class LicenseActivity extends RikkaActivity {
25 |
26 | private WebView licenseView;
27 |
28 | @Override
29 | protected void onCreate(@Nullable Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | AlertDialog dialog = new AlertDialog.Builder(LicenseActivity.this)
32 | .setTitle(R.string.license)
33 | .setCancelable(true)
34 | .setOnCancelListener(new DialogInterface.OnCancelListener() {
35 | @Override
36 | public void onCancel(DialogInterface dialogInterface) {
37 | LicenseActivity.this.finish();
38 | }
39 | })
40 | .create();
41 | dialog.show();
42 | Window dialogWindow = dialog.getWindow();
43 | dialogWindow.setContentView(R.layout.dialog_license);
44 | licenseView = (WebView) dialogWindow.findViewById(R.id.webview_license);
45 | preLoadData();
46 | }
47 |
48 | private void preLoadData() {
49 | ThreadUtils.runOnNewThread(new Runnable() {
50 | @Override
51 | public void run() {
52 | loadData(readStringFromRawResource(R.raw.license));
53 | }
54 | });
55 | }
56 |
57 | private void loadData(final String html) {
58 | ThreadUtils.runOnUIThread(new Runnable() {
59 | @Override
60 | public void run() {
61 | try {
62 | licenseView.loadData(html, "text/html", "UTF-8");
63 | } catch (Throwable t) {
64 | StandardUtils.printStack(t);
65 | }
66 | }
67 | });
68 | }
69 |
70 | private String readStringFromRawResource(@RawRes int resId) {
71 | InputStream in = getResources().openRawResource(resId);
72 | InputStreamReader reader = new InputStreamReader(in);
73 | char[] flush = new char[10];
74 | int length;
75 | StringBuilder sb = new StringBuilder();
76 | try {
77 | while (-1 != (length = reader.read(flush))) {
78 | sb.append(flush, 0, length);
79 | }
80 | } catch (Throwable t) {
81 | StandardUtils.printStack(t);
82 | }
83 | return sb.toString();
84 | }
85 |
86 | public static void start(Context context) {
87 | Intent starter = new Intent(context, LicenseActivity.class);
88 | starter.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
89 | context.startActivity(starter);
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/app/src/main/java/moe/haruue/wadb/ui/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package moe.haruue.wadb.ui.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.v7.widget.Toolbar;
7 |
8 | import moe.haruue.wadb.R;
9 | import moe.haruue.wadb.ui.fragment.MainFragment;
10 | import moe.haruue.wadb.util.NotificationHelper;
11 |
12 | public class MainActivity extends RikkaActivity {
13 |
14 | Toolbar toolbar;
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_main);
20 | initializeToolbar();
21 | getFragmentManager().beginTransaction()
22 | .replace(R.id.container_fragment, new MainFragment())
23 | .commit();
24 | }
25 |
26 | private void initializeToolbar() {
27 | toolbar = $(R.id.toolbar);
28 | setSupportActionBar(toolbar);
29 | toolbar.setTitle(R.string.app_name);
30 | }
31 |
32 | @Override
33 | protected void onDestroy() {
34 | super.onDestroy();
35 | }
36 |
37 | @Override
38 | protected void onPause() {
39 | super.onPause();
40 | }
41 |
42 | @Override
43 | protected void onResume() {
44 | super.onResume();
45 | NotificationHelper.start(MainActivity.this);
46 | }
47 |
48 | public static void start(Context context) {
49 | Intent starter = new Intent(context, MainActivity.class);
50 | starter.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
51 | context.startActivity(starter);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/moe/haruue/wadb/ui/activity/RikkaActivity.java:
--------------------------------------------------------------------------------
1 | package moe.haruue.wadb.ui.activity;
2 |
3 | import android.app.ActivityManager;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Canvas;
6 | import android.graphics.drawable.Drawable;
7 | import android.os.Build;
8 | import android.os.Bundle;
9 | import android.support.annotation.Nullable;
10 | import android.support.v4.content.ContextCompat;
11 |
12 | import moe.haruue.util.abstracts.HaruueActivity;
13 | import moe.haruue.wadb.R;
14 |
15 | /**
16 | * @author Rikka
17 | */
18 |
19 | public class RikkaActivity extends HaruueActivity {
20 |
21 | @Override
22 | protected void onCreate(@Nullable Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 |
25 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
26 | Drawable drawable = ContextCompat.getDrawable(this, R.drawable.ic_task);
27 | Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
28 | Canvas canvas = new Canvas(bitmap);
29 | drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
30 | drawable.draw(canvas);
31 |
32 | setTaskDescription(new ActivityManager.TaskDescription(null, bitmap, ContextCompat.getColor(this, R.color.colorPrimary)));
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/moe/haruue/wadb/ui/activity/RootPermissionErrorDialogShadowActivity.java:
--------------------------------------------------------------------------------
1 | package moe.haruue.wadb.ui.activity;
2 |
3 | import android.content.Context;
4 | import android.content.DialogInterface;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.v7.app.AlertDialog;
9 |
10 | import moe.haruue.util.ActivityCollector;
11 | import moe.haruue.util.StandardUtils;
12 | import moe.haruue.wadb.R;
13 | import moe.haruue.wadb.util.NotificationHelper;
14 |
15 | /**
16 | * @author Haruue Icymoon haruue@caoyue.com.cn
17 | */
18 |
19 | public class RootPermissionErrorDialogShadowActivity extends RikkaActivity {
20 |
21 | @Override
22 | protected void onCreate(@Nullable Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | new AlertDialog.Builder(this).setIcon(R.drawable.ic_error_red_24dp)
25 | .setTitle(StandardUtils.getApplication().getResources().getString(R.string.permission_error))
26 | .setMessage(StandardUtils.getApplication().getResources().getString(R.string.supersu_tip))
27 | .setPositiveButton(StandardUtils.getApplication().getResources().getString(R.string.exit), new DialogInterface.OnClickListener() {
28 | @Override
29 | public void onClick(DialogInterface dialogInterface, int i) {
30 | dialogInterface.dismiss();
31 | NotificationHelper.stop(getApplication());
32 | ActivityCollector.finishAllActivity();
33 | android.os.Process.killProcess(android.os.Process.myPid());
34 | }
35 | })
36 | .setCancelable(false)
37 | .create().show();
38 | }
39 |
40 | public static void start(Context context) {
41 | Intent starter = new Intent(context, RootPermissionErrorDialogShadowActivity.class);
42 | starter.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
43 | context.startActivity(starter);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/moe/haruue/wadb/ui/fragment/MainFragment.java:
--------------------------------------------------------------------------------
1 | package moe.haruue.wadb.ui.fragment;
2 |
3 | import android.content.SharedPreferences;
4 | import android.os.Bundle;
5 | import android.preference.EditTextPreference;
6 | import android.preference.PreferenceFragment;
7 | import android.preference.PreferenceManager;
8 | import android.preference.SwitchPreference;
9 | import android.widget.Toast;
10 |
11 | import moe.haruue.util.StandardUtils;
12 | import moe.haruue.wadb.R;
13 | import moe.haruue.wadb.data.Commands;
14 | import moe.haruue.wadb.presenter.Commander;
15 | import moe.haruue.wadb.ui.activity.LaunchActivity;
16 | import moe.haruue.wadb.util.NotificationHelper;
17 | import moe.haruue.wadb.util.ScreenKeeper;
18 |
19 | /**
20 | * @author Haruue Icymoon haruue@caoyue.com.cn
21 | */
22 |
23 | public class MainFragment extends PreferenceFragment {
24 |
25 | SwitchPreference wadbSwitchPreference;
26 | EditTextPreference portPreference;
27 | Listener listener = new Listener();
28 |
29 | @Override
30 | public void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | addPreferencesFromResource(R.xml.preferences);
33 | Commander.addChangeListener(listener);
34 | Commander.addFailureListener(listener);
35 | PreferenceManager.setDefaultValues(getActivity(), R.xml.preferences, false);
36 | wadbSwitchPreference = (SwitchPreference) findPreference("pref_key_wadb_switch");
37 | portPreference = (EditTextPreference) findPreference("pref_key_wadb_port");
38 | Commander.checkWadbState();
39 | }
40 |
41 | private void init() {
42 | }
43 |
44 | @Override
45 | public void onDestroy() {
46 | super.onDestroy();
47 | Commander.removeChangeListener(listener);
48 | Commander.removeFailureListener(listener);
49 | }
50 |
51 | @Override
52 | public void onPause() {
53 | super.onPause();
54 | getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(listener);
55 | }
56 |
57 | @Override
58 | public void onResume() {
59 | super.onResume();
60 | getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(listener);
61 | }
62 |
63 | class Listener implements Commander.WadbStateChangeListener, Commander.WadbFailureListener, SharedPreferences.OnSharedPreferenceChangeListener {
64 |
65 | @Override
66 | public void onRootPermissionFailure() {
67 |
68 | }
69 |
70 | @Override
71 | public void onStateRefreshFailure() {
72 | onWadbStop();
73 | }
74 |
75 | @Override
76 | public void onOperateFailure() {
77 |
78 | }
79 |
80 | @Override
81 | public void onWadbStart(String ip, int port) {
82 | // refresh switch
83 | wadbSwitchPreference.setChecked(true);
84 | wadbSwitchPreference.setSummaryOn(ip + ":" + port);
85 | // refresh port
86 | portPreference.setText(port + "");
87 | portPreference.setSummary(port + "");
88 | wadbSwitchPreference.setEnabled(true);
89 | }
90 |
91 | @Override
92 | public void onWadbStop() {
93 | // refresh switch
94 | wadbSwitchPreference.setChecked(false);
95 | wadbSwitchPreference.getEditor().putBoolean("pref_key_wadb_switch", false).commit();
96 | // refresh port
97 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(StandardUtils.getApplication());
98 | String port = sharedPreferences.getString("pref_key_wadb_port", "5555");
99 | portPreference.setSummary(port);
100 | portPreference.setText(port);
101 | wadbSwitchPreference.setEnabled(true);
102 | }
103 |
104 | @Override
105 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
106 | switch (s) {
107 | case "pref_key_wadb_switch":
108 | if (wadbSwitchPreference.isEnabled()) {
109 | wadbSwitchPreference.setEnabled(false);
110 | if (sharedPreferences.getBoolean("pref_key_wadb_switch", false)) {
111 | Commander.startWadb();
112 | } else {
113 | Commander.stopWadb();
114 | }
115 | }
116 | break;
117 | // refresh notification when notification preferences are changed
118 | case "pref_key_notification":
119 | case "pref_key_notification_low_priority":
120 | if (sharedPreferences.getBoolean("pref_key_wadb_switch", false)) {
121 | NotificationHelper.refresh(StandardUtils.getApplication());
122 | } else {
123 | NotificationHelper.stop(StandardUtils.getApplication());
124 | }
125 | break;
126 | case "pref_key_hide_launcher_icon":
127 | if (sharedPreferences.getBoolean("pref_key_hide_launcher_icon", false)) {
128 | LaunchActivity.hideLaunchIcon(getActivity());
129 | } else {
130 | LaunchActivity.showLaunchIcon(getActivity());
131 | }
132 | break;
133 | case "pref_key_wake_lock":
134 | if (sharedPreferences.getBoolean("pref_key_wake_lock", false) && sharedPreferences.getBoolean("pref_key_wadb_switch", false)) {
135 | ScreenKeeper.acquireWakeLock();
136 | } else {
137 | ScreenKeeper.releaseWakeLock();
138 | }
139 | break;
140 | case "pref_key_wadb_port":
141 | String port = sharedPreferences.getString("pref_key_wadb_port", "5555");
142 | try {
143 | int p = Integer.parseInt(port);
144 | if (p < 1025 || p > 65535) {
145 | throw new NumberFormatException(getText(R.string.bad_port_number).toString());
146 | }
147 | } catch (NumberFormatException e) {
148 | Toast.makeText(StandardUtils.getApplication(), R.string.bad_port_number, Toast.LENGTH_SHORT).show();
149 | port = "5555";
150 | e.printStackTrace();
151 | }
152 | portPreference.setText(port);
153 | portPreference.setSummary(port);
154 | Commands.getWadbState(new Commands.AbstractCommandsListener() {
155 | @Override
156 | public void onGetAdbState(boolean isWadb, int port) {
157 | if (isWadb) {
158 | Commander.startWadb();
159 | }
160 | }
161 | });
162 | break;
163 | }
164 | }
165 | }
166 |
167 | }
168 |
--------------------------------------------------------------------------------
/app/src/main/java/moe/haruue/wadb/ui/item/MenuItemModel.java:
--------------------------------------------------------------------------------
1 | package moe.haruue.wadb.ui.item;
2 |
3 | /**
4 | * @author Haruue Icymoon haruue@caoyue.com.cn
5 | */
6 |
7 | public class MenuItemModel {
8 |
9 | public final static int VIEW_TYPE_MENU_CLASS = 21355;
10 | public final static int VIEW_TYPE_MENU_ITEM = 51214;
11 |
12 | private int viewType;
13 |
14 | public int getViewType() {
15 | return viewType;
16 | }
17 |
18 | private String title;
19 | private String subTitle;
20 | private boolean hasCheckbox;
21 | private boolean isChecked;
22 |
23 | public MenuItemModel(String title) {
24 | viewType = VIEW_TYPE_MENU_CLASS;
25 | this.title = title;
26 | }
27 |
28 | public MenuItemModel(String title, String subTitle, boolean hasCheckbox) {
29 | viewType = VIEW_TYPE_MENU_ITEM;
30 | this.title = title;
31 | this.subTitle = subTitle;
32 | this.hasCheckbox = hasCheckbox;
33 | }
34 |
35 | public String getTitle() {
36 | return title;
37 | }
38 |
39 | public String getSubTitle() {
40 | return subTitle;
41 | }
42 |
43 | public void setSubTitle(String subTitle) {
44 | this.subTitle = subTitle;
45 | }
46 |
47 | public boolean isHasCheckbox() {
48 | return hasCheckbox;
49 | }
50 |
51 | public boolean isChecked() {
52 | return isChecked;
53 | }
54 |
55 | public void setChecked(boolean checked) {
56 | isChecked = checked;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/moe/haruue/wadb/ui/receiver/TurnOffReceiver.java:
--------------------------------------------------------------------------------
1 | package moe.haruue.wadb.ui.receiver;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 |
7 | import moe.haruue.wadb.presenter.Commander;
8 |
9 | public class TurnOffReceiver extends BroadcastReceiver {
10 |
11 | public TurnOffReceiver() {
12 | }
13 |
14 | @Override
15 | public void onReceive(Context context, Intent intent) {
16 | Commander.stopWadb();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/moe/haruue/wadb/ui/service/WadbTileService.java:
--------------------------------------------------------------------------------
1 | package moe.haruue.wadb.ui.service;
2 |
3 | import android.graphics.drawable.Icon;
4 | import android.os.Build;
5 | import android.preference.PreferenceManager;
6 | import android.service.quicksettings.Tile;
7 | import android.service.quicksettings.TileService;
8 | import android.support.annotation.RequiresApi;
9 |
10 | import moe.haruue.util.StandardUtils;
11 | import moe.haruue.wadb.R;
12 | import moe.haruue.wadb.presenter.Commander;
13 | import moe.haruue.wadb.util.NotificationHelper;
14 |
15 | /**
16 | * @author Haruue Icymoon haruue@caoyue.com.cn
17 | */
18 |
19 | @RequiresApi(api = Build.VERSION_CODES.N)
20 | public class WadbTileService extends TileService {
21 |
22 | Listener listener = new Listener();
23 |
24 | @Override
25 | public void onCreate() {
26 | super.onCreate();
27 | Commander.addChangeListener(listener);
28 | }
29 |
30 | @Override
31 | public void onDestroy() {
32 | super.onDestroy();
33 | Commander.removeChangeListener(listener);
34 | }
35 |
36 | @Override
37 | public void onStartListening() {
38 | super.onStartListening();
39 | Commander.checkWadbState();
40 | NotificationHelper.start(getApplicationContext());
41 | }
42 |
43 | Runnable startWadbRunnable = new Runnable() {
44 | @Override
45 | public void run() {
46 | Commander.startWadb();
47 | }
48 | };
49 | Runnable stopWadbRunnable = new Runnable() {
50 | @Override
51 | public void run() {
52 | Commander.stopWadb();
53 | }
54 | };
55 |
56 | @Override
57 | public void onClick() {
58 | super.onClick();
59 | boolean enableScreenLockSwitch = PreferenceManager.getDefaultSharedPreferences(StandardUtils.getApplication()).getBoolean("pref_key_screen_lock_switch", false);
60 | if (getQsTile().getState() == Tile.STATE_ACTIVE) {
61 | if (enableScreenLockSwitch) {
62 | stopWadbRunnable.run();
63 | } else {
64 | unlockAndRun(stopWadbRunnable);
65 | }
66 | } else {
67 | if (enableScreenLockSwitch) {
68 | startWadbRunnable.run();
69 | } else {
70 | unlockAndRun(startWadbRunnable);
71 | }
72 | }
73 | }
74 |
75 | private void showStateOn(String ip, int port) {
76 | Tile tile = getQsTile();
77 | tile.setState(Tile.STATE_ACTIVE);
78 | tile.setIcon(Icon.createWithResource(getApplication(), R.drawable.ic_qs_network_adb_on));
79 | tile.setLabel(ip + ":" + port);
80 | tile.updateTile();
81 | }
82 |
83 | private void showStateOff() {
84 | Tile tile = getQsTile();
85 | tile.setState(Tile.STATE_INACTIVE);
86 | tile.setIcon(Icon.createWithResource(getApplication(), R.drawable.ic_qs_network_adb_off));
87 | tile.setLabel(getApplication().getResources().getString(R.string.app_name));
88 | tile.updateTile();
89 | }
90 |
91 | private void showStateUnavailable() {
92 | Tile tile = getQsTile();
93 | tile.setState(Tile.STATE_UNAVAILABLE);
94 | tile.updateTile();
95 | }
96 |
97 | class Listener implements Commander.WadbStateChangeListener {
98 |
99 | @Override
100 | public void onWadbStart(String ip, int port) {
101 | showStateOn(ip, port);
102 | }
103 |
104 | @Override
105 | public void onWadbStop() {
106 | showStateOff();
107 | }
108 | }
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/app/src/main/java/moe/haruue/wadb/util/IPUtils.java:
--------------------------------------------------------------------------------
1 | package moe.haruue.wadb.util;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.net.wifi.WifiInfo;
5 | import android.net.wifi.WifiManager;
6 |
7 | import moe.haruue.util.StandardUtils;
8 |
9 | import static android.content.Context.WIFI_SERVICE;
10 |
11 | /**
12 | * @author Haruue Icymoon haruue@caoyue.com.cn
13 | */
14 |
15 | public class IPUtils {
16 |
17 | // 获取本地IP函数
18 | public static String getLocalIPAddress() {
19 | @SuppressLint("WifiManagerLeak") WifiManager wifiManger = (WifiManager) StandardUtils.getApplication().getSystemService(WIFI_SERVICE);
20 | WifiInfo wifiInfo = wifiManger.getConnectionInfo();
21 | return intToIp(wifiInfo.getIpAddress());
22 | }
23 |
24 |
25 | private static String intToIp(int i) {
26 | return (i & 0xFF) + "." + ((i >> 8) & 0xFF) + "." + ((i >> 16) & 0xFF) + "." + (i >> 24 & 0xFF);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/moe/haruue/wadb/util/NotificationHelper.java:
--------------------------------------------------------------------------------
1 | package moe.haruue.wadb.util;
2 |
3 | import android.app.Notification;
4 | import android.app.NotificationManager;
5 | import android.app.PendingIntent;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.preference.PreferenceManager;
9 | import android.support.v4.content.ContextCompat;
10 | import android.support.v7.app.NotificationCompat;
11 |
12 | import moe.haruue.util.StandardUtils;
13 | import moe.haruue.wadb.R;
14 | import moe.haruue.wadb.presenter.Commander;
15 | import moe.haruue.wadb.ui.activity.MainActivity;
16 |
17 | public class NotificationHelper {
18 |
19 | private static final String TAG = NotificationHelper.class.getSimpleName();
20 |
21 | private static Listener listener;
22 |
23 | private static void showNotification(Context context, String ip, int port) {
24 | PendingIntent contentPendingIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
25 | PendingIntent turnOffPendingIntent = PendingIntent.getBroadcast(context, 0, new Intent("moe.haruue.wadb.action.TURN_OFF_WADB"), 0);
26 | // Notification
27 | Notification notification = new NotificationCompat.Builder(context)
28 | .setContentTitle(context.getString(R.string.wadb_on))
29 | .setContentText(ip + ":" + port)
30 | .setSmallIcon(R.drawable.ic_qs_network_adb_on)
31 | .setContentIntent(contentPendingIntent)
32 | .addAction(R.drawable.ic_close_white_24dp, context.getString(R.string.turn_off), turnOffPendingIntent)
33 | .setColor(ContextCompat.getColor(context, R.color.colorPrimary))
34 | .setOngoing(true)
35 | .setPriority(PreferenceManager.getDefaultSharedPreferences(StandardUtils.getApplication()).getBoolean("pref_key_notification_low_priority", true) ?
36 | NotificationCompat.PRIORITY_MIN : NotificationCompat.PRIORITY_DEFAULT)
37 | .build();
38 |
39 | NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
40 | notificationManager.notify(R.string.app_name, notification);
41 | }
42 |
43 | private static void cancelNotification(Context context) {
44 | NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
45 | notificationManager.cancel(R.string.app_name);
46 | }
47 |
48 | private static class Listener implements Commander.WadbStateChangeListener {
49 |
50 | @Override
51 | public void onWadbStart(String ip, int port) {
52 | showNotification(StandardUtils.getApplication(), ip, port);
53 | ScreenKeeper.acquireWakeLock();
54 | }
55 |
56 | @Override
57 | public void onWadbStop() {
58 | cancelNotification(StandardUtils.getApplication());
59 | ScreenKeeper.releaseWakeLock();
60 | }
61 | }
62 |
63 | public static void start(Context context) {
64 | if (!PreferenceManager.getDefaultSharedPreferences(context).getBoolean("pref_key_notification", true)) {
65 | return;
66 | }
67 |
68 | if (listener == null) {
69 | listener = new Listener();
70 | }
71 | Commander.addChangeListener(listener);
72 | Commander.checkWadbState();
73 | }
74 |
75 | public static void stop(Context context) {
76 | Commander.removeChangeListener(listener);
77 | cancelNotification(context);
78 | }
79 |
80 | public static void refresh(Context context) {
81 | if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("pref_key_notification", true)) {
82 | start(context);
83 | } else {
84 | stop(context);
85 | }
86 |
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/java/moe/haruue/wadb/util/ScreenKeeper.java:
--------------------------------------------------------------------------------
1 | package moe.haruue.wadb.util;
2 |
3 | import android.os.PowerManager;
4 | import android.preference.PreferenceManager;
5 |
6 | import moe.haruue.util.StandardUtils;
7 | import moe.haruue.wadb.R;
8 |
9 | import static android.content.Context.POWER_SERVICE;
10 |
11 | /**
12 | * @author PinkD
13 | */
14 |
15 | public class ScreenKeeper {
16 | private static PowerManager.WakeLock wakeLock;
17 |
18 | public static void acquireWakeLock() {
19 | if (wakeLock == null) {
20 | PowerManager powerManager = (PowerManager) StandardUtils.getApplication().getSystemService(POWER_SERVICE);
21 | wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, StandardUtils.getApplication().getText(R.string.app_name).toString());
22 | wakeLock.setReferenceCounted(false);
23 | }
24 | if (!wakeLock.isHeld() && PreferenceManager.getDefaultSharedPreferences(StandardUtils.getApplication()).getBoolean("pref_key_wake_lock", false)) {
25 | wakeLock.acquire();
26 | }
27 | }
28 |
29 | public static void releaseWakeLock() {
30 | if (wakeLock != null) {
31 | wakeLock.release();
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
18 |
23 |
24 |
28 |
29 |
33 |
34 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_close_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_error_red_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_full.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/app/src/main/res/drawable/ic_launcher_full.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_qs_network_adb_off.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
24 |
25 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_qs_network_adb_on.xml:
--------------------------------------------------------------------------------
1 |
18 |
23 |
24 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_task.xml:
--------------------------------------------------------------------------------
1 |
18 |
23 |
24 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
18 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_license.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_menu_class.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_menu_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
24 |
25 |
32 |
33 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/raw/license.html:
--------------------------------------------------------------------------------
1 | WADB
2 | Author: Haruue Icymoon, PinkD
3 | Link: https://github.com/haruue/WADB
4 | Copyright 2016 Haruue Icymoon, PinkD
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License");
7 | you may not use this file except in compliance with the License.
8 | You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 |
18 | HaruueUtils
19 | Author: Haruue Icymoon
20 | Link: https://github.com/haruue/HaruueUtils
21 | Copyright 2016 Haruue Icymoon
22 |
23 | Licensed under the Apache License, Version 2.0 (the "License");
24 | you may not use this file except in compliance with the License.
25 | You may obtain a copy of the License at
26 |
27 | http://www.apache.org/licenses/LICENSE-2.0
28 |
29 | Unless required by applicable law or agreed to in writing, software
30 | distributed under the License is distributed on an "AS IS" BASIS,
31 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32 | See the License for the specific language governing permissions and
33 | limitations under the License.
34 |
35 | /res/drawable/ic_qs_network_adb_on.xml
36 | Author: The CyanogenMod Open Source Project
37 | Link: https://github.com/CyanogenMod/android_frameworks_base/blob/7699100fa82f4b61871f90a9c381ea292b8d3a08/packages/SystemUI/res/drawable/ic_qs_network_adb_on.xml
38 | /res/drawable/ic_qs_network_adb_off.xml
39 | Author: The CyanogenMod Open Source Project
40 | Link: https://github.com/CyanogenMod/android_frameworks_base/blob/7699100fa82f4b61871f90a9c381ea292b8d3a08/packages/SystemUI/res/drawable/ic_qs_network_adb_off.xml
41 | Copyright (C) 2015 The CyanogenMod Open Source Project
42 |
43 | Licensed under the Apache License, Version 2.0 (the "License");
44 | you may not use this file except in compliance with the License.
45 | You may obtain a copy of the License at
46 |
47 | http://www.apache.org/licenses/LICENSE-2.0
48 |
49 | Unless required by applicable law or agreed to in writing, software
50 | distributed under the License is distributed on an "AS IS" BASIS,
51 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
52 | See the License for the specific language governing permissions and
53 | limitations under the License.
54 |
55 | libsuperuser
56 | Author: Chainfire
57 | Link: https://github.com/Chainfire/libsuperuser
58 | Apache License
59 | Version 2.0, January 2004
60 | http://www.apache.org/licenses/
61 |
62 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
63 |
64 | 1. Definitions.
65 |
66 | "License" shall mean the terms and conditions for use, reproduction,
67 | and distribution as defined by Sections 1 through 9 of this document.
68 |
69 | "Licensor" shall mean the copyright owner or entity authorized by
70 | the copyright owner that is granting the License.
71 |
72 | "Legal Entity" shall mean the union of the acting entity and all
73 | other entities that control, are controlled by, or are under common
74 | control with that entity. For the purposes of this definition,
75 | "control" means (i) the power, direct or indirect, to cause the
76 | direction or management of such entity, whether by contract or
77 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
78 | outstanding shares, or (iii) beneficial ownership of such entity.
79 |
80 | "You" (or "Your") shall mean an individual or Legal Entity
81 | exercising permissions granted by this License.
82 |
83 | "Source" form shall mean the preferred form for making modifications,
84 | including but not limited to software source code, documentation
85 | source, and configuration files.
86 |
87 | "Object" form shall mean any form resulting from mechanical
88 | transformation or translation of a Source form, including but
89 | not limited to compiled object code, generated documentation,
90 | and conversions to other media types.
91 |
92 | "Work" shall mean the work of authorship, whether in Source or
93 | Object form, made available under the License, as indicated by a
94 | copyright notice that is included in or attached to the work
95 | (an example is provided in the Appendix below).
96 |
97 | "Derivative Works" shall mean any work, whether in Source or Object
98 | form, that is based on (or derived from) the Work and for which the
99 | editorial revisions, annotations, elaborations, or other modifications
100 | represent, as a whole, an original work of authorship. For the purposes
101 | of this License, Derivative Works shall not include works that remain
102 | separable from, or merely link (or bind by name) to the interfaces of,
103 | the Work and Derivative Works thereof.
104 |
105 | "Contribution" shall mean any work of authorship, including
106 | the original version of the Work and any modifications or additions
107 | to that Work or Derivative Works thereof, that is intentionally
108 | submitted to Licensor for inclusion in the Work by the copyright owner
109 | or by an individual or Legal Entity authorized to submit on behalf of
110 | the copyright owner. For the purposes of this definition, "submitted"
111 | means any form of electronic, verbal, or written communication sent
112 | to the Licensor or its representatives, including but not limited to
113 | communication on electronic mailing lists, source code control systems,
114 | and issue tracking systems that are managed by, or on behalf of, the
115 | Licensor for the purpose of discussing and improving the Work, but
116 | excluding communication that is conspicuously marked or otherwise
117 | designated in writing by the copyright owner as "Not a Contribution."
118 |
119 | "Contributor" shall mean Licensor and any individual or Legal Entity
120 | on behalf of whom a Contribution has been received by Licensor and
121 | subsequently incorporated within the Work.
122 |
123 | 2. Grant of Copyright License. Subject to the terms and conditions of
124 | this License, each Contributor hereby grants to You a perpetual,
125 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
126 | copyright license to reproduce, prepare Derivative Works of,
127 | publicly display, publicly perform, sublicense, and distribute the
128 | Work and such Derivative Works in Source or Object form.
129 |
130 | 3. Grant of Patent License. Subject to the terms and conditions of
131 | this License, each Contributor hereby grants to You a perpetual,
132 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
133 | (except as stated in this section) patent license to make, have made,
134 | use, offer to sell, sell, import, and otherwise transfer the Work,
135 | where such license applies only to those patent claims licensable
136 | by such Contributor that are necessarily infringed by their
137 | Contribution(s) alone or by combination of their Contribution(s)
138 | with the Work to which such Contribution(s) was submitted. If You
139 | institute patent litigation against any entity (including a
140 | cross-claim or counterclaim in a lawsuit) alleging that the Work
141 | or a Contribution incorporated within the Work constitutes direct
142 | or contributory patent infringement, then any patent licenses
143 | granted to You under this License for that Work shall terminate
144 | as of the date such litigation is filed.
145 |
146 | 4. Redistribution. You may reproduce and distribute copies of the
147 | Work or Derivative Works thereof in any medium, with or without
148 | modifications, and in Source or Object form, provided that You
149 | meet the following conditions:
150 |
151 | (a) You must give any other recipients of the Work or
152 | Derivative Works a copy of this License; and
153 |
154 | (b) You must cause any modified files to carry prominent notices
155 | stating that You changed the files; and
156 |
157 | (c) You must retain, in the Source form of any Derivative Works
158 | that You distribute, all copyright, patent, trademark, and
159 | attribution notices from the Source form of the Work,
160 | excluding those notices that do not pertain to any part of
161 | the Derivative Works; and
162 |
163 | (d) If the Work includes a "NOTICE" text file as part of its
164 | distribution, then any Derivative Works that You distribute must
165 | include a readable copy of the attribution notices contained
166 | within such NOTICE file, excluding those notices that do not
167 | pertain to any part of the Derivative Works, in at least one
168 | of the following places: within a NOTICE text file distributed
169 | as part of the Derivative Works; within the Source form or
170 | documentation, if provided along with the Derivative Works; or,
171 | within a display generated by the Derivative Works, if and
172 | wherever such third-party notices normally appear. The contents
173 | of the NOTICE file are for informational purposes only and
174 | do not modify the License. You may add Your own attribution
175 | notices within Derivative Works that You distribute, alongside
176 | or as an addendum to the NOTICE text from the Work, provided
177 | that such additional attribution notices cannot be construed
178 | as modifying the License.
179 |
180 | You may add Your own copyright statement to Your modifications and
181 | may provide additional or different license terms and conditions
182 | for use, reproduction, or distribution of Your modifications, or
183 | for any such Derivative Works as a whole, provided Your use,
184 | reproduction, and distribution of the Work otherwise complies with
185 | the conditions stated in this License.
186 |
187 | 5. Submission of Contributions. Unless You explicitly state otherwise,
188 | any Contribution intentionally submitted for inclusion in the Work
189 | by You to the Licensor shall be under the terms and conditions of
190 | this License, without any additional terms or conditions.
191 | Notwithstanding the above, nothing herein shall supersede or modify
192 | the terms of any separate license agreement you may have executed
193 | with Licensor regarding such Contributions.
194 |
195 | 6. Trademarks. This License does not grant permission to use the trade
196 | names, trademarks, service marks, or product names of the Licensor,
197 | except as required for reasonable and customary use in describing the
198 | origin of the Work and reproducing the content of the NOTICE file.
199 |
200 | 7. Disclaimer of Warranty. Unless required by applicable law or
201 | agreed to in writing, Licensor provides the Work (and each
202 | Contributor provides its Contributions) on an "AS IS" BASIS,
203 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
204 | implied, including, without limitation, any warranties or conditions
205 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
206 | PARTICULAR PURPOSE. You are solely responsible for determining the
207 | appropriateness of using or redistributing the Work and assume any
208 | risks associated with Your exercise of permissions under this License.
209 |
210 | 8. Limitation of Liability. In no event and under no legal theory,
211 | whether in tort (including negligence), contract, or otherwise,
212 | unless required by applicable law (such as deliberate and grossly
213 | negligent acts) or agreed to in writing, shall any Contributor be
214 | liable to You for damages, including any direct, indirect, special,
215 | incidental, or consequential damages of any character arising as a
216 | result of this License or out of the use or inability to use the
217 | Work (including but not limited to damages for loss of goodwill,
218 | work stoppage, computer failure or malfunction, or any and all
219 | other commercial damages or losses), even if such Contributor
220 | has been advised of the possibility of such damages.
221 |
222 | 9. Accepting Warranty or Additional Liability. While redistributing
223 | the Work or Derivative Works thereof, You may choose to offer,
224 | and charge a fee for, acceptance of support, warranty, indemnity,
225 | or other liability obligations and/or rights consistent with this
226 | License. However, in accepting such obligations, You may act only
227 | on Your own behalf and on Your sole responsibility, not on behalf
228 | of any other Contributor, and only if You agree to indemnify,
229 | defend, and hold each Contributor harmless for any liability
230 | incurred by, or claims asserted against, such Contributor by reason
231 | of your accepting any such warranty or additional liability.
232 |
233 | END OF TERMS AND CONDITIONS
234 |
235 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-zh-rCN/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 网络 adb
4 | 权限故障
5 | 此程序需要超级用户权限,请确保您的设备已经破解 ROOT 授权。
6 | 确定
7 | 退出程序
8 | 状态更新失败
9 | 操作失败
10 | 网络 adb 已经启动
11 | 关闭网络 adb
12 | 开关
13 | 开启基于网络的 adb
14 | 基于网络的 adb
15 | 行为
16 | 网络 adb 开启时显示通知
17 | 网络 adb 开启时不显示通知
18 | 基于网络的 adb 已禁用
19 | 基于网络的 adb 已启用
20 | 已禁用
21 | 已启用
22 | 通知
23 | 锁屏时允许切换状态
24 | 使用快速设置开关时必须解锁屏幕
25 | 屏幕锁定时允许使用快速设置开关直接更改状态
26 | 关于
27 | Copyright © Haruue Icymoon\n点击这里访问 GitHub 上的开源仓库
28 | 开源许可
29 | 隐藏启动器图标
30 | 不隐藏图标
31 | 隐藏图标,你可以通过长按我们的快速设置瓷贴打开此应用
32 | 图标隐藏可能需要几分钟的时间才能生效
33 | 取消图标隐藏可能需要几分钟的时间才能生效
34 | 屏幕常亮
35 | 启用调试时屏幕常亮
36 | 不启用调试时屏幕常亮
37 | 端口
38 | 端口只能在1025–65535之间\n已重置为5555
39 | 低优先级通知
40 | 使用低优先级通知来隐藏通知图标
41 | 使用默认优先级通知
42 |
--------------------------------------------------------------------------------
/app/src/main/res/values-zh-rHK/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 網路 adb
4 | 權限問題
5 | 此程序需要超級用戶授權,請確保您的設備已破解 ROOT 授權。
6 | 確定
7 | 退出應用程式
8 | 狀態更新失敗
9 | 操作失敗
10 | 網路 adb 已經啟動
11 | 關閉網路 adb
12 | 開關
13 | 啟用基於網路的 adb
14 | 基於網路的 adb
15 | 行為
16 | 網路 adb 開啟時顯示通知
17 | 網路 adb 開啟時不顯示通知
18 | 基於網路的 adb 已禁用
19 | 基於網路的 adb 已啟用
20 | 已禁用
21 | 已啟用
22 | 通知
23 | 鎖定屏幕時允許切換狀態
24 | 使用快速設置開關時必須解鎖屏幕
25 | 屏幕鎖定時允許使用快速設置開關直接更改狀態
26 | 關於
27 | Copyright © Haruue Icymoon\n點按這裡來訪問 GitHub 上的開源倉庫
28 | 開放原始碼許可
29 | 在啟動器中隱藏圖標
30 | 不隱藏啟動器中的圖標
31 | 隱藏圖標,你可以通過長按我們的快速設置磁貼來回到此介面
32 | 圖標隱藏可能需要幾分鐘的時間才能生效
33 | 取消圖標隱藏可能需要幾分鐘的時間才能生效
34 | 屏幕常亮
35 | 啟用調試時屏幕常亮
36 | 不啟用調試時屏幕常亮
37 | 埠
38 | 埠只能在1025–65535之間 \n已重置為5555
39 | 低優先順序通知
40 | 使用低優先順序通知來隱藏通知圖示
41 | 使用默認優先順序通知
42 |
--------------------------------------------------------------------------------
/app/src/main/res/values-zh-rTW/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 網路 adb
4 | 權限問題
5 | 此程序需要超級用戶授權,請確保您的設備已破解 ROOT 授權。
6 | 確定
7 | 退出應用程式
8 | 狀態更新失敗
9 | 操作失敗
10 | 網路 adb 已經啟動
11 | 關閉網路 adb
12 | 開關
13 | 啟用基於網路的 adb
14 | 基於網路的 adb
15 | 行為
16 | 網路 adb 開啟時顯示通知
17 | 網路 adb 開啟時不顯示通知
18 | 基於網路的 adb 已禁用
19 | 基于网络的 adb 已啟用
20 | 已禁用
21 | 已啟用
22 | 通知
23 | 鎖定屏幕時允許切換狀態
24 | 使用快速設置開關時必須解鎖屏幕
25 | 屏幕鎖定時允許使用快速設置開關直接更改狀態
26 | 關於
27 | Copyright © Haruue Icymoon\n點按這裡來訪問 GitHub 上的開源倉庫
28 | 開放原始碼許可
29 | 在啟動器中隱藏圖標
30 | 不在啟動器中的圖標
31 | 隱藏圖標,你可以通過長按我們的快速設置磁貼來回到此介面
32 | 圖標隱藏可能需要幾分鐘的時間才能生效
33 | 取消圖標隱藏可能需要幾分鐘的時間才能生效
34 | 屏幕常亮
35 | 啟用調試時屏幕常亮
36 | 不啟用調試時屏幕常亮
37 | 埠
38 | 埠只能在1025–65535之間 \n已重置為5555
39 | 低優先順序通知
40 | 使用低優先順序通知來隱藏通知圖示
41 | 使用默認優先順序通知
42 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | @color/teal_600
4 | @color/teal_800
5 | @color/teal_600
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ADB Over Network
3 | Permission denied
4 | Need root!
5 | OK
6 | Exit
7 | Refresh state failed.
8 | Failed
9 | Network adb is on
10 | Turn off
11 | Switch
12 | Enable adb over network
13 | ADB Over Network
14 | Behavior
15 | Show notification when adb over network is on
16 | Don\'t show notification when adb over network is on
17 | ADB over network is enabled
18 | ADB over network is disabled
19 | Enabled
20 | Disabled
21 | Notification
22 | Allow switch when screen is locked
23 | You have to unlock screen to switch with quick setting tile
24 | You can switch with quick setting tile when screen is locked
25 | About
26 | Copyright © Haruue Icymoon\nTouch to visit the repository on GitHub
27 | License
28 | Apache License 2.0
29 | don\'t hide the icon in launcher
30 | hide the icon in launcher, you can launch this app by long pressing our quick setting tile
31 | Hide the icon in launcher
32 | It may take a while before system hides the launcher icon
33 | It may take a while before system unhides the launcher icon
34 | Keep Screen On
35 | Keep screen on when adb is enabling
36 | Don\'t keep screen on when adb is enabling
37 | Port
38 | 5555
39 | Port number can only be 1025–65535\nReset to 5555
40 | Low priority notification
41 | Use low priority notification to hide the notification icon
42 | Use default priority notification
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
12 |
13 |
14 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/xml-v24/preferences.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
14 |
15 |
19 |
20 |
21 |
22 |
25 |
26 |
32 |
33 |
40 |
41 |
47 |
48 |
54 |
55 |
61 |
62 |
63 |
64 |
67 |
68 |
71 |
72 |
75 |
76 |
77 |
78 |
81 |
82 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/preferences.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
14 |
15 |
19 |
20 |
21 |
22 |
25 |
26 |
32 |
33 |
40 |
41 |
47 |
48 |
49 |
50 |
53 |
54 |
57 |
58 |
61 |
62 |
63 |
64 |
67 |
68 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/app/src/test/java/moe/haruue/wadb/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package moe.haruue.wadb;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | ## Project-wide Gradle settings.
2 | #
3 | # For more details on how to configure your build environment visit
4 | # http://www.gradle.org/docs/current/userguide/build_environment.html
5 | #
6 | # Specifies the JVM arguments used for the daemon process.
7 | # The setting is particularly useful for tweaking memory settings.
8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m
9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
10 | #
11 | # When configured, Gradle will run in incubating parallel mode.
12 | # This option should only be used with decoupled projects. More details, visit
13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
14 | # org.gradle.parallel=true
15 | #Fri Oct 21 14:57:45 CST 2016
16 | systemProp.http.proxyHost=127.0.0.1
17 | systemProp.http.nonProxyHosts=dl.google.com
18 | org.gradle.jvmargs=-Xmx1536m
19 | systemProp.http.proxyPort=41080
20 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Apr 10 13:13:01 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/readme.res/01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/readme.res/01.png
--------------------------------------------------------------------------------
/readme.res/02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/readme.res/02.png
--------------------------------------------------------------------------------
/readme.res/03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/readme.res/03.png
--------------------------------------------------------------------------------
/readme.res/04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/readme.res/04.png
--------------------------------------------------------------------------------
/readme.res/zh_rCN/01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/readme.res/zh_rCN/01.png
--------------------------------------------------------------------------------
/readme.res/zh_rCN/02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/readme.res/zh_rCN/02.png
--------------------------------------------------------------------------------
/readme.res/zh_rCN/03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/readme.res/zh_rCN/03.png
--------------------------------------------------------------------------------
/readme.res/zh_rCN/04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RikkaW/WADB/fb3f68cc91434a2567fe7b167f1f8dc55944b49d/readme.res/zh_rCN/04.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------