Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8ddc2d5 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Move moveCompleteApp() to Binder.

Also start manually checking thread-locking, since Binder methods
don't funnel through the old transact().

Test: builds, boots, apps install fine
Bug: 13758960, 30944031
Change-Id: I661eade7dc8e060689ecbcb9b6d19528e5c4ca66
parent 19fc36fa
Loading
Loading
Loading
Loading
+26 −17
Original line number Diff line number Diff line
@@ -37,8 +37,6 @@ import java.util.Arrays;
public final class Installer extends SystemService {
    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
     * frameworks/native/cmds/installd/installd.h
@@ -63,6 +61,8 @@ public final class Installer extends SystemService {
    private final InstallerConnection mInstaller;
    private final IInstalld mInstalld;

    private volatile Object mWarnIfHeld;

    public Installer(Context context) {
        super(context);
        mInstaller = new InstallerConnection();
@@ -85,6 +85,7 @@ public final class Installer extends SystemService {
     */
    public void setWarnIfHeld(Object warnIfHeld) {
        mInstaller.setWarnIfHeld(warnIfHeld);
        mWarnIfHeld = warnIfHeld;
    }

    @Override
@@ -93,19 +94,22 @@ public final class Installer extends SystemService {
        mInstaller.waitForConnection();
    }

    public void createAppData(String uuid, String pkgname, int userid, int flags, int appid,
            String seinfo, int targetSdkVersion) throws InstallerException {
        if (USE_BINDER) {
    private void checkLock() {
        if (mWarnIfHeld != null && Thread.holdsLock(mWarnIfHeld)) {
            Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() + " is holding 0x"
                    + Integer.toHexString(System.identityHashCode(mWarnIfHeld)), new Throwable());
        }
    }

    public void createAppData(String uuid, String packageName, int userId, int flags, int appId,
            String seInfo, int targetSdkVersion) throws InstallerException {
        checkLock();
        try {
                mInstalld.createAppData(uuid, pkgname, userid, flags, appid, seinfo,
            mInstalld.createAppData(uuid, packageName, userId, flags, appId, seInfo,
                    targetSdkVersion);
        } catch (RemoteException | ServiceSpecificException e) {
            throw new InstallerException(e.getMessage());
        }
        } else {
            mInstaller.execute("create_app_data", uuid, pkgname, userid, flags, appid, seinfo,
                    targetSdkVersion);
        }
    }

    public void restoreconAppData(String uuid, String pkgname, int userid, int flags, int appid,
@@ -129,11 +133,16 @@ public final class Installer extends SystemService {
        mInstaller.execute("destroy_app_data", uuid, pkgname, userid, flags, ceDataInode);
    }

    public void moveCompleteApp(String from_uuid, String to_uuid, String package_name,
            String data_app_name, int appid, String seinfo, int targetSdkVersion)
    public void moveCompleteApp(String fromUuid, String toUuid, String packageName,
            String dataAppName, int appId, String seInfo, int targetSdkVersion)
            throws InstallerException {
        mInstaller.execute("move_complete_app", from_uuid, to_uuid, package_name,
                data_app_name, appid, seinfo, targetSdkVersion);
        checkLock();
        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,