| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 1 | /* |
| Michael Bestas | ec05005 | 2024-02-14 20:35:43 +0200 | [diff] [blame] | 2 | * SPDX-FileCopyrightText: 2016 The CyanogenMod Project |
| 3 | * SPDX-FileCopyrightText: 2017-2024 The LineageOS Project |
| 4 | * SPDX-License-Identifier: Apache-2.0 |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
| Michael Bestas | c83309e | 2018-02-03 17:42:13 +0200 | [diff] [blame] | 7 | package org.lineageos.setupwizard; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 8 | |
| 9 | import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION; |
| 10 | |
| Michael Bestas | c83309e | 2018-02-03 17:42:13 +0200 | [diff] [blame] | 11 | import static org.lineageos.setupwizard.SetupWizardApp.ACTION_LOAD; |
| 12 | import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_SCRIPT_URI; |
| Oliver Scott | ab9a5ea | 2024-07-16 19:33:50 -0400 | [diff] [blame] | 13 | import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_WIZARD_BUNDLE; |
| Michael Bestas | c83309e | 2018-02-03 17:42:13 +0200 | [diff] [blame] | 14 | import static org.lineageos.setupwizard.SetupWizardApp.LOGV; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 15 | |
| 16 | import android.annotation.Nullable; |
| 17 | import android.content.Intent; |
| 18 | import android.os.Bundle; |
| 19 | import android.util.Log; |
| 20 | |
| Oliver Scott | f58c0f4 | 2024-01-08 14:52:12 -0500 | [diff] [blame] | 21 | import androidx.appcompat.app.AppCompatActivity; |
| 22 | |
| Michael Bestas | c83309e | 2018-02-03 17:42:13 +0200 | [diff] [blame] | 23 | import org.lineageos.setupwizard.util.SetupWizardUtils; |
| 24 | import org.lineageos.setupwizard.wizardmanager.WizardManager; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 25 | |
| Oliver Scott | f58c0f4 | 2024-01-08 14:52:12 -0500 | [diff] [blame] | 26 | public class SetupWizardActivity extends AppCompatActivity { |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 27 | private static final String TAG = SetupWizardActivity.class.getSimpleName(); |
| 28 | |
| 29 | @Override |
| 30 | protected void onCreate(@Nullable Bundle savedInstanceState) { |
| 31 | super.onCreate(savedInstanceState); |
| 32 | if (LOGV) { |
| 33 | Log.v(TAG, "onCreate savedInstanceState=" + savedInstanceState); |
| 34 | } |
| Aaron Kling | 3ed0a33 | 2024-04-21 00:16:44 -0500 | [diff] [blame] | 35 | if (SetupWizardUtils.hasLeanback(this) && SetupWizardUtils.hasGMS(this)) { |
| 36 | finish(); |
| 37 | return; |
| 38 | } |
| Oliver Scott | feadacc | 2024-02-18 01:05:08 -0500 | [diff] [blame] | 39 | SetupWizardUtils.enableComponent(this, WizardManager.class); |
| 40 | Intent intent = new Intent(ACTION_LOAD); |
| Oliver Scott | ab9a5ea | 2024-07-16 19:33:50 -0400 | [diff] [blame] | 41 | Bundle wizardBundle = new Bundle(); |
| Oliver Scott | feadacc | 2024-02-18 01:05:08 -0500 | [diff] [blame] | 42 | if (SetupWizardUtils.isOwner()) { |
| Oliver Scott | ab9a5ea | 2024-07-16 19:33:50 -0400 | [diff] [blame] | 43 | wizardBundle.putString(EXTRA_SCRIPT_URI, getString(R.string.lineage_wizard_script_uri)); |
| Oliver Scott | feadacc | 2024-02-18 01:05:08 -0500 | [diff] [blame] | 44 | } else if (SetupWizardUtils.isManagedProfile(this)) { |
| Oliver Scott | ab9a5ea | 2024-07-16 19:33:50 -0400 | [diff] [blame] | 45 | wizardBundle.putString(EXTRA_SCRIPT_URI, |
| 46 | getString(R.string.lineage_wizard_script_managed_profile_uri)); |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 47 | } else { |
| Oliver Scott | ab9a5ea | 2024-07-16 19:33:50 -0400 | [diff] [blame] | 48 | wizardBundle.putString(EXTRA_SCRIPT_URI, |
| Oliver Scott | feadacc | 2024-02-18 01:05:08 -0500 | [diff] [blame] | 49 | getString(R.string.lineage_wizard_script_user_uri)); |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 50 | } |
| Oliver Scott | ab9a5ea | 2024-07-16 19:33:50 -0400 | [diff] [blame] | 51 | intent.putExtra(EXTRA_WIZARD_BUNDLE, wizardBundle); |
| Oliver Scott | feadacc | 2024-02-18 01:05:08 -0500 | [diff] [blame] | 52 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | FLAG_GRANT_READ_URI_PERMISSION); |
| 53 | intent.setPackage(getPackageName()); |
| 54 | startActivity(intent); |
| 55 | finish(); |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 56 | } |
| 57 | } |