• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2013, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <sys/types.h>
18 
19 #include <utils/Singleton.h>
20 
21 #include <binder/BinderService.h>
22 #include <binder/Parcel.h>
23 
24 #include "ConnectivityManager.h"
25 
26 namespace android {
27 
ConnectivityManager()28 ConnectivityManager::ConnectivityManager() {
29     const sp<IServiceManager> sm(defaultServiceManager());
30     if (sm != NULL) {
31         const String16 name("connectivity");
32         mConnectivityService = sm->getService(name);
33     }
34 }
35 
markSocketAsUserImpl(int fd,uid_t uid)36 void ConnectivityManager::markSocketAsUserImpl(int fd, uid_t uid) {
37     Parcel data, reply;
38     data.writeInterfaceToken(DESCRIPTOR);
39     // parcelable objects are preceded by a 1 if not null in aidl generated code.
40     // Play nice with the generated Java
41     data.writeInt32(1);
42     data.writeFileDescriptor(fd);
43     data.writeInt32(uid);
44     mConnectivityService->transact(TRANSACTION_markSocketAsUser, data, &reply, 0);
45 }
46 
47 const String16 ConnectivityManager::DESCRIPTOR("android.net.IConnectivityManager");
48 
49 ANDROID_SINGLETON_STATIC_INSTANCE(ConnectivityManager)
50 
51 };
52