Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
This commit is contained in:
kehaoyuan
2019-12-31 16:26:49 +08:00

View File

@ -20,6 +20,7 @@ import androidx.core.app.ActivityCompat;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.g00fy2.versioncompare.Version;
import com.gh.base.BaseActivity;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DeviceTokenUtils;
@ -44,7 +45,6 @@ import com.gh.gamecenter.user.UserRepository;
import com.halo.assistant.HaloApp;
import com.lightgame.download.DownloadEntity;
import com.lightgame.download.FileUtils;
import com.lightgame.utils.Utils;
import com.qq.gdt.action.ActionType;
import org.jetbrains.annotations.NotNull;
@ -241,7 +241,7 @@ public class SplashScreenActivity extends BaseActivity {
if (EasyPermissions.hasPermissions(this, mPermissions)) {
MtaHelper.onEvent("授权情况", "启动授权", "都授权");
// 检查是否有旧版本光环,有就删掉
HaloApp.getInstance().getMainExecutor().execute(this::checkOldGhFile);
HaloApp.getInstance().getMainExecutor().execute(this::deleteOutdatedUpdatePackage);
} else {
ActivityCompat.requestPermissions(this, mPermissions, REQUEST_PERMISSION_TAG);
}
@ -268,7 +268,7 @@ public class SplashScreenActivity extends BaseActivity {
private void logGrantedPermission(List<String> perms) {
if (perms.size() == 1) {
MtaHelper.onEvent("授权情况", "启动授权", "只授权存储");
HaloApp.getInstance().getMainExecutor().execute(this::checkOldGhFile);
HaloApp.getInstance().getMainExecutor().execute(this::deleteOutdatedUpdatePackage);
} else {
if (perms.contains(Manifest.permission.READ_PHONE_STATE)) {
MtaHelper.onEvent("授权情况", "启动授权", "都不授权");
@ -279,7 +279,8 @@ public class SplashScreenActivity extends BaseActivity {
}
// 检查下载文件夹下是否有旧版本的光环助手的包,有则删除
private void checkOldGhFile() {
@SuppressWarnings("ResultOfMethodCallIgnored")
private void deleteOutdatedUpdatePackage() {
File folder = new File(FileUtils.getDownloadDir(this) + File.separator);
if (folder.isDirectory()) {
for (File file : folder.listFiles()) {
@ -288,13 +289,13 @@ public class SplashScreenActivity extends BaseActivity {
int index = name.indexOf("_");
if (index != -1) {
try {
float version = Float.valueOf(name.substring(name.indexOf("V") + 1, index));
float currentVersion = Float.valueOf(PackageUtils.getVersionName());
if (version <= currentVersion && file.delete()) {
Utils.log(file.getName() + " file delete success.");
String versionString = name.substring(name.indexOf("V") + 1, index);
Version currentVersion = new Version(PackageUtils.getVersionName());
if (currentVersion.isHigherThan(versionString) || currentVersion.isEqual(versionString)) {
file.delete();
}
} catch (Exception ignore) {
} catch (Exception exception) {
exception.printStackTrace();
}
}
}