blob: e769425970ebefce67a50560b62daf396c1e37bb [file] [log] [blame]
cretin45d4cea552016-04-25 11:00:04 -07001/*
2 * Copyright (C) 2016 The CyanogenMod Project
Timi Rautamäki5e2f7f22021-08-21 08:58:14 +00003 * Copyright (C) 2017-2021 The LineageOS Project
cretin45d4cea552016-04-25 11:00:04 -07004 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
Michael Bestasc83309e2018-02-03 17:42:13 +020018package org.lineageos.setupwizard;
cretin45d4cea552016-04-25 11:00:04 -070019
20import android.os.Bundle;
21import android.widget.ImageView;
22
Chirayu Desai0ebdabe2019-09-13 01:12:59 +053023import com.google.android.setupcompat.util.ResultCodes;
cretin45d4cea552016-04-25 11:00:04 -070024
Michael Bestasc83309e2018-02-03 17:42:13 +020025import org.lineageos.setupwizard.util.PhoneMonitor;
Oliver Scott1167c042020-12-28 20:53:59 -050026import org.lineageos.setupwizard.util.SetupWizardUtils;
cretin45d4cea552016-04-25 11:00:04 -070027
28public class SimMissingActivity extends BaseSetupWizardActivity {
29
30 public static final String TAG = SimMissingActivity.class.getSimpleName();
31
32 private static final int SIM_DEFAULT = 0;
33 private static final int SIM_SIDE = 1;
34 private static final int SIM_BACK = 2;
35
36 private PhoneMonitor mPhoneMonitor;
37
38 @Override
39 protected void onCreate(Bundle savedInstanceState) {
40 super.onCreate(savedInstanceState);
41 mPhoneMonitor = PhoneMonitor.getInstance();
42 if (!mPhoneMonitor.simMissing()) {
43 finishAction(RESULT_OK);
44 }
cretin45d4cea552016-04-25 11:00:04 -070045 final int simLocation = getResources().getInteger(
46 R.integer.sim_image_type);
47 ImageView simLogo = ((ImageView)findViewById(R.id.sim_slot_image));
48 switch (simLocation) {
49 case SIM_SIDE:
50 simLogo.setImageResource(R.drawable.sim_side);
51 break;
52 case SIM_BACK:
53 simLogo.setImageResource(R.drawable.sim_back);
54 break;
55 default:
56 simLogo.setImageResource(R.drawable.sim);
57 simLogo.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
58 }
59 }
60
61 @Override
Oliver Scott1167c042020-12-28 20:53:59 -050062 protected void onResume() {
63 super.onResume();
64 SetupWizardUtils.enableComponent(this, ChooseDataSimActivity.class);
65 SetupWizardUtils.enableComponent(this, MobileDataActivity.class);
66 }
67
68 @Override
cretin45d4cea552016-04-25 11:00:04 -070069 public void onNavigateNext() {
70 if (mPhoneMonitor.simMissing()) {
Oliver Scott1167c042020-12-28 20:53:59 -050071 SetupWizardUtils.disableComponent(this, ChooseDataSimActivity.class);
72 SetupWizardUtils.disableComponent(this, MobileDataActivity.class);
Oliver Scott7e04f9c2021-08-24 14:52:10 -040073 } else if (!mPhoneMonitor.isMultiSimDevice() || mPhoneMonitor.singleSimInserted()) {
74 SetupWizardUtils.disableComponent(this, ChooseDataSimActivity.class);
cretin45d4cea552016-04-25 11:00:04 -070075 }
Oliver Scott1167c042020-12-28 20:53:59 -050076 super.onNavigateNext();
cretin45d4cea552016-04-25 11:00:04 -070077 }
78
79 @Override
cretin45d4cea552016-04-25 11:00:04 -070080 protected int getLayoutResId() {
81 return R.layout.sim_missing_page;
82 }
83
84 @Override
85 protected int getTitleResId() {
86 return R.string.setup_sim_missing;
87 }
88
89 @Override
90 protected int getIconResId() {
91 return R.drawable.ic_sim;
92 }
93
94}