1 /*
2  * Copyright (C) 2019 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.phone.euicc;
17 
18 import android.annotation.Nullable;
19 import android.content.Intent;
20 import android.service.euicc.EuiccService;
21 import android.telephony.euicc.EuiccManager;
22 import android.util.Log;
23 
24 /**
25  * Trampoline activity to forward privileged eUICC intents from the system to the active UI
26  * implementation.
27  *
28  * <p>Unlike {@link EuiccUiDispatcherActivity}, this activity requires a locked-down permission to
29  * start.
30  */
31 public class EuiccPrivilegedActionUiDispatcherActivity extends EuiccUiDispatcherActivity {
32     private static final String TAG = "EuiccPrivUiDispatcher";
33 
34     @Override
35     @Nullable
getEuiccUiIntent()36     protected Intent getEuiccUiIntent() {
37         String action = getIntent().getAction();
38 
39         Intent intent = new Intent();
40         // Propagate the extras from the original Intent.
41         intent.putExtras(getIntent());
42         switch (action) {
43             case EuiccManager.ACTION_TOGGLE_SUBSCRIPTION_PRIVILEGED:
44                 intent.setAction(EuiccService.ACTION_TOGGLE_SUBSCRIPTION_PRIVILEGED);
45                 break;
46             case EuiccManager.ACTION_DELETE_SUBSCRIPTION_PRIVILEGED:
47                 intent.setAction(EuiccService.ACTION_DELETE_SUBSCRIPTION_PRIVILEGED);
48                 break;
49             case EuiccManager.ACTION_RENAME_SUBSCRIPTION_PRIVILEGED:
50                 intent.setAction(EuiccService.ACTION_RENAME_SUBSCRIPTION_PRIVILEGED);
51                 break;
52             default:
53                 Log.w(TAG, "Unsupported action: " + action);
54                 return null;
55         }
56 
57         return intent;
58     }
59 }
60