1 /*
2  * Copyright (C) 2017 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 package android.net;
18 
19 /**
20  * Describes specific properties of a network for use in a {@link NetworkRequest}.
21  *
22  * Applications cannot instantiate this class by themselves, but can obtain instances of
23  * subclasses of this class via other APIs.
24  */
25 public abstract class NetworkSpecifier {
26     /** @hide */
NetworkSpecifier()27     public NetworkSpecifier() {}
28 
29     /**
30      * Returns true if a request with this {@link NetworkSpecifier} is satisfied by a network
31      * with the given NetworkSpecifier.
32      *
33      * @hide
34      */
satisfiedBy(NetworkSpecifier other)35     public abstract boolean satisfiedBy(NetworkSpecifier other);
36 
37     /**
38      * Optional method which can be overriden by concrete implementations of NetworkSpecifier to
39      * check a self-reported UID. A concrete implementation may contain a UID which would be self-
40      * reported by the caller (since NetworkSpecifier implementations should be non-mutable). This
41      * function is called by ConnectivityService and is passed the actual UID of the caller -
42      * allowing the verification of the self-reported UID. In cases of mismatch the implementation
43      * should throw a SecurityException.
44      *
45      * @param requestorUid The UID of the requestor as obtained from its binder.
46      *
47      * @hide
48      */
assertValidFromUid(int requestorUid)49     public void assertValidFromUid(int requestorUid) {
50         // empty
51     }
52 }
53