Merge changes Ie865aba7,Ic51a9ceb into udc-dev
* changes: [pm] do not stop system apps with disabled a launcher activity [pm] fix SCAN_AS_STOPPED_SYSTEM_APP for restoreDisabledSystemPackage
This commit is contained in:
committed by
Android (Google) Code Review
commit
85b959f478
@@ -110,6 +110,7 @@ import android.app.backup.IBackupManager;
|
|||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.content.IntentSender;
|
import android.content.IntentSender;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.DataLoaderType;
|
import android.content.pm.DataLoaderType;
|
||||||
@@ -119,7 +120,6 @@ import android.content.pm.PackageInstaller;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PermissionGroupInfo;
|
import android.content.pm.PermissionGroupInfo;
|
||||||
import android.content.pm.PermissionInfo;
|
import android.content.pm.PermissionInfo;
|
||||||
import android.content.pm.ResolveInfo;
|
|
||||||
import android.content.pm.SharedLibraryInfo;
|
import android.content.pm.SharedLibraryInfo;
|
||||||
import android.content.pm.Signature;
|
import android.content.pm.Signature;
|
||||||
import android.content.pm.SigningDetails;
|
import android.content.pm.SigningDetails;
|
||||||
@@ -184,7 +184,9 @@ import com.android.server.pm.pkg.PackageState;
|
|||||||
import com.android.server.pm.pkg.PackageStateInternal;
|
import com.android.server.pm.pkg.PackageStateInternal;
|
||||||
import com.android.server.pm.pkg.SharedLibraryWrapper;
|
import com.android.server.pm.pkg.SharedLibraryWrapper;
|
||||||
import com.android.server.pm.pkg.component.ComponentMutateUtils;
|
import com.android.server.pm.pkg.component.ComponentMutateUtils;
|
||||||
|
import com.android.server.pm.pkg.component.ParsedActivity;
|
||||||
import com.android.server.pm.pkg.component.ParsedInstrumentation;
|
import com.android.server.pm.pkg.component.ParsedInstrumentation;
|
||||||
|
import com.android.server.pm.pkg.component.ParsedIntentInfo;
|
||||||
import com.android.server.pm.pkg.component.ParsedPermission;
|
import com.android.server.pm.pkg.component.ParsedPermission;
|
||||||
import com.android.server.pm.pkg.component.ParsedPermissionGroup;
|
import com.android.server.pm.pkg.component.ParsedPermissionGroup;
|
||||||
import com.android.server.pm.pkg.parsing.ParsingPackageUtils;
|
import com.android.server.pm.pkg.parsing.ParsingPackageUtils;
|
||||||
@@ -207,6 +209,7 @@ import java.security.cert.CertificateException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -3925,23 +3928,6 @@ final class InstallPackageHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is a system app we hadn't seen before, and this is a first boot or OTA,
|
|
||||||
// we need to unstop it if it doesn't have a launcher entry.
|
|
||||||
if (mPm.mShouldStopSystemPackagesByDefault && scanResult.mRequest.mPkgSetting == null
|
|
||||||
&& ((scanFlags & SCAN_FIRST_BOOT_OR_UPGRADE) != 0)
|
|
||||||
&& ((scanFlags & SCAN_AS_SYSTEM) != 0)) {
|
|
||||||
final Intent launcherIntent = new Intent(Intent.ACTION_MAIN);
|
|
||||||
launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
|
||||||
launcherIntent.setPackage(parsedPackage.getPackageName());
|
|
||||||
final List<ResolveInfo> launcherActivities =
|
|
||||||
mPm.snapshotComputer().queryIntentActivitiesInternal(launcherIntent, null,
|
|
||||||
PackageManager.MATCH_DIRECT_BOOT_AWARE
|
|
||||||
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE, 0);
|
|
||||||
if (launcherActivities.isEmpty()) {
|
|
||||||
scanResult.mPkgSetting.setStopped(false, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mIncrementalManager != null && isIncrementalPath(parsedPackage.getPath())) {
|
if (mIncrementalManager != null && isIncrementalPath(parsedPackage.getPath())) {
|
||||||
if (scanResult.mPkgSetting != null && scanResult.mPkgSetting.isLoading()) {
|
if (scanResult.mPkgSetting != null && scanResult.mPkgSetting.isLoading()) {
|
||||||
// Continue monitoring loading progress of active incremental packages
|
// Continue monitoring loading progress of active incremental packages
|
||||||
@@ -4314,6 +4300,8 @@ final class InstallPackageHelper {
|
|||||||
// - It's an APEX or overlay package since stopped state does not affect them.
|
// - It's an APEX or overlay package since stopped state does not affect them.
|
||||||
// - It is enumerated with a <initial-package-state> tag having the stopped attribute
|
// - It is enumerated with a <initial-package-state> tag having the stopped attribute
|
||||||
// set to false
|
// set to false
|
||||||
|
// - It doesn't have an enabled and exported launcher activity, which means the user
|
||||||
|
// wouldn't have a way to un-stop it
|
||||||
final boolean isApexPkg = (scanFlags & SCAN_AS_APEX) != 0;
|
final boolean isApexPkg = (scanFlags & SCAN_AS_APEX) != 0;
|
||||||
if (mPm.mShouldStopSystemPackagesByDefault
|
if (mPm.mShouldStopSystemPackagesByDefault
|
||||||
&& scanSystemPartition
|
&& scanSystemPartition
|
||||||
@@ -4322,8 +4310,9 @@ final class InstallPackageHelper {
|
|||||||
&& !parsedPackage.isOverlayIsStatic()
|
&& !parsedPackage.isOverlayIsStatic()
|
||||||
) {
|
) {
|
||||||
String packageName = parsedPackage.getPackageName();
|
String packageName = parsedPackage.getPackageName();
|
||||||
if (!mPm.mInitialNonStoppedSystemPackages.contains(packageName)
|
if (!"android".contentEquals(packageName)
|
||||||
&& !"android".contentEquals(packageName)) {
|
&& !mPm.mInitialNonStoppedSystemPackages.contains(packageName)
|
||||||
|
&& hasLauncherEntry(parsedPackage)) {
|
||||||
scanFlags |= SCAN_AS_STOPPED_SYSTEM_APP;
|
scanFlags |= SCAN_AS_STOPPED_SYSTEM_APP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4333,6 +4322,26 @@ final class InstallPackageHelper {
|
|||||||
return new Pair<>(scanResult, shouldHideSystemApp);
|
return new Pair<>(scanResult, shouldHideSystemApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean hasLauncherEntry(ParsedPackage parsedPackage) {
|
||||||
|
final HashSet<String> categories = new HashSet<>();
|
||||||
|
categories.add(Intent.CATEGORY_LAUNCHER);
|
||||||
|
final List<ParsedActivity> activities = parsedPackage.getActivities();
|
||||||
|
for (int indexActivity = 0; indexActivity < activities.size(); indexActivity++) {
|
||||||
|
final ParsedActivity activity = activities.get(indexActivity);
|
||||||
|
if (!activity.isEnabled() || !activity.isExported()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final List<ParsedIntentInfo> intents = activity.getIntents();
|
||||||
|
for (int indexIntent = 0; indexIntent < intents.size(); indexIntent++) {
|
||||||
|
final IntentFilter intentFilter = intents.get(indexIntent).getIntentFilter();
|
||||||
|
if (intentFilter != null && intentFilter.matchCategories(categories) == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if forced apk verification can be skipped for the whole package, including splits.
|
* Returns if forced apk verification can be skipped for the whole package, including splits.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user