SetupWizard: Add hook to finish setup for CTS automation

Change-Id: Ifd7edda671fd8011a9b9ed894333c292cd0c3331
This commit is contained in:
cretin45 2015-06-17 13:56:09 -07:00
parent 1fc47a0a79
commit c5e926d67f
5 changed files with 43 additions and 1 deletions

View File

@ -93,5 +93,12 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name=".setup.FinishSetupReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.cyanogenmod.setupwizard.ACTION_FINISH_SETUPWIZARD" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@ -50,7 +50,7 @@ public class SetupWizardApp extends Application {
public static final String EXTRA_CKSOP = "cksOp";
public static final String EXTRA_LOGIN_FOR_KILL_SWITCH = "authCks";
private static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled";
public static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled";
private static final String[] THEME_PACKAGES = {
"org.cyanogenmod.theme.chooser",

View File

@ -0,0 +1,29 @@
package com.cyanogenmod.setupwizard.setup;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import com.cyanogenmod.setupwizard.SetupWizardApp;
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
public class FinishSetupReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (SetupWizardUtils.isDeviceLocked()) {
return;
}
Settings.Global.putInt(context.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE, 1);
((StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE)).disable(
StatusBarManager.DISABLE_NONE);
Settings.Global.putInt(context.getContentResolver(),
SetupWizardApp.KEY_DETECT_CAPTIVE_PORTAL, 1);
SetupWizardUtils.disableGMSSetupWizard(context);
SetupWizardUtils.disableSetupWizard(context);
}
}

View File

@ -192,6 +192,8 @@ public class SetupWizardUtils {
public static void disableSetupWizard(Context context) {
disableComponent(context, context.getPackageName(),
"com.cyanogenmod.setupwizard.ui.SetupWizardActivity");
disableComponent(context, context.getPackageName(),
"com.cyanogenmod.setupwizard.setup.FinishSetupReceiver");
}
public static void disableGMSSetupWizard(Context context) {

View File

@ -66,6 +66,10 @@ public class ManualTestActivity extends Activity {
"com.cyanogenmod.setupwizard.ui.SetupWizardActivity");
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
componentName = new ComponentName("com.cyanogenmod.setupwizard",
"com.cyanogenmod.setupwizard.setup.FinishSetupReceiver");
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
pm.clearApplicationUserData("com.cyanogenmod.setupwizard", null);
ActivityManager am = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE);
am.killBackgroundProcesses("com.cyanogenmod.setupwizard");