Skip to content

Commit 13579ed

Browse files
author
Dianne Hackborn
committed
Cleaner initial boot.
This does some cleanup of the initial boot, especially when booting in "no core apps" mode for encryption/decryption. Change-Id: Ifb3949f580e52f54559e603c4b0b104f6bac2f6c
1 parent 71175f7 commit 13579ed

File tree

7 files changed

+43
-7
lines changed

7 files changed

+43
-7
lines changed

core/java/android/content/pm/IPackageManager.aidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ interface IPackageManager {
378378
VerifierDeviceIdentity getVerifierDeviceIdentity();
379379

380380
boolean isFirstBoot();
381+
boolean isOnlyCoreApps();
381382

382383
void setPermissionEnforced(String permission, boolean enforced);
383384
boolean isPermissionEnforced(String permission);

packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import android.content.Context;
2222
import android.content.Intent;
2323
import android.content.pm.ActivityInfo;
24+
import android.content.pm.IPackageManager;
2425
import android.content.pm.PackageManager;
2526
import android.content.res.XmlResourceParser;
2627
import android.database.Cursor;
@@ -31,6 +32,8 @@
3132
import android.media.AudioService;
3233
import android.net.ConnectivityManager;
3334
import android.os.Environment;
35+
import android.os.RemoteException;
36+
import android.os.ServiceManager;
3437
import android.os.SystemProperties;
3538
import android.os.UserHandle;
3639
import android.provider.Settings;
@@ -171,7 +174,15 @@ public void onCreate(SQLiteDatabase db) {
171174
db.execSQL("CREATE INDEX bookmarksIndex2 ON bookmarks (shortcut);");
172175

173176
// Populate bookmarks table with initial bookmarks
174-
loadBookmarks(db);
177+
boolean onlyCore = false;
178+
try {
179+
onlyCore = IPackageManager.Stub.asInterface(ServiceManager.getService(
180+
"package")).isOnlyCoreApps();
181+
} catch (RemoteException e) {
182+
}
183+
if (!onlyCore) {
184+
loadBookmarks(db);
185+
}
175186

176187
// Load initial volume levels into DB
177188
loadVolumeLevels(db);

services/java/com/android/server/BootReceiver.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020
import android.content.Context;
2121
import android.content.Intent;
2222
import android.content.SharedPreferences;
23+
import android.content.pm.IPackageManager;
2324
import android.os.Build;
2425
import android.os.DropBoxManager;
2526
import android.os.FileObserver;
2627
import android.os.FileUtils;
2728
import android.os.RecoverySystem;
29+
import android.os.RemoteException;
30+
import android.os.ServiceManager;
2831
import android.os.SystemProperties;
2932
import android.provider.Downloads;
3033
import android.util.Slog;
@@ -69,7 +72,15 @@ public void run() {
6972
Slog.e(TAG, "Can't log boot events", e);
7073
}
7174
try {
72-
removeOldUpdatePackages(context);
75+
boolean onlyCore = false;
76+
try {
77+
onlyCore = IPackageManager.Stub.asInterface(ServiceManager.getService(
78+
"package")).isOnlyCoreApps();
79+
} catch (RemoteException e) {
80+
}
81+
if (!onlyCore) {
82+
removeOldUpdatePackages(context);
83+
}
7384
} catch (Exception e) {
7485
Slog.e(TAG, "Can't remove old update packages", e);
7586
}

services/java/com/android/server/EntropyMixer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.android.server;
1818

1919
import java.io.File;
20+
import java.io.FileNotFoundException;
2021
import java.io.FileOutputStream;
2122
import java.io.IOException;
2223
import java.io.OutputStream;
@@ -97,16 +98,18 @@ private void scheduleEntropyWriter() {
9798
private void loadInitialEntropy() {
9899
try {
99100
RandomBlock.fromFile(entropyFile).toFile(randomDevice, false);
101+
} catch (FileNotFoundException e) {
102+
Slog.w(TAG, "No existing entropy file -- first boot?");
100103
} catch (IOException e) {
101-
Slog.w(TAG, "unable to load initial entropy (first boot?)", e);
104+
Slog.w(TAG, "Failure loading existing entropy file", e);
102105
}
103106
}
104107

105108
private void writeEntropy() {
106109
try {
107110
RandomBlock.fromFile(randomDevice).toFile(entropyFile, true);
108111
} catch (IOException e) {
109-
Slog.w(TAG, "unable to write entropy", e);
112+
Slog.w(TAG, "Unable to write entropy", e);
110113
}
111114
}
112115

services/java/com/android/server/WallpaperManagerService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,8 @@ private void loadSettingsLocked(int userId) {
10961096
}
10971097
} while (type != XmlPullParser.END_DOCUMENT);
10981098
success = true;
1099+
} catch (FileNotFoundException e) {
1100+
Slog.w(TAG, "no current wallpaper -- first boot?");
10991101
} catch (NullPointerException e) {
11001102
Slog.w(TAG, "failed parsing " + file + " " + e);
11011103
} catch (NumberFormatException e) {

services/java/com/android/server/pm/PackageManagerService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,8 @@ public PackageManagerService(Context context, Installer installer,
10201020

10211021
readPermissions();
10221022

1023-
mRestoredSettings = mSettings.readLPw(sUserManager.getUsers(false));
1023+
mRestoredSettings = mSettings.readLPw(sUserManager.getUsers(false),
1024+
mSdkVersion, mOnlyCore);
10241025
long startTime = SystemClock.uptimeMillis();
10251026

10261027
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_SYSTEM_SCAN_START,
@@ -1320,6 +1321,10 @@ public boolean isFirstBoot() {
13201321
return !mRestoredSettings;
13211322
}
13221323

1324+
public boolean isOnlyCoreApps() {
1325+
return mOnlyCore;
1326+
}
1327+
13231328
private String getRequiredVerifierLPr() {
13241329
final Intent verification = new Intent(Intent.ACTION_PACKAGE_NEEDS_VERIFICATION);
13251330
final List<ResolveInfo> receivers = queryIntentReceivers(verification, PACKAGE_MIME_TYPE,

services/java/com/android/server/pm/Settings.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ void addPackageToCleanLPw(PackageCleanItem pkg) {
15561556
}
15571557
}
15581558

1559-
boolean readLPw(List<UserInfo> users) {
1559+
boolean readLPw(List<UserInfo> users, int sdkVersion, boolean onlyCore) {
15601560
FileInputStream str = null;
15611561
if (mBackupSettingsFilename.exists()) {
15621562
try {
@@ -1586,7 +1586,10 @@ boolean readLPw(List<UserInfo> users) {
15861586
mReadMessages.append("No settings file found\n");
15871587
PackageManagerService.reportSettingsProblem(Log.INFO,
15881588
"No settings file; creating initial state");
1589-
readDefaultPreferredAppsLPw(0);
1589+
if (!onlyCore) {
1590+
readDefaultPreferredAppsLPw(0);
1591+
}
1592+
mInternalSdkPlatform = mExternalSdkPlatform = sdkVersion;
15901593
return false;
15911594
}
15921595
str = new FileInputStream(mSettingsFilename);

0 commit comments

Comments
 (0)