2

我已经实现了一个动态功能模块。基本模块安装成功,但是当我请求动态模块时,它会被下载,但在安装 PlayCore 库中说 INSUFFICIENT_STORAGE = -10时抛出错误,即使有很多空间(超过 18GB)。对于所有其他用户来说,它就像黄油一样顺畅。

@Override
public void onStateUpdate(SplitInstallSessionState splitInstallSessionState) {
    long totalModuleSize = splitInstallSessionState.totalBytesToDownload();
    long downloadedBytes = splitInstallSessionState.bytesDownloaded();

    Log.d(TAG, "onStateUpdate() called with: totalModuleSize = [" + totalModuleSize + "]" + "  :   " +
            "+downloadedBytes = [" + downloadedBytes + "]");


    if (splitInstallSessionState.status() == SplitInstallSessionStatus.REQUIRES_USER_CONFIRMATION) {

        try {
            splitInstallManager.startConfirmationDialogForResult(
                    splitInstallSessionState, this, MY_REQUEST_CODE_UGAM);
        } catch (IntentSender.SendIntentException e) {
            Log.e(TAG, "onStateUpdate: IntentSender.SendIntentException : " + e.getMessage());
        }
    } else if (splitInstallSessionState.status() == SplitInstallSessionStatus.INSTALLING) {
        mCustomProgressDialog.setMessage(getString(R.string.installing_dailog_message_base));
        return;
    } else if (splitInstallSessionState.status() == SplitInstallSessionStatus.INSTALLED) {
        if (mCustomProgressDialog != null && mCustomProgressDialog.isShowing()) {
            mCustomProgressDialog.dismiss();
        }
        performLogin();

    } else if (splitInstallSessionState.status() == SplitInstallSessionStatus.FAILED) {
        if (mCustomProgressDialog != null && mCustomProgressDialog.isShowing()) {
            mCustomProgressDialog.dismiss();
        }
        if (splitInstallSessionState.errorCode() == SplitInstallErrorCode.NETWORK_ERROR) {
            showAlertDialogWithOkBtn(getString(R.string.dynamic_module_download_failed_base_network_err));

        } else if (splitInstallSessionState.errorCode() == SplitInstallErrorCode.INSUFFICIENT_STORAGE) { //  this is true in Redmi K20 PRO
            showAlertDialogWithOkBtn(getString(R.string.dynamic_module_download_failed_base_insufficient_storage));

        } else {
            showAlertDialogWithOkBtn(getString(R.string.dynamic_module_download_failed_base) + " (" + splitInstallSessionState.errorCode() + ")");
        }
    }

    if (totalModuleSize == 0) {
        return;
    }
    final int progress = ((int) (((double) downloadedBytes / (double) totalModuleSize) * 100));

    Log.d(TAG, "onStateUpdate: progress : " + progress);
    mCustomProgressDialog.setMessage(getString(R.string.downloading_dialog_message_base) + String.valueOf(progress) + "%");
}
4

0 回答 0