Merge "Move moveCompleteApp() to Binder."

This commit is contained in:
Jeff Sharkey
2016-12-06 22:24:25 +00:00
committed by Gerrit Code Review

View File

@@ -37,8 +37,6 @@ import java.util.Arrays;
public final class Installer extends SystemService { public final class Installer extends SystemService {
private static final String TAG = "Installer"; private static final String TAG = "Installer";
private static final boolean USE_BINDER = true;
/* *************************************************************************** /* ***************************************************************************
* IMPORTANT: These values are passed to native code. Keep them in sync with * IMPORTANT: These values are passed to native code. Keep them in sync with
* frameworks/native/cmds/installd/installd.h * frameworks/native/cmds/installd/installd.h
@@ -63,6 +61,8 @@ public final class Installer extends SystemService {
private final InstallerConnection mInstaller; private final InstallerConnection mInstaller;
private final IInstalld mInstalld; private final IInstalld mInstalld;
private volatile Object mWarnIfHeld;
public Installer(Context context) { public Installer(Context context) {
super(context); super(context);
mInstaller = new InstallerConnection(); mInstaller = new InstallerConnection();
@@ -85,6 +85,7 @@ public final class Installer extends SystemService {
*/ */
public void setWarnIfHeld(Object warnIfHeld) { public void setWarnIfHeld(Object warnIfHeld) {
mInstaller.setWarnIfHeld(warnIfHeld); mInstaller.setWarnIfHeld(warnIfHeld);
mWarnIfHeld = warnIfHeld;
} }
@Override @Override
@@ -93,18 +94,21 @@ public final class Installer extends SystemService {
mInstaller.waitForConnection(); mInstaller.waitForConnection();
} }
public void createAppData(String uuid, String pkgname, int userid, int flags, int appid, private void checkLock() {
String seinfo, int targetSdkVersion) throws InstallerException { if (mWarnIfHeld != null && Thread.holdsLock(mWarnIfHeld)) {
if (USE_BINDER) { Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() + " is holding 0x"
try { + Integer.toHexString(System.identityHashCode(mWarnIfHeld)), new Throwable());
mInstalld.createAppData(uuid, pkgname, userid, flags, appid, seinfo, }
targetSdkVersion); }
} catch (RemoteException | ServiceSpecificException e) {
throw new InstallerException(e.getMessage()); public void createAppData(String uuid, String packageName, int userId, int flags, int appId,
} String seInfo, int targetSdkVersion) throws InstallerException {
} else { checkLock();
mInstaller.execute("create_app_data", uuid, pkgname, userid, flags, appid, seinfo, try {
mInstalld.createAppData(uuid, packageName, userId, flags, appId, seInfo,
targetSdkVersion); targetSdkVersion);
} catch (RemoteException | ServiceSpecificException e) {
throw new InstallerException(e.getMessage());
} }
} }
@@ -129,11 +133,16 @@ public final class Installer extends SystemService {
mInstaller.execute("destroy_app_data", uuid, pkgname, userid, flags, ceDataInode); mInstaller.execute("destroy_app_data", uuid, pkgname, userid, flags, ceDataInode);
} }
public void moveCompleteApp(String from_uuid, String to_uuid, String package_name, public void moveCompleteApp(String fromUuid, String toUuid, String packageName,
String data_app_name, int appid, String seinfo, int targetSdkVersion) String dataAppName, int appId, String seInfo, int targetSdkVersion)
throws InstallerException { throws InstallerException {
mInstaller.execute("move_complete_app", from_uuid, to_uuid, package_name, checkLock();
data_app_name, appid, seinfo, targetSdkVersion); try {
mInstalld.moveCompleteApp(fromUuid, toUuid, packageName, dataAppName, appId, seInfo,
targetSdkVersion);
} catch (RemoteException | ServiceSpecificException e) {
throw new InstallerException(e.getMessage());
}
} }
public void getAppSize(String uuid, String pkgname, int userid, int flags, long ceDataInode, public void getAppSize(String uuid, String pkgname, int userid, int flags, long ceDataInode,