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

View File

@ -59,14 +59,19 @@ 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);
try {
componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.SetupWizardActivity"); componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.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);
} 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() {
try {
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0); Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0);
Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0); Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0);
Intent intent = new Intent("android.intent.action.MAIN"); Intent intent = new Intent("android.intent.action.MAIN");
@ -77,6 +82,9 @@ public class ManualTestActivity extends Activity {
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags()); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags());
startActivity(intent); startActivity(intent);
finish(); 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);
try {
componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.SetupWizardActivity"); componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.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);
} 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();