Home | History | Annotate | Download | only in devicepolicy
      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 package com.android.cts.devicepolicy;
     17 
     18 public class DeviceAdminHelper {
     19 
     20     private static final String ADMIN_RECEIVER_TEST_CLASS = "BaseDeviceAdminTest$AdminReceiver";
     21 
     22     private static final String UNPROTECTED_ADMIN_RECEIVER_TEST_CLASS =
     23             "DeviceAdminReceiverWithNoProtection";
     24 
     25     /** returns "com.android.cts.deviceadmin" */
     26     static String getDeviceAdminJavaPackage() {
     27         return "com.android.cts.deviceadmin";
     28     }
     29 
     30     /** e.g. CtsDeviceAdminApp24.apk */
     31     static String getDeviceAdminApkFileName(int targetApiVersion) {
     32         return "CtsDeviceAdminApp" + targetApiVersion + ".apk";
     33     }
     34 
     35     /** e.g. "com.android.cts.deviceadmin24" */
     36     static String getDeviceAdminApkPackage(int targetApiVersion) {
     37         return getDeviceAdminJavaPackage() + targetApiVersion;
     38     }
     39 
     40     /**
     41      * e.g.
     42      * "com.android.cts.deviceadmin24/com.android.cts.deviceadmin.BaseDeviceAdminTest$AdminReceiver"
     43      */
     44     static String getAdminReceiverComponent(int targetApiVersion) {
     45         return getDeviceAdminApkPackage(targetApiVersion) + "/" + getDeviceAdminJavaPackage() + "."
     46                 + ADMIN_RECEIVER_TEST_CLASS;
     47     }
     48 
     49     /**
     50      * e.g.
     51      * "com.android.cts.deviceadmin24/com.android.cts.deviceadmin.DeviceAdminReceiverWithNoProtection"
     52      */
     53      static String getUnprotectedAdminReceiverComponent(int targetApiVersion) {
     54         return getDeviceAdminApkPackage(targetApiVersion) + "/" + getDeviceAdminJavaPackage()
     55                 + "." + UNPROTECTED_ADMIN_RECEIVER_TEST_CLASS;
     56     }
     57 }
     58