Skip to content

Commit 9ea9766

Browse files
committed
Improve compatibility
1 parent d8ab578 commit 9ea9766

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ android:
88
components:
99
- tools
1010
- platform-tools
11-
- build-tools-27.0.1
11+
- build-tools-27.0.2
1212
- android-27
1313

1414
script:

app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 27
5-
buildToolsVersion '27.0.1'
5+
buildToolsVersion '27.0.2'
66
useLibrary 'org.apache.http.legacy'
77
signingConfigs {
88
release {
@@ -25,7 +25,7 @@ android {
2525
applicationId "bin.xposed.Unblock163MusicClient"
2626
minSdkVersion 9
2727
targetSdkVersion 27
28-
versionCode 23
28+
versionCode 24
2929
versionName = "0.0.${versionCode}"
3030
archivesBaseName = "${applicationId}-${versionName}"
3131
}

app/src/main/java/bin/xposed/Unblock163MusicClient/CloudMusicPackage.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ static class HttpEapi {
259259
private static boolean useOkHttp = false;
260260
private static Class clazz;
261261
private static Method m_getCookieString;
262+
private static Class c_cookieClass;
262263
final Object httpBase;
263264

264265
HttpEapi(Object httpBase) {
@@ -267,7 +268,12 @@ static class HttpEapi {
267268

268269
static void init() throws PackageManager.NameNotFoundException, IllegalAccessException {
269270
if (!getFilteredClasses("okhttp3", null).isEmpty()) {
270-
clazz = findClass("com.netease.cloudmusic.h.f.d.d", classLoader);
271+
Pattern pattern = Pattern.compile("^com\\.netease\\.cloudmusic\\.[a-z]\\.f\\.d\\.d$");
272+
List<String> list = getFilteredClasses(pattern, Collections.<String>reverseOrder());
273+
if (list.isEmpty()) {
274+
throw new RuntimeException("init failed");
275+
}
276+
clazz = findClass(list.get(0), classLoader);
271277
useOkHttp = true;
272278
} else {
273279
Pattern pattern = Pattern.compile("^com\\.netease\\.cloudmusic\\.[a-z]\\.[a-z]$");
@@ -299,7 +305,11 @@ static Class getClazz() {
299305

300306
static String getDefaultCookie() throws UnsupportedEncodingException, JSONException, InvocationTargetException, IllegalAccessException {
301307
if (useOkHttp) {
302-
List list = (List) callMethod(callStaticMethod(findClass("com.netease.cloudmusic.h.e.a.a", classLoader), "a"), "d");
308+
if (c_cookieClass == null) {
309+
String className = getClazz().getName().substring(0, PACKAGE_NAME.length() + 2) + ".e.a.a";
310+
c_cookieClass = findClass(className, classLoader);
311+
}
312+
List list = (List) callMethod(callStaticMethod(c_cookieClass, "a"), "d");
303313
StringBuilder sb = new StringBuilder();
304314
boolean first = true;
305315
for (Object l : list) {

app/src/main/java/bin/xposed/Unblock163MusicClient/Handler.java

+1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ private static boolean processSong(JSONObject oldSongJson, int expectBr, String
248248
if (preferSong.getPrefer() > oldSong.getPrefer()) {
249249
oldSongJson.put("br", preferSong.br)
250250
.put("code", 200)
251+
.put("flag", 0)
251252
.put("gain", preferSong.gain)
252253
.put("md5", preferSong.md5)
253254
.put("size", preferSong.size)

0 commit comments

Comments
 (0)