1
2// Copyright 2023 Google LLC
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
16syntax = "proto3";
17
18package com.android.server.sdksandbox.proto;
19
20message AllowedApisPerTargetSdk {
21    // Map from targetSdkVersion to allowlist
22    map<int64, AllowedApisList> allowlist_per_target_sdk = 1;
23}
24
25message AllowedApisList {
26    repeated AllowedApi allowed_apis = 1;
27}
28// Rules are applied based on longest matching prefix, so specific rules will
29// have precedence over general rules and literal match takes precedence over
30// wildcard match. For example:
31//{
32//     allow : false
33//     class_name : "Landroid/view/Display"
34//     method_name : "getFlags"
35// }
36// takes precedence over
37// {
38//     allow : false
39//     class_name : "Landroid/view/Display"
40// }
41// and the latter takes precedence over
42// {
43//     allow : true
44//     class_name : "Landroid/view/*"
45// }
46message AllowedApi {
47    // If true, a match with this rule allows the usage.
48    bool allow = 1;
49    // Full name of the class, supports wildcards after a divider (/*)
50    // to match a package.
51    string class_name = 2;
52    // If empty, this matches any method.
53    string method_name = 3;
54    // If empty, this matches any parameter type list. To match only
55    // methods without parameters, a single parameter "V" should be added.
56    repeated string parameters = 4;
57    // If empty matches any return type. This should be used to get only
58    // one of the overloads of a function.
59    string return_type = 5;
60}
61