Skip to content

Commit faeea32

Browse files
authored
Merge pull request #9 from zerobranch/develop
Develop
2 parents a042087 + d77beac commit faeea32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+859
-144
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
.DS_Store
55
/build
66
/debugger/build
7-
/example
87
/captures
98
.externalNativeBuild
109
local.properties

CHANGELOG.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
# Change Log
22

3-
## Version 1.1.0 *(2021-03-01)*
3+
## Version 1.1.2 *(17-03-2022)*
4+
* Updated gradle version
5+
* Updated dependencies
6+
* Specified flags for PendingIntent
7+
* Increased minSdkVersion to 21
8+
9+
10+
## Version 1.1.0 *(01-03-2021)*
411
Added no-op version.
512

613

7-
## Version 1.0.1 *(2020-11-08)*
14+
## Version 1.0.1 *(08-11-2020)*
815
Made resources private.
916

1017

11-
## Version 1.0.0 *(2020-01-06)*
18+
## Version 1.0.0 *(06-01-2020)*
1219
Initial release

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Android Remote Debugger
22
[![](https://jitpack.io/v/zerobranch/android-remote-debugger.svg)](https://jitpack.io/#zerobranch/android-remote-debugger)
3-
[![API](https://img.shields.io/badge/API-19%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=19) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/zerobranch/android-remote-debugger/blob/master/LICENSE)
3+
[![API](https://img.shields.io/badge/API-21%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=21)
4+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/zerobranch/android-remote-debugger/blob/master/LICENSE)
45
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android%20Remote%20Debugger-green.svg?style=flat)](https://android-arsenal.com/details/1/8040)
56

67
**Android Remote Debugger** is a library for remote debugging Android applications. It allows you to view logs, databases, shared preferences and network requests directly in the browser.
@@ -47,8 +48,8 @@ allprojects {
4748
Add the following dependency to your module's build.gradle:
4849
```groovy
4950
dependencies {
50-
debugImplementation 'com.github.zerobranch.android-remote-debugger:debugger:1.1.0'
51-
releaseImplementation 'com.github.zerobranch.android-remote-debugger:noop:1.1.0'
51+
debugImplementation 'com.github.zerobranch.android-remote-debugger:debugger:1.1.2'
52+
releaseImplementation 'com.github.zerobranch.android-remote-debugger:noop:1.1.2'
5253
}
5354
```
5455
**Note:** The final line above will use a no-op version, which does nothing.

RUSSIAN_README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Android Remote Debugger
22
[![](https://jitpack.io/v/zerobranch/android-remote-debugger.svg)](https://jitpack.io/#zerobranch/android-remote-debugger)
3-
[![API](https://img.shields.io/badge/API-19%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=19) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/zerobranch/android-remote-debugger/blob/master/LICENSE)
3+
[![API](https://img.shields.io/badge/API-21%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=21)
4+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/zerobranch/android-remote-debugger/blob/master/LICENSE)
45
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android%20Remote%20Debugger-green.svg?style=flat)](https://android-arsenal.com/details/1/8040)
56

67
**Android Remote Debugger** - это библиотека для удаленной отладки Android приложений. Она позволяет просматривать логи, базы данных, shared preferences и сетевые запросы прямо в браузере.
@@ -47,8 +48,8 @@ allprojects {
4748
Добавьте в build.gradle вашего модуля следующую зависимость:
4849
```groovy
4950
dependencies {
50-
debugImplementation 'com.github.zerobranch.android-remote-debugger:debugger:1.1.0'
51-
releaseImplementation 'com.github.zerobranch.android-remote-debugger:noop:1.1.0'
51+
debugImplementation 'com.github.zerobranch.android-remote-debugger:debugger:1.1.2'
52+
releaseImplementation 'com.github.zerobranch.android-remote-debugger:noop:1.1.2'
5253
}
5354
```
5455
**Примечание:** В последней строке выше будет использоваться no-op версия, которая ничего не делает. Её следует использовать только в релизных сборках. Это делает невозможным запуск сервера в релизной сборке.

build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
54
repositories {
65
google()
7-
jcenter()
6+
mavenCentral()
87
}
8+
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:4.1.0'
11-
10+
classpath 'com.android.tools.build:gradle:7.1.2'
1211

1312
// NOTE: Do not place your application dependencies here; they belong
1413
// in the individual module build.gradle files
@@ -18,7 +17,7 @@ buildscript {
1817
allprojects {
1918
repositories {
2019
google()
21-
jcenter()
20+
mavenCentral()
2221
}
2322
}
2423

debugger/build.gradle

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ plugins {
33
}
44

55
android {
6-
compileSdkVersion 29
6+
compileSdkVersion 31
77

88
defaultConfig {
9-
minSdkVersion 19
10-
targetSdkVersion 29
11-
versionCode 1
12-
versionName '1.0'
9+
minSdkVersion 21
10+
targetSdkVersion 31
1311
consumerProguardFiles 'proguard-rules.pro'
1412
}
1513

@@ -19,11 +17,16 @@ android {
1917
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2018
}
2119
}
20+
21+
compileOptions {
22+
sourceCompatibility JavaVersion.VERSION_1_8
23+
targetCompatibility JavaVersion.VERSION_1_8
24+
}
2225
}
2326

2427
dependencies {
2528
implementation 'org.nanohttpd:nanohttpd:2.3.1'
26-
implementation 'com.google.code.gson:gson:2.8.5'
27-
implementation 'androidx.appcompat:appcompat:1.2.0'
28-
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
29+
implementation 'com.google.code.gson:gson:2.8.8'
30+
implementation 'androidx.core:core:1.7.0'
31+
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
2932
}

debugger/src/main/java/zerobranch/androidremotedebugger/AppNotification.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,24 @@ private void notification(@Nullable String title, @Nullable String description,
114114
.setStyle(new NotificationCompat.BigTextStyle().bigText(description))
115115
.setAutoCancel(true);
116116

117+
int pendingIntentFlag = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE : 0;
118+
117119
if (isError) {
118120
Intent repeatConnectionIntent = new Intent(context, NotificationReceiver.class);
119121
repeatConnectionIntent.setAction(NotificationReceiver.ACTION_REPEAT_CONNECTION);
120-
PendingIntent repeatConnectionPendingIntent = PendingIntent.getBroadcast(context, 0, repeatConnectionIntent, 0);
122+
PendingIntent repeatConnectionPendingIntent = PendingIntent.getBroadcast(context, 0, repeatConnectionIntent, pendingIntentFlag);
121123

122124
Intent changePortIntent = new Intent(context, NotificationReceiver.class);
123125
changePortIntent.setAction(NotificationReceiver.ACTION_CHANGE_PORT);
124-
PendingIntent changePortPendingIntent = PendingIntent.getBroadcast(context, 0, changePortIntent, 0);
126+
PendingIntent changePortPendingIntent = PendingIntent.getBroadcast(context, 0, changePortIntent, pendingIntentFlag);
125127

126128
builder.addAction(0, "Repeat", repeatConnectionPendingIntent);
127129
builder.addAction(0, "Change port", changePortPendingIntent);
128130
} else {
129131
Intent disconnectIntent = new Intent(context, NotificationReceiver.class);
130132
disconnectIntent.setAction(NotificationReceiver.ACTION_DISCONNECT);
131-
PendingIntent disconnectPendingIntent = PendingIntent.getBroadcast(context, 0, disconnectIntent, 0);
133+
134+
PendingIntent disconnectPendingIntent = PendingIntent.getBroadcast(context, 0, disconnectIntent, pendingIntentFlag);
132135
builder.addAction(0, "Disconnect", disconnectPendingIntent);
133136
}
134137

debugger/src/main/java/zerobranch/androidremotedebugger/api/base/Controller.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
import com.google.gson.GsonBuilder;
2323
import com.google.gson.JsonParser;
2424
import com.google.gson.JsonSyntaxException;
25-
import zerobranch.androidremotedebugger.settings.InternalSettings;
26-
import zerobranch.androidremotedebugger.utils.InternalUtils;
2725

2826
import java.lang.reflect.Type;
2927
import java.nio.charset.StandardCharsets;
3028
import java.util.List;
3129
import java.util.Map;
3230

3331
import fi.iki.elonen.NanoHTTPD;
32+
import zerobranch.androidremotedebugger.settings.InternalSettings;
33+
import zerobranch.androidremotedebugger.utils.InternalUtils;
3434

3535
public abstract class Controller {
3636
protected static final String EMPTY = "";
@@ -105,11 +105,11 @@ protected <T> List<T> deserialize(String json, Type type) {
105105

106106
protected void throwEmptyParameterException(String parameter) throws NanoHTTPD.ResponseException {
107107
throw new NanoHTTPD.ResponseException(NanoHTTPD.Response.Status.BAD_REQUEST,
108-
"'" + parameter + "' parameter not found");
108+
"'" + parameter + "' parameter not found");
109109
}
110110

111111
protected String prettyJson(String item) throws JsonSyntaxException {
112-
return prettyPrintJson.toJson(new JsonParser().parse(item));
112+
return prettyPrintJson.toJson(JsonParser.parseString(item));
113113
}
114114

115115
protected String fromBase64(String value) {

debugger/src/main/java/zerobranch/androidremotedebugger/api/database/DatabaseController.java

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717

1818
import android.content.Context;
1919

20+
import java.util.Collections;
21+
import java.util.List;
22+
import java.util.Map;
23+
24+
import fi.iki.elonen.NanoHTTPD;
25+
import fi.iki.elonen.NanoHTTPD.ResponseException;
2026
import zerobranch.androidremotedebugger.api.base.Controller;
2127
import zerobranch.androidremotedebugger.api.base.HtmlParams;
2228
import zerobranch.androidremotedebugger.http.Host;
@@ -28,14 +34,6 @@
2834
import zerobranch.androidremotedebugger.source.models.UpdatingDatabase;
2935
import zerobranch.androidremotedebugger.utils.FileUtils;
3036

31-
import java.util.Collections;
32-
import java.util.Comparator;
33-
import java.util.List;
34-
import java.util.Map;
35-
36-
import fi.iki.elonen.NanoHTTPD;
37-
import fi.iki.elonen.NanoHTTPD.ResponseException;
38-
3937
public class DatabaseController extends Controller {
4038
private static final int FIRST_PAGE = 1;
4139
private static final int LAST_PAGE = -1;
@@ -101,12 +99,7 @@ private String getTables(Map<String, List<String>> params) throws ResponseExcept
10199
DatabaseManager.connect(context, dbName);
102100

103101
List<String> tables = getDBAccess().getTables();
104-
Collections.sort(tables, new Comparator<String>() {
105-
@Override
106-
public int compare(String o1, String o2) {
107-
return o1.compareToIgnoreCase(o2);
108-
}
109-
});
102+
Collections.sort(tables, String::compareToIgnoreCase);
110103

111104
return serialize(new Tables(tables, getDBAccess().getDatabaseVersion()));
112105
}
@@ -122,8 +115,8 @@ private String updateTable(Map<String, List<String>> params) throws ResponseExce
122115

123116
final String tableName = getStringValue(params, HtmlParams.NAME);
124117
final UpdatingDatabase fields = deserialize(
125-
getStringValue(params, HtmlParams.DATA),
126-
UpdatingDatabase.class
118+
getStringValue(params, HtmlParams.DATA),
119+
UpdatingDatabase.class
127120
);
128121

129122
for (int i = 0; i < fields.newValues.size(); i++) {
@@ -146,8 +139,8 @@ private String deleteTableItems(Map<String, List<String>> params) throws Respons
146139

147140
final String tableName = getStringValue(params, HtmlParams.NAME);
148141
final DeletingDatabase deletingDatabase = deserialize(
149-
getStringValue(params, HtmlParams.DATA),
150-
DeletingDatabase.class
142+
getStringValue(params, HtmlParams.DATA),
143+
DeletingDatabase.class
151144
);
152145

153146
for (int i = 0; i < deletingDatabase.fields.size(); i++) {
@@ -182,12 +175,7 @@ private String dropDatabase(Map<String, List<String>> params) throws ResponseExc
182175

183176
private String getDatabases() {
184177
List<String> databases = DatabaseManager.getDBNameList(context);
185-
Collections.sort(databases, new Comparator<String>() {
186-
@Override
187-
public int compare(String o1, String o2) {
188-
return o1.compareToIgnoreCase(o2);
189-
}
190-
});
178+
Collections.sort(databases, String::compareToIgnoreCase);
191179
return serialize(databases);
192180
}
193181

debugger/src/main/java/zerobranch/androidremotedebugger/api/sharedprefs/SharedPrefsController.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,24 @@
1818
import android.content.Context;
1919

2020
import com.google.gson.reflect.TypeToken;
21-
import zerobranch.androidremotedebugger.api.base.Controller;
22-
import zerobranch.androidremotedebugger.api.base.HtmlParams;
23-
import zerobranch.androidremotedebugger.http.Host;
24-
import zerobranch.androidremotedebugger.settings.InternalSettings;
25-
import zerobranch.androidremotedebugger.source.managers.SharedPrefsManager;
26-
import zerobranch.androidremotedebugger.source.models.SharedPrefsData;
27-
import zerobranch.androidremotedebugger.utils.FileUtils;
2821

2922
import java.math.BigDecimal;
3023
import java.util.ArrayList;
3124
import java.util.Arrays;
3225
import java.util.Collections;
33-
import java.util.Comparator;
3426
import java.util.HashSet;
3527
import java.util.List;
3628
import java.util.Map;
3729
import java.util.Set;
3830

3931
import fi.iki.elonen.NanoHTTPD.ResponseException;
32+
import zerobranch.androidremotedebugger.api.base.Controller;
33+
import zerobranch.androidremotedebugger.api.base.HtmlParams;
34+
import zerobranch.androidremotedebugger.http.Host;
35+
import zerobranch.androidremotedebugger.settings.InternalSettings;
36+
import zerobranch.androidremotedebugger.source.managers.SharedPrefsManager;
37+
import zerobranch.androidremotedebugger.source.models.SharedPrefsData;
38+
import zerobranch.androidremotedebugger.utils.FileUtils;
4039

4140
public class SharedPrefsController extends Controller {
4241
private final static String TYPE_INTEGER = "Integer";
@@ -106,9 +105,9 @@ private String update(Map<String, List<String>> params) throws ResponseException
106105
manager.put(prefsData.key, prefsData.value);
107106
} else if (prefsData.type.equalsIgnoreCase(TYPE_SET_STRING)) {
108107
final String[] splitData = prefsData.value
109-
.replaceAll("\\[", "")
110-
.replaceAll("]", "")
111-
.split(",");
108+
.replaceAll("\\[", "")
109+
.replaceAll("]", "")
110+
.split(",");
112111
manager.put(prefsData.key, new HashSet<>(Arrays.asList(splitData)));
113112
}
114113

@@ -127,12 +126,7 @@ private String dropSharedPreferences(Map<String, List<String>> params) throws Re
127126

128127
private String getAllSharedPreferencesNames() {
129128
List<String> sharedPreferences = SharedPrefsManager.getSharedPreferences(context);
130-
Collections.sort(sharedPreferences, new Comparator<String>() {
131-
@Override
132-
public int compare(String o1, String o2) {
133-
return o1.compareToIgnoreCase(o2);
134-
}
135-
});
129+
Collections.sort(sharedPreferences, String::compareToIgnoreCase);
136130
return serialize(sharedPreferences);
137131
}
138132

0 commit comments

Comments
 (0)