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();
}
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;
}
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);
}
}
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));
}
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));
}
Aggregations