Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a6986e7e authored by Fan Zhang's avatar Fan Zhang
Browse files

Misc fix for secondary user

- Theme fix: action bar and status bar color now have enough contrast
  for SUW theme.
- Fix a ConcurrentModificationError when switching between users
  quickly.

Change-Id: If31f88e36f1d4c5d7f90bc9d128041f0e0a81ff9
Fix: 35948464
Test: make RunSettingsRoboTests
parent fdb307bf
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -102,8 +102,10 @@

    <!-- Accessibility portion of Setup Wizard -->
    <style name="SetupWizardAccessibilityTheme" parent="Theme.SettingsBase">
        <item name="android:windowLightStatusBar">false</item>
        <item name="android:colorPrimary">@color/material_blue_700</item>
        <item name="android:colorPrimaryDark">@color/material_blue_700</item>
        <item name="android:actionBarTheme">@android:style/ThemeOverlay.Material.Dark.ActionBar</item>
        <item name="preferenceTheme">@style/PreferenceTheme</item>
        <item name="switchBarTheme">@style/SetupWizardAccessibilitySwitchBarTheme</item>
    </style>
+35 −42
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.nfc.NfcAdapter;
@@ -661,6 +660,9 @@ public class SettingsActivity extends SettingsDrawerActivity
    @Override
    protected void onPause() {
        super.onPause();
        mDevelopmentPreferences.unregisterOnSharedPreferenceChangeListener(
                mDevelopmentPreferencesListener);
        mDevelopmentPreferencesListener = null;
        unregisterReceiver(mBatteryInfoReceiver);
        if (!mSearchFeatureProvider.isEnabled(this)) {
            unregisterReceiver(mUserAddRemoveReceiver);
@@ -670,15 +672,6 @@ public class SettingsActivity extends SettingsDrawerActivity
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();

        mDevelopmentPreferences.unregisterOnSharedPreferenceChangeListener(
                mDevelopmentPreferencesListener);
        mDevelopmentPreferencesListener = null;
    }

    @Override
    public void setTaskDescription(ActivityManager.TaskDescription taskDescription) {
        final Bitmap icon = getBitmapFromXmlResource(R.drawable.ic_launcher_settings);
@@ -944,32 +937,36 @@ public class SettingsActivity extends SettingsDrawerActivity
                        Settings.DevelopmentSettingsActivity.class.getName()),
                showDev, isAdmin);

        // Enable/disable backup settings depending on whether the user is admin.
        setTileEnabled(new ComponentName(packageName,
                        BackupSettingsActivity.class.getName()), true,
                isAdmin || Utils.isCarrierDemoUser(this));

        setTileEnabled(new ComponentName(packageName,
                        Settings.EnterprisePrivacySettingsActivity.class.getName()),
                FeatureFactory.getFactory(this).getEnterprisePrivacyFeatureProvider(this)
                        .hasDeviceOwner(), isAdmin);

        if (UserHandle.MU_ENABLED && !isAdmin) {

            // When on restricted users, disable all extra categories (but only the settings ones).
            final List<DashboardCategory> categories = mDashboardFeatureProvider.getAllCategories();

            synchronized (categories) {
                for (DashboardCategory category : categories) {
                    for (Tile tile : category.tiles) {
                        ComponentName component = tile.intent.getComponent();
                        final String name = component.getClassName();
                        final boolean isEnabledForRestricted = ArrayUtils.contains(
                                SettingsGateway.SETTINGS_FOR_RESTRICTED, name);
                    if (packageName.equals(component.getPackageName()) && !isEnabledForRestricted) {
                        if (packageName.equals(component.getPackageName())
                                && !isEnabledForRestricted) {
                            setTileEnabled(component, false, isAdmin);
                        }
                    }
                }
            }
        }

        // Enable/disable backup settings depending on whether the user is admin.
        setTileEnabled(new ComponentName(packageName,
                BackupSettingsActivity.class.getName()), true,
                isAdmin || Utils.isCarrierDemoUser(this));

        setTileEnabled(new ComponentName(packageName,
                Settings.EnterprisePrivacySettingsActivity.class.getName()),
                FeatureFactory.getFactory(this).getEnterprisePrivacyFeatureProvider(this)
                        .hasDeviceOwner(), isAdmin);
        // Final step, refresh categories.
        updateCategories();
    }
@@ -1099,10 +1096,6 @@ public class SettingsActivity extends SettingsDrawerActivity
        return mResultIntentData;
    }

    public void setResultIntentData(Intent resultIntentData) {
        mResultIntentData = resultIntentData;
    }

    public void startSuggestion(Intent intent) {
        if (intent == null || ActivityManager.isUserAMonkey()) {
            return;
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.graphics.Bitmap;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+6 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import org.robolectric.Robolectric;
import org.robolectric.annotation.Config;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -54,8 +55,12 @@ public class HardwareInfoDialogFragmentTest {
        final HardwareInfoDialogFragment fragment = spy(HardwareInfoDialogFragment.newInstance());
        fragment.show(mActivity.getFragmentManager(), HardwareInfoDialogFragment.TAG);

        verify(fragment).setText(
                any(View.class), eq(R.id.model_label), eq(R.id.model_value),
                anyString());

        verify(fragment).setText(
                any(View.class), eq(R.id.hardware_rev_label), eq(R.id.hardware_rev_value),
                eq(TEST_HARDWARE_REV));
                anyString());
    }
}