Merge "Cherry pick: Batch calls to create app data for new users. DO NOT MERGE" into rvc-dev
This commit is contained in:
@@ -39,6 +39,7 @@ import dalvik.system.BlockGuard;
|
|||||||
import dalvik.system.VMRuntime;
|
import dalvik.system.VMRuntime;
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Installer extends SystemService {
|
public class Installer extends SystemService {
|
||||||
private static final String TAG = "Installer";
|
private static final String TAG = "Installer";
|
||||||
@@ -186,6 +187,30 @@ public class Installer extends SystemService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Batched version of createAppData for use with multiple packages.
|
||||||
|
*/
|
||||||
|
public void createAppDataBatched(String[] uuids, String[] packageNames, int userId, int flags,
|
||||||
|
int[] appIds, String[] seInfos, int[] targetSdkVersions) throws InstallerException {
|
||||||
|
if (!checkBeforeRemote()) return;
|
||||||
|
final int batchSize = 256;
|
||||||
|
for (int i = 0; i < uuids.length; i += batchSize) {
|
||||||
|
int to = i + batchSize;
|
||||||
|
if (to > uuids.length) {
|
||||||
|
to = uuids.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
mInstalld.createAppDataBatched(Arrays.copyOfRange(uuids, i, to),
|
||||||
|
Arrays.copyOfRange(packageNames, i, to), userId, flags,
|
||||||
|
Arrays.copyOfRange(appIds, i, to), Arrays.copyOfRange(seInfos, i, to),
|
||||||
|
Arrays.copyOfRange(targetSdkVersions, i, to));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw InstallerException.from(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void restoreconAppData(String uuid, String packageName, int userId, int flags, int appId,
|
public void restoreconAppData(String uuid, String packageName, int userId, int flags, int appId,
|
||||||
String seInfo) throws InstallerException {
|
String seInfo) throws InstallerException {
|
||||||
if (!checkBeforeRemote()) return;
|
if (!checkBeforeRemote()) return;
|
||||||
|
|||||||
@@ -4207,19 +4207,13 @@ public final class Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.traceBegin("createAppData");
|
t.traceBegin("createAppData");
|
||||||
for (int i = 0; i < packagesCount; i++) {
|
|
||||||
if (names[i] == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// TODO: triage flags!
|
|
||||||
final int flags = StorageManager.FLAG_STORAGE_CE | StorageManager.FLAG_STORAGE_DE;
|
final int flags = StorageManager.FLAG_STORAGE_CE | StorageManager.FLAG_STORAGE_DE;
|
||||||
try {
|
try {
|
||||||
installer.createAppData(volumeUuids[i], names[i], userHandle, flags, appIds[i],
|
installer.createAppDataBatched(volumeUuids, names, userHandle, flags, appIds, seinfos,
|
||||||
seinfos[i], targetSdkVersions[i]);
|
targetSdkVersions);
|
||||||
} catch (InstallerException e) {
|
} catch (InstallerException e) {
|
||||||
Slog.w(TAG, "Failed to prepare app data", e);
|
Slog.w(TAG, "Failed to prepare app data", e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
t.traceEnd(); // createAppData
|
t.traceEnd(); // createAppData
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
applyDefaultPreferredAppsLPw(userHandle);
|
applyDefaultPreferredAppsLPw(userHandle);
|
||||||
|
|||||||
Reference in New Issue
Block a user