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

Commit 39e09ae2 authored by Alice Wang's avatar Alice Wang
Browse files

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

This fixes a crash in 3p libraries.

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

Bug: 354674329
Bug: 355187769
Test: Run the demo app in b/354674329 and check it works
Change-Id: Ie7f5556b48f87546e1b427d5408120acd9aeea9f
parent e90a4d26
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -425,7 +425,7 @@ public final class ServiceManager {
    private static IBinder rawGetService(String name) throws RemoteException {
        final long start = sStatLogger.getTime();

        final IBinder binder = getIServiceManager().getService(name).getBinder();
        final IBinder binder = getIServiceManager().getService2(name).getBinder();

        final int time = (int) sStatLogger.logDurationStat(Stats.GET_SERVICE, start);

+7 −1
Original line number Diff line number Diff line
@@ -57,8 +57,14 @@ class ServiceManagerProxy implements IServiceManager {
        return mRemote;
    }

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

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