mirror of https://github.com/NekoX-Dev/NekoX.git
fix updater npe
This commit is contained in:
parent
fa5b44b51e
commit
8311829a9b
|
@ -39,6 +39,7 @@ public class InternalUpdater {
|
|||
callback.apply(null, true);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
|
||||
List<UpdateMetadata> metas = new ArrayList<>();
|
||||
for (TLRPC.Message message : res.messages) {
|
||||
|
@ -77,6 +78,10 @@ public class InternalUpdater {
|
|||
}
|
||||
FileLog.w("Found Update Metadata " + found.versionName + " " + found.versionCode);
|
||||
callback.apply(found, false);
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
callback.apply(null, true);
|
||||
}
|
||||
});
|
||||
if (req.peer.access_hash != 0) sendReq.run();
|
||||
else {
|
||||
|
@ -117,6 +122,7 @@ public class InternalUpdater {
|
|||
callback.apply(null, err);
|
||||
return;
|
||||
}
|
||||
|
||||
TLRPC.TL_messages_getHistory req = new TLRPC.TL_messages_getHistory();
|
||||
req.peer = accountInstance.getMessagesController().getInputPeer(-CHANNEL_APKS_ID);
|
||||
req.min_id = metadata.apkChannelMessageID;
|
||||
|
@ -128,6 +134,7 @@ public class InternalUpdater {
|
|||
callback.apply(null, true);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
|
||||
FileLog.d("Retrieve update messages, size:" + res.messages.size());
|
||||
final String target = metadata.versionName + "-" + BuildConfig.FLAVOR + "-" + FileUtil.getAbi() + "-" + ("debug".equals(BuildConfig.BUILD_TYPE) ? "release" : BuildConfig.BUILD_TYPE) + ".apk";
|
||||
|
@ -135,6 +142,7 @@ public class InternalUpdater {
|
|||
if (res.messages.get(i).media == null) continue;
|
||||
|
||||
TLRPC.Document apkDocument = res.messages.get(i).media.document;
|
||||
if (apkDocument.attributes == null) continue;
|
||||
String fileName = apkDocument.attributes.size() == 0 ? "" : apkDocument.attributes.get(0).file_name;
|
||||
if (!fileName.contains(target))
|
||||
continue;
|
||||
|
@ -151,6 +159,10 @@ public class InternalUpdater {
|
|||
return;
|
||||
}
|
||||
callback.apply(null, false);
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
callback.apply(null, true);
|
||||
}
|
||||
});
|
||||
if (req.peer.access_hash != 0) sendReq.run();
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue