Merge "Cleaner initial boot." into jb-mr1.1-dev

This commit is contained in:
Dianne Hackborn
2012-11-28 18:19:09 -08:00
committed by Android (Google) Code Review
7 changed files with 43 additions and 7 deletions

View File

@ -378,6 +378,7 @@ interface IPackageManager {
VerifierDeviceIdentity getVerifierDeviceIdentity();
boolean isFirstBoot();
boolean isOnlyCoreApps();
void setPermissionEnforced(String permission, boolean enforced);
boolean isPermissionEnforced(String permission);

View File

@ -21,6 +21,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.res.XmlResourceParser;
import android.database.Cursor;
@ -31,6 +32,8 @@ import android.media.AudioManager;
import android.media.AudioService;
import android.net.ConnectivityManager;
import android.os.Environment;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
@ -171,7 +174,15 @@ public class DatabaseHelper extends SQLiteOpenHelper {
db.execSQL("CREATE INDEX bookmarksIndex2 ON bookmarks (shortcut);");
// Populate bookmarks table with initial bookmarks
boolean onlyCore = false;
try {
onlyCore = IPackageManager.Stub.asInterface(ServiceManager.getService(
"package")).isOnlyCoreApps();
} catch (RemoteException e) {
}
if (!onlyCore) {
loadBookmarks(db);
}
// Load initial volume levels into DB
loadVolumeLevels(db);

View File

@ -20,11 +20,14 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.IPackageManager;
import android.os.Build;
import android.os.DropBoxManager;
import android.os.FileObserver;
import android.os.FileUtils;
import android.os.RecoverySystem;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.provider.Downloads;
import android.util.Slog;
@ -69,7 +72,15 @@ public class BootReceiver extends BroadcastReceiver {
Slog.e(TAG, "Can't log boot events", e);
}
try {
boolean onlyCore = false;
try {
onlyCore = IPackageManager.Stub.asInterface(ServiceManager.getService(
"package")).isOnlyCoreApps();
} catch (RemoteException e) {
}
if (!onlyCore) {
removeOldUpdatePackages(context);
}
} catch (Exception e) {
Slog.e(TAG, "Can't remove old update packages", e);
}

View File

@ -17,6 +17,7 @@
package com.android.server;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@ -97,8 +98,10 @@ public class EntropyMixer extends Binder {
private void loadInitialEntropy() {
try {
RandomBlock.fromFile(entropyFile).toFile(randomDevice, false);
} catch (FileNotFoundException e) {
Slog.w(TAG, "No existing entropy file -- first boot?");
} catch (IOException e) {
Slog.w(TAG, "unable to load initial entropy (first boot?)", e);
Slog.w(TAG, "Failure loading existing entropy file", e);
}
}
@ -106,7 +109,7 @@ public class EntropyMixer extends Binder {
try {
RandomBlock.fromFile(randomDevice).toFile(entropyFile, true);
} catch (IOException e) {
Slog.w(TAG, "unable to write entropy", e);
Slog.w(TAG, "Unable to write entropy", e);
}
}

View File

@ -1096,6 +1096,8 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
}
} while (type != XmlPullParser.END_DOCUMENT);
success = true;
} catch (FileNotFoundException e) {
Slog.w(TAG, "no current wallpaper -- first boot?");
} catch (NullPointerException e) {
Slog.w(TAG, "failed parsing " + file + " " + e);
} catch (NumberFormatException e) {

View File

@ -1020,7 +1020,8 @@ public class PackageManagerService extends IPackageManager.Stub {
readPermissions();
mRestoredSettings = mSettings.readLPw(sUserManager.getUsers(false));
mRestoredSettings = mSettings.readLPw(sUserManager.getUsers(false),
mSdkVersion, mOnlyCore);
long startTime = SystemClock.uptimeMillis();
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_SYSTEM_SCAN_START,
@ -1320,6 +1321,10 @@ public class PackageManagerService extends IPackageManager.Stub {
return !mRestoredSettings;
}
public boolean isOnlyCoreApps() {
return mOnlyCore;
}
private String getRequiredVerifierLPr() {
final Intent verification = new Intent(Intent.ACTION_PACKAGE_NEEDS_VERIFICATION);
final List<ResolveInfo> receivers = queryIntentReceivers(verification, PACKAGE_MIME_TYPE,

View File

@ -1556,7 +1556,7 @@ final class Settings {
}
}
boolean readLPw(List<UserInfo> users) {
boolean readLPw(List<UserInfo> users, int sdkVersion, boolean onlyCore) {
FileInputStream str = null;
if (mBackupSettingsFilename.exists()) {
try {
@ -1586,7 +1586,10 @@ final class Settings {
mReadMessages.append("No settings file found\n");
PackageManagerService.reportSettingsProblem(Log.INFO,
"No settings file; creating initial state");
if (!onlyCore) {
readDefaultPreferredAppsLPw(0);
}
mInternalSdkPlatform = mExternalSdkPlatform = sdkVersion;
return false;
}
str = new FileInputStream(mSettingsFilename);