Clean/destroy app shared storage via installd.

In P we moved destroying per-user shared storage into installd,
where it can iterate quickly over large sets of files.  This change
now moves cleaning/destroying of per-app shared storage data down into
installd, letting us greatly simplify the logic in PMS to no longer
require spinning up DefaultContainerService.  This also fixes an
obscure bug where DCS (which always runs as USER_SYSTEM) wasn't able
to clear shared storage for secondary users.

This also gives us the ability to target specific storage devices
by UUID, such as when the user has migrated their primary shared
storage to an adopted device.

We no longer distinguish between keeping or deleting OBB files
during various operations, since upcoming changes in the Q release
will mean OBB files are no longer shared between users, and they'll
now live inside a sandbox that will be fully cleared when the user
clears data.  (Going forward, apps should be using splits instead
of OBBs, so they're effectively deprecated.)

Uses newer "const" feature of AIDL to ensure constant values remain
consistent between native and Java code.

Bug: 111854851, 111838160
Test: atest android.appsecurity.cts.StorageHostTest#testCache
Change-Id: Ib90be155718a768da76110fbfcf010a471b37378
This commit is contained in:
Jeff Sharkey
2018-08-24 17:25:42 -06:00
committed by Jeff Sharkey
parent be3a75cb55
commit 4e7a765855
11 changed files with 17 additions and 441 deletions

View File

@@ -1753,12 +1753,6 @@ HPLandroid/content/pm/LauncherApps$CallbackMessageHandler;->postOnPackageAdded(L
HPLandroid/content/pm/LauncherApps$CallbackMessageHandler;->postOnPackageChanged(Ljava/lang/String;Landroid/os/UserHandle;)V
HPLandroid/content/pm/LauncherApps$CallbackMessageHandler;->postOnPackageRemoved(Ljava/lang/String;Landroid/os/UserHandle;)V
HPLandroid/content/pm/LauncherApps$ShortcutQuery;->setActivity(Landroid/content/ComponentName;)Landroid/content/pm/LauncherApps$ShortcutQuery;
HPLandroid/content/pm/PackageCleanItem$1;-><init>()V
HPLandroid/content/pm/PackageCleanItem$1;->createFromParcel(Landroid/os/Parcel;)Landroid/content/pm/PackageCleanItem;
HPLandroid/content/pm/PackageCleanItem$1;->createFromParcel(Landroid/os/Parcel;)Ljava/lang/Object;
HPLandroid/content/pm/PackageCleanItem;-><init>(ILjava/lang/String;Z)V
HPLandroid/content/pm/PackageCleanItem;->equals(Ljava/lang/Object;)Z
HPLandroid/content/pm/PackageCleanItem;->writeToParcel(Landroid/os/Parcel;I)V
HPLandroid/content/pm/PackageInfo$1;->newArray(I)[Landroid/content/pm/PackageInfo;
HPLandroid/content/pm/PackageInfo$1;->newArray(I)[Ljava/lang/Object;
HPLandroid/content/pm/PackageInfo;->isOverlayPackage()Z
@@ -18113,7 +18107,6 @@ HSPLandroid/content/pm/IPackageManager;->isUpgrade()Z
HSPLandroid/content/pm/IPackageManager;->logAppProcessStartIfNeeded(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;I)V
HSPLandroid/content/pm/IPackageManager;->movePackage(Ljava/lang/String;Ljava/lang/String;)I
HSPLandroid/content/pm/IPackageManager;->movePrimaryStorage(Ljava/lang/String;)I
HSPLandroid/content/pm/IPackageManager;->nextPackageToClean(Landroid/content/pm/PackageCleanItem;)Landroid/content/pm/PackageCleanItem;
HSPLandroid/content/pm/IPackageManager;->notifyDexLoad(Ljava/lang/String;Ljava/util/List;Ljava/util/List;Ljava/lang/String;)V
HSPLandroid/content/pm/IPackageManager;->notifyPackageUse(Ljava/lang/String;I)V
HSPLandroid/content/pm/IPackageManager;->performDexOptMode(Ljava/lang/String;ZLjava/lang/String;ZZLjava/lang/String;)Z

View File

@@ -37,7 +37,6 @@ import android.content.pm.IntentFilterVerificationInfo;
import android.content.pm.InstrumentationInfo;
import android.content.pm.KeySet;
import android.content.pm.PackageInfo;
import android.content.pm.PackageCleanItem;
import android.content.pm.ParceledListSlice;
import android.content.pm.ProviderInfo;
import android.content.pm.PermissionGroupInfo;
@@ -553,8 +552,6 @@ interface IPackageManager {
*/
void reconcileSecondaryDexFiles(String packageName);
PackageCleanItem nextPackageToClean(in PackageCleanItem lastPackage);
int getMoveStatus(int moveId);
void registerMoveCallback(in IPackageMoveObserver callback);

View File

@@ -1,18 +0,0 @@
/* Copyright 2012, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
package android.content.pm;
parcelable PackageCleanItem;

View File

@@ -1,85 +0,0 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content.pm;
import android.os.Parcel;
import android.os.Parcelable;
/** @hide */
public class PackageCleanItem implements Parcelable {
public final int userId;
public final String packageName;
public final boolean andCode;
public PackageCleanItem(int userId, String packageName, boolean andCode) {
this.userId = userId;
this.packageName = packageName;
this.andCode = andCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
try {
if (obj != null) {
PackageCleanItem other = (PackageCleanItem)obj;
return userId == other.userId && packageName.equals(other.packageName)
&& andCode == other.andCode;
}
} catch (ClassCastException e) {
}
return false;
}
@Override
public int hashCode() {
int result = 17;
result = 31 * result + userId;
result = 31 * result + packageName.hashCode();
result = 31 * result + (andCode ? 1 : 0);
return result;
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel dest, int parcelableFlags) {
dest.writeInt(userId);
dest.writeString(packageName);
dest.writeInt(andCode ? 1 : 0);
}
public static final Parcelable.Creator<PackageCleanItem> CREATOR
= new Parcelable.Creator<PackageCleanItem>() {
public PackageCleanItem createFromParcel(Parcel source) {
return new PackageCleanItem(source);
}
public PackageCleanItem[] newArray(int size) {
return new PackageCleanItem[size];
}
};
private PackageCleanItem(Parcel source) {
userId = source.readInt();
packageName = source.readString();
andCode = source.readInt() != 0;
}
}

View File

@@ -2677,13 +2677,6 @@ public abstract class PackageManager {
public static final String FEATURE_DEVICE_ID_ATTESTATION =
"android.software.device_id_attestation";
/**
* Action to external storage service to clean out removed apps.
* @hide
*/
public static final String ACTION_CLEAN_EXTERNAL_STORAGE
= "android.content.pm.CLEAN_EXTERNAL_STORAGE";
/**
* Extra field name for the URI to a verification file. Passed to a package
* verifier.

View File

@@ -38,6 +38,7 @@ import android.os.Binder;
import android.os.Environment;
import android.os.FileUtils;
import android.os.Handler;
import android.os.IInstalld;
import android.os.IVold;
import android.os.IVoldTaskListener;
import android.os.Looper;
@@ -213,11 +214,10 @@ public class StorageManager {
/** {@hide} */
public static final int DEBUG_VIRTUAL_DISK = 1 << 5;
// NOTE: keep in sync with installd
/** {@hide} */
public static final int FLAG_STORAGE_DE = 1 << 0;
public static final int FLAG_STORAGE_DE = IInstalld.FLAG_STORAGE_DE;
/** {@hide} */
public static final int FLAG_STORAGE_CE = 1 << 1;
public static final int FLAG_STORAGE_CE = IInstalld.FLAG_STORAGE_CE;
/** {@hide} */
public static final int FLAG_FOR_WRITE = 1 << 8;

View File

@@ -25,6 +25,5 @@ interface IMediaContainerService {
PackageInfoLite getMinimalPackageInfo(String packagePath, int flags, String abiOverride);
ObbInfo getObbInfo(String filename);
void clearDirectory(String directory);
long calculateInstalledSize(String packagePath, String abiOverride);
}

View File

@@ -16,11 +16,9 @@
package com.android.defcontainer;
import android.app.IntentService;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.IPackageManager;
import android.content.pm.PackageCleanItem;
import android.content.pm.PackageInfoLite;
import android.content.pm.PackageManager;
import android.content.pm.PackageParser;
@@ -29,13 +27,10 @@ import android.content.pm.PackageParser.PackageParserException;
import android.content.res.ObbInfo;
import android.content.res.ObbScanner;
import android.os.Binder;
import android.os.Environment.UserEnvironment;
import android.os.FileUtils;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Slog;
import com.android.internal.app.IMediaContainerService;
@@ -57,7 +52,7 @@ import java.io.OutputStream;
* open files that cause the kernel to kill it when the underlying device is
* removed.
*/
public class DefaultContainerService extends IntentService {
public class DefaultContainerService extends Service {
private static final String TAG = "DefContainer";
// TODO: migrate native code unpacking to always be a derivative work
@@ -159,16 +154,6 @@ public class DefaultContainerService extends IntentService {
}
}
@Override
public void clearDirectory(String path) throws RemoteException {
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
final File directory = new File(path);
if (directory.exists() && directory.isDirectory()) {
eraseFiles(directory);
}
}
/**
* Calculate estimated footprint of given package post-installation.
*
@@ -191,49 +176,6 @@ public class DefaultContainerService extends IntentService {
}
};
public DefaultContainerService() {
super("DefaultContainerService");
setIntentRedelivery(true);
}
@Override
protected void onHandleIntent(Intent intent) {
if (PackageManager.ACTION_CLEAN_EXTERNAL_STORAGE.equals(intent.getAction())) {
final IPackageManager pm = IPackageManager.Stub.asInterface(
ServiceManager.getService("package"));
PackageCleanItem item = null;
try {
while ((item = pm.nextPackageToClean(item)) != null) {
final UserEnvironment userEnv = new UserEnvironment(item.userId);
eraseFiles(userEnv.buildExternalStorageAppDataDirs(item.packageName));
eraseFiles(userEnv.buildExternalStorageAppMediaDirs(item.packageName));
if (item.andCode) {
eraseFiles(userEnv.buildExternalStorageAppObbDirs(item.packageName));
}
}
} catch (RemoteException e) {
}
}
}
void eraseFiles(File[] paths) {
for (File path : paths) {
eraseFiles(path);
}
}
void eraseFiles(File path) {
if (path.isDirectory()) {
String[] files = path.list();
if (files != null) {
for (String file : files) {
eraseFiles(new File(path, file));
}
}
}
path.delete();
}
@Override
public IBinder onBind(Intent intent) {
return mBinder;

View File

@@ -71,14 +71,18 @@ public class Installer extends SystemService {
/** Indicates that dexopt should generate an app image */
public static final int DEXOPT_GENERATE_APP_IMAGE = 1 << 12;
// NOTE: keep in sync with installd
public static final int FLAG_CLEAR_CACHE_ONLY = 1 << 8;
public static final int FLAG_CLEAR_CODE_CACHE_ONLY = 1 << 9;
public static final int FLAG_USE_QUOTA = 1 << 12;
public static final int FLAG_FREE_CACHE_V2 = 1 << 13;
public static final int FLAG_FREE_CACHE_V2_DEFY_QUOTA = 1 << 14;
public static final int FLAG_FREE_CACHE_NOOP = 1 << 15;
public static final int FLAG_FORCE = 1 << 16;
public static final int FLAG_STORAGE_DE = IInstalld.FLAG_STORAGE_DE;
public static final int FLAG_STORAGE_CE = IInstalld.FLAG_STORAGE_CE;
public static final int FLAG_CLEAR_CACHE_ONLY = IInstalld.FLAG_CLEAR_CACHE_ONLY;
public static final int FLAG_CLEAR_CODE_CACHE_ONLY = IInstalld.FLAG_CLEAR_CODE_CACHE_ONLY;
public static final int FLAG_FREE_CACHE_V2 = IInstalld.FLAG_FREE_CACHE_V2;
public static final int FLAG_FREE_CACHE_V2_DEFY_QUOTA = IInstalld.FLAG_FREE_CACHE_V2_DEFY_QUOTA;
public static final int FLAG_FREE_CACHE_NOOP = IInstalld.FLAG_FREE_CACHE_NOOP;
public static final int FLAG_USE_QUOTA = IInstalld.FLAG_USE_QUOTA;
public static final int FLAG_FORCE = IInstalld.FLAG_FORCE;
private final boolean mIsolated;

View File

@@ -161,7 +161,6 @@ import android.content.pm.InstantAppRequest;
import android.content.pm.InstrumentationInfo;
import android.content.pm.IntentFilterVerificationInfo;
import android.content.pm.KeySet;
import android.content.pm.PackageCleanItem;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInfoLite;
import android.content.pm.PackageInstaller;
@@ -618,12 +617,6 @@ public class PackageManagerService extends IPackageManager.Stub
private final ProcessLoggingHandler mProcessLoggingHandler;
/**
* Messages for {@link #mHandler} that need to wait for system ready before
* being dispatched.
*/
private ArrayList<Message> mPostSystemReadyMessages;
final int mSdkVersion = Build.VERSION.SDK_INT;
final Context mContext;
@@ -636,10 +629,6 @@ public class PackageManagerService extends IPackageManager.Stub
final boolean mIsPreNUpgrade;
final boolean mIsPreNMR1Upgrade;
// Have we told the Activity Manager to whitelist the default container service by uid yet?
@GuardedBy("mPackages")
boolean mDefaultContainerWhitelisted = false;
@GuardedBy("mPackages")
private boolean mDexOptDialogShown;
@@ -1257,7 +1246,6 @@ public class PackageManagerService extends IPackageManager.Stub
static final int MCS_BOUND = 3;
static final int INIT_COPY = 5;
static final int MCS_UNBIND = 6;
static final int START_CLEANING_PACKAGE = 7;
static final int POST_INSTALL = 9;
static final int MCS_RECONNECT = 10;
static final int MCS_GIVE_UP = 11;
@@ -1601,26 +1589,6 @@ public class PackageManagerService extends IPackageManager.Stub
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
break;
}
case START_CLEANING_PACKAGE: {
Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
final String packageName = (String)msg.obj;
final int userId = msg.arg1;
final boolean andCode = msg.arg2 != 0;
synchronized (mPackages) {
if (userId == UserHandle.USER_ALL) {
int[] users = sUserManager.getUserIds();
for (int user : users) {
mSettings.addPackageToCleanLPw(
new PackageCleanItem(user, packageName, andCode));
}
} else {
mSettings.addPackageToCleanLPw(
new PackageCleanItem(userId, packageName, andCode));
}
}
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
startCleaningPackages();
} break;
case POST_INSTALL: {
if (DEBUG_INSTALL) Log.v(TAG, "Handling post-install for " + msg.arg1);
@@ -11533,14 +11501,6 @@ public class PackageManagerService extends IPackageManager.Stub
mSettings.insertPackageSettingLPw(pkgSetting, pkg);
// Add the new setting to mPackages
mPackages.put(pkg.applicationInfo.packageName, pkg);
// Make sure we don't accidentally delete its data.
final Iterator<PackageCleanItem> iter = mSettings.mPackagesToBeCleaned.iterator();
while (iter.hasNext()) {
PackageCleanItem item = iter.next();
if (pkgName.equals(item.packageName)) {
iter.remove();
}
}
// Add the package's KeySets to the global KeySetManagerService
KeySetManagerService ksms = mSettings.mKeySetManagerService;
@@ -12396,75 +12356,6 @@ public class PackageManagerService extends IPackageManager.Stub
return mMediaMounted || Environment.isExternalStorageEmulated();
}
@Override
public PackageCleanItem nextPackageToClean(PackageCleanItem lastPackage) {
if (getInstantAppPackageName(Binder.getCallingUid()) != null) {
return null;
}
if (!isExternalMediaAvailable()) {
// If the external storage is no longer mounted at this point,
// the caller may not have been able to delete all of this
// packages files and can not delete any more. Bail.
return null;
}
synchronized (mPackages) {
final ArrayList<PackageCleanItem> pkgs = mSettings.mPackagesToBeCleaned;
if (lastPackage != null) {
pkgs.remove(lastPackage);
}
if (pkgs.size() > 0) {
return pkgs.get(0);
}
}
return null;
}
void schedulePackageCleaning(String packageName, int userId, boolean andCode) {
final Message msg = mHandler.obtainMessage(START_CLEANING_PACKAGE,
userId, andCode ? 1 : 0, packageName);
if (mSystemReady) {
msg.sendToTarget();
} else {
if (mPostSystemReadyMessages == null) {
mPostSystemReadyMessages = new ArrayList<>();
}
mPostSystemReadyMessages.add(msg);
}
}
void startCleaningPackages() {
// reader
if (!isExternalMediaAvailable()) {
return;
}
synchronized (mPackages) {
if (mSettings.mPackagesToBeCleaned.isEmpty()) {
return;
}
}
Intent intent = new Intent(PackageManager.ACTION_CLEAN_EXTERNAL_STORAGE);
intent.setComponent(DEFAULT_CONTAINER_COMPONENT);
IActivityManager am = ActivityManager.getService();
if (am != null) {
int dcsUid = -1;
synchronized (mPackages) {
if (!mDefaultContainerWhitelisted) {
mDefaultContainerWhitelisted = true;
PackageSetting ps = mSettings.mPackages.get(DEFAULT_CONTAINER_PACKAGE);
dcsUid = UserHandle.getUid(UserHandle.USER_SYSTEM, ps.appId);
}
}
try {
if (dcsUid > 0) {
am.backgroundWhitelistUid(dcsUid);
}
am.startService(null, intent, null, false, mContext.getOpPackageName(),
UserHandle.USER_SYSTEM);
} catch (RemoteException e) {
}
}
}
/**
* Ensure that the install reason matches what we know about the package installer (e.g. whether
* it is acting on behalf on an enterprise or the user).
@@ -13934,15 +13825,6 @@ public class PackageManagerService extends IPackageManager.Stub
abstract void handleReturnCode();
}
private static void clearDirectory(IMediaContainerService mcs, File[] paths) {
for (File path : paths) {
try {
mcs.clearDirectory(path.getAbsolutePath());
} catch (RemoteException e) {
}
}
}
static class OriginInfo {
/**
* Location where install is coming from, before it has been
@@ -17268,7 +17150,6 @@ public class PackageManagerService extends IPackageManager.Stub
if (outInfo != null) {
outInfo.dataRemoved = true;
}
schedulePackageCleaning(packageName, UserHandle.USER_ALL, true);
}
int removedAppId = -1;
@@ -17925,7 +17806,6 @@ public class PackageManagerService extends IPackageManager.Stub
destroyAppProfilesLIF(pkg, userId);
clearDefaultBrowserIfNeededForUser(ps.name, userId);
removeKeystoreDataIfNeeded(nextUserId, ps.appId);
schedulePackageCleaning(ps.name, nextUserId, false);
synchronized (mPackages) {
if (clearPackagePreferredActivitiesLPw(ps.name, nextUserId)) {
scheduleWritePackageRestrictionsLocked(nextUserId);
@@ -17946,83 +17826,6 @@ public class PackageManagerService extends IPackageManager.Stub
return true;
}
private final class ClearStorageConnection implements ServiceConnection {
IMediaContainerService mContainerService;
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
synchronized (this) {
mContainerService = IMediaContainerService.Stub
.asInterface(Binder.allowBlocking(service));
notifyAll();
}
}
@Override
public void onServiceDisconnected(ComponentName name) {
}
}
private void clearExternalStorageDataSync(String packageName, int userId, boolean allData) {
if (DEFAULT_CONTAINER_PACKAGE.equals(packageName)) return;
final boolean mounted;
if (Environment.isExternalStorageEmulated()) {
mounted = true;
} else {
final String status = Environment.getExternalStorageState();
mounted = status.equals(Environment.MEDIA_MOUNTED)
|| status.equals(Environment.MEDIA_MOUNTED_READ_ONLY);
}
if (!mounted) {
return;
}
final Intent containerIntent = new Intent().setComponent(DEFAULT_CONTAINER_COMPONENT);
int[] users;
if (userId == UserHandle.USER_ALL) {
users = sUserManager.getUserIds();
} else {
users = new int[] { userId };
}
final ClearStorageConnection conn = new ClearStorageConnection();
if (mContext.bindServiceAsUser(
containerIntent, conn, Context.BIND_AUTO_CREATE, UserHandle.SYSTEM)) {
try {
for (int curUser : users) {
long timeout = SystemClock.uptimeMillis() + 5000;
synchronized (conn) {
long now;
while (conn.mContainerService == null &&
(now = SystemClock.uptimeMillis()) < timeout) {
try {
conn.wait(timeout - now);
} catch (InterruptedException e) {
}
}
}
if (conn.mContainerService == null) {
return;
}
final UserEnvironment userEnv = new UserEnvironment(curUser);
clearDirectory(conn.mContainerService,
userEnv.buildExternalStorageAppCacheDirs(packageName));
if (allData) {
clearDirectory(conn.mContainerService,
userEnv.buildExternalStorageAppDataDirs(packageName));
clearDirectory(conn.mContainerService,
userEnv.buildExternalStorageAppMediaDirs(packageName));
}
}
} finally {
mContext.unbindService(conn);
}
}
}
@Override
public void clearApplicationProfileData(String packageName) {
enforceSystemOrRoot("Only the system can clear all profile data");
@@ -18066,7 +17869,6 @@ public class PackageManagerService extends IPackageManager.Stub
synchronized (mInstallLock) {
succeeded = clearApplicationUserDataLIF(packageName, userId);
}
clearExternalStorageDataSync(packageName, userId, true);
synchronized (mPackages) {
mInstantAppRegistry.deleteInstantApplicationMetadataLPw(
packageName, userId);
@@ -18359,7 +18161,6 @@ public class PackageManagerService extends IPackageManager.Stub
clearAppDataLIF(pkg, userId, flags | Installer.FLAG_CLEAR_CACHE_ONLY);
clearAppDataLIF(pkg, userId, flags | Installer.FLAG_CLEAR_CODE_CACHE_ONLY);
}
clearExternalStorageDataSync(packageName, userId, false);
}
if (observer != null) {
try {
@@ -20009,14 +19810,6 @@ public class PackageManagerService extends IPackageManager.Stub
mPermissionCallback);
}
// Kick off any messages waiting for system ready
if (mPostSystemReadyMessages != null) {
for (Message msg : mPostSystemReadyMessages) {
msg.sendToTarget();
}
mPostSystemReadyMessages = null;
}
// Watch for external volumes that come and go over time
final StorageManager storage = mContext.getSystemService(StorageManager.class);
storage.registerListener(mStorageListener);

View File

@@ -42,7 +42,6 @@ import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ComponentInfo;
import android.content.pm.IntentFilterVerificationInfo;
import android.content.pm.PackageCleanItem;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.pm.PackageParser;
@@ -209,8 +208,6 @@ public final class Settings {
public static final String ATTR_NAME = "name";
public static final String ATTR_PACKAGE = "package";
private static final String ATTR_USER = "user";
private static final String ATTR_CODE = "code";
private static final String ATTR_GRANTED = "granted";
private static final String ATTR_FLAGS = "flags";
private static final String ATTR_VERSION = "version";
@@ -388,10 +385,6 @@ public final class Settings {
private final ArrayMap<Long, Integer> mKeySetRefs =
new ArrayMap<Long, Integer>();
// Packages that have been uninstalled and still need their external
// storage data deleted.
final ArrayList<PackageCleanItem> mPackagesToBeCleaned = new ArrayList<PackageCleanItem>();
// Packages that have been renamed since they were first installed.
// Keys are the new names of the packages, values are the original
// names. The packages appear everywhere else under their original
@@ -2546,17 +2539,6 @@ public final class Settings {
serializer.endTag(null, "shared-user");
}
if (mPackagesToBeCleaned.size() > 0) {
for (PackageCleanItem item : mPackagesToBeCleaned) {
final String userStr = Integer.toString(item.userId);
serializer.startTag(null, "cleaning-package");
serializer.attribute(null, ATTR_NAME, item.packageName);
serializer.attribute(null, ATTR_CODE, item.andCode ? "true" : "false");
serializer.attribute(null, ATTR_USER, userStr);
serializer.endTag(null, "cleaning-package");
}
}
if (mRenamedPackages.size() > 0) {
for (Map.Entry<String, String> e : mRenamedPackages.entrySet()) {
serializer.startTag(null, "renamed-package");
@@ -2972,12 +2954,6 @@ public final class Settings {
bp.writeLPr(serializer);
}
void addPackageToCleanLPw(PackageCleanItem pkg) {
if (!mPackagesToBeCleaned.contains(pkg)) {
mPackagesToBeCleaned.add(pkg);
}
}
boolean readLPw(@NonNull List<UserInfo> users) {
FileInputStream str = null;
if (mBackupSettingsFilename.exists()) {
@@ -3070,24 +3046,6 @@ public final class Settings {
readDefaultAppsLPw(parser, 0);
} else if (tagName.equals("updated-package")) {
readDisabledSysPackageLPw(parser);
} else if (tagName.equals("cleaning-package")) {
String name = parser.getAttributeValue(null, ATTR_NAME);
String userStr = parser.getAttributeValue(null, ATTR_USER);
String codeStr = parser.getAttributeValue(null, ATTR_CODE);
if (name != null) {
int userId = UserHandle.USER_SYSTEM;
boolean andCode = true;
try {
if (userStr != null) {
userId = Integer.parseInt(userStr);
}
} catch (NumberFormatException e) {
}
if (codeStr != null) {
andCode = Boolean.parseBoolean(codeStr);
}
addPackageToCleanLPw(new PackageCleanItem(userId, name, andCode));
}
} else if (tagName.equals("renamed-package")) {
String nname = parser.getAttributeValue(null, "new");
String oname = parser.getAttributeValue(null, "old");