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

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

Snap for 5719479 from 2dbb6080 to qt-c2f2-release

Change-Id: I30570cabeb0dbb8d77da3c47549a877984e00e4b
parents 15d29607 2dbb6080
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -575,7 +575,7 @@ static void android_os_Debug_getMemInfo(JNIEnv *env, jobject clazz, jlongArray o
    if (outArray != NULL) {
        outLen = MEMINFO_COUNT;
        for (int i = 0; i < outLen; i++) {
            if (i == MEMINFO_VMALLOC_USED) {
            if (i == MEMINFO_VMALLOC_USED && mem[i] == 0) {
                outArray[i] = smi.ReadVmallocInfo() / 1024;
                continue;
            }
+1 −1
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ public class HidProfile implements LocalBluetoothProfile {

    public boolean isPreferred(BluetoothDevice device) {
        if (mService == null) return false;
        return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF;
        return mService.getPriority(device) != BluetoothProfile.PRIORITY_OFF;
    }

    public int getPreferred(BluetoothDevice device) {
+3 −22
Original line number Diff line number Diff line
@@ -18,15 +18,11 @@ package com.android.settingslib.net;

import android.content.Context;
import android.net.NetworkTemplate;
import android.os.ParcelUuid;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;

/**
 * Utils class for data usage
 */
@@ -38,7 +34,7 @@ public class DataUsageUtils {
     */
    public static NetworkTemplate getMobileTemplate(Context context, int subId) {
        final TelephonyManager telephonyManager = context.getSystemService(
                TelephonyManager.class);
                TelephonyManager.class).createForSubscriptionId(subId);
        final SubscriptionManager subscriptionManager = context.getSystemService(
                SubscriptionManager.class);
        final SubscriptionInfo info = subscriptionManager.getActiveSubscriptionInfo(subId);
@@ -49,23 +45,8 @@ public class DataUsageUtils {
            Log.i(TAG, "Subscription is not active: " + subId);
            return mobileAll;
        }
        final ParcelUuid groupUuid = info.getGroupUuid();
        if (groupUuid == null) {
            Log.i(TAG, "Subscription doesn't have valid group uuid: " + subId);
            return mobileAll;
        }

        // Otherwise merge other subscriberId to create new NetworkTemplate
        final List<SubscriptionInfo> groupInfos = subscriptionManager.getSubscriptionsInGroup(
                groupUuid);
        final List<String> mergedSubscriberIds = new ArrayList<>();
        for (SubscriptionInfo subInfo : groupInfos) {
            final String subscriberId = telephonyManager.getSubscriberId(
                    subInfo.getSubscriptionId());
            if (subscriberId != null) {
                mergedSubscriberIds.add(subscriberId);
            }
        }
        return NetworkTemplate.normalize(mobileAll, mergedSubscriberIds.toArray(new String[0]));
        // Use old API to build networkTemplate
        return NetworkTemplate.normalize(mobileAll, telephonyManager.getMergedSubscriberIds());
    }
}
+4 −15
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ import java.util.List;
public class DataUsageUtilsTest {

    private static final int SUB_ID = 1;
    private static final int SUB_ID_2 = 2;
    private static final String SUBSCRIBER_ID = "Test Subscriber";
    private static final String SUBSCRIBER_ID_2 = "Test Subscriber 2";

@@ -67,11 +66,11 @@ public class DataUsageUtilsTest {

        mContext = spy(RuntimeEnvironment.application);
        when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
        when(mTelephonyManager.createForSubscriptionId(SUB_ID)).thenReturn(mTelephonyManager);
        when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
        when(mTelephonyManager.getSubscriberId(SUB_ID)).thenReturn(SUBSCRIBER_ID);
        when(mTelephonyManager.getSubscriberId(SUB_ID_2)).thenReturn(SUBSCRIBER_ID_2);
        when(mInfo1.getSubscriptionId()).thenReturn(SUB_ID);
        when(mInfo2.getSubscriptionId()).thenReturn(SUB_ID_2);
        when(mTelephonyManager.getMergedSubscriberIds()).thenReturn(
                new String[]{SUBSCRIBER_ID, SUBSCRIBER_ID_2});

        mInfos = new ArrayList<>();
        mInfos.add(mInfo1);
@@ -89,17 +88,7 @@ public class DataUsageUtilsTest {
    }

    @Test
    public void getMobileTemplate_groupUuidNull_returnMobileAll() {
        when(mSubscriptionManager.getActiveSubscriptionInfo(SUB_ID)).thenReturn(mInfo1);
        when(mInfo1.getGroupUuid()).thenReturn(null);

        final NetworkTemplate networkTemplate = DataUsageUtils.getMobileTemplate(mContext, SUB_ID);
        assertThat(networkTemplate.matchesSubscriberId(SUBSCRIBER_ID)).isTrue();
        assertThat(networkTemplate.matchesSubscriberId(SUBSCRIBER_ID_2)).isFalse();
    }

    @Test
    public void getMobileTemplate_groupUuidExist_returnMobileMerged() {
    public void getMobileTemplate_infoExisted_returnMobileMerged() {
        when(mSubscriptionManager.getActiveSubscriptionInfo(SUB_ID)).thenReturn(mInfo1);
        when(mInfo1.getGroupUuid()).thenReturn(mParcelUuid);

+45 −3
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ public class ImageWallpaper extends WallpaperService {
    // We delayed destroy render context that subsequent render requests have chance to cancel it.
    // This is to avoid destroying then recreating render context in a very short time.
    private static final int DELAY_FINISH_RENDERING = 1000;
    private static final int INTERVAL_WAIT_FOR_RENDERING = 100;
    private static final int PATIENCE_WAIT_FOR_RENDERING = 5;
    private HandlerThread mWorker;

    @Override
@@ -80,7 +82,10 @@ public class ImageWallpaper extends WallpaperService {
        private StatusBarStateController mController;
        private final Runnable mFinishRenderingTask = this::finishRendering;
        private final boolean mNeedTransition;
        private final Object mMonitor = new Object();
        private boolean mNeedRedraw;
        // This variable can only be accessed in synchronized block.
        private boolean mWaitingForRendering;

        GLEngine(Context context) {
            mNeedTransition = ActivityManager.isHighEndGfx()
@@ -122,6 +127,27 @@ public class ImageWallpaper extends WallpaperService {
            long duration = mNeedTransition || animationDuration != 0 ? animationDuration : 0;
            mWorker.getThreadHandler().post(
                    () -> mRenderer.updateAmbientMode(inAmbientMode, duration));
            if (inAmbientMode && duration == 0) {
                // This means that we are transiting from home to aod, to avoid
                // race condition between window visibility and transition,
                // we don't return until the transition is finished. See b/136643341.
                waitForBackgroundRendering();
            }
        }

        private void waitForBackgroundRendering() {
            synchronized (mMonitor) {
                try {
                    mWaitingForRendering = true;
                    for (int patience = 1; mWaitingForRendering; patience++) {
                        mMonitor.wait(INTERVAL_WAIT_FOR_RENDERING);
                        mWaitingForRendering &= patience < PATIENCE_WAIT_FOR_RENDERING;
                    }
                } catch (InterruptedException ex) {
                } finally {
                    mWaitingForRendering = false;
                }
            }
        }

        @Override
@@ -178,7 +204,8 @@ public class ImageWallpaper extends WallpaperService {

        @Override
        public void preRender() {
            mWorker.getThreadHandler().post(this::preRenderInternal);
            // This method should only be invoked from worker thread.
            preRenderInternal();
        }

        private void preRenderInternal() {
@@ -212,7 +239,8 @@ public class ImageWallpaper extends WallpaperService {

        @Override
        public void requestRender() {
            mWorker.getThreadHandler().post(this::requestRenderInternal);
            // This method should only be invoked from worker thread.
            requestRenderInternal();
        }

        private void requestRenderInternal() {
@@ -234,7 +262,21 @@ public class ImageWallpaper extends WallpaperService {

        @Override
        public void postRender() {
            mWorker.getThreadHandler().post(this::scheduleFinishRendering);
            // This method should only be invoked from worker thread.
            notifyWaitingThread();
            scheduleFinishRendering();
        }

        private void notifyWaitingThread() {
            synchronized (mMonitor) {
                if (mWaitingForRendering) {
                    try {
                        mWaitingForRendering = false;
                        mMonitor.notify();
                    } catch (IllegalMonitorStateException ex) {
                    }
                }
            }
        }

        private void cancelFinishRenderingTask() {
Loading