SetupWizardTests: Don't crash when there is no GMS

Change-Id: I0bc86384c172c0abb7960f140b9155e75264957c
This commit is contained in:
cretin45 2015-01-30 15:26:08 -08:00
parent fa88fbad19
commit 7e9af47d04
1 changed files with 26 additions and 14 deletions

View File

@ -59,24 +59,32 @@ public class ManualTestActivity extends Activity {
final PackageManager pm = getPackageManager(); final PackageManager pm = getPackageManager();
ComponentName componentName = new ComponentName("com.cyanogenmod.setupwizard", "com.cyanogenmod.setupwizard.ui.SetupWizardActivity"); ComponentName componentName = new ComponentName("com.cyanogenmod.setupwizard", "com.cyanogenmod.setupwizard.ui.SetupWizardActivity");
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.SetupWizardActivity"); try {
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);
} catch (Exception e) {
e.printStackTrace();
}
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags()); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags());
startActivity(intent); startActivity(intent);
finish(); finish();
} }
private void enableGoogleSetup() { private void enableGoogleSetup() {
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0); try {
Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0); Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0);
Intent intent = new Intent("android.intent.action.MAIN"); Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0);
intent.addCategory("android.intent.category.HOME"); Intent intent = new Intent("android.intent.action.MAIN");
final PackageManager pm = getPackageManager(); intent.addCategory("android.intent.category.HOME");
ComponentName componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.SetupWizardActivity"); final PackageManager pm = getPackageManager();
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); ComponentName componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.SetupWizardActivity");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags()); pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
startActivity(intent); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags());
finish(); startActivity(intent);
finish();
} catch (Exception e) {
e.printStackTrace();
}
} }
private void setSetupComplete() { private void setSetupComplete() {
@ -87,8 +95,12 @@ public class ManualTestActivity extends Activity {
final PackageManager pm = getPackageManager(); final PackageManager pm = getPackageManager();
ComponentName componentName = new ComponentName("com.cyanogenmod.setupwizard", "com.cyanogenmod.setupwizard.ui.SetupWizardActivity"); ComponentName componentName = new ComponentName("com.cyanogenmod.setupwizard", "com.cyanogenmod.setupwizard.ui.SetupWizardActivity");
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.SetupWizardActivity"); try {
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);
} catch (Exception e) {
e.printStackTrace();
}
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags()); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags());
startActivity(intent); startActivity(intent);
finish(); finish();