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

Commit 7531a28e authored by Etan Cohen's avatar Etan Cohen
Browse files

[NAN] Provide calling package name to service

Useful for permission checks.

Bug: 30000323
Change-Id: I8c7f06cff346437aa24ca5da9822cbd7b20c59c4
parent 009b1fcb
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -491,15 +491,15 @@ final class SystemServiceRegistry {
            }});

        registerService(Context.WIFI_NAN_SERVICE, WifiNanManager.class,
                new StaticServiceFetcher<WifiNanManager>() {
                new CachedServiceFetcher<WifiNanManager>() {
            @Override
            public WifiNanManager createService() {
            public WifiNanManager createService(ContextImpl ctx) {
                IBinder b = ServiceManager.getService(Context.WIFI_NAN_SERVICE);
                IWifiNanManager service = IWifiNanManager.Stub.asInterface(b);
                if (service == null) {
                    return null;
                }
                return new WifiNanManager(service);
                return new WifiNanManager(ctx.getOuterContext(), service);
            }});

        registerService(Context.WIFI_SCANNING_SERVICE, WifiScanner.class,
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ interface IWifiNanManager
    boolean isUsageEnabled();

    // client API
    int connect(in IBinder binder, in IWifiNanEventCallback callback,
    int connect(in IBinder binder, in String callingPackage, in IWifiNanEventCallback callback,
            in ConfigRequest configRequest);
    void disconnect(int clientId, in IBinder binder);

+5 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.Nullable;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkRequest;
import android.net.wifi.RttManager;
@@ -220,6 +221,7 @@ public class WifiNanManager {

    public static final int WIFI_NAN_DATA_PATH_ROLE_RESPONDER = 1;

    private final Context mContext;
    private final IWifiNanManager mService;

    private final Object mLock = new Object(); // lock access to the following vars
@@ -239,7 +241,8 @@ public class WifiNanManager {
    /**
     * {@hide}
     */
    public WifiNanManager(IWifiNanManager service) {
    public WifiNanManager(Context context, IWifiNanManager service) {
        mContext = context;
        mService = service;
    }

@@ -324,7 +327,7 @@ public class WifiNanManager {
            mLooper = looper;

            try {
                mClientId = mService.connect(mBinder,
                mClientId = mService.connect(mBinder, mContext.getOpPackageName(),
                        new WifiNanEventCallbackProxy(this, looper, callback), configRequest);
            } catch (RemoteException e) {
                mClientId = INVALID_CLIENT_ID;