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

Commit 2ebe45c9 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: Ibed2c8ab7499e7a8bda2286397f61bb259e2acf4
parents 6b773441 7bb412a0
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -1204,13 +1204,4 @@ public class Binder implements IBinder {
        StrictMode.clearGatheredViolations();
        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 Diff line number Diff line
@@ -1036,31 +1036,6 @@ static void android_os_Binder_blockUntilThreadAvailable(JNIEnv* env, jobject cla
    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) {
    JavaBBinderHolder* jbh = (JavaBBinderHolder*) env->GetLongField(obj, gBinderOffsets.mObject);
    return javaObjectForIBinder(env, jbh->getExtension());
@@ -1101,7 +1076,6 @@ static const JNINativeMethod gBinderMethods[] = {
    { "getNativeBBinderHolder", "()J", (void*)android_os_Binder_getNativeBBinderHolder },
    { "getNativeFinalizer", "()J", (void*)android_os_Binder_getNativeFinalizer },
    { "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 },
    { "setExtension", "(Landroid/os/IBinder;)V", (void*)android_os_Binder_setExtension },
};
+2 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.gsi.IGsiServiceCallback;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.image.IDynamicSystemService;
@@ -55,7 +56,7 @@ public class DynamicSystemService extends IDynamicSystemService.Stub {
        if (mGsiService != null) {
            return mGsiService;
        }
        return IGsiService.Stub.asInterface(waitForService("gsiservice"));
        return IGsiService.Stub.asInterface(ServiceManager.waitForService("gsiservice"));
    }

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

        @Override