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

Commit 8a376c7e authored by android-build-team Robot's avatar android-build-team Robot
Browse files

release-request-2b6c1b3d-5e73-4d4a-9a8d-92acb8a1483b-for-git_oc-mr1-release-42...

release-request-2b6c1b3d-5e73-4d4a-9a8d-92acb8a1483b-for-git_oc-mr1-release-4212424 snap-temp-L13800000085536241

Change-Id: I839f1c9c1df5c11ae8374913c37d0ce2a16d1674
parents d79b72d2 7edaa603
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -387,7 +387,7 @@
    <string name="bluetooth_sap_acceptance_dialog_text"><xliff:g id="device_name">%1$s</xliff:g> wants to access your SIM card. Granting access to the SIM card will disable data connectivity on your device for the duration of the connection. Give access to <xliff:g id="device_name">%2$s?</xliff:g></string>
    <!-- Description for bluetooth device name summary [CHAR LIMIT=none] -->
    <string name="bluetooth_device_name_summary">Visible as \'<xliff:g id="device_name">^1</xliff:g>\' to other devices</string>
    <string name="bluetooth_device_name_summary">Visible as \"<xliff:g id="device_name">^1</xliff:g>\" to other devices</string>
    <!-- Title for paired device group [CHAR LIMIT=none] -->
    <string name="bluetooth_paired_device_title">Your devices</string>
+5 −0
Original line number Diff line number Diff line
@@ -1222,6 +1222,11 @@ public final class Utils extends com.android.settingslib.Utils {
        }
    }

    public static boolean hasFingerprintHardware(Context context) {
        FingerprintManager fingerprintManager = getFingerprintManagerOrNull(context);
        return fingerprintManager != null && fingerprintManager.isHardwareDetected();
    }

    /**
     * Launches an intent which may optionally have a user id defined.
     * @param fragment Fragment to use to launch the activity.
+5 −3
Original line number Diff line number Diff line
@@ -65,12 +65,14 @@ public class SuggestionsChecks {
        } else if (className.equals(WifiCallingSuggestionActivity.class.getName())) {
            return isWifiCallingUnavailableOrEnabled();
        } else if (className.equals(FingerprintSuggestionActivity.class.getName())) {
            return isNotSingleFingerprintEnrolled() || !isFingerprintEnabled();
            return !Utils.hasFingerprintHardware(mContext) || !isFingerprintEnabled()
                    || isNotSingleFingerprintEnrolled();
        } else if (className.equals(ScreenLockSuggestionActivity.class.getName())) {
            return isDeviceSecured();
        } else if (className.equals(FingerprintEnrollSuggestionActivity.class.getName())) {
            FingerprintManager manager = Utils.getFingerprintManagerOrNull(mContext);
            if (manager == null || !isFingerprintEnabled()) {
            final FingerprintManager manager = Utils.getFingerprintManagerOrNull(mContext);
            if (manager == null || !isFingerprintEnabled()
                    || !Utils.hasFingerprintHardware(mContext)) {
                return true;
            }
            return manager.hasEnrolledFingerprints();
+21 −5
Original line number Diff line number Diff line
@@ -15,23 +15,28 @@
 */
package com.android.settings.display;

import static android.provider.Settings.Secure.DOZE_ALWAYS_ON;


import android.content.Context;
import android.content.Intent;
import android.os.UserHandle;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;

import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.search.DatabaseIndexingUtils;
import com.android.settings.search.InlineSwitchPayload;
import com.android.settings.search.ResultPayload;
import com.android.settingslib.core.AbstractPreferenceController;

public class AmbientDisplayAlwaysOnPreferenceController extends
        AbstractPreferenceController implements PreferenceControllerMixin,
        Preference.OnPreferenceChangeListener {

    private final int ON = 1;
    private final int OFF = 0;

    private static final String KEY_ALWAYS_ON = "ambient_display_always_on";
    private static final int MY_USER = UserHandle.myUserId();

@@ -61,8 +66,9 @@ public class AmbientDisplayAlwaysOnPreferenceController extends

    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        int enabled = (boolean) newValue ? 1 : 0;
        Settings.Secure.putInt(mContext.getContentResolver(), DOZE_ALWAYS_ON, enabled);
        int enabled = (boolean) newValue ? ON : OFF;
        Settings.Secure.putInt(
                mContext.getContentResolver(), Settings.Secure.DOZE_ALWAYS_ON, enabled);
        if (mCallback != null) {
            mCallback.onPreferenceChanged();
        }
@@ -73,4 +79,14 @@ public class AmbientDisplayAlwaysOnPreferenceController extends
    public boolean isAvailable() {
        return mConfig.alwaysOnAvailable();
    }

    @Override
    public ResultPayload getResultPayload() {
        final Intent intent = DatabaseIndexingUtils.buildSubsettingIntent(mContext,
                AmbientDisplaySettings.class.getName(), KEY_ALWAYS_ON,
                mContext.getString(R.string.ambient_display_screen_title));

        return new InlineSwitchPayload(Settings.Secure.DOZE_ALWAYS_ON,
                ResultPayload.SettingsSource.SECURE, ON, intent, isAvailable());
    }
}
+42 −18
Original line number Diff line number Diff line
@@ -53,14 +53,16 @@ public class BatteryUtils {
    public static final int SDK_NULL = -1;

    @Retention(RetentionPolicy.SOURCE)
    @IntDef({StatusType.FOREGROUND,
    @IntDef({StatusType.SCREEN_USAGE,
            StatusType.FOREGROUND,
            StatusType.BACKGROUND,
            StatusType.ALL
    })
    public @interface StatusType {
        int FOREGROUND = 0;
        int BACKGROUND = 1;
        int ALL = 2;
        int SCREEN_USAGE = 0;
        int FOREGROUND = 1;
        int BACKGROUND = 2;
        int ALL = 3;
    }

    private static final String TAG = "BatteryUtils";
@@ -96,6 +98,8 @@ public class BatteryUtils {
        }

        switch (type) {
            case StatusType.SCREEN_USAGE:
                return getScreenUsageTimeMs(uid, which);
            case StatusType.FOREGROUND:
                return getProcessForegroundTimeMs(uid, which);
            case StatusType.BACKGROUND:
@@ -107,18 +111,7 @@ public class BatteryUtils {
        return 0;
    }

    private long getProcessBackgroundTimeMs(BatteryStats.Uid uid, int which) {
        final long rawRealTimeUs = convertMsToUs(SystemClock.elapsedRealtime());
        final long timeUs = uid.getProcessStateTime(
                BatteryStats.Uid.PROCESS_STATE_BACKGROUND, rawRealTimeUs, which);

        Log.v(TAG, "package: " + mPackageManager.getNameForUid(uid.getUid()));
        Log.v(TAG, "background time(us): " + timeUs);
        return convertUsToMs(timeUs);
    }

    private long getProcessForegroundTimeMs(BatteryStats.Uid uid, int which) {
        final long rawRealTimeUs = convertMsToUs(SystemClock.elapsedRealtime());
    private long getScreenUsageTimeMs(BatteryStats.Uid uid, int which, long rawRealTimeUs) {
        final int foregroundTypes[] = {BatteryStats.Uid.PROCESS_STATE_TOP};
        Log.v(TAG, "package: " + mPackageManager.getNameForUid(uid.getUid()));

@@ -131,11 +124,32 @@ public class BatteryUtils {
        Log.v(TAG, "foreground time(us): " + timeUs);

        // Return the min value of STATE_TOP time and foreground activity time, since both of these
        // time have some errors.
        // time have some errors
        return convertUsToMs(
                Math.min(timeUs, getForegroundActivityTotalTimeUs(uid, rawRealTimeUs)));
    }

    private long getScreenUsageTimeMs(BatteryStats.Uid uid, int which) {
        final long rawRealTimeUs = convertMsToUs(SystemClock.elapsedRealtime());
        return getScreenUsageTimeMs(uid, which, rawRealTimeUs);
    }

    private long getProcessBackgroundTimeMs(BatteryStats.Uid uid, int which) {
        final long rawRealTimeUs = convertMsToUs(SystemClock.elapsedRealtime());
        final long timeUs = uid.getProcessStateTime(
                BatteryStats.Uid.PROCESS_STATE_BACKGROUND, rawRealTimeUs, which);

        Log.v(TAG, "package: " + mPackageManager.getNameForUid(uid.getUid()));
        Log.v(TAG, "background time(us): " + timeUs);
        return convertUsToMs(timeUs);
    }

    private long getProcessForegroundTimeMs(BatteryStats.Uid uid, int which) {
        final long rawRealTimeUs = convertMsToUs(SystemClock.elapsedRealtime());
        return getScreenUsageTimeMs(uid, which, rawRealTimeUs)
                + convertUsToMs(getForegroundServiceTotalTimeUs(uid, rawRealTimeUs));
    }

    /**
     * Remove the {@link BatterySipper} that we should hide and smear the screen usage based on
     * foreground activity time.
@@ -183,7 +197,7 @@ public class BatteryUtils {
        for (int i = 0, size = sippers.size(); i < size; i++) {
            final BatteryStats.Uid uid = sippers.get(i).uidObj;
            if (uid != null) {
                final long timeMs = getProcessTimeMs(StatusType.FOREGROUND, uid,
                final long timeMs = getProcessTimeMs(StatusType.SCREEN_USAGE, uid,
                        BatteryStats.STATS_SINCE_CHARGED);
                activityTimeArray.put(uid.getUid(), timeMs);
                totalActivityTimeMs += timeMs;
@@ -388,5 +402,15 @@ public class BatteryUtils {
        return 0;
    }

    @VisibleForTesting
    long getForegroundServiceTotalTimeUs(BatteryStats.Uid uid, long rawRealtimeUs) {
        final BatteryStats.Timer timer = uid.getForegroundServiceTimer();
        if (timer != null) {
            return timer.getTotalTimeLocked(rawRealtimeUs, BatteryStats.STATS_SINCE_CHARGED);
        }

        return 0;
    }

}
Loading