1 /* 2 * Copyright 2021 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 * https://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.google.android.enterprise.connectedapps; 17 18 import org.checkerframework.checker.nullness.qual.Nullable; 19 20 /** Utility methods for dealing with profile awareness. */ 21 public interface ConnectedAppsUtils { 22 /** 23 * Get the identifier of the current profile. 24 * 25 * <p>For use with {@code profile(int profileIdentifier) calls. 26 * 27 * <p>These values may change between runs of your app and should not be persisted. 28 */ getCurrentProfile()29 Profile getCurrentProfile(); 30 31 /** 32 * Get the identifier of the other profile. 33 * 34 * <p>For use with {@code profile(int profileIdentifier) calls. 35 * 36 * <p>These values may change between runs of your app and should not be persisted. 37 */ getOtherProfile()38 Profile getOtherProfile(); 39 40 /** 41 * Get the identifier of the primary profile. 42 * 43 * <p>For use with {@code profile(int profileIdentifier) calls. 44 * 45 * <p>These values may change between runs of your app and should not be persisted. 46 * 47 * @throws IllegalStateException if the used connector has not set a primary profile. 48 */ 49 @Nullable getPrimaryProfile()50 Profile getPrimaryProfile(); 51 52 /** 53 * Get the identifier of the primary profile. 54 * 55 * <p>For use with {@code profile(int profileIdentifier) calls. 56 * 57 * <p>These values may change between runs of your app and should not be persisted. 58 * 59 * @throws IllegalStateException if the used connector has not set a primary profile. 60 */ 61 @Nullable getSecondaryProfile()62 Profile getSecondaryProfile(); 63 64 /** 65 * Get the identifier of the work profile. 66 * 67 * <p>For use with {@code profile(int profileIdentifier) calls. 68 * 69 * <p>These values may change between runs of your app and should not be persisted. 70 */ getWorkProfile()71 Profile getWorkProfile(); 72 73 /** 74 * Get the identifier of the personal profile. 75 * 76 * <p>For use with {@code profile(int profileIdentifier) calls. 77 * 78 * <p>These values may change between runs of your app and should not be persisted. 79 */ getPersonalProfile()80 Profile getPersonalProfile(); 81 82 /** Return true if the current profile is the personal profile. */ runningOnPersonal()83 boolean runningOnPersonal(); 84 85 /** Return true if the current profile is the work profile. */ runningOnWork()86 boolean runningOnWork(); 87 } 88