Search in sources :

Example 46 with VisibleForTesting

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

the class EligibleCardChecker method isSliceToggleable.

@VisibleForTesting
boolean isSliceToggleable(Slice slice) {
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    final List<SliceAction> toggles = metadata.getToggles();
    return !toggles.isEmpty();
}
Also used : SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 47 with VisibleForTesting

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

the class EligibleCardChecker method isCardEligibleToDisplay.

@VisibleForTesting
boolean isCardEligibleToDisplay(ContextualCard card) {
    if (card.getRankingScore() < 0) {
        return false;
    }
    if (card.isCustomCard()) {
        return true;
    }
    final Uri uri = card.getSliceUri();
    if (!ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
        return false;
    }
    final Slice slice = bindSlice(uri);
    if (isSliceToggleable(slice)) {
        mCard = card.mutate().setHasInlineAction(true).build();
    }
    if (slice == null || slice.hasHint(HINT_ERROR)) {
        Log.w(TAG, "Failed to bind slice, not eligible for display " + uri);
        return false;
    }
    return true;
}
Also used : Slice(androidx.slice.Slice) Uri(android.net.Uri) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 48 with VisibleForTesting

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

the class NetworkScorerPicker method updateCandidates.

@VisibleForTesting
public void updateCandidates() {
    final PreferenceScreen screen = getPreferenceScreen();
    screen.removeAll();
    final List<NetworkScorerAppData> scorers = mNetworkScoreManager.getAllValidScorers();
    final String defaultAppKey = getActiveScorerPackage();
    final RadioButtonPreference nonePref = new RadioButtonPreference(getPrefContext());
    nonePref.setTitle(R.string.network_scorer_picker_none_preference);
    if (scorers.isEmpty()) {
        nonePref.setChecked(true);
    } else {
        nonePref.setKey(null);
        nonePref.setChecked(TextUtils.isEmpty(defaultAppKey));
        nonePref.setOnClickListener(this);
    }
    screen.addPreference(nonePref);
    final int numScorers = scorers.size();
    for (int i = 0; i < numScorers; i++) {
        final RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
        final NetworkScorerAppData appData = scorers.get(i);
        final String appKey = appData.getRecommendationServicePackageName();
        pref.setTitle(appData.getRecommendationServiceLabel());
        pref.setKey(appKey);
        pref.setChecked(TextUtils.equals(defaultAppKey, appKey));
        pref.setOnClickListener(this);
        screen.addPreference(pref);
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) NetworkScorerAppData(android.net.NetworkScorerAppData) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 49 with VisibleForTesting

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

the class SubscriptionsPreferenceController method setIcon.

@VisibleForTesting
void setIcon(Preference pref, int subId, boolean isDefaultForData) {
    final TelephonyManager mgr = mContext.getSystemService(TelephonyManager.class).createForSubscriptionId(subId);
    final SignalStrength strength = mgr.getSignalStrength();
    int level = (strength == null) ? 0 : strength.getLevel();
    int numLevels = SignalStrength.NUM_SIGNAL_STRENGTH_BINS;
    if (shouldInflateSignalStrength(subId)) {
        level += 1;
        numLevels += 1;
    }
    final boolean showCutOut = !isDefaultForData || !mgr.isDataEnabled();
    pref.setIcon(getIcon(level, numLevels, showCutOut));
}
Also used : TelephonyManager(android.telephony.TelephonyManager) SignalStrength(android.telephony.SignalStrength) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 50 with VisibleForTesting

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

the class VpnPreferenceController method updateSummary.

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
void updateSummary() {
    if (mPreference == null) {
        return;
    }
    // Copied from SystemUI::SecurityControllerImpl
    SparseArray<VpnConfig> vpns = new SparseArray<>();
    try {
        final List<UserInfo> users = mUserManager.getUsers();
        for (UserInfo user : users) {
            VpnConfig cfg = mConnectivityManagerService.getVpnConfig(user.id);
            if (cfg == null) {
                continue;
            } else if (cfg.legacy) {
                // Legacy VPNs should do nothing if the network is disconnected. Third-party
                // VPN warnings need to continue as traffic can still go to the app.
                final LegacyVpnInfo legacyVpn = mConnectivityManagerService.getLegacyVpnInfo(user.id);
                if (legacyVpn == null || legacyVpn.state != LegacyVpnInfo.STATE_CONNECTED) {
                    continue;
                }
            }
            vpns.put(user.id, cfg);
        }
    } catch (RemoteException rme) {
        // Roll back to previous state
        Log.e(TAG, "Unable to list active VPNs", rme);
        return;
    }
    final UserInfo userInfo = mUserManager.getUserInfo(UserHandle.myUserId());
    final int uid;
    if (userInfo.isRestricted()) {
        uid = userInfo.restrictedProfileParentId;
    } else {
        uid = userInfo.id;
    }
    VpnConfig vpn = vpns.get(uid);
    final String summary;
    if (vpn == null) {
        summary = mContext.getString(R.string.vpn_disconnected_summary);
    } else {
        summary = getNameForVpnConfig(vpn, UserHandle.of(uid));
    }
    ThreadUtils.postOnMainThread(() -> mPreference.setSummary(summary));
}
Also used : SparseArray(android.util.SparseArray) VpnConfig(com.android.internal.net.VpnConfig) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) UserInfo(android.content.pm.UserInfo) RemoteException(android.os.RemoteException) 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