1 /*
2  * Copyright (C) 2020 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.telephonyprovider.cts;
18 
19 import android.compat.cts.CompatChangeGatingTestCase;
20 
21 import com.google.common.collect.ImmutableSet;
22 
23 /**
24  * Tests for the {@link android.app.compat.CompatChanges} SystemApi.
25  */
26 
27 public class TelephonyProviderHostTest extends CompatChangeGatingTestCase {
28 
29     protected static final String TEST_APK = "TelephonyProviderDeviceTest.apk";
30     protected static final String TEST_PKG = "android.telephonyprovider.device.cts";
31 
32     private static final long APN_READING_PERMISSION_CHANGE_ID = 124107808L;
33     private static final String FEATURE_TELEPHONY = "android.hardware.telephony";
34 
35     @Override
setUp()36     protected void setUp() throws Exception {
37         if (!getDevice().hasFeature(FEATURE_TELEPHONY)) {
38             return;
39         }
40         installPackage(TEST_APK, true);
41     }
42 
testWithChangeEnabled()43     public void testWithChangeEnabled() throws Exception {
44         if (!getDevice().hasFeature(FEATURE_TELEPHONY)) {
45             return;
46         }
47         runDeviceCompatTest(TEST_PKG, ".TelephonyProviderTest", "testAccessToApnsWithChangeEnabled",
48                 /*enabledChanges*/ImmutableSet.of(APN_READING_PERMISSION_CHANGE_ID),
49                 /*disabledChanges*/ ImmutableSet.of());
50     }
51 
testWithChangeDisabled()52     public void testWithChangeDisabled() throws Exception {
53         if (!getDevice().hasFeature(FEATURE_TELEPHONY)) {
54             return;
55         }
56         runDeviceCompatTest(TEST_PKG, ".TelephonyProviderTest",
57                 "testAccessToApnsWithChangeDisabled",
58                 /*enabledChanges*/ImmutableSet.of(),
59                 /*disabledChanges*/ ImmutableSet.of(APN_READING_PERMISSION_CHANGE_ID));
60     }
61 }
62