Restore old invalidations after apk installs/uninstalls. Do not refresh the same app multiple times.
This commit is contained in:
parent
f5785c3de0
commit
3ce8cbf5bd
@ -706,15 +706,17 @@ public class AppDetails extends ListActivity {
|
|||||||
Uri uri = Uri.fromParts("package", pkginfo.packageName, null);
|
Uri uri = Uri.fromParts("package", pkginfo.packageName, null);
|
||||||
Intent intent = new Intent(Intent.ACTION_DELETE, uri);
|
Intent intent = new Intent(Intent.ACTION_DELETE, uri);
|
||||||
startActivityForResult(intent, REQUEST_UNINSTALL);
|
startActivityForResult(intent, REQUEST_UNINSTALL);
|
||||||
|
((FDroidApp) getApplication()).invalidateApp(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void installApk(File file) {
|
private void installApk(File file, String id) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(android.content.Intent.ACTION_VIEW);
|
intent.setAction(android.content.Intent.ACTION_VIEW);
|
||||||
intent.setDataAndType(Uri.parse("file://" + file.getPath()),
|
intent.setDataAndType(Uri.parse("file://" + file.getPath()),
|
||||||
"application/vnd.android.package-archive");
|
"application/vnd.android.package-archive");
|
||||||
startActivityForResult(intent, REQUEST_INSTALL);
|
startActivityForResult(intent, REQUEST_INSTALL);
|
||||||
|
((FDroidApp) getApplication()).invalidateApp(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchApk(String id) {
|
private void launchApk(String id) {
|
||||||
@ -751,8 +753,10 @@ public class AppDetails extends ListActivity {
|
|||||||
private Downloader download;
|
private Downloader download;
|
||||||
private ProgressDialog pd;
|
private ProgressDialog pd;
|
||||||
private boolean updating;
|
private boolean updating;
|
||||||
|
private String id;
|
||||||
|
|
||||||
public DownloadHandler(DB.Apk apk, String repoaddress) {
|
public DownloadHandler(DB.Apk apk, String repoaddress) {
|
||||||
|
id = apk.id;
|
||||||
download = new Downloader(apk, repoaddress);
|
download = new Downloader(apk, repoaddress);
|
||||||
download.start();
|
download.start();
|
||||||
startUpdates();
|
startUpdates();
|
||||||
@ -790,7 +794,7 @@ public class AppDetails extends ListActivity {
|
|||||||
case DONE:
|
case DONE:
|
||||||
if (pd != null)
|
if (pd != null)
|
||||||
pd.dismiss();
|
pd.dismiss();
|
||||||
installApk(download.localFile());
|
installApk(download.localFile(), id);
|
||||||
finished = true;
|
finished = true;
|
||||||
break;
|
break;
|
||||||
case CANCELLED:
|
case CANCELLED:
|
||||||
|
@ -800,7 +800,9 @@ public class DB {
|
|||||||
List<PackageInfo> installedPackages = mContext.getPackageManager()
|
List<PackageInfo> installedPackages = mContext.getPackageManager()
|
||||||
.getInstalledPackages(0);
|
.getInstalledPackages(0);
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
List<String> refreshedApps = new ArrayList<String>();
|
||||||
for (String appid : invalidApps) {
|
for (String appid : invalidApps) {
|
||||||
|
if (refreshedApps.contains(appid)) continue;
|
||||||
App app = null;
|
App app = null;
|
||||||
int index = -1;
|
int index = -1;
|
||||||
for (App oldapp : apps) {
|
for (App oldapp : apps) {
|
||||||
@ -839,8 +841,9 @@ public class DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apps.set(index, app);
|
apps.set(index, app);
|
||||||
|
refreshedApps.add(appid);
|
||||||
}
|
}
|
||||||
Log.d("FDroid", "Refreshing " + invalidApps.size() + " apps took "
|
Log.d("FDroid", "Refreshing " + refreshedApps.size() + " apps took "
|
||||||
+ (System.currentTimeMillis() - startTime) + " ms");
|
+ (System.currentTimeMillis() - startTime) + " ms");
|
||||||
|
|
||||||
return apps;
|
return apps;
|
||||||
|
@ -28,7 +28,7 @@ public class PackageReceiver extends BroadcastReceiver {
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context ctx, Intent intent) {
|
public void onReceive(Context ctx, Intent intent) {
|
||||||
String appid = intent.getData().getSchemeSpecificPart();
|
String appid = intent.getData().getSchemeSpecificPart();
|
||||||
Log.d("FDroid", "PackageReceiver invalidating "+appid);
|
Log.d("FDroid", "PackageReceiver received "+appid);
|
||||||
((FDroidApp) ctx.getApplicationContext()).invalidateApp(appid);
|
((FDroidApp) ctx.getApplicationContext()).invalidateApp(appid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user