Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9cd2a06 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11834877 from 2dbb27de to 24Q3-release

Change-Id: Ieed92f531be066e0b3d009c7314868390ce682ff
parents a31e3fd9 2dbb27de
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
# The Android Biometric team should approve all changes to biometrics subdirectories.
set noparent

graciecheng@google.com
ilyamaty@google.com
jaggies@google.com
+3 −0
Original line number Diff line number Diff line
# The Android Biometric team should approve all changes to biometrics2 subdirectories.
set noparent

include /src/com/android/settings/biometrics/OWNERS
+17 −10
Original line number Diff line number Diff line
@@ -23,11 +23,12 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.res.stringResource
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.settings.R
import com.android.settings.datausage.lib.DataUsageFormatter
import com.android.settings.datausage.lib.NetworkUsageDetailsData
import com.android.settings.spa.preference.ComposePreferenceController
import com.android.settingslib.spa.widget.preference.Preference
import com.android.settingslib.spa.widget.preference.PreferenceModel
import com.android.settingslib.spaprivileged.framework.compose.placeholder
import com.android.settingslib.spaprivileged.framework.compose.getPlaceholder
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.map

@@ -35,17 +36,20 @@ class AppDataUsageSummaryController(context: Context, preferenceKey: String) :
    ComposePreferenceController(context, preferenceKey) {

    private val dataFlow = MutableStateFlow(NetworkUsageDetailsData.AllZero)
    private val dataUsageFormatter = DataUsageFormatter(context)
    private val emptyDataUsage =
        DataUsageFormatter.FormattedDataUsage(context.getPlaceholder(), context.getPlaceholder())

    private val totalUsageFlow = dataFlow.map {
        DataUsageUtils.formatDataUsage(mContext, it.totalUsage).toString()
        dataUsageFormatter.formatDataUsage(it.totalUsage)
    }

    private val foregroundUsageFlow = dataFlow.map {
        DataUsageUtils.formatDataUsage(mContext, it.foregroundUsage).toString()
        dataUsageFormatter.formatDataUsage(it.foregroundUsage)
    }

    private val backgroundUsageFlow = dataFlow.map {
        DataUsageUtils.formatDataUsage(mContext, it.backgroundUsage).toString()
        dataUsageFormatter.formatDataUsage(it.backgroundUsage)
    }

    override fun getAvailabilityStatus() = AVAILABLE
@@ -57,20 +61,23 @@ class AppDataUsageSummaryController(context: Context, preferenceKey: String) :
    @Composable
    override fun Content() {
        Column {
            val totalUsage by totalUsageFlow.collectAsStateWithLifecycle(placeholder())
            val foregroundUsage by foregroundUsageFlow.collectAsStateWithLifecycle(placeholder())
            val backgroundUsage by backgroundUsageFlow.collectAsStateWithLifecycle(placeholder())
            val totalUsage by totalUsageFlow.collectAsStateWithLifecycle(emptyDataUsage)
            val foregroundUsage by foregroundUsageFlow.collectAsStateWithLifecycle(emptyDataUsage)
            val backgroundUsage by backgroundUsageFlow.collectAsStateWithLifecycle(emptyDataUsage)
            Preference(object : PreferenceModel {
                override val title = stringResource(R.string.total_size_label)
                override val summary = { totalUsage }
                override val summary = { totalUsage.displayText }
                override val summaryContentDescription = { totalUsage.contentDescription }
            })
            Preference(object : PreferenceModel {
                override val title = stringResource(R.string.data_usage_label_foreground)
                override val summary = { foregroundUsage }
                override val summary = { foregroundUsage.displayText }
                override val summaryContentDescription = { foregroundUsage.contentDescription }
            })
            Preference(object : PreferenceModel {
                override val title = stringResource(R.string.data_usage_label_background)
                override val summary = { backgroundUsage }
                override val summary = { backgroundUsage.displayText }
                override val summaryContentDescription = { backgroundUsage.contentDescription }
            })
        }
    }
+3 −2
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import androidx.preference.TwoStatePreference;

import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.datausage.lib.DataUsageFormatter;
import com.android.settings.datausage.lib.NetworkTemplates;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.telephony.MobileNetworkUtils;
@@ -322,8 +323,8 @@ public class BillingCycleSettings extends DataUsageBaseFragment implements
                    : editor.getPolicyWarningBytes(template);

            final String[] unitNames = new String[] {
                    DataUsageFormatter.INSTANCE.getBytesDisplayUnit(getResources(), MIB_IN_BYTES),
                    DataUsageFormatter.INSTANCE.getBytesDisplayUnit(getResources(), GIB_IN_BYTES),
                    DataUsageFormatter.Companion.getBytesDisplayUnit(getResources(), MIB_IN_BYTES),
                    DataUsageFormatter.Companion.getBytesDisplayUnit(getResources(), GIB_IN_BYTES),
            };
            final ArrayAdapter<String> adapter = new ArrayAdapter<String>(
                    getContext(), android.R.layout.simple_spinner_item, unitNames);
+0 −32
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.datausage

import android.content.res.Resources
import android.text.format.Formatter

object DataUsageFormatter {

    /**
     * Gets the display unit of the given bytes.
     *
     * Similar to MeasureFormat.getUnitDisplayName(), but with the expected result for the bytes in
     * Settings, and align with other places in Settings.
     */
    fun Resources.getBytesDisplayUnit(bytes: Long): String =
        Formatter.formatBytes(this, bytes, Formatter.FLAG_IEC_UNITS).units
}
 No newline at end of file
Loading