SetupWizardTests: Underp re-enabling GMS setup
Change-Id: I13d38acd8d5875a71375ceec51f284fa58605989
This commit is contained in:
parent
e12f85551e
commit
6ea46dd6d8
@ -29,6 +29,7 @@
|
||||
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" />
|
||||
<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
|
||||
|
||||
<application android:icon="@drawable/icon">
|
||||
<uses-library android:name="android.test.runner" />
|
||||
|
@ -21,14 +21,11 @@ import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ManualTestActivity extends Activity {
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -58,23 +55,17 @@ public class ManualTestActivity extends Activity {
|
||||
private void enableSetup() {
|
||||
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0);
|
||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0);
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
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, 0);
|
||||
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
try {
|
||||
final List<ResolveInfo> resolveInfos =
|
||||
pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
for (ResolveInfo info : resolveInfos) {
|
||||
if ("com.google.android.setupwizard".equals(info.activityInfo.packageName)) {
|
||||
final ComponentName cn =
|
||||
new ComponentName(info.activityInfo.packageName, info.activityInfo.name);
|
||||
pm.setComponentEnabledSetting(cn,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||
0);
|
||||
}
|
||||
}
|
||||
componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.SetupWizardActivity");
|
||||
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.WizardManager");
|
||||
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
pm.clearApplicationUserData("com.google.android.setupwizard", null);
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(this, "GMS not installed", Toast.LENGTH_SHORT).show();
|
||||
e.printStackTrace();
|
||||
@ -88,29 +79,19 @@ public class ManualTestActivity extends Activity {
|
||||
try {
|
||||
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0);
|
||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0);
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
Intent intent = new Intent("android.intent.action.MAIN");
|
||||
intent.addCategory("android.intent.category.HOME");
|
||||
final PackageManager pm = getPackageManager();
|
||||
try {
|
||||
final List<ResolveInfo> resolveInfos =
|
||||
pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
for (ResolveInfo info : resolveInfos) {
|
||||
if ("com.google.android.setupwizard".equals(info.activityInfo.packageName)) {
|
||||
final ComponentName cn =
|
||||
new ComponentName(info.activityInfo.packageName, info.activityInfo.name);
|
||||
pm.setComponentEnabledSetting(cn,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||
0);
|
||||
}
|
||||
}
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags());
|
||||
startActivity(intent);
|
||||
finish();
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(this, "GMS not installed", Toast.LENGTH_SHORT).show();
|
||||
e.printStackTrace();
|
||||
}
|
||||
ComponentName componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.SetupWizardActivity");
|
||||
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.WizardManager");
|
||||
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
pm.clearApplicationUserData("com.google.android.setupwizard", null);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags());
|
||||
startActivity(intent);
|
||||
finish();
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(this, "GMS not installed", Toast.LENGTH_SHORT).show();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -118,23 +99,16 @@ public class ManualTestActivity extends Activity {
|
||||
private void setSetupComplete() {
|
||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
|
||||
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0);
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
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);
|
||||
try {
|
||||
final List<ResolveInfo> resolveInfos =
|
||||
pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
for (ResolveInfo info : resolveInfos) {
|
||||
if ("com.google.android.setupwizard".equals(info.activityInfo.packageName)) {
|
||||
final ComponentName cn =
|
||||
new ComponentName(info.activityInfo.packageName, info.activityInfo.name);
|
||||
pm.setComponentEnabledSetting(cn,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||
0);
|
||||
}
|
||||
}
|
||||
componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.SetupWizardActivity");
|
||||
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.WizardManager");
|
||||
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(this, "GMS not installed", Toast.LENGTH_SHORT).show();
|
||||
e.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user