remove OTA packages from the old (pre-froyo) updater
The old updater ran in the system process, so only that UID can delete its downloads. Do this on startup in case we've just upgraded from something before froyo and need to clean up those packages. b/2571619 - eclair -> froyo update package not deleted Change-Id: I0a5e7834c3ecd2cc2f6fd73052b3a38e1294b5d5
This commit is contained in:
@@ -21,6 +21,7 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Downloads;
|
||||
import android.os.Build;
|
||||
import android.os.DropBoxManager;
|
||||
import android.os.FileObserver;
|
||||
@@ -45,6 +46,14 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final File TOMBSTONE_DIR = new File("/data/tombstones");
|
||||
|
||||
// The pre-froyo package and class of the system updater, which
|
||||
// ran in the system process. We need to remove its packages here
|
||||
// in order to clean up after a pre-froyo-to-froyo update.
|
||||
private static final String OLD_UPDATER_PACKAGE =
|
||||
"com.google.android.systemupdater";
|
||||
private static final String OLD_UPDATER_CLASS =
|
||||
"com.google.android.systemupdater.SystemUpdateReceiver";
|
||||
|
||||
// Keep a reference to the observer so the finalizer doesn't disable it.
|
||||
private static FileObserver sTombstoneObserver = null;
|
||||
|
||||
@@ -70,10 +79,21 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG, "Can't log boot events", e);
|
||||
}
|
||||
try {
|
||||
removeOldUpdatePackages(context);
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG, "Can't remove old update packages", e);
|
||||
}
|
||||
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
private void removeOldUpdatePackages(Context ctx) {
|
||||
Downloads.ByUri.removeAllDownloadsByPackage(
|
||||
ctx, OLD_UPDATER_PACKAGE, OLD_UPDATER_CLASS);
|
||||
}
|
||||
|
||||
private void logBootEvents(Context ctx) throws IOException {
|
||||
final DropBoxManager db = (DropBoxManager) ctx.getSystemService(Context.DROPBOX_SERVICE);
|
||||
final SharedPreferences prefs = ctx.getSharedPreferences("log_files", Context.MODE_PRIVATE);
|
||||
|
||||
Reference in New Issue
Block a user