Search in sources :

Example 41 with VisibleForTesting

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

the class AppInfoDashboardFragment method getNumberOfUserWithPackageInstalled.

@VisibleForTesting
int getNumberOfUserWithPackageInstalled(String packageName) {
    final List<UserInfo> userInfos = mUserManager.getUsers(true);
    int count = 0;
    for (final UserInfo userInfo : userInfos) {
        try {
            // Use this API to check whether user has this package
            final ApplicationInfo info = mPm.getApplicationInfoAsUser(packageName, PackageManager.GET_META_DATA, userInfo.id);
            if ((info.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
                count++;
            }
        } catch (NameNotFoundException e) {
            Log.e(TAG, "Package: " + packageName + " not found for user: " + userInfo.id);
        }
    }
    return count;
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ApplicationInfo(android.content.pm.ApplicationInfo) UserInfo(android.content.pm.UserInfo) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 42 with VisibleForTesting

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

the class DataUsageList method updatePolicy.

/**
 * Update chart sweeps and cycle list to reflect {@link NetworkPolicy} for
 * current {@link #mTemplate}.
 */
@VisibleForTesting
void updatePolicy() {
    final NetworkPolicy policy = services.mPolicyEditor.getPolicy(mTemplate);
    final View configureButton = mHeader.findViewById(R.id.filter_settings);
    // SUB SELECT
    if (isNetworkPolicyModifiable(policy, mSubId) && isMobileDataAvailable(mSubId)) {
        mChart.setNetworkPolicy(policy);
        configureButton.setVisibility(View.VISIBLE);
        ((ImageView) configureButton).setColorFilter(android.R.color.white);
    } else {
        // controls are disabled; don't bind warning/limit sweeps
        mChart.setNetworkPolicy(null);
        configureButton.setVisibility(View.GONE);
    }
    // generate cycle list based on policy and available history
    if (mCycleAdapter.updateCycleList(mCycleData)) {
        updateDetailData();
    }
}
Also used : NetworkPolicy(android.net.NetworkPolicy) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 43 with VisibleForTesting

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

the class DatePreferenceController method setDate.

@VisibleForTesting
void setDate(int year, int month, int day) {
    Calendar c = Calendar.getInstance();
    c.set(Calendar.YEAR, year);
    c.set(Calendar.MONTH, month);
    c.set(Calendar.DAY_OF_MONTH, day);
    long when = Math.max(c.getTimeInMillis(), DatePreferenceHost.MIN_DATE);
    if (when / 1000 < Integer.MAX_VALUE) {
        ((AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE)).setTime(when);
    }
}
Also used : Calendar(java.util.Calendar) AlarmManager(android.app.AlarmManager) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 44 with VisibleForTesting

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

the class ContextualCardLoader method getDisplayableCards.

// Get final displayed cards and log what cards will be displayed/hidden
@VisibleForTesting
List<ContextualCard> getDisplayableCards(List<ContextualCard> candidates) {
    final List<ContextualCard> eligibleCards = filterEligibleCards(candidates);
    final List<ContextualCard> visibleCards = new ArrayList<>();
    final List<ContextualCard> hiddenCards = new ArrayList<>();
    final int size = eligibleCards.size();
    for (int i = 0; i < size; i++) {
        if (i < DEFAULT_CARD_COUNT) {
            visibleCards.add(eligibleCards.get(i));
        } else {
            hiddenCards.add(eligibleCards.get(i));
        }
    }
    if (!CardContentProvider.DELETE_CARD_URI.equals(mNotifyUri)) {
        final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
        metricsFeatureProvider.action(mContext, SettingsEnums.ACTION_CONTEXTUAL_CARD_NOT_SHOW, ContextualCardLogUtils.buildCardListLog(hiddenCards));
    }
    return visibleCards;
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) ArrayList(java.util.ArrayList) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 45 with VisibleForTesting

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

the class SettingsHomepageActivity method setHomepageContainerPaddingTop.

@VisibleForTesting
void setHomepageContainerPaddingTop() {
    final View view = this.findViewById(R.id.homepage_container);
    final int searchBarHeight = getResources().getDimensionPixelSize(R.dimen.search_bar_height);
    final int searchBarMargin = getResources().getDimensionPixelSize(R.dimen.search_bar_margin);
    // The top padding is the height of action bar(48dp) + top/bottom margins(16dp)
    final int paddingTop = searchBarHeight + searchBarMargin * 2;
    view.setPadding(0, /* left */
    paddingTop, 0, /* right */
    0);
}
Also used : LottieAnimationView(com.airbnb.lottie.LottieAnimationView) ImageView(android.widget.ImageView) View(android.view.View) 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