Search in sources :

Example 61 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DashboardFragment method updatePreferenceVisibility.

@VisibleForTesting
void updatePreferenceVisibility(Map<Class, List<AbstractPreferenceController>> preferenceControllers) {
    final PreferenceScreen screen = getPreferenceScreen();
    if (screen == null || preferenceControllers == null || mBlockerController == null) {
        return;
    }
    final boolean visible = mBlockerController.isBlockerFinished();
    for (List<AbstractPreferenceController> controllerList : preferenceControllers.values()) {
        for (AbstractPreferenceController controller : controllerList) {
            final String key = controller.getPreferenceKey();
            final Preference preference = findPreference(key);
            if (preference != null) {
                preference.setVisible(visible && controller.isAvailable());
            }
        }
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Preference(androidx.preference.Preference) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 62 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DashboardFragment method refreshDashboardTiles.

/**
 * Refresh preference items backed by DashboardCategory.
 */
@VisibleForTesting
void refreshDashboardTiles(final String TAG) {
    final PreferenceScreen screen = getPreferenceScreen();
    final DashboardCategory category = mDashboardFeatureProvider.getTilesForCategory(getCategoryKey());
    if (category == null) {
        Log.d(TAG, "NO dashboard tiles for " + TAG);
        return;
    }
    final List<Tile> tiles = category.getTiles();
    if (tiles == null) {
        Log.d(TAG, "tile list is empty, skipping category " + category.key);
        return;
    }
    // Create a list to track which tiles are to be removed.
    final List<String> remove = new ArrayList<>(mDashboardTilePrefKeys);
    // There are dashboard tiles, so we need to install SummaryLoader.
    if (mSummaryLoader != null) {
        mSummaryLoader.release();
    }
    final Context context = getContext();
    mSummaryLoader = new SummaryLoader(getActivity(), getCategoryKey());
    mSummaryLoader.setSummaryConsumer(this);
    // Install dashboard tiles.
    final boolean forceRoundedIcons = shouldForceRoundedIcon();
    for (Tile tile : tiles) {
        final String key = mDashboardFeatureProvider.getDashboardKeyForTile(tile);
        if (TextUtils.isEmpty(key)) {
            Log.d(TAG, "tile does not contain a key, skipping " + tile);
            continue;
        }
        if (!displayTile(tile)) {
            continue;
        }
        if (mDashboardTilePrefKeys.contains(key)) {
            // Have the key already, will rebind.
            final Preference preference = screen.findPreference(key);
            mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), forceRoundedIcons, getMetricsCategory(), preference, tile, key, mPlaceholderPreferenceController.getOrder());
        } else {
            // Don't have this key, add it.
            final Preference pref = new Preference(getPrefContext());
            mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), forceRoundedIcons, getMetricsCategory(), pref, tile, key, mPlaceholderPreferenceController.getOrder());
            screen.addPreference(pref);
            mDashboardTilePrefKeys.add(key);
        }
        remove.remove(key);
    }
    // Finally remove tiles that are gone.
    for (String key : remove) {
        mDashboardTilePrefKeys.remove(key);
        final Preference preference = screen.findPreference(key);
        if (preference != null) {
            screen.removePreference(preference);
        }
    }
    mSummaryLoader.setListening(true);
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) Context(android.content.Context) PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference) ArrayList(java.util.ArrayList) Tile(com.android.settingslib.drawer.Tile) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 63 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BackgroundActivityPreferenceController method showDialog.

@VisibleForTesting
void showDialog(boolean restricted) {
    final AppInfo appInfo = new AppInfo.Builder().setUid(mUid).setPackageName(mTargetPackage).build();
    BatteryTip tip = restricted ? new UnrestrictAppTip(BatteryTip.StateType.NEW, appInfo) : new RestrictAppTip(BatteryTip.StateType.NEW, appInfo);
    final BatteryTipDialogFragment dialogFragment = BatteryTipDialogFragment.newInstance(tip, mFragment.getMetricsCategory());
    dialogFragment.setTargetFragment(mFragment, 0);
    dialogFragment.show(mFragment.getFragmentManager(), TAG);
}
Also used : BatteryTipDialogFragment(com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment) RestrictAppTip(com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip) AppInfo(com.android.settings.fuelgauge.batterytip.AppInfo) UnrestrictAppTip(com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 64 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ActionDisabledByAdminDialogHelper method maybeSetLearnMoreButton.

@VisibleForTesting
void maybeSetLearnMoreButton(AlertDialog.Builder builder) {
    // The "Learn more" button appears only if the restriction is enforced by an admin in the
    // same profile group. Otherwise the admin package and its policies are not accessible to
    // the current user.
    final UserManager um = UserManager.get(mActivity.getApplicationContext());
    if (um.isSameProfileGroup(getEnforcementAdminUserId(mEnforcedAdmin), um.getUserHandle())) {
        builder.setNeutralButton(R.string.learn_more, (dialog, which) -> {
            showAdminPolicies(mEnforcedAdmin, mActivity);
            mActivity.finish();
        });
    }
}
Also used : UserManager(android.os.UserManager) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 65 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ActionDisabledByAdminDialogHelper method setAdminSupportDetails.

@VisibleForTesting
void setAdminSupportDetails(final Activity activity, final View root, final EnforcedAdmin enforcedAdmin) {
    if (enforcedAdmin == null || enforcedAdmin.component == null) {
        return;
    }
    final DevicePolicyManager dpm = (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
    if (!RestrictedLockUtilsInternal.isAdminInCurrentUserOrProfile(activity, enforcedAdmin.component) || !RestrictedLockUtils.isCurrentUserOrProfile(activity, getEnforcementAdminUserId(enforcedAdmin))) {
        enforcedAdmin.component = null;
    } else {
        if (enforcedAdmin.user == null) {
            enforcedAdmin.user = UserHandle.of(UserHandle.myUserId());
        }
        CharSequence supportMessage = null;
        if (UserHandle.isSameApp(Process.myUid(), Process.SYSTEM_UID)) {
            supportMessage = dpm.getShortSupportMessageForUser(enforcedAdmin.component, getEnforcementAdminUserId(enforcedAdmin));
        }
        if (supportMessage != null) {
            final TextView textView = root.findViewById(R.id.admin_support_msg);
            textView.setText(supportMessage);
        }
    }
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) TextView(android.widget.TextView) VisibleForTesting(androidx.annotation.VisibleForTesting)

Aggregations

VisibleForTesting (androidx.annotation.VisibleForTesting)385 Intent (android.content.Intent)36 ArrayList (java.util.ArrayList)36 Context (android.content.Context)34 Bundle (android.os.Bundle)30 Uri (android.net.Uri)18 View (android.view.View)18 Preference (androidx.preference.Preference)18 TextView (android.widget.TextView)16 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)16 MetricsFeatureProvider (com.android.settingslib.core.instrumentation.MetricsFeatureProvider)16 SuppressLint (android.annotation.SuppressLint)15 Activity (android.app.Activity)14 RemoteException (android.os.RemoteException)14 SubscriptionInfo (android.telephony.SubscriptionInfo)12 ImageView (android.widget.ImageView)12 BluetoothDevice (android.bluetooth.BluetoothDevice)11 ComponentName (android.content.ComponentName)11 Drawable (android.graphics.drawable.Drawable)11 SharedPreferences (android.content.SharedPreferences)10