Skip to content

Commit c03fa34

Browse files
committed
update dependencies, update gradle, add flags for PendingIntent
1 parent 28d7355 commit c03fa34

File tree

13 files changed

+124
-147
lines changed

13 files changed

+124
-147
lines changed

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

debugger/src/main/java/zerobranch/androidremotedebugger/source/managers/ContinuousDBManager.java

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,16 @@ private ContinuousDBManager(final Context context) {
4444
loggingHandlerThread.start();
4545
loggingHandler = new Handler(loggingHandlerThread.getLooper());
4646

47-
loggingHandler.post(new Runnable() {
48-
@Override
49-
public void run() {
50-
SQLiteDatabase.deleteDatabase(context.getDatabasePath(DATABASE_NAME));
51-
database = context.openOrCreateDatabase(DATABASE_NAME, Context.MODE_PRIVATE, null);
52-
database.setVersion(Integer.MAX_VALUE);
53-
54-
httpLogRepository = new HttpLogRepository(database);
55-
httpLogRepository.createHttpLogsTable(database);
56-
57-
logRepository = new LogRepository(database);
58-
logRepository.createLogsTable(database);
59-
}
47+
loggingHandler.post(() -> {
48+
SQLiteDatabase.deleteDatabase(context.getDatabasePath(DATABASE_NAME));
49+
database = context.openOrCreateDatabase(DATABASE_NAME, Context.MODE_PRIVATE, null);
50+
database.setVersion(Integer.MAX_VALUE);
51+
52+
httpLogRepository = new HttpLogRepository(database);
53+
httpLogRepository.createHttpLogsTable(database);
54+
55+
logRepository = new LogRepository(database);
56+
logRepository.createLogsTable(database);
6057
});
6158
}
6259

@@ -96,23 +93,13 @@ public long addHttpLog(HttpLogModel logModel) {
9693

9794
public void clearAllHttpLogs() {
9895
synchronized (LOCK) {
99-
loggingHandler.post(new Runnable() {
100-
@Override
101-
public void run() {
102-
httpLogRepository.clearAll();
103-
}
104-
});
96+
loggingHandler.post(() -> httpLogRepository.clearAll());
10597
}
10698
}
10799

108100
public void addLog(final LogModel model) {
109101
synchronized (LOCK) {
110-
loggingHandler.post(new Runnable() {
111-
@Override
112-
public void run() {
113-
logRepository.addLog(model);
114-
}
115-
});
102+
loggingHandler.post(() -> logRepository.addLog(model));
116103
}
117104
}
118105

@@ -124,12 +111,7 @@ public List<LogModel> getLogsByFilter(int offset, int limit, String level, Strin
124111

125112
public void clearAllLogs() {
126113
synchronized (LOCK) {
127-
loggingHandler.post(new Runnable() {
128-
@Override
129-
public void run() {
130-
logRepository.clearAllLogs();
131-
}
132-
});
114+
loggingHandler.post(() -> logRepository.clearAllLogs());
133115
}
134116
}
135117

0 commit comments

Comments
 (0)