Simplify exit code
Change-Id: Ied4a7cb143ef979fd70da81cda6472f85e750739
diff --git a/Android.bp b/Android.bp
index 51ca78b..18f8fdd 100644
--- a/Android.bp
+++ b/Android.bp
@@ -21,7 +21,6 @@
static_libs: [
"androidx.activity_activity",
- "androidx.work_work-runtime-ktx",
"SettingsLib",
"setupcompat",
"setupdesign",
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 69a15f3..e710633 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -324,9 +324,5 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
-
- <service
- android:name=".SetupWizardExitWorker"
- android:exported="false" />
</application>
</manifest>
diff --git a/res/raw/lineage_wizard_script.xml b/res/raw/lineage_wizard_script.xml
index 0befc2b..ac4f5a8 100644
--- a/res/raw/lineage_wizard_script.xml
+++ b/res/raw/lineage_wizard_script.xml
@@ -16,6 +16,7 @@
<WizardAction
wizard:uri="intent:#Intent;action=org.lineageos.setupwizard.LINEAGE_WELCOME;end"
id="welcome">
+ <result wizard:name="skip" wizard:resultCode="1" />
<result wizard:action="locale" />
</WizardAction>
diff --git a/res/raw/lineage_wizard_script_managed_profile.xml b/res/raw/lineage_wizard_script_managed_profile.xml
index 6a4d1e5..36f80c6 100644
--- a/res/raw/lineage_wizard_script_managed_profile.xml
+++ b/res/raw/lineage_wizard_script_managed_profile.xml
@@ -11,6 +11,7 @@
<WizardAction
wizard:uri="intent:#Intent;action=org.lineageos.setupwizard.LINEAGE_WELCOME;end"
id="welcome">
+ <result wizard:name="skip" wizard:resultCode="1" />
<result wizard:action="restore" />
</WizardAction>
diff --git a/res/raw/lineage_wizard_script_user.xml b/res/raw/lineage_wizard_script_user.xml
index aef7f2e..f0ff14e 100644
--- a/res/raw/lineage_wizard_script_user.xml
+++ b/res/raw/lineage_wizard_script_user.xml
@@ -10,6 +10,7 @@
<WizardAction
wizard:uri="intent:#Intent;action=org.lineageos.setupwizard.LINEAGE_WELCOME;end"
id="welcome">
+ <result wizard:name="skip" wizard:resultCode="1" />
<result wizard:action="restore" />
</WizardAction>
diff --git a/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java b/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java
index b0e52d5..5a64abb 100644
--- a/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java
+++ b/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java
@@ -10,15 +10,11 @@
import static com.google.android.setupcompat.util.ResultCodes.RESULT_SKIP;
-import static org.lineageos.setupwizard.SetupWizardApp.ACTION_SETUP_COMPLETE;
import static org.lineageos.setupwizard.SetupWizardApp.LOGV;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.content.BroadcastReceiver;
-import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
import android.graphics.drawable.Drawable;
import android.net.wifi.WifiManager;
import android.os.Bundle;
@@ -50,18 +46,6 @@
private NavigationLayout mNavigationBar;
- private final BroadcastReceiver finishReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (ACTION_SETUP_COMPLETE.equals(intent.getAction())) {
- if (BaseSetupWizardActivity.this instanceof FinishActivity) return;
- if (mNavigationBar != null) {
- // hide the activity's view, so it does not pop up again
- mNavigationBar.getRootView().setVisibility(INVISIBLE);
- }
- }
- }
- };
private final ActivityResultLauncher<Intent> activityResultLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
BaseSetupWizardActivity.this::onActivityResult);
@@ -72,7 +56,6 @@
logActivityState("onCreate savedInstanceState=" + savedInstanceState);
}
super.onCreate(savedInstanceState);
- registerReceiver(finishReceiver, new IntentFilter(ACTION_SETUP_COMPLETE));
initLayout();
mNavigationBar = getNavigationBar();
if (mNavigationBar != null) {
@@ -136,7 +119,6 @@
if (LOGV) {
logActivityState("onDestroy");
}
- unregisterReceiver(finishReceiver);
super.onDestroy();
}
@@ -253,7 +235,7 @@
finish();
}
- protected final void nextAction(int resultCode) {
+ public final void nextAction(int resultCode) {
nextAction(resultCode, null);
}
diff --git a/src/org/lineageos/setupwizard/FinishActivity.java b/src/org/lineageos/setupwizard/FinishActivity.java
index 0427a4d..71e61ba 100644
--- a/src/org/lineageos/setupwizard/FinishActivity.java
+++ b/src/org/lineageos/setupwizard/FinishActivity.java
@@ -6,86 +6,42 @@
package org.lineageos.setupwizard;
-import static android.os.Binder.getCallingUserHandle;
-import static android.os.UserHandle.USER_CURRENT;
-
-import static org.lineageos.setupwizard.Manifest.permission.FINISH_SETUP;
-import static org.lineageos.setupwizard.SetupWizardApp.ACTION_FINISHED;
-import static org.lineageos.setupwizard.SetupWizardApp.ACTION_SETUP_COMPLETE;
-import static org.lineageos.setupwizard.SetupWizardApp.DISABLE_NAV_KEYS;
-import static org.lineageos.setupwizard.SetupWizardApp.ENABLE_RECOVERY_UPDATE;
-import static org.lineageos.setupwizard.SetupWizardApp.KEY_SEND_METRICS;
import static org.lineageos.setupwizard.SetupWizardApp.LOGV;
-import static org.lineageos.setupwizard.SetupWizardApp.NAVIGATION_OPTION_KEY;
-import static org.lineageos.setupwizard.SetupWizardApp.UPDATE_RECOVERY_PROP;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
-import android.app.WallpaperManager;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.om.IOverlayManager;
import android.content.pm.ActivityInfo;
-import android.graphics.Bitmap;
-import android.graphics.Point;
-import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
-import android.os.ServiceManager;
-import android.os.SystemProperties;
-import android.os.UserHandle;
import android.util.Log;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.Window;
-import android.widget.ImageView;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
-import lineageos.providers.LineageSettings;
-
import org.lineageos.setupwizard.util.SetupWizardUtils;
public class FinishActivity extends BaseSetupWizardActivity {
public static final String TAG = FinishActivity.class.getSimpleName();
- private ImageView mBackground;
-
- private SetupWizardApp mSetupWizardApp;
-
private final Handler mHandler = new Handler(Looper.getMainLooper());
private boolean mIsFinishing;
- private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (LOGV) {
- Log.v(TAG, "onReceive intent=" + intent);
- }
- if (intent != null && intent.getAction().equals(ACTION_FINISHED)) {
- unregisterReceiver(mIntentReceiver);
- completeSetup();
- }
- }
- };
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- overridePendingTransition(R.anim.translucent_enter, R.anim.translucent_exit);
+ overrideActivityTransition(OVERRIDE_TRANSITION_CLOSE, R.anim.translucent_enter,
+ R.anim.translucent_exit);
if (LOGV) {
logActivityState("onCreate savedInstanceState=" + savedInstanceState);
}
- mSetupWizardApp = (SetupWizardApp) getApplication();
- mBackground = findViewById(R.id.background);
setNextText(R.string.start);
// Edge-to-edge. Needed for the background view to fill the full screen.
@@ -126,15 +82,6 @@
}
mIsFinishing = true;
- // Listen for completion from the exit service.
- IntentFilter filter = new IntentFilter();
- filter.addAction(ACTION_FINISHED);
- registerReceiver(mIntentReceiver, filter, null, null);
-
- Intent i = new Intent(ACTION_SETUP_COMPLETE);
- i.setPackage(getPackageName());
- sendBroadcastAsUser(i, getCallingUserHandle(), FINISH_SETUP);
-
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
hideNextButton();
@@ -163,77 +110,10 @@
if (LOGV) {
Log.v(TAG, "Animation ended");
}
- // Start exit procedures, including the exit service.
- SetupWizardUtils.startSetupWizardExitProcedure(FinishActivity.this);
+ SetupWizardUtils.finishSetupWizard(FinishActivity.this);
});
}
});
anim.start();
}
-
- private void completeSetup() {
- handleEnableMetrics(mSetupWizardApp);
- handleNavKeys(mSetupWizardApp);
- handleRecoveryUpdate(mSetupWizardApp);
- handleNavigationOption(mSetupWizardApp);
- final WallpaperManager wallpaperManager =
- WallpaperManager.getInstance(mSetupWizardApp);
- wallpaperManager.forgetLoadedWallpaper();
- finishAffinity();
- nextAction(RESULT_OK);
- SetupWizardUtils.enableStatusBar();
- Log.i(TAG, "Setup complete!");
- }
-
- private static void handleEnableMetrics(SetupWizardApp setupWizardApp) {
- Bundle privacyData = setupWizardApp.getSettingsBundle();
- if (privacyData != null
- && privacyData.containsKey(KEY_SEND_METRICS)) {
- LineageSettings.Secure.putInt(setupWizardApp.getContentResolver(),
- LineageSettings.Secure.STATS_COLLECTION,
- privacyData.getBoolean(KEY_SEND_METRICS)
- ? 1 : 0);
- }
- }
-
- private static void handleNavKeys(SetupWizardApp setupWizardApp) {
- if (setupWizardApp.getSettingsBundle().containsKey(DISABLE_NAV_KEYS)) {
- writeDisableNavkeysOption(setupWizardApp,
- setupWizardApp.getSettingsBundle().getBoolean(DISABLE_NAV_KEYS));
- }
- }
-
- private static void handleRecoveryUpdate(SetupWizardApp setupWizardApp) {
- if (setupWizardApp.getSettingsBundle().containsKey(ENABLE_RECOVERY_UPDATE)) {
- boolean update = setupWizardApp.getSettingsBundle()
- .getBoolean(ENABLE_RECOVERY_UPDATE);
-
- SystemProperties.set(UPDATE_RECOVERY_PROP, String.valueOf(update));
- }
- }
-
- private void handleNavigationOption(Context context) {
- Bundle settingsBundle = mSetupWizardApp.getSettingsBundle();
- if (settingsBundle.containsKey(NAVIGATION_OPTION_KEY)) {
- IOverlayManager overlayManager = IOverlayManager.Stub.asInterface(
- ServiceManager.getService(Context.OVERLAY_SERVICE));
- String selectedNavMode = settingsBundle.getString(NAVIGATION_OPTION_KEY);
-
- try {
- overlayManager.setEnabledExclusiveInCategory(selectedNavMode, USER_CURRENT);
- } catch (Exception ignored) {
- }
- }
- }
-
- private static void writeDisableNavkeysOption(Context context, boolean enabled) {
- final boolean virtualKeysEnabled = LineageSettings.System.getIntForUser(
- context.getContentResolver(), LineageSettings.System.FORCE_SHOW_NAVBAR, 0,
- UserHandle.USER_CURRENT) != 0;
- if (enabled != virtualKeysEnabled) {
- LineageSettings.System.putIntForUser(context.getContentResolver(),
- LineageSettings.System.FORCE_SHOW_NAVBAR, enabled ? 1 : 0,
- UserHandle.USER_CURRENT);
- }
- }
}
diff --git a/src/org/lineageos/setupwizard/SetupWizardApp.java b/src/org/lineageos/setupwizard/SetupWizardApp.java
index e64d6ed..34b8b1b 100644
--- a/src/org/lineageos/setupwizard/SetupWizardApp.java
+++ b/src/org/lineageos/setupwizard/SetupWizardApp.java
@@ -22,9 +22,6 @@
// Verbose logging
public static final boolean LOGV = Log.isLoggable(TAG, Log.VERBOSE);
- public static final String ACTION_FINISHED = "org.lineageos.setupwizard.SETUP_FINISHED";
- public static final String ACTION_SETUP_COMPLETE =
- "org.lineageos.setupwizard.LINEAGE_SETUP_COMPLETE";
public static final String ACTION_RESTORE_FROM_BACKUP =
"com.stevesoltys.seedvault.RESTORE_BACKUP";
public static final String ACTION_EMERGENCY_DIAL = "com.android.phone.EmergencyDialer.DIAL";
@@ -53,7 +50,7 @@
private boolean mIsRadioReady = false;
private boolean mIgnoreSimLocale = false;
- private final Bundle mSettingsBundle = new Bundle();
+ private static final Bundle mSettingsBundle = new Bundle();
private final Handler mHandler = new Handler(Looper.getMainLooper());
private final Runnable mRadioTimeoutRunnable = () -> mIsRadioReady = true;
@@ -88,7 +85,7 @@
mIgnoreSimLocale = ignoreSimLocale;
}
- public Bundle getSettingsBundle() {
+ public static Bundle getSettingsBundle() {
return mSettingsBundle;
}
}
diff --git a/src/org/lineageos/setupwizard/SetupWizardExitWorker.java b/src/org/lineageos/setupwizard/SetupWizardExitWorker.java
deleted file mode 100644
index ba72173..0000000
--- a/src/org/lineageos/setupwizard/SetupWizardExitWorker.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2024 The LineageOS Project
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package org.lineageos.setupwizard;
-
-import android.content.Context;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.work.CoroutineWorker;
-import androidx.work.WorkerParameters;
-
-import org.lineageos.setupwizard.util.SetupWizardUtils;
-
-import kotlin.coroutines.Continuation;
-
-public class SetupWizardExitWorker extends CoroutineWorker {
-
- public SetupWizardExitWorker(@NonNull Context appContext,
- @NonNull WorkerParameters params) {
- super(appContext, params);
- }
-
- @Nullable
- @Override
- public Object doWork(@NonNull Continuation<? super Result> continuation) {
- SetupWizardUtils.finishSetupWizard(getApplicationContext());
- return Result.success();
- }
-}
diff --git a/src/org/lineageos/setupwizard/util/SetupWizardUtils.java b/src/org/lineageos/setupwizard/util/SetupWizardUtils.java
index 9dfc5da..7b10a1f 100644
--- a/src/org/lineageos/setupwizard/util/SetupWizardUtils.java
+++ b/src/org/lineageos/setupwizard/util/SetupWizardUtils.java
@@ -11,59 +11,58 @@
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
import static android.content.pm.PackageManager.DONT_KILL_APP;
import static android.content.pm.PackageManager.GET_ACTIVITIES;
-import static android.content.pm.PackageManager.GET_RECEIVERS;
-import static android.content.pm.PackageManager.GET_SERVICES;
import static android.telephony.TelephonyManager.PHONE_TYPE_GSM;
-import static android.telephony.TelephonyManager.SIM_STATE_ABSENT;
import static com.android.internal.telephony.PhoneConstants.LTE_ON_CDMA_TRUE;
import static com.android.internal.telephony.PhoneConstants.LTE_ON_CDMA_UNKNOWN;
+import static com.google.android.setupcompat.util.ResultCodes.RESULT_SKIP;
+
+import static org.lineageos.setupwizard.SetupWizardApp.DISABLE_NAV_KEYS;
+import static org.lineageos.setupwizard.SetupWizardApp.ENABLE_RECOVERY_UPDATE;
+import static org.lineageos.setupwizard.SetupWizardApp.KEY_SEND_METRICS;
import static org.lineageos.setupwizard.SetupWizardApp.LOGV;
+import static org.lineageos.setupwizard.SetupWizardApp.NAVIGATION_OPTION_KEY;
+import static org.lineageos.setupwizard.SetupWizardApp.UPDATE_RECOVERY_PROP;
import android.app.StatusBarManager;
+import android.app.WallpaperManager;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.content.pm.ComponentInfo;
-import android.content.pm.PackageInfo;
+import android.content.om.IOverlayManager;
import android.content.pm.PackageManager;
-import android.content.pm.ServiceInfo;
import android.content.res.Resources;
import android.hardware.biometrics.BiometricManager;
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
-import android.os.Binder;
+import android.os.Bundle;
+import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.sysprop.TelephonyProperties;
-import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;
-import androidx.work.OneTimeWorkRequest;
-import androidx.work.OutOfQuotaPolicy;
-import androidx.work.WorkManager;
-
-import org.lineageos.internal.util.PackageManagerUtils;
+import org.lineageos.setupwizard.BaseSetupWizardActivity;
import org.lineageos.setupwizard.BiometricActivity;
import org.lineageos.setupwizard.BluetoothSetupActivity;
import org.lineageos.setupwizard.NetworkSetupActivity;
import org.lineageos.setupwizard.ScreenLockActivity;
import org.lineageos.setupwizard.SetupWizardApp;
-import org.lineageos.setupwizard.SetupWizardExitWorker;
import org.lineageos.setupwizard.SimMissingActivity;
import java.io.File;
-import java.util.ArrayList;
import java.util.List;
+import lineageos.providers.LineageSettings;
+
public class SetupWizardUtils {
private static final String TAG = SetupWizardUtils.class.getSimpleName();
@@ -153,8 +152,8 @@
public static boolean hasGMS(Context context) {
String gmsSuwPackage = hasLeanback(context) ? GMS_TV_SUW_PACKAGE : GMS_SUW_PACKAGE;
- if (PackageManagerUtils.isAppInstalled(context, GMS_PACKAGE) &&
- PackageManagerUtils.isAppInstalled(context, gmsSuwPackage)) {
+ if (isPackageInstalled(context, GMS_PACKAGE) &&
+ isPackageInstalled(context, gmsSuwPackage)) {
PackageManager packageManager = context.getPackageManager();
if (LOGV) {
Log.v(TAG, GMS_SUW_PACKAGE + " state = " +
@@ -176,21 +175,7 @@
}
}
- public static void startSetupWizardExitProcedure(Context context) {
- try {
- WorkManager.getInstance(context).enqueue(new OneTimeWorkRequest.Builder(
- SetupWizardExitWorker.class).setExpedited(
- OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST).build());
- } catch (IllegalArgumentException e) {
- // finishSetupWizard -- called by the exit worker -- disables components at the end,
- // including the WorkManager component required here, so this is likely an error finding
- // that component. The worker only needs to run once. We can assume it already has.
- Log.w(TAG, "Could not start SetupWizardExitWorker. It has likely already run.", e);
- return;
- }
- }
-
- public static void finishSetupWizard(Context context) {
+ public static void finishSetupWizard(BaseSetupWizardActivity context) {
if (LOGV) {
Log.v(TAG, "finishSetupWizard");
}
@@ -210,20 +195,16 @@
Settings.Secure.TV_USER_SETUP_COMPLETE, 1);
}
- disableComponentsAndSendFinishedBroadcast(context);
- }
-
- private static void disableComponentsAndSendFinishedBroadcast(Context context) {
- if (LOGV) {
- Log.v(TAG, "Disabling Setup Wizard components and sending FINISHED broadcast.");
- }
+ handleEnableMetrics(context);
+ handleNavKeys(context);
+ handleRecoveryUpdate();
+ handleNavigationOption();
+ WallpaperManager.getInstance(context).forgetLoadedWallpaper();
disableHome(context);
- context.sendStickyBroadcastAsUser(
- new Intent(SetupWizardApp.ACTION_FINISHED),
- Binder.getCallingUserHandle());
- disableComponentSets(context, GET_RECEIVERS | GET_SERVICES);
- // Note: The WizardManager component is disabled when the WizardManager exits,
- // which happens when FinishActivity calls nextAction while completing.
+ enableStatusBar();
+ context.finishAffinity();
+ context.nextAction(RESULT_SKIP);
+ Log.i(TAG, "Setup complete!");
}
public static boolean isBluetoothDisabled() {
@@ -273,6 +254,9 @@
}
}
+ /**
+ * Disable the Home component, which is presumably SetupWizardActivity at this time.
+ */
public static void disableHome(Context context) {
ComponentName homeComponent = getHomeComponent(context);
if (homeComponent != null) {
@@ -282,7 +266,7 @@
}
}
- public static ComponentName getHomeComponent(Context context) {
+ private static ComponentName getHomeComponent(Context context) {
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.HOME");
intent.setPackage(context.getPackageName());
@@ -293,11 +277,6 @@
return comp;
}
- public static void disableComponentSets(Context context, int flags) {
- setComponentListEnabledState(context, getComponentSets(context, flags),
- COMPONENT_ENABLED_STATE_DISABLED);
- }
-
public static void disableComponent(Context context, Class<?> cls) {
setComponentEnabledState(context, new ComponentName(context, cls),
COMPONENT_ENABLED_STATE_DISABLED);
@@ -314,42 +293,57 @@
enabledState, DONT_KILL_APP);
}
- public static void setComponentListEnabledState(Context context,
- List<ComponentName> componentNames, int enabledState) {
- for (ComponentName componentName : componentNames) {
- setComponentEnabledState(context, componentName, enabledState);
+ private static void handleEnableMetrics(Context context) {
+ Bundle privacyData = SetupWizardApp.getSettingsBundle();
+ if (privacyData != null
+ && privacyData.containsKey(KEY_SEND_METRICS)) {
+ LineageSettings.Secure.putInt(context.getContentResolver(),
+ LineageSettings.Secure.STATS_COLLECTION,
+ privacyData.getBoolean(KEY_SEND_METRICS)
+ ? 1 : 0);
}
}
- public static List<ComponentName> getComponentSets(Context context, int flags) {
- int i = 0;
- List<ComponentName> componentNames = new ArrayList<>();
- try {
- PackageInfo allInfo = context.getPackageManager()
- .getPackageInfo(context.getPackageName(), flags);
- if (allInfo != null) {
- if (allInfo.activities != null && (flags & GET_ACTIVITIES) != 0) {
- for (ComponentInfo info : allInfo.activities) {
- componentNames.add(new ComponentName(context, info.name));
- }
- }
- if (allInfo.receivers != null && (flags & GET_RECEIVERS) != 0) {
- for (ComponentInfo info2 : allInfo.receivers) {
- componentNames.add(new ComponentName(context, info2.name));
- }
- }
- if (allInfo.services != null && (flags & GET_SERVICES) != 0) {
- ServiceInfo[] serviceInfoArr = allInfo.services;
- int length = serviceInfoArr.length;
- while (i < length) {
- componentNames.add(new ComponentName(context, serviceInfoArr[i].name));
- i++;
- }
- }
- }
- } catch (PackageManager.NameNotFoundException ignored) {
+ private static void handleNavKeys(Context context) {
+ if (SetupWizardApp.getSettingsBundle().containsKey(DISABLE_NAV_KEYS)) {
+ writeDisableNavkeysOption(context,
+ SetupWizardApp.getSettingsBundle().getBoolean(DISABLE_NAV_KEYS));
}
- return componentNames;
+ }
+
+ private static void handleRecoveryUpdate() {
+ if (SetupWizardApp.getSettingsBundle().containsKey(ENABLE_RECOVERY_UPDATE)) {
+ boolean update = SetupWizardApp.getSettingsBundle()
+ .getBoolean(ENABLE_RECOVERY_UPDATE);
+
+ SystemProperties.set(UPDATE_RECOVERY_PROP, String.valueOf(update));
+ }
+ }
+
+ private static void handleNavigationOption() {
+ Bundle settingsBundle = SetupWizardApp.getSettingsBundle();
+ if (settingsBundle.containsKey(NAVIGATION_OPTION_KEY)) {
+ IOverlayManager overlayManager = IOverlayManager.Stub.asInterface(
+ ServiceManager.getService(Context.OVERLAY_SERVICE));
+ String selectedNavMode = settingsBundle.getString(NAVIGATION_OPTION_KEY);
+
+ try {
+ overlayManager.setEnabledExclusiveInCategory(selectedNavMode,
+ UserHandle.USER_CURRENT);
+ } catch (Exception ignored) {
+ }
+ }
+ }
+
+ private static void writeDisableNavkeysOption(Context context, boolean enabled) {
+ final boolean virtualKeysEnabled = LineageSettings.System.getIntForUser(
+ context.getContentResolver(), LineageSettings.System.FORCE_SHOW_NAVBAR, 0,
+ UserHandle.USER_CURRENT) != 0;
+ if (enabled != virtualKeysEnabled) {
+ LineageSettings.System.putIntForUser(context.getContentResolver(),
+ LineageSettings.System.FORCE_SHOW_NAVBAR, enabled ? 1 : 0,
+ UserHandle.USER_CURRENT);
+ }
}
public static long getBuildDateTimestamp() {
diff --git a/src/org/lineageos/setupwizard/wizardmanager/WizardManager.java b/src/org/lineageos/setupwizard/wizardmanager/WizardManager.java
index 44deb57..b1d3848 100644
--- a/src/org/lineageos/setupwizard/wizardmanager/WizardManager.java
+++ b/src/org/lineageos/setupwizard/wizardmanager/WizardManager.java
@@ -23,7 +23,6 @@
import android.util.Log;
import com.google.android.setupcompat.util.ResultCodes;
-import com.google.android.setupcompat.util.WizardManagerHelper;
import org.lineageos.setupwizard.util.SetupWizardUtils;
@@ -71,10 +70,6 @@
finish();
}
- private void addExtras(Intent intent) {
- intent.putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true);
- }
-
private void doAction(String scriptUri, WizardAction action, Intent extras) {
Intent intent = action.getIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@@ -83,7 +78,6 @@
+ " intent=" + intent + " extras2=" + intent.getExtras() + " action=" + action);
}
- addExtras(intent);
if (extras != null) {
intent.putExtras(extras);
}