Remove old tests
Change-Id: I4344408d7e72093606e0cf90ada4f6bc02831a6b
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b38649e..cce6703 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -326,15 +326,6 @@
</intent-filter>
</activity>
- <activity
- android:name=".SetupWizardTestActivity"
- android:configChanges="keyboard|keyboardHidden|mcc|mnc|orientation|screenSize"
- android:exported="false"
- android:immersive="true"
- android:label="@string/activity_label_empty"
- android:launchMode="singleInstance"
- android:theme="@style/NoDisplay" />
-
<receiver
android:name=".PartnerReceiver"
android:exported="true">
diff --git a/exit_wizard.sh b/exit_wizard.sh
index bfdaf8a..efc3a76 100755
--- a/exit_wizard.sh
+++ b/exit_wizard.sh
@@ -3,18 +3,18 @@
adb root
wait ${!}
has_google_suw=$(adb shell pm list packages com.google.android.setupwizard)
-adb shell pm enable org.lineageos.setupwizard/org.lineageos.setupwizard.FinishActivity || true
+adb shell pm enable org.lineageos.setupwizard/.FinishActivity || true
if [[ ! -z "$has_google_suw" ]]
then
wait ${!}
- adb shell pm enable com.google.android.setupwizard/com.google.android.setupwizard.SetupWizardExitActivity || true
+ adb shell pm enable com.google.android.setupwizard/.SetupWizardExitActivity || true
wait ${!}
fi
sleep 1
-adb shell am start org.lineageos.setupwizard/org.lineageos.setupwizard.FinishActivity || true
+adb shell am start org.lineageos.setupwizard/.FinishActivity || true
if [[ ! -z "$has_google_suw" ]]
then
wait ${!}
sleep 1
- adb shell am start com.google.android.setupwizard/com.google.android.setupwizard.SetupWizardExitActivity
+ adb shell am start com.google.android.setupwizard/.SetupWizardExitActivity
fi
diff --git a/src/org/lineageos/setupwizard/SetupWizardTestActivity.java b/src/org/lineageos/setupwizard/SetupWizardTestActivity.java
deleted file mode 100644
index 912964b..0000000
--- a/src/org/lineageos/setupwizard/SetupWizardTestActivity.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2017 The LineageOS Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.lineageos.setupwizard;
-
-import static android.content.pm.PackageManager.GET_ACTIVITIES;
-import static android.content.pm.PackageManager.GET_RECEIVERS;
-import static android.content.pm.PackageManager.GET_SERVICES;
-import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
-
-import static org.lineageos.setupwizard.SetupWizardApp.LOGV;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiManager;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.util.Log;
-
-import org.lineageos.setupwizard.util.SetupWizardUtils;
-
-import java.util.List;
-
-public class SetupWizardTestActivity extends Activity {
-
- private static final String TAG = SetupWizardTestActivity.class.getSimpleName();
-
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (LOGV) {
- Log.v(TAG, "onCreate savedInstanceState=" + savedInstanceState);
- }
- if (SetupWizardUtils.isOwner()) {
- Settings.Global.putInt(getContentResolver(), "device_provisioned", 0);
- }
- Settings.Secure.putInt(getContentResolver(), "user_setup_complete", 0);
- SetupWizardUtils.resetComponentSets(this, GET_ACTIVITIES |
- GET_RECEIVERS | GET_SERVICES | MATCH_DISABLED_COMPONENTS);
- forgetAllWifi();
- Intent setupIntent = new Intent("android.intent.action.MAIN")
- .addCategory("android.intent.category.HOME")
- .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION);
- SetupWizardUtils.disableComponentsForMissingFeatures(this);
- startActivity(setupIntent);
- finish();
- }
-
- private void forgetAllWifi() {
- WifiManager wm = getSystemService(WifiManager.class);
- if (wm != null) {
- List<WifiConfiguration> configs = wm.getConfiguredNetworks();
- if (configs != null) {
- for (WifiConfiguration config : configs) {
- wm.forget(config.networkId, null);
- }
- }
- }
- }
-}
diff --git a/start_lineage_wizard.sh b/start_lineage_wizard.sh
index 09ab6d1..6442539 100755
--- a/start_lineage_wizard.sh
+++ b/start_lineage_wizard.sh
@@ -2,6 +2,10 @@
adb root
wait ${!}
+adb shell pm enable org.lineageos.setupwizard || true
+wait ${!}
+adb shell pm enable org.lineageos.setupwizard/.SetupWizardActivity || true
+wait ${!}
if adb shell pm list packages | grep com.google.android.setupwizard; then
adb shell pm disable com.google.android.setupwizard || true
wait ${!}
@@ -10,4 +14,4 @@
adb shell pm disable com.android.provision || true
wait ${!}
fi
-adb shell am start org.lineageos.setupwizard/org.lineageos.setupwizard.SetupWizardTestActivity
+adb shell am start -c android.intent.category.HOME org.lineageos.setupwizard/.SetupWizardActivity
diff --git a/start_lineage_wizard_with_gms.sh b/start_lineage_wizard_with_gms.sh
index 11a533c..bcee34a 100755
--- a/start_lineage_wizard_with_gms.sh
+++ b/start_lineage_wizard_with_gms.sh
@@ -2,13 +2,15 @@
adb root
wait ${!}
+adb shell pm enable org.lineageos.setupwizard || true
+wait ${!}
+adb shell pm enable org.lineageos.setupwizard/.SetupWizardActivity || true
+wait ${!}
adb shell pm enable com.google.android.setupwizard || true
wait ${!}
if adb shell pm list packages | grep com.android.provision; then
adb shell pm disable com.android.provision || true
wait ${!}
fi
-adb shell am start org.lineageos.setupwizard/org.lineageos.setupwizard.SetupWizardTestActivity
-wait ${!}
sleep 1
-adb shell am start com.google.android.setupwizard/com.google.android.setupwizard.SetupWizardTestActivity
+adb shell am start com.google.android.setupwizard/.SetupWizardTestActivity
diff --git a/tests/Android.mk b/tests/Android.mk
deleted file mode 100644
index 61db411..0000000
--- a/tests/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PRIVILEGED_MODULE := true
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- org.lineageos.platform.internal
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := LineageSetupWizardTests
-LOCAL_CERTIFICATE := platform
-
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_REQUIRED_MODULES := privapp_whitelist_org.lineageos.setupwizard-tests.xml
-
-LOCAL_USES_LIBRARIES := android.test.runner
-
-include $(BUILD_PACKAGE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := privapp_whitelist_org.lineageos.setupwizard-tests.xml
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions
-LOCAL_SRC_FILES := $(LOCAL_MODULE)
-include $(BUILD_PREBUILT)
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
deleted file mode 100644
index 733fa4b..0000000
--- a/tests/AndroidManifest.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2013 The CyanogenMod Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.lineageos.setupwizard.tests">
- <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
- <uses-permission android:name="android.permission.STATUS_BAR"/>
- <uses-permission android:name="android.permission.WRITE_SETTINGS" />
- <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> >
- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
- <uses-permission android:name="android.permission.INTERNET"/>
- <uses-permission android:name="android.permission.GET_ACCOUNTS" />
- <uses-permission android:name="android.permission.USE_CREDENTIALS" />
- <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" />
- <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
-
- <application android:icon="@drawable/icon">
- <uses-library android:name="android.test.runner" />
- <activity android:name="org.lineageos.setupwizard.tests.ManualTestActivity"
- android:label="@string/app_test"
- android:theme="@android:style/Theme.Material.NoActionBar"
- android:launchMode="singleTask">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
- <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" />
-
- <instrumentation android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="org.lineageos.setupwizard"
- android:label="Tests for LineageSetupWizard."/>
-
-</manifest>
diff --git a/tests/privapp_whitelist_org.lineageos.setupwizard-tests.xml b/tests/privapp_whitelist_org.lineageos.setupwizard-tests.xml
deleted file mode 100644
index 255596c..0000000
--- a/tests/privapp_whitelist_org.lineageos.setupwizard-tests.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2017-2020 The LineageOS Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<permissions>
- <privapp-permissions package="org.lineageos.setupwizard.tests">
- <permission name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>
- <permission name="android.permission.CHANGE_CONFIGURATION"/>
- <permission name="android.permission.STATUS_BAR"/>
- <permission name="android.permission.WRITE_SECURE_SETTINGS"/>
- </privapp-permissions>
-</permissions>
diff --git a/tests/res/drawable/icon.png b/tests/res/drawable/icon.png
deleted file mode 100644
index 0a2f2e4..0000000
--- a/tests/res/drawable/icon.png
+++ /dev/null
Binary files differ
diff --git a/tests/res/layout/setupwizard_test.xml b/tests/res/layout/setupwizard_test.xml
deleted file mode 100644
index 488f691..0000000
--- a/tests/res/layout/setupwizard_test.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2013 The CyanogenMod Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_height="match_parent"
- android:layout_width="match_parent">
- <LinearLayout android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:orientation="vertical">
-
- <Button android:id="@+id/enable_setup"
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:text="@string/enable_setup"/>
-
- <Button android:id="@+id/enable_google_setup"
- android:layout_height="wrap_content"
- 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>
diff --git a/tests/res/values/strings.xml b/tests/res/values/strings.xml
deleted file mode 100644
index 0bba372..0000000
--- a/tests/res/values/strings.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2013 The CyanogenMod Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<resources>
- <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>
diff --git a/tests/src/org/lineageos/setupwizard/tests/ManualTestActivity.java b/tests/src/org/lineageos/setupwizard/tests/ManualTestActivity.java
deleted file mode 100644
index 38a91e1..0000000
--- a/tests/src/org/lineageos/setupwizard/tests/ManualTestActivity.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (C) 2013 The CyanogenMod Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.lineageos.setupwizard.tests;
-
-
-import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
-import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
-import static android.content.pm.PackageManager.DONT_KILL_APP;
-import static android.content.pm.PackageManager.GET_ACTIVITIES;
-import static android.content.pm.PackageManager.GET_RECEIVERS;
-import static android.content.pm.PackageManager.GET_SERVICES;
-import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
-
-import android.app.Activity;
-import android.content.ComponentName;
-import android.content.Intent;
-import android.content.pm.ComponentInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ServiceInfo;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.util.Log;
-import android.view.View;
-import android.widget.Toast;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ManualTestActivity extends Activity {
-
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.setupwizard_test);
-
- findViewById(R.id.enable_setup).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- enableSetup();
- }
- });
- findViewById(R.id.enable_google_setup).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- enableGoogleSetup();
- }
- });
- findViewById(R.id.setup_complete_flag).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- setSetupComplete();
- }
- });
- }
-
- private void enableSetup() {
- try {
- Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0);
- Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0);
- final Intent intent = new Intent("android.intent.action.MAIN");
- intent.addCategory("android.intent.category.HOME");
- resetComponentSets("org.lineageos.setupwizard", GET_ACTIVITIES |
- GET_RECEIVERS | GET_SERVICES | MATCH_DISABLED_COMPONENTS);
- resetComponentSets("com.google.android.setupwizard", GET_ACTIVITIES |
- GET_RECEIVERS | GET_SERVICES | MATCH_DISABLED_COMPONENTS);
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags());
- startActivity(intent);
- finish();
- } catch (Exception e) {
- Toast.makeText(this, "Error enabling setup " + e.toString(), Toast.LENGTH_SHORT).show();
- e.printStackTrace();
- }
- }
-
-
- private void enableGoogleSetup() {
- try {
- Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0);
- Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0);
- Intent intent = new Intent("android.intent.action.MAIN");
- intent.addCategory("android.intent.category.HOME");
- resetComponentSets("com.google.android.setupwizard", GET_ACTIVITIES |
- GET_RECEIVERS | GET_SERVICES | MATCH_DISABLED_COMPONENTS);
- 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();
- }
- }
-
- private void setSetupComplete() {
- Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
- Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
- Intent intent = new Intent("android.intent.action.MAIN");
- intent.addCategory("android.intent.category.HOME");
- disableComponentSets("org.lineageos.setupwizard", GET_ACTIVITIES |
- GET_RECEIVERS | GET_SERVICES);
- try {
- disableComponentSets("com.google.android.setupwizard", GET_ACTIVITIES |
- GET_RECEIVERS | GET_SERVICES);
- } catch (Exception e) {
- Toast.makeText(this, "GMS not installed", Toast.LENGTH_SHORT).show();
- e.printStackTrace();
- }
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags());
- startActivity(intent);
- finish();
- }
-
- private void disableComponentSets(String packageName, int flags) {
- setComponentListEnabledState(getComponentSets(packageName, flags),
- COMPONENT_ENABLED_STATE_DISABLED);
- }
-
- private void resetComponentSets(String packageName, int flags) {
- setComponentListEnabledState(getComponentSets(packageName, flags),
- COMPONENT_ENABLED_STATE_DEFAULT);
- }
-
- private void setComponentListEnabledState(List<ComponentName> componentNames,
- int enabledState) {
- for (ComponentName componentName : componentNames) {
- Log.i("ManualTestActivity", " Changing component state " +
- componentName.flattenToString() + " state=" + enabledState);
- setComponentEnabledState(componentName, enabledState);
- }
- }
-
- private void setComponentEnabledState(ComponentName componentName,
- int enabledState) {
- getPackageManager().setComponentEnabledSetting(componentName,
- enabledState, DONT_KILL_APP);
- }
-
- private List<ComponentName> getComponentSets(String packageName, int flags) {
- int i = 0;
- List<ComponentName> componentNames = new ArrayList();
- try {
- PackageInfo allInfo = getPackageManager()
- .getPackageInfo(packageName, flags);
- if (allInfo != null) {
- if (allInfo.activities != null && (flags & GET_ACTIVITIES) != 0) {
- for (ComponentInfo info : allInfo.activities) {
- componentNames.add(new ComponentName(packageName, info.name));
- }
- }
- if (allInfo.receivers != null && (flags & GET_RECEIVERS) != 0) {
- for (ComponentInfo info2 : allInfo.receivers) {
- componentNames.add(new ComponentName(packageName, info2.name));
- }
- }
- if (allInfo.services != null && (flags & GET_SERVICES) != 0) {
- ServiceInfo[] serviceInfoArr = allInfo.services;
- int length = serviceInfoArr.length;
- while (i < length) {
- componentNames.add(new ComponentName(packageName, serviceInfoArr[i].name));
- i++;
- }
- }
- }
- } catch (PackageManager.NameNotFoundException e) {
- }
- return componentNames;
- }
-
-}