Merge "Add boot mode where only "core apps" are started."
This commit is contained in:
committed by
Android (Google) Code Review
commit
83f9dfe0f0
@@ -92,6 +92,7 @@ public class PackageParser {
|
||||
|
||||
private String mArchiveSourcePath;
|
||||
private String[] mSeparateProcesses;
|
||||
private boolean mOnlyCoreApps;
|
||||
private static final int SDK_VERSION = Build.VERSION.SDK_INT;
|
||||
private static final String SDK_CODENAME = "REL".equals(Build.VERSION.CODENAME)
|
||||
? null : Build.VERSION.CODENAME;
|
||||
@@ -180,6 +181,10 @@ public class PackageParser {
|
||||
mSeparateProcesses = procs;
|
||||
}
|
||||
|
||||
public void setOnlyCoreApps(boolean onlyCoreApps) {
|
||||
mOnlyCoreApps = onlyCoreApps;
|
||||
}
|
||||
|
||||
private static final boolean isPackageFilename(String name) {
|
||||
return name.endsWith(".apk");
|
||||
}
|
||||
@@ -433,18 +438,22 @@ public class PackageParser {
|
||||
|
||||
|
||||
if (pkg == null) {
|
||||
if (errorException != null) {
|
||||
Slog.w(TAG, mArchiveSourcePath, errorException);
|
||||
} else {
|
||||
Slog.w(TAG, mArchiveSourcePath + " (at "
|
||||
+ parser.getPositionDescription()
|
||||
+ "): " + errorText[0]);
|
||||
// If we are only parsing core apps, then a null with INSTALL_SUCCEEDED
|
||||
// just means to skip this app so don't make a fuss about it.
|
||||
if (!mOnlyCoreApps || mParseError != PackageManager.INSTALL_SUCCEEDED) {
|
||||
if (errorException != null) {
|
||||
Slog.w(TAG, mArchiveSourcePath, errorException);
|
||||
} else {
|
||||
Slog.w(TAG, mArchiveSourcePath + " (at "
|
||||
+ parser.getPositionDescription()
|
||||
+ "): " + errorText[0]);
|
||||
}
|
||||
if (mParseError == PackageManager.INSTALL_SUCCEEDED) {
|
||||
mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
|
||||
}
|
||||
}
|
||||
parser.close();
|
||||
assmgr.close();
|
||||
if (mParseError == PackageManager.INSTALL_SUCCEEDED) {
|
||||
mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -782,6 +791,14 @@ public class PackageParser {
|
||||
}
|
||||
int type;
|
||||
|
||||
if (mOnlyCoreApps) {
|
||||
boolean core = attrs.getAttributeBooleanValue(null, "coreApp", false);
|
||||
if (!core) {
|
||||
mParseError = PackageManager.INSTALL_SUCCEEDED;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
final Package pkg = new Package(pkgName);
|
||||
boolean foundApp = false;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="android" android:sharedUserId="android.uid.system"
|
||||
package="android" coreApp="true" android:sharedUserId="android.uid.system"
|
||||
android:sharedUserLabel="@string/android_system_label">
|
||||
|
||||
<!-- ================================================ -->
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.defcontainer">
|
||||
package="com.android.defcontainer" coreApp="true">
|
||||
<uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_ALL_DOWNLOADS"/>
|
||||
<uses-permission android:name="android.permission.ASEC_ACCESS"/>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.providers.settings"
|
||||
coreApp="true"
|
||||
android:sharedUserId="android.uid.system">
|
||||
|
||||
<application android:allowClearUserData="false"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.systemui"
|
||||
coreApp="true"
|
||||
android:sharedUserId="android.uid.system"
|
||||
android:process="system"
|
||||
>
|
||||
|
||||
@@ -148,7 +148,8 @@ class ServerThread extends Thread {
|
||||
|
||||
Slog.i(TAG, "Package Manager");
|
||||
pm = PackageManagerService.main(context,
|
||||
factoryTest != SystemServer.FACTORY_TEST_OFF);
|
||||
factoryTest != SystemServer.FACTORY_TEST_OFF,
|
||||
false);
|
||||
|
||||
ActivityManagerService.setSystemProcess();
|
||||
|
||||
|
||||
@@ -221,6 +221,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
|
||||
final Context mContext;
|
||||
final boolean mFactoryTest;
|
||||
final boolean mOnlyCore;
|
||||
final boolean mNoDexOpt;
|
||||
final DisplayMetrics mMetrics;
|
||||
final int mDefParseFlags;
|
||||
@@ -809,8 +810,9 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static final IPackageManager main(Context context, boolean factoryTest) {
|
||||
PackageManagerService m = new PackageManagerService(context, factoryTest);
|
||||
public static final IPackageManager main(Context context, boolean factoryTest,
|
||||
boolean onlyCore) {
|
||||
PackageManagerService m = new PackageManagerService(context, factoryTest, onlyCore);
|
||||
ServiceManager.addService("package", m);
|
||||
return m;
|
||||
}
|
||||
@@ -837,7 +839,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
return res;
|
||||
}
|
||||
|
||||
public PackageManagerService(Context context, boolean factoryTest) {
|
||||
public PackageManagerService(Context context, boolean factoryTest, boolean onlyCore) {
|
||||
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_START,
|
||||
SystemClock.uptimeMillis());
|
||||
|
||||
@@ -847,6 +849,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
|
||||
mContext = context;
|
||||
mFactoryTest = factoryTest;
|
||||
mOnlyCore = onlyCore;
|
||||
mNoDexOpt = "eng".equals(SystemProperties.get("ro.build.type"));
|
||||
mMetrics = new DisplayMetrics();
|
||||
mSettings = new Settings();
|
||||
@@ -1051,18 +1054,20 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
mInstaller.moveFiles();
|
||||
|
||||
// Prune any system packages that no longer exist.
|
||||
Iterator<PackageSetting> psit = mSettings.mPackages.values().iterator();
|
||||
while (psit.hasNext()) {
|
||||
PackageSetting ps = psit.next();
|
||||
if ((ps.pkgFlags&ApplicationInfo.FLAG_SYSTEM) != 0
|
||||
&& !mPackages.containsKey(ps.name)
|
||||
&& !mSettings.mDisabledSysPackages.containsKey(ps.name)) {
|
||||
psit.remove();
|
||||
String msg = "System package " + ps.name
|
||||
+ " no longer exists; wiping its data";
|
||||
reportSettingsProblem(Log.WARN, msg);
|
||||
mInstaller.remove(ps.name, 0);
|
||||
mUserManager.removePackageForAllUsers(ps.name);
|
||||
if (!mOnlyCore) {
|
||||
Iterator<PackageSetting> psit = mSettings.mPackages.values().iterator();
|
||||
while (psit.hasNext()) {
|
||||
PackageSetting ps = psit.next();
|
||||
if ((ps.pkgFlags&ApplicationInfo.FLAG_SYSTEM) != 0
|
||||
&& !mPackages.containsKey(ps.name)
|
||||
&& !mSettings.mDisabledSysPackages.containsKey(ps.name)) {
|
||||
psit.remove();
|
||||
String msg = "System package " + ps.name
|
||||
+ " no longer exists; wiping its data";
|
||||
reportSettingsProblem(Log.WARN, msg);
|
||||
mInstaller.remove(ps.name, 0);
|
||||
mUserManager.removePackageForAllUsers(ps.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1077,18 +1082,23 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
//delete tmp files
|
||||
deleteTempPackageFiles();
|
||||
|
||||
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_DATA_SCAN_START,
|
||||
SystemClock.uptimeMillis());
|
||||
mAppInstallObserver = new AppDirObserver(
|
||||
mAppInstallDir.getPath(), OBSERVER_EVENTS, false);
|
||||
mAppInstallObserver.startWatching();
|
||||
scanDirLI(mAppInstallDir, 0, scanMode, 0);
|
||||
|
||||
mDrmAppInstallObserver = new AppDirObserver(
|
||||
mDrmAppPrivateInstallDir.getPath(), OBSERVER_EVENTS, false);
|
||||
mDrmAppInstallObserver.startWatching();
|
||||
scanDirLI(mDrmAppPrivateInstallDir, PackageParser.PARSE_FORWARD_LOCK,
|
||||
scanMode, 0);
|
||||
if (!mOnlyCore) {
|
||||
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_DATA_SCAN_START,
|
||||
SystemClock.uptimeMillis());
|
||||
mAppInstallObserver = new AppDirObserver(
|
||||
mAppInstallDir.getPath(), OBSERVER_EVENTS, false);
|
||||
mAppInstallObserver.startWatching();
|
||||
scanDirLI(mAppInstallDir, 0, scanMode, 0);
|
||||
|
||||
mDrmAppInstallObserver = new AppDirObserver(
|
||||
mDrmAppPrivateInstallDir.getPath(), OBSERVER_EVENTS, false);
|
||||
mDrmAppInstallObserver.startWatching();
|
||||
scanDirLI(mDrmAppPrivateInstallDir, PackageParser.PARSE_FORWARD_LOCK,
|
||||
scanMode, 0);
|
||||
} else {
|
||||
mAppInstallObserver = null;
|
||||
mDrmAppInstallObserver = null;
|
||||
}
|
||||
|
||||
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_SCAN_END,
|
||||
SystemClock.uptimeMillis());
|
||||
@@ -2749,6 +2759,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
parseFlags |= mDefParseFlags;
|
||||
PackageParser pp = new PackageParser(scanPath);
|
||||
pp.setSeparateProcesses(mSeparateProcesses);
|
||||
pp.setOnlyCoreApps(mOnlyCore);
|
||||
final PackageParser.Package pkg = pp.parsePackage(scanFile,
|
||||
scanPath, mMetrics, parseFlags);
|
||||
if (pkg == null) {
|
||||
@@ -4044,7 +4055,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
+ " info=" + bp.pendingInfo);
|
||||
if (bp.packageSetting == null && bp.pendingInfo != null) {
|
||||
final BasePermission tree = findPermissionTreeLP(bp.name);
|
||||
if (tree != null) {
|
||||
if (tree != null && tree.perm != null) {
|
||||
bp.packageSetting = tree.packageSetting;
|
||||
bp.perm = new PackageParser.Permission(tree.perm.owner,
|
||||
new PermissionInfo(bp.pendingInfo));
|
||||
|
||||
Reference in New Issue
Block a user