<uses-library android:name="org.apache.http.legacy" />
<!-- Settings -->
- <activity android:name="Settings"
+ <activity android:name="SettingsActivity"
android:label="@string/settings_label_launcher"
android:launchMode="singleTask">
- <intent-filter android:priority="1">
- <action android:name="android.settings.SETTINGS" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
android:value="true" />
</activity>
android:label="@string/settings_label_launcher"
android:theme="@style/Theme.Settings.Home"
android:launchMode="singleTask">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
</activity>
<activity android:name=".network.telephony.MobileSettingsActivity"
<receiver
android:name=".slices.SliceBroadcastReceiver"
- android:exported="false">
- </receiver>
+ android:exported="false" />
<receiver
android:name=".slices.SliceRelayReceiver"
android:permission="android.permission.MANAGE_SLICE_PERMISSIONS"
- android:exported="true">
-
- </receiver>
+ android:exported="true" />
<!-- Couldn't be triggered from outside of settings. Statsd can trigger it because we send
PendingIntent to it-->
package com.android.settings;
-import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO;
-
import android.app.ActionBar;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
// Getting Intent properties can only be done after the super.onCreate(...)
final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT);
- final ComponentName cn = intent.getComponent();
- final String className = cn.getClassName();
-
- mIsShowingDashboard = className.equals(Settings.class.getName());
+ mIsShowingDashboard = TextUtils.equals(
+ SettingsActivity.class.getName(), intent.getComponent().getClassName());
// This is a "Sub Settings" when:
// - this is a real SubSettings
package com.android.settings.homepage;
-import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.FeatureFlagUtils;
import androidx.fragment.app.FragmentTransaction;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.homepage.contextualcards.ContextualCardsFragment;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- if (!isDynamicHomepageEnabled(this)) {
- final Intent settings = new Intent();
- settings.setAction("android.settings.SETTINGS");
+ if (!FeatureFlagUtils.isEnabled(this, FeatureFlags.DYNAMIC_HOMEPAGE)) {
+ final Intent settings = new Intent(this, SettingsActivity.class);
startActivity(settings);
finish();
return;
showFragment(new TopLevelSettings(), R.id.main_content);
}
- public static boolean isDynamicHomepageEnabled(Context context) {
- return FeatureFlagUtils.isEnabled(context, FeatureFlags.DYNAMIC_HOMEPAGE);
- }
-
private void showFragment(Fragment fragment, int id) {
final FragmentManager fragmentManager = getSupportFragmentManager();
final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
@Test
public void onCreate_deviceNotProvisioned_shouldDisableSearch() {
Global.putInt(mContext.getContentResolver(), Global.DEVICE_PROVISIONED, 0);
- final Intent intent = new Intent(mContext, Settings.class);
- final SettingsActivity activity =
- Robolectric.buildActivity(SettingsActivity.class, intent).create(
- Bundle.EMPTY).get();
+ final SettingsActivity activity = Robolectric.buildActivity(SettingsActivity.class)
+ .create(Bundle.EMPTY)
+ .get();
assertThat(activity.findViewById(R.id.search_bar).getVisibility())
.isEqualTo(View.INVISIBLE);
@Test
public void onCreate_deviceProvisioned_shouldEnableSearch() {
Global.putInt(mContext.getContentResolver(), Global.DEVICE_PROVISIONED, 1);
- final Intent intent = new Intent(mContext, Settings.class);
- final SettingsActivity activity =
- Robolectric.buildActivity(SettingsActivity.class, intent).create(
- Bundle.EMPTY).get();
+ final SettingsActivity activity = Robolectric.buildActivity(SettingsActivity.class)
+ .create(Bundle.EMPTY)
+ .get();
assertThat(activity.findViewById(R.id.search_bar).getVisibility()).isEqualTo(View.VISIBLE);
}
--- /dev/null
+/*
+ * Copyright (C) 2018 The Android Open Source 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 com.android.settings.homepage;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.util.FeatureFlagUtils;
+
+import com.android.settings.SettingsActivity;
+import com.android.settings.core.FeatureFlags;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
+import org.robolectric.shadows.ShadowActivity;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class SettingsHomepageActivityTest {
+
+ @Test
+ public void launch_featureFlagOff_shouldRedirectToSettingsActivity() {
+ FeatureFlagUtils.setEnabled(RuntimeEnvironment.application, FeatureFlags.DYNAMIC_HOMEPAGE,
+ false);
+
+ final ShadowActivity shadowActivity = Shadows.shadowOf(
+ Robolectric.setupActivity(SettingsHomepageActivity.class));
+ assertThat(shadowActivity.getNextStartedActivity().getComponent().getClassName())
+ .isEqualTo(SettingsActivity.class.getName());
+ }
+}