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

Commit 9f78536d authored by Alice Wang's avatar Alice Wang
Browse files

[java] Restore ServiceManager#checkService() to return IBinder

This fixes crashes in 3p libraries.

A new API ServiceManager#checkService2() has been introduced to
work with the Service enum type.

Bug: 387175643
Test: atest servicemanager_test
Change-Id: Icc7f61772c64448de24a6e9ef12bed732e9eca8d
parent 46160a9f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -278,7 +278,7 @@ public final class ServiceManager {
                return service;
            } else {
                return Binder.allowBlocking(
                        getIServiceManager().checkService(name).getServiceWithMetadata().service);
                        getIServiceManager().checkService2(name).getServiceWithMetadata().service);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "error in checkService", e);
+11 −4
Original line number Diff line number Diff line
@@ -62,16 +62,23 @@ class ServiceManagerProxy implements IServiceManager {
    @UnsupportedAppUsage
    public IBinder getService(String name) throws RemoteException {
        // Same as checkService (old versions of servicemanager had both methods).
        return checkService(name).getServiceWithMetadata().service;
        return checkService2(name).getServiceWithMetadata().service;
    }

    public Service getService2(String name) throws RemoteException {
        // Same as checkService (old versions of servicemanager had both methods).
        return checkService(name);
        return checkService2(name);
    }

    public Service checkService(String name) throws RemoteException {
        return mServiceManager.checkService(name);
    // TODO(b/355394904): This function has been deprecated, please use checkService2 instead.
    @UnsupportedAppUsage
    public IBinder checkService(String name) throws RemoteException {
        // Same as checkService (old versions of servicemanager had both methods).
        return checkService2(name).getServiceWithMetadata().service;
    }

    public Service checkService2(String name) throws RemoteException {
        return mServiceManager.checkService2(name);
    }

    public void addService(String name, IBinder service, boolean allowIsolated, int dumpPriority)