[NAN] Provide calling package name to service
Useful for permission checks.
Bug: 30000323
Change-Id: I8c7f06cff346437aa24ca5da9822cbd7b20c59c4
(cherry picked from commit 7531a28e26)
This commit is contained in:
committed by
Mitchell Wills
parent
40f8b92518
commit
4503dc6fba
@@ -515,15 +515,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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user