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