Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f363092 authored by cretin45's avatar cretin45
Browse files

SetupWizardTest: Add a test to mark as setup complete

Change-Id: I9d76e66dc68eb85094060548309e948bf91c4eeb
parent 202f9273
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -31,5 +31,10 @@
                android:layout_width="match_parent"
                android:text="@string/enable_google_setup"/>

        <Button android:id="@+id/setup_complete_flag"
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:text="@string/user_setup_complete"/>

    </LinearLayout>
</ScrollView>
+1 −0
Original line number Diff line number Diff line
@@ -18,4 +18,5 @@
    <string name="app_test">SetupWizard Test</string>
    <string name="enable_setup">Enable Setup Wizard</string>
    <string name="enable_google_setup">Enable Google Setup Wizard</string>
    <string name="user_setup_complete">Set SetupWizard complete</string>
</resources>
+21 −0
Original line number Diff line number Diff line
@@ -43,6 +43,12 @@ public class ManualTestActivity extends Activity {
                enableGoogleSetup();
            }
        });
        findViewById(R.id.setup_complete_flag).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                setSetupComplete();
            }
        });
    }

    private void enableSetup() {
@@ -73,4 +79,19 @@ public class ManualTestActivity extends Activity {
        finish();
    }

    private void setSetupComplete() {
        Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
        Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0);
        Intent intent = new Intent("android.intent.action.MAIN");
        intent.addCategory("android.intent.category.HOME");
        final PackageManager pm = getPackageManager();
        ComponentName componentName = new ComponentName("com.cyanogenmod.setupwizard", "com.cyanogenmod.setupwizard.ui.SetupWizardActivity");
        pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
        componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.SetupWizardActivity");
        pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags());
        startActivity(intent);
        finish();
    }

}
 No newline at end of file