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

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

Snap for 9358956 from 1f139628 to tm-qpr2-release

Change-Id: I37d848b94546cbb6f2bf270b08d58555c57204fb
parents 3551726d 1f139628
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -78,9 +78,7 @@ public class FingerprintStatusUtils {
     * Returns the class name of the Settings page corresponding to fingerprint settings.
     */
    public String getSettingsClassName() {
        return !hasEnrolled() && isAvailable()
            ? FingerprintEnrollIntroductionInternal.class.getName()
            : FingerprintSettings.class.getName();
        return FingerprintSettings.class.getName();
    }

    /**
+10 −7
Original line number Diff line number Diff line
@@ -50,9 +50,11 @@ public class ControlsTrivialPrivacyPreferenceController extends TogglePreference

    @Override
    public CharSequence getSummary() {
        if (getAvailabilityStatus() == DISABLED_DEPENDENT_SETTING) {
        if (!CustomizableLockScreenUtils.isFeatureEnabled(mContext)
                && getAvailabilityStatus() == DISABLED_DEPENDENT_SETTING) {
            return mContext.getText(R.string.lockscreen_trivial_disabled_controls_summary);
        }

        return mContext.getText(R.string.lockscreen_trivial_controls_summary);
    }

@@ -70,21 +72,22 @@ public class ControlsTrivialPrivacyPreferenceController extends TogglePreference

    @Override
    public int getAvailabilityStatus() {
        if (CustomizableLockScreenUtils.isFeatureEnabled(mContext)) {
            return UNSUPPORTED_ON_DEVICE;
        }

        return showDeviceControlsSettingsEnabled() ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
    }

    private boolean showDeviceControlsSettingsEnabled() {
        return Settings.Secure.getInt(mContext.getContentResolver(), DEPENDENCY_SETTING_KEY, 0)
                != 0;
        return CustomizableLockScreenUtils.isFeatureEnabled(mContext)
                || Settings.Secure.getInt(
                        mContext.getContentResolver(), DEPENDENCY_SETTING_KEY, 0) != 0;
    }

    @Override
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);
        if (CustomizableLockScreenUtils.isFeatureEnabled(mContext)) {
            return;
        }

        Preference currentPreference = screen.findPreference(getPreferenceKey());
        currentPreference.setDependency("lockscreen_privacy_controls_switch");
    }
+1 −2
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ public class PowerUsageAdvanced extends PowerUsageBase {
    private static final String KEY_REFRESH_TYPE = "refresh_type";
    private static final String KEY_BATTERY_GRAPH = "battery_graph";
    private static final String KEY_APP_LIST = "app_list";
    private static final int LOADER_BATTERY_USAGE_STATS = 2;

    @VisibleForTesting
    BatteryHistoryPreference mHistPref;
@@ -188,7 +187,7 @@ public class PowerUsageAdvanced extends PowerUsageBase {
        // Uses customized battery history loader if chart design is enabled.
        if (mIsChartGraphEnabled && !mIsChartDataLoaded) {
            mIsChartDataLoaded = true;
            getLoaderManager().restartLoader(LOADER_BATTERY_USAGE_STATS, bundle,
            restartLoader(LoaderIndex.BATTERY_HISTORY_LOADER, bundle,
                    mBatteryHistoryLoaderCallbacks);
        } else if (!mIsChartGraphEnabled) {
            super.restartBatteryStatsLoader(refreshType);
+42 −6
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Bundle;
import android.os.UserManager;
import android.util.Log;

import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.loader.app.LoaderManager;
@@ -33,17 +34,19 @@ import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.fuelgauge.BatteryBroadcastReceiver;
import com.android.settings.fuelgauge.BatteryUtils;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Common base class for things that need to show the battery usage graph.
 */
public abstract class PowerUsageBase extends DashboardFragment {

    private static final String TAG = "PowerUsageBase";
    private static final String KEY_REFRESH_TYPE = "refresh_type";
    private static final String KEY_INCLUDE_HISTORY = "include_history";

    private static final int LOADER_BATTERY_USAGE_STATS = 1;

    @VisibleForTesting
    static final String KEY_REFRESH_TYPE = "refresh_type";
    @VisibleForTesting
    static final String KEY_INCLUDE_HISTORY = "include_history";
    @VisibleForTesting
    BatteryUsageStats mBatteryUsageStats;

@@ -55,6 +58,21 @@ public abstract class PowerUsageBase extends DashboardFragment {
    final BatteryUsageStatsLoaderCallbacks mBatteryUsageStatsLoaderCallbacks =
            new BatteryUsageStatsLoaderCallbacks();

    @Retention(RetentionPolicy.SOURCE)
    @IntDef({
            LoaderIndex.BATTERY_USAGE_STATS_LOADER,
            LoaderIndex.BATTERY_INFO_LOADER,
            LoaderIndex.BATTERY_TIP_LOADER,
            LoaderIndex.BATTERY_HISTORY_LOADER

    })
    public @interface LoaderIndex {
        int BATTERY_USAGE_STATS_LOADER = 0;
        int BATTERY_INFO_LOADER = 1;
        int BATTERY_TIP_LOADER = 2;
        int BATTERY_HISTORY_LOADER = 3;
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
@@ -91,10 +109,28 @@ public abstract class PowerUsageBase extends DashboardFragment {
        final Bundle bundle = new Bundle();
        bundle.putInt(KEY_REFRESH_TYPE, refreshType);
        bundle.putBoolean(KEY_INCLUDE_HISTORY, isBatteryHistoryNeeded());
        getLoaderManager().restartLoader(LOADER_BATTERY_USAGE_STATS, bundle,
        restartLoader(LoaderIndex.BATTERY_USAGE_STATS_LOADER, bundle,
                mBatteryUsageStatsLoaderCallbacks);
    }

    protected LoaderManager getLoaderManagerForCurrentFragment() {
        return LoaderManager.getInstance(this);
    }

    protected void restartLoader(int loaderId, Bundle bundle,
            LoaderManager.LoaderCallbacks<?> loaderCallbacks) {
        LoaderManager loaderManager = getLoaderManagerForCurrentFragment();
        Loader<?> loader = loaderManager.getLoader(
                loaderId);
        if (loader != null && !loader.isReset()) {
            loaderManager.restartLoader(loaderId, bundle,
                    loaderCallbacks);
        } else {
            loaderManager.initLoader(loaderId, bundle,
                    loaderCallbacks);
        }
    }

    protected void onLoadFinished(@BatteryUpdateType int refreshType) {
        refreshUi(refreshType);
    }
+2 −8
Original line number Diff line number Diff line
@@ -64,11 +64,6 @@ public class PowerUsageSummary extends PowerUsageBase implements
    @VisibleForTesting
    static final String KEY_BATTERY_USAGE = "battery_usage_summary";

    @VisibleForTesting
    static final int BATTERY_INFO_LOADER = 1;
    @VisibleForTesting
    static final int BATTERY_TIP_LOADER = 2;

    @VisibleForTesting
    PowerUsageFeatureProvider mPowerFeatureProvider;
    @VisibleForTesting
@@ -241,7 +236,7 @@ public class PowerUsageSummary extends PowerUsageBase implements

    @VisibleForTesting
    void restartBatteryTipLoader() {
        getLoaderManager().restartLoader(BATTERY_TIP_LOADER, Bundle.EMPTY, mBatteryTipsCallbacks);
        restartLoader(LoaderIndex.BATTERY_TIP_LOADER, Bundle.EMPTY, mBatteryTipsCallbacks);
    }

    @VisibleForTesting
@@ -274,8 +269,7 @@ public class PowerUsageSummary extends PowerUsageBase implements
        if (!mIsBatteryPresent) {
            return;
        }
        getLoaderManager().restartLoader(BATTERY_INFO_LOADER, Bundle.EMPTY,
                mBatteryInfoLoaderCallbacks);
        restartLoader(LoaderIndex.BATTERY_INFO_LOADER, Bundle.EMPTY, mBatteryInfoLoaderCallbacks);
    }

    @VisibleForTesting
Loading