Merge "[NAN] Provide calling package name to service" into mm-wireless-dev

This commit is contained in:
Etan Cohen
2016-08-19 17:23:15 +00:00
committed by Android Partner Code Review
3 changed files with 9 additions and 6 deletions

View File

@@ -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,

View File

@@ -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);

View File

@@ -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;
@@ -222,6 +223,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 CloseGuard mCloseGuard = CloseGuard.get();
@@ -242,7 +244,8 @@ public class WifiNanManager {
/**
* {@hide}
*/
public WifiNanManager(IWifiNanManager service) {
public WifiNanManager(Context context, IWifiNanManager service) {
mContext = context;
mService = service;
}
@@ -327,7 +330,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;