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