1 /* 2 * Copyright (C) 2021 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 com.android.cts.packagemanager.verify.domain.java 18 19 object DomainUtils { 20 private const val BASE_PACKAGE = "com.android.cts.packagemanager.verify.domain" 21 22 const val DOMAIN_TLD = "pmctstesting" 23 const val DOMAIN_1 = "$BASE_PACKAGE.1.$DOMAIN_TLD" 24 const val DOMAIN_2 = "$BASE_PACKAGE.2.$DOMAIN_TLD" 25 const val DOMAIN_3 = "$BASE_PACKAGE.3.$DOMAIN_TLD" 26 const val DOMAIN_7 = "$BASE_PACKAGE.7.$DOMAIN_TLD" 27 const val DOMAIN_UNHANDLED = "$BASE_PACKAGE.unhandled.$DOMAIN_TLD" 28 29 const val CALLING_PKG_NAME = "$BASE_PACKAGE.callingapp" 30 31 const val DECLARING_PKG_NAME_BASE = "$BASE_PACKAGE.declaringapp" 32 private const val DECLARING_PKG_APK_BASE = "CtsDomainVerificationTestDeclaringApp" 33 34 const val DECLARING_PKG_NAME_1 = "${DECLARING_PKG_NAME_BASE}1" 35 val DECLARING_PKG_APK_1 = ApkName("${DECLARING_PKG_APK_BASE}1.apk") 36 37 const val DECLARING_PKG_NAME_2 = "${DECLARING_PKG_NAME_BASE}2" 38 val DECLARING_PKG_APK_2 = ApkName("${DECLARING_PKG_APK_BASE}2.apk") 39 40 inline class ApkName(val value: String) 41 42 val ALL_PACKAGES = listOf(CALLING_PKG_NAME, DECLARING_PKG_NAME_1, DECLARING_PKG_NAME_2) 43 resetAppLinksnull44 fun resetAppLinks(packageName: String) = "pm reset-app-links $packageName" 45 46 fun setAppLinks(packageName: String, state: String, vararg domains: String) = 47 "pm set-app-links --package $packageName $state " + 48 domains.joinToString(separator = " ") 49 50 fun setAppLinksAllowed(packageName: String, userId: Int, enabled: Boolean) = 51 "pm set-app-links-allowed --package $packageName --user $userId $enabled" 52 53 fun setAppLinksUserSelection( 54 packageName: String, 55 userId: Int, 56 enabled: Boolean, 57 vararg domains: String 58 ) = "pm set-app-links-user-selection --package $packageName --user $userId $enabled " + 59 domains.joinToString(separator = " ") 60 } 61