fix OBB support for repositories
The repoId was hard-coded to 0. fdroid/fdroidclient#1403
This commit is contained in:
parent
5f14628524
commit
c7c16131e9
@ -207,8 +207,8 @@ public class InstallManagerService extends Service {
|
|||||||
appUpdateStatusManager.addApk(apk, AppUpdateStatusManager.Status.Downloading, null);
|
appUpdateStatusManager.addApk(apk, AppUpdateStatusManager.Status.Downloading, null);
|
||||||
|
|
||||||
registerPackageDownloaderReceivers(canonicalUrl);
|
registerPackageDownloaderReceivers(canonicalUrl);
|
||||||
getObb(canonicalUrl, apk.getMainObbUrl(), apk.getMainObbFile(), apk.obbMainFileSha256);
|
getMainObb(canonicalUrl, apk);
|
||||||
getObb(canonicalUrl, apk.getPatchObbUrl(), apk.getPatchObbFile(), apk.obbPatchFileSha256);
|
getPatchObb(canonicalUrl, apk);
|
||||||
|
|
||||||
File apkFilePath = ApkCache.getApkDownloadPath(this, apk.getCanonicalUrl());
|
File apkFilePath = ApkCache.getApkDownloadPath(this, apk.getCanonicalUrl());
|
||||||
long apkFileSize = apkFilePath.length();
|
long apkFileSize = apkFilePath.length();
|
||||||
@ -235,6 +235,14 @@ public class InstallManagerService extends Service {
|
|||||||
localBroadcastManager.sendBroadcast(intent);
|
localBroadcastManager.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getMainObb(final String canonicalUrl, Apk apk) {
|
||||||
|
getObb(canonicalUrl, apk.getMainObbUrl(), apk.getMainObbFile(), apk.obbMainFileSha256, apk.repoId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getPatchObb(final String canonicalUrl, Apk apk) {
|
||||||
|
getObb(canonicalUrl, apk.getPatchObbUrl(), apk.getPatchObbFile(), apk.obbPatchFileSha256, apk.repoId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if any OBB files are available, and if so, download and install them. This
|
* Check if any OBB files are available, and if so, download and install them. This
|
||||||
* also deletes any obsolete OBB files, per the spec, since there can be only one
|
* also deletes any obsolete OBB files, per the spec, since there can be only one
|
||||||
@ -243,7 +251,7 @@ public class InstallManagerService extends Service {
|
|||||||
* @see <a href="https://developer.android.com/google/play/expansion-files.html">APK Expansion Files</a>
|
* @see <a href="https://developer.android.com/google/play/expansion-files.html">APK Expansion Files</a>
|
||||||
*/
|
*/
|
||||||
private void getObb(final String canonicalUrl, String obbUrlString,
|
private void getObb(final String canonicalUrl, String obbUrlString,
|
||||||
final File obbDestFile, final String hash) {
|
final File obbDestFile, final String hash, final long repoId) {
|
||||||
if (obbDestFile == null || obbDestFile.exists() || TextUtils.isEmpty(obbUrlString)) {
|
if (obbDestFile == null || obbDestFile.exists() || TextUtils.isEmpty(obbUrlString)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -293,13 +301,13 @@ public class InstallManagerService extends Service {
|
|||||||
} else if (Downloader.ACTION_INTERRUPTED.equals(action)) {
|
} else if (Downloader.ACTION_INTERRUPTED.equals(action)) {
|
||||||
localBroadcastManager.unregisterReceiver(this);
|
localBroadcastManager.unregisterReceiver(this);
|
||||||
} else if (Downloader.ACTION_CONNECTION_FAILED.equals(action)) {
|
} else if (Downloader.ACTION_CONNECTION_FAILED.equals(action)) {
|
||||||
DownloaderService.queueUsingDifferentMirror(context, 0, canonicalUrl);
|
DownloaderService.queueUsingDifferentMirror(context, repoId, canonicalUrl);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("intent action not handled!");
|
throw new RuntimeException("intent action not handled!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
DownloaderService.queueUsingRandomMirror(this, 0, obbUrlString);
|
DownloaderService.queueUsingRandomMirror(this, repoId, obbUrlString);
|
||||||
localBroadcastManager.registerReceiver(downloadReceiver,
|
localBroadcastManager.registerReceiver(downloadReceiver,
|
||||||
DownloaderService.getIntentFilter(obbUrlString));
|
DownloaderService.getIntentFilter(obbUrlString));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user