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

Commit 3002b572 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Migrate clients from Binder.waitForService to...

Merge "Migrate clients from Binder.waitForService to ServiceManager.waitForService" into rvc-dev am: 8f0b08f1 am: 7bb412a0

Change-Id: I10bbc4057ad354f0d6c3dcba94e45fe081995a9e
parents ed08ec65 7bb412a0
Loading
Loading
Loading
Loading
+0 −9
Original line number Original line Diff line number Diff line
@@ -1202,13 +1202,4 @@ public class Binder implements IBinder {
        StrictMode.clearGatheredViolations();
        StrictMode.clearGatheredViolations();
        return res;
        return res;
    }
    }

    /**
     * Returns the specified service from servicemanager. If the service is not running,
     * servicemanager will attempt to start it, and this function will wait for it to be ready.
     * Returns nullptr only if there are permission problems or fatal errors.
     * @hide
     */
    public static final native @Nullable IBinder waitForService(@NonNull String serviceName)
            throws RemoteException;
}
}
+0 −26
Original line number Original line Diff line number Diff line
@@ -1036,31 +1036,6 @@ static void android_os_Binder_blockUntilThreadAvailable(JNIEnv* env, jobject cla
    return IPCThreadState::self()->blockUntilThreadAvailable();
    return IPCThreadState::self()->blockUntilThreadAvailable();
}
}


static jobject android_os_Binder_waitForService(
        JNIEnv *env,
        jclass /* clazzObj */,
        jstring serviceNameObj) {

    const jchar* serviceName = env->GetStringCritical(serviceNameObj, nullptr);
    if (!serviceName) {
        signalExceptionForError(env, nullptr, BAD_VALUE, true /*canThrowRemoteException*/);
        return nullptr;
    }
    String16 nameCopy = String16(reinterpret_cast<const char16_t *>(serviceName),
            env->GetStringLength(serviceNameObj));
    env->ReleaseStringCritical(serviceNameObj, serviceName);

    auto sm = android::defaultServiceManager();
    sp<IBinder> service = sm->waitForService(nameCopy);

    if (!service) {
        signalExceptionForError(env, nullptr, NAME_NOT_FOUND, true /*canThrowRemoteException*/);
        return nullptr;
    }

    return javaObjectForIBinder(env, service);
}

static jobject android_os_Binder_getExtension(JNIEnv* env, jobject obj) {
static jobject android_os_Binder_getExtension(JNIEnv* env, jobject obj) {
    JavaBBinderHolder* jbh = (JavaBBinderHolder*) env->GetLongField(obj, gBinderOffsets.mObject);
    JavaBBinderHolder* jbh = (JavaBBinderHolder*) env->GetLongField(obj, gBinderOffsets.mObject);
    return javaObjectForIBinder(env, jbh->getExtension());
    return javaObjectForIBinder(env, jbh->getExtension());
@@ -1101,7 +1076,6 @@ static const JNINativeMethod gBinderMethods[] = {
    { "getNativeBBinderHolder", "()J", (void*)android_os_Binder_getNativeBBinderHolder },
    { "getNativeBBinderHolder", "()J", (void*)android_os_Binder_getNativeBBinderHolder },
    { "getNativeFinalizer", "()J", (void*)android_os_Binder_getNativeFinalizer },
    { "getNativeFinalizer", "()J", (void*)android_os_Binder_getNativeFinalizer },
    { "blockUntilThreadAvailable", "()V", (void*)android_os_Binder_blockUntilThreadAvailable },
    { "blockUntilThreadAvailable", "()V", (void*)android_os_Binder_blockUntilThreadAvailable },
    { "waitForService", "(Ljava/lang/String;)Landroid/os/IBinder;", (void*)android_os_Binder_waitForService },
    { "getExtension", "()Landroid/os/IBinder;", (void*)android_os_Binder_getExtension },
    { "getExtension", "()Landroid/os/IBinder;", (void*)android_os_Binder_getExtension },
    { "setExtension", "(Landroid/os/IBinder;)V", (void*)android_os_Binder_setExtension },
    { "setExtension", "(Landroid/os/IBinder;)V", (void*)android_os_Binder_setExtension },
};
};
+2 −1
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import android.gsi.IGsiServiceCallback;
import android.os.Environment;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserHandle;
import android.os.image.IDynamicSystemService;
import android.os.image.IDynamicSystemService;
@@ -55,7 +56,7 @@ public class DynamicSystemService extends IDynamicSystemService.Stub {
        if (mGsiService != null) {
        if (mGsiService != null) {
            return mGsiService;
            return mGsiService;
        }
        }
        return IGsiService.Stub.asInterface(waitForService("gsiservice"));
        return IGsiService.Stub.asInterface(ServiceManager.waitForService("gsiservice"));
    }
    }


    private void checkPermission() {
    private void checkPermission() {
+4 −7
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ import android.content.pm.parsing.PackageInfoWithoutStateUtils;
import android.os.Binder;
import android.os.Binder;
import android.os.Environment;
import android.os.Environment;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.Trace;
import android.os.Trace;
import android.sysprop.ApexProperties;
import android.sysprop.ApexProperties;
import android.util.ArrayMap;
import android.util.ArrayMap;
@@ -398,13 +399,9 @@ public abstract class ApexManager {
         */
         */
        @VisibleForTesting
        @VisibleForTesting
        protected IApexService waitForApexService() {
        protected IApexService waitForApexService() {
            try {
            // Since apexd is a trusted platform component, synchronized calls are allowable
            // Since apexd is a trusted platform component, synchronized calls are allowable
            return IApexService.Stub.asInterface(
            return IApexService.Stub.asInterface(
                        Binder.allowBlocking(Binder.waitForService("apexservice")));
                    Binder.allowBlocking(ServiceManager.waitForService("apexservice")));
            } catch (RemoteException e) {
                throw new IllegalStateException("Required service apexservice not available");
            }
        }
        }


        @Override
        @Override