Skip to content

Commit

Permalink
Bug: updater sucked on loading if no version found
Browse files Browse the repository at this point in the history
  • Loading branch information
androidlover5842 committed Jan 12, 2017
1 parent b948a45 commit 56d5bf8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class DialogActivity extends Activity {
private DownloadManager downloadManager;
private ProgressBar mProgressBar;
private PromptDialog mNoUpdate;
private String Tag="RomUpdater";
private String Tag="RomUpdater",Url;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -44,9 +44,14 @@ protected void onCreate(Bundle savedInstanceState) {
mNoUpdate = new PromptDialog(this);
ActivityCompat.requestPermissions(DialogActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100);
if(isOnline(this)) {
if(!isVersionValid(UpdaterUri())){
Url="https://raw.githubusercontent.com/Grace5921/OtaUpdater/master/Updater.xml";
}else {
Url=UpdaterUri();
}
RomUpdaterUtils romUpdaterUtils = new RomUpdaterUtils(this)
.setUpdateFrom(UpdateFrom.XML)
.setUpdateXML(UpdaterUri())
.setUpdateXML(Url)
.withListener(new RomUpdaterUtils.UpdateListener() {
@Override
public void onSuccess(final Update update, Boolean isUpdateAvailable) {
Expand Down Expand Up @@ -137,6 +142,9 @@ public void onClick(PromptDialog dialog) {
}

}
private boolean isVersionValid(String version) {
return version.length() > 3;
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

class UtilsLibrary {

private static String TAG="RomUpdater";

static String getRomName(Context context) {
return context.getString(context.getApplicationInfo().labelRes);
}
Expand All @@ -35,12 +37,27 @@ static String getRomPackageName(Context context) {
return context.getPackageName();
}

static String getRomInstalledVersion() {
static String getRomVersion() {
String version;
version=ShellExecuter.runAsRoot("getprop ro.rom.version");
return version;
}

static String getRomInstalledVersion(){
String version;
if(!isVersionValid(getRomVersion()))
{
version="20161220";
Log.e(TAG,"no version found in build.prop using default "+ version );
}
else {
version=getRomVersion();
}
return version;
}
private static boolean isVersionValid(String version) {
return version.length() > 2;
}
static Boolean isUpdateAvailable(String installedVersion, String latestVersion) {
Boolean res = false;

Expand Down

0 comments on commit 56d5bf8

Please sign in to comment.