Search in sources :

Example 66 with VisibleForTesting

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

the class ActionDisabledByAdminDialogHelper method showAdminPolicies.

@VisibleForTesting
void showAdminPolicies(final EnforcedAdmin enforcedAdmin, final Activity activity) {
    final Intent intent = new Intent();
    if (enforcedAdmin.component != null) {
        intent.setClass(activity, DeviceAdminAdd.class);
        intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, enforcedAdmin.component);
        intent.putExtra(DeviceAdminAdd.EXTRA_CALLED_FROM_SUPPORT_DIALOG, true);
        // DeviceAdminAdd class may need to run as managed profile.
        activity.startActivityAsUser(intent, enforcedAdmin.user);
    } else {
        intent.setClass(activity, Settings.DeviceAdminSettingsActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        // Activity merges both managed profile and parent users
        // admins so show as same user as this activity.
        activity.startActivity(intent);
    }
}
Also used : Intent(android.content.Intent) Settings(com.android.settings.Settings) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 67 with VisibleForTesting

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

the class AdvancedPowerUsageDetail method startBatteryDetailPage.

@VisibleForTesting
static void startBatteryDetailPage(Activity caller, BatteryUtils batteryUtils, InstrumentedPreferenceFragment fragment, BatteryStatsHelper helper, int which, BatteryEntry entry, String usagePercent) {
    // Initialize mStats if necessary.
    helper.getStats();
    final Bundle args = new Bundle();
    final BatterySipper sipper = entry.sipper;
    final BatteryStats.Uid uid = sipper.uidObj;
    final boolean isTypeApp = sipper.drainType == BatterySipper.DrainType.APP;
    final long foregroundTimeMs = isTypeApp ? batteryUtils.getProcessTimeMs(BatteryUtils.StatusType.FOREGROUND, uid, which) : sipper.usageTimeMs;
    final long backgroundTimeMs = isTypeApp ? batteryUtils.getProcessTimeMs(BatteryUtils.StatusType.BACKGROUND, uid, which) : 0;
    if (ArrayUtils.isEmpty(sipper.mPackages)) {
        // populate data for system app
        args.putString(EXTRA_LABEL, entry.getLabel());
        args.putInt(EXTRA_ICON_ID, entry.iconId);
        args.putString(EXTRA_PACKAGE_NAME, null);
    } else {
        // populate data for normal app
        args.putString(EXTRA_PACKAGE_NAME, entry.defaultPackageName != null ? entry.defaultPackageName : sipper.mPackages[0]);
    }
    args.putInt(EXTRA_UID, sipper.getUid());
    args.putLong(EXTRA_BACKGROUND_TIME, backgroundTimeMs);
    args.putLong(EXTRA_FOREGROUND_TIME, foregroundTimeMs);
    args.putString(EXTRA_POWER_USAGE_PERCENT, usagePercent);
    args.putInt(EXTRA_POWER_USAGE_AMOUNT, (int) sipper.totalPowerMah);
    new SubSettingLauncher(caller).setDestination(AdvancedPowerUsageDetail.class.getName()).setTitleRes(R.string.battery_details_title).setArguments(args).setSourceMetricsCategory(fragment.getMetricsCategory()).setUserHandle(new UserHandle(getUserIdToLaunchAdvancePowerUsageDetail(sipper))).launch();
}
Also used : BatterySipper(com.android.internal.os.BatterySipper) SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle) UserHandle(android.os.UserHandle) BatteryStats(android.os.BatteryStats) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 68 with VisibleForTesting

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

the class DarkThemeSlice method isAvailable.

@VisibleForTesting
boolean isAvailable(Context context) {
    // checking dark theme mode.
    if (isDarkThemeMode(context)) {
        return false;
    }
    // checking the current battery level
    final BatteryManager batteryManager = context.getSystemService(BatteryManager.class);
    final int level = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
    Log.d(TAG, "battery level=" + level);
    return level <= BATTERY_LEVEL_THRESHOLD;
}
Also used : BatteryManager(android.os.BatteryManager) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 69 with VisibleForTesting

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

the class SliceContextualCardController method showFeedbackDialog.

@VisibleForTesting
void showFeedbackDialog(ContextualCard card) {
    final String email = mContext.getString(R.string.config_contextual_card_feedback_email);
    if (!isFeedbackEnabled(email)) {
        return;
    }
    final Intent feedbackIntent = new Intent(mContext, ContextualCardFeedbackDialog.class);
    feedbackIntent.putExtra(ContextualCardFeedbackDialog.EXTRA_CARD_NAME, getSimpleCardName(card));
    feedbackIntent.putExtra(ContextualCardFeedbackDialog.EXTRA_FEEDBACK_EMAIL, email);
    feedbackIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mContext.startActivity(feedbackIntent);
}
Also used : Intent(android.content.Intent) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 70 with VisibleForTesting

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

the class DeviceInfoSlice method getPhoneNumber.

@VisibleForTesting
CharSequence getPhoneNumber() {
    final SubscriptionInfo subscriptionInfo = getFirstSubscriptionInfo();
    if (subscriptionInfo == null) {
        return mContext.getString(R.string.device_info_default);
    }
    final String phoneNumber = DeviceInfoUtils.getFormattedPhoneNumber(mContext, subscriptionInfo);
    return TextUtils.isEmpty(phoneNumber) ? mContext.getString(R.string.device_info_default) : BidiFormatter.getInstance().unicodeWrap(phoneNumber, TextDirectionHeuristics.LTR);
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo) 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