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.imsserviceentitlement; 18 19 import android.content.Intent; 20 import android.telephony.SubscriptionManager; 21 import android.util.Log; 22 23 /** 24 * Constants shared by framework to start WFC activation activity. 25 * 26 * <p>Must match with WifiCallingSettings. 27 */ 28 public final class ActivityConstants { 29 public static final String TAG = "IMSSE-ActivityConstants"; 30 31 /** Constants shared by WifiCallingSettings */ 32 public static final String EXTRA_LAUNCH_CARRIER_APP = "EXTRA_LAUNCH_CARRIER_APP"; 33 34 public static final int LAUNCH_APP_ACTIVATE = 0; 35 public static final int LAUNCH_APP_UPDATE = 1; 36 public static final int LAUNCH_APP_SHOW_TC = 2; 37 38 /** 39 * Returns {@code true} if the app is launched for WFC activation; {@code false} for emergency 40 * address update or displaying terms & conditions. 41 */ isActivationFlow(Intent intent)42 public static boolean isActivationFlow(Intent intent) { 43 int intention = getLaunchIntention(intent); 44 Log.d(TAG, "Start Activity intention : " + intention); 45 return intention == LAUNCH_APP_ACTIVATE; 46 } 47 48 /** Returns the launch intention extra in the {@code intent}. */ getLaunchIntention(Intent intent)49 public static int getLaunchIntention(Intent intent) { 50 if (intent == null) { 51 return LAUNCH_APP_ACTIVATE; 52 } 53 54 return intent.getIntExtra(EXTRA_LAUNCH_CARRIER_APP, LAUNCH_APP_ACTIVATE); 55 } 56 57 /** Returns the subscription id of starting the WFC activation activity. */ getSubId(Intent intent)58 public static int getSubId(Intent intent) { 59 if (intent == null) { 60 return SubscriptionManager.INVALID_SUBSCRIPTION_ID; 61 } 62 int subId = 63 intent.getIntExtra( 64 SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, 65 SubscriptionManager.INVALID_SUBSCRIPTION_ID); 66 Log.d(TAG, "Start Activity with subId : " + subId); 67 return subId; 68 } 69 ActivityConstants()70 private ActivityConstants() {} 71 } 72