Merge branch 'fix/progress-indicator-and-root-installer' into 'master'

Fix issues #74 and #75

The indeterminent progress indicator in the `AppDetails` view is now hidden by default on Android 4.0.3 (which is the only reproducing device I had access to). Had to replace a bunch of calls with those provided by appcompat.

As for the "(De-)Installation Error" message when using the root installer, it was due to the timeout being set to 5 seconds for the superuser shell. Note that just accepting the super user prompt takes a minimum of 3 seconds, plus the install time. I changed the timeout to 30 seconds, for reasons explained in the commit.

NOTE: @mvdan, I noted that you mentioned you were not interested in client development any more, so I'm not quite sure if it is worthwhile me submitting this as a MR (FYI - thanks for all the help on the client, also happy that your able to spend more time on build recipies and fdroidserver stuff. Great to see all that moving along). Perhaps @CiaranG, if you had the time to review it you could give it the thumbs up or down? Otherwise, I'll merge it myself.

See merge request !27
This commit is contained in:
Peter Serwylo 2014-08-20 11:52:45 +00:00
commit 87c3cd456e
2 changed files with 48 additions and 28 deletions

View File

@ -129,26 +129,32 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
// observer to update view when package has been installed/deleted
AppObserver myAppObserver;
class AppObserver extends ContentObserver {
public AppObserver(Handler handler) {
super(handler);
}
@Override
public void onChange(boolean selfChange) {
this.onChange(selfChange, null);
}
public AppObserver(Handler handler) {
super(handler);
}
@Override
public void onChange(boolean selfChange, Uri uri) {
if (!reset(app.id)) {
@Override
public void onChange(boolean selfChange) {
onChange(selfChange, null);
}
@Override
public void onChange(boolean selfChange, Uri uri) {
onChange();
}
public void onChange() {
if (!reset(app.id)) {
AppDetails.this.finish();
return;
}
}
refreshApkList();
supportInvalidateOptionsMenu();
}
refreshApkList();
supportInvalidateOptionsMenu();
}
}
class ApkListAdapter extends ArrayAdapter<Apk> {
@ -370,13 +376,16 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
fdroidApp = ((FDroidApp) getApplication());
fdroidApp.applyTheme(this);
super.onCreate(savedInstanceState);
// Must be called *after* super.onCreate(), as that is where the action bar
// compat implementation is assigned in the ActionBarActivity base class.
supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
if (getIntent().hasExtra(EXTRA_FROM)) {
setTitle(getIntent().getStringExtra(EXTRA_FROM));
}
@ -425,6 +434,13 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
listFragment.removeSummaryHeader();
}
// Spinner seems to default to visible on Android 4.0.3 and 4.0.4
// https://gitlab.com/fdroid/fdroidclient/issues/75
// Can't put this in onResume(), because that is called on return from asking
// the user permission to use su (in which case we still want to show the
// progress indicator after returning from that prompt).
setSupportProgressBarIndeterminateVisibility(false);
}
// The signature of the installed version.
@ -480,7 +496,6 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
*/
private void downloadCompleteInstallApk() {
if (downloadHandler != null) {
assert downloadHandler.isComplete();
installApk(downloadHandler.localFile(), downloadHandler.getApk().id);
cleanUpFinishedDownload();
}
@ -855,23 +870,25 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
}
private void installApk(File file, String packageName) {
setProgressBarIndeterminateVisibility(true);
setSupportProgressBarIndeterminateVisibility(true);
try {
installer.installPackage(file);
} catch (AndroidNotCompatibleException e) {
Log.e(TAG, "Android not compatible with this Installer!", e);
setSupportProgressBarIndeterminateVisibility(false);
}
}
@Override
public void removeApk(String packageName) {
setProgressBarIndeterminateVisibility(true);
setSupportProgressBarIndeterminateVisibility(true);
try {
installer.deletePackage(packageName);
} catch (AndroidNotCompatibleException e) {
Log.e(TAG, "Android not compatible with this Installer!", e);
setSupportProgressBarIndeterminateVisibility(false);
}
}
@ -886,7 +903,8 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
PackageManagerCompat.setInstaller(mPm, app.id);
}
setProgressBarIndeterminateVisibility(false);
setSupportProgressBarIndeterminateVisibility(false);
myAppObserver.onChange();
}
});
}
@ -897,14 +915,16 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
runOnUiThread(new Runnable() {
@Override
public void run() {
setProgressBarIndeterminateVisibility(false);
setSupportProgressBarIndeterminateVisibility(false);
myAppObserver.onChange();
}
});
} else {
runOnUiThread(new Runnable() {
@Override
public void run() {
setProgressBarIndeterminateVisibility(false);
setSupportProgressBarIndeterminateVisibility(false);
myAppObserver.onChange();
Log.e(TAG, "Installer aborted with errorCode: " + errorCode);

View File

@ -19,15 +19,15 @@
package org.fdroid.fdroid.installer;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import eu.chainfire.libsuperuser.Shell;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.util.Log;
import eu.chainfire.libsuperuser.Shell;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* Installer using a root shell and "pm install", "pm uninstall" commands
@ -45,8 +45,8 @@ public class RootInstaller extends Installer {
Shell.Builder shellBuilder = new Shell.Builder()
.useSU()
.setWantSTDERR(true)
.setWatchdogTimeout(5)
.setMinimalLogging(true);
.setWatchdogTimeout(30)
.setMinimalLogging(false);
return shellBuilder;
}