From 830217f277e31e63d9ab8acd21ee2a8f81ee1c8f Mon Sep 17 00:00:00 2001 From: Chienyuan Date: Tue, 9 Jul 2019 15:09:56 +0800 Subject: [PATCH 01/12] HidProfile: sync isPreferred() with HidHostService HidHostService allow to connect when priority is PRIORITY_UNDEFINED. HidProfile should return ture when priority is PRIORITY_UNDEFINED. Otherwise, the "Input device" toggle in off state when HID device connected. Bug: 132456322 Test: manual Change-Id: Id7bae694c57aec17e019d591c0a677e3cb64f845 --- .../src/com/android/settingslib/bluetooth/HidProfile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidProfile.java index a9e8db599177a..fb6a990a29fd3 100755 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidProfile.java @@ -121,7 +121,7 @@ public final 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) { From b378059f1152ed41c9b096c4c48701a1f4bb900e Mon Sep 17 00:00:00 2001 From: Ahan Wu Date: Thu, 4 Jul 2019 20:50:00 +0800 Subject: [PATCH 02/12] Fix wallpaper flicker issue while transiting from home to aod. There is a race condition between window visibility and wallpaper transition, so wallpaper window might become visible before background thread has done its rendering work and a flicker happens. This solution just lets main thread wait for background thread to synchronize window visibility and wallpaper transition. Bug: 136643341 Test: atest SystemUITests Test: Screen off Launcher/APP -> AOD : No extra transition by design, The duration between press Power Key and AOD show should be same. Test: Screen on AOD -> Launcher : Face unlock work without flickr Test: Screen off Keyguard -> AOD : Either Panel or background transition without flickr Test: Screen on AOD -> Keyguard : Either Panel or background transition without flickr Test: Reach in AOD -> Keyguard : Either Panel or background transition without flickr Test: Reach out Keyguard -> AOD : Either Panel or background transition without flickr Test: Manually operate and observe log. Change-Id: Iebfdac18972569864c047bc2c4a33d7791940896 --- .../com/android/systemui/ImageWallpaper.java | 48 +++++++++++++++++-- .../glwallpaper/ImageRevealHelper.java | 12 ++++- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java index 9a0e9fc92af66..c9d4957494e4c 100644 --- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java +++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java @@ -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() { diff --git a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageRevealHelper.java b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageRevealHelper.java index 6a1f24afe6200..45e97b38d87ed 100644 --- a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageRevealHelper.java +++ b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageRevealHelper.java @@ -84,7 +84,17 @@ class ImageRevealHelper { void updateAwake(boolean awake, long duration) { mAwake = awake; mAnimator.setDuration(duration); - animate(); + if (!mAwake && duration == 0) { + // We are transiting from home to aod, + // since main thread is waiting for rendering finished, we only need draw + // the last state directly, which is a black screen. + mReveal = MIN_REVEAL; + mRevealListener.onRevealStart(); + mRevealListener.onRevealStateChanged(); + mRevealListener.onRevealEnd(); + } else { + animate(); + } } /** From ea64a78dd9c442983a9099fa8dc9a60ffd2b1b50 Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Tue, 9 Jul 2019 10:40:53 -0700 Subject: [PATCH 03/12] Import translations. DO NOT MERGE Auto-generated-cl: translation import Bug: 64712476 Change-Id: I75c667821566cceb965581d51a0a2e59418faf1f --- packages/SystemUI/res/values-ar/strings.xml | 2 +- packages/SystemUI/res/values-bn/strings.xml | 2 +- packages/SystemUI/res/values-hi/strings.xml | 4 ++-- packages/SystemUI/res/values-pa/strings.xml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/res/values-ar/strings.xml b/packages/SystemUI/res/values-ar/strings.xml index 0c90466e3e045..916137ee05275 100644 --- a/packages/SystemUI/res/values-ar/strings.xml +++ b/packages/SystemUI/res/values-ar/strings.xml @@ -463,7 +463,7 @@ "تم تفعيل ميزة توفير شحن البطارية" "لخفض مستوى الأداء وبيانات الخلفية" "إيقاف ميزة توفير شحن البطارية" - "أثناء التسجيل أو الإرسال، يمكن لتطبيق %s تسجيل أي معلومات حساسة يتم عرضها على الشاشة أو تشغيلها من جهازك، بما فيها المعلومات الحساسة مثل الصوت الذي تشغّله وكلمات المرور ومعلومات الدفع والصور والرسائل." + "أثناء التسجيل أو البث، يمكن لتطبيق %s تسجيل أي معلومات حسّاسة يتم عرضها على الشاشة أو تشغيلها من جهازك، بما فيها المعلومات الحسّاسة مثل المقاطع الصوتية وكلمات المرور ومعلومات الدفع والصور والرسائل." "أثناء التسجيل أو الإرسال، يمكن للخدمة التي تقدّم هذه الوظيفة تسجيل أي معلومات حساسة يتم عرضها على الشاشة أو تشغيلها من جهازك، بما فيها المعلومات الحساسة مثل الصوت الذي تشغّله وكلمات المرور ومعلومات الدفع والصور والرسائل." "عرض معلومات حسّاسة أثناء الإرسال/التسجيل" "عدم الإظهار مرة أخرى" diff --git a/packages/SystemUI/res/values-bn/strings.xml b/packages/SystemUI/res/values-bn/strings.xml index 5ed858c18d9de..5a690d47bbad1 100644 --- a/packages/SystemUI/res/values-bn/strings.xml +++ b/packages/SystemUI/res/values-bn/strings.xml @@ -778,7 +778,7 @@ "টাইল যোগ করতে ধরে থেকে টেনে আনুন" "টাইলগুলি আবার সাজানোর জন্য ধরে থেকে টেনে আনুন" "সরানোর জন্য এখানে টেনে আনুন" - "অন্তত ৬টি টাইল রাখতে হবে" + "আপনাকে কমপক্ষে %1$dটি টাইল রাখতে হবে" "সম্পাদনা করুন" "সময়" diff --git a/packages/SystemUI/res/values-hi/strings.xml b/packages/SystemUI/res/values-hi/strings.xml index 63800ae71320b..566731cbacf92 100644 --- a/packages/SystemUI/res/values-hi/strings.xml +++ b/packages/SystemUI/res/values-hi/strings.xml @@ -483,7 +483,7 @@ "डिवाइस प्रबंधन" "प्रोफ़ाइल को मॉनीटर करना" "नेटवर्क को मॉनीटर करना" - "VPN" + "वीपीएन" "नेटवर्क लॉगिंग" "CA प्रमाणपत्र" "VPN अक्षम करें" @@ -512,7 +512,7 @@ "आपके एडमिन ने नेटवर्क लॉग करना चालू कर दिया है, जो आपके डिवाइस पर ट्रैफ़िक की निगरानी करता है.\n\nज़्यादा जानकारी के लिए अपने एडमिन से संपर्क करें." "आपने किसी ऐप को VPN कनेक्‍शन सेट करने की अनुमति दी है.\n\nयह ऐप ईमेल, ऐप्‍स और सुरक्षित वेबसाइटों सहित आपके डिवाइस और नेटवर्क की गतिविधि की निगरानी कर सकता है." "%1$s आपकी वर्क प्रोफ़ाइल को प्रबंधित करता है.\n\n आपका एडमिन ईमेल, ऐप्लिकेशन और वेबसाइटों सहित आपकी नेटवर्क गतिविधि की निगरानी कर सकता है.\n\nऔर जानकारी के लिए अपने एडमिन से संपर्क करें.\n\nआप ऐसे VPN से भी कनेक्‍ट हैं, जो आपकी नेटवर्क गतिविधि की निगरानी कर सकता है." - "VPN" + "वीपीएन" "आप %1$s से कनेक्ट हैं, जो ईमेल, ऐप्लिकेशन और वेबसाइटों सहित आपकी नेटवर्क गतिविधि की निगरानी कर सकता है." "आप %1$s से कनेक्‍ट हैं, जो ईमेल, ऐप्‍स और वेबसाइटों सहित आपकी व्‍यक्‍तिगत नेटवर्क गतिविधि की निगरानी कर सकता है." "आप %1$s से कनेक्‍ट हैं, जो ईमेल, ऐप्लिकेशन और वेबसाइट सहित आपकी व्‍यक्‍तिगत नेटवर्क गतिविधि को मॉनिटर कर सकता है." diff --git a/packages/SystemUI/res/values-pa/strings.xml b/packages/SystemUI/res/values-pa/strings.xml index 897875c8fcfc1..393469ee0d9e2 100644 --- a/packages/SystemUI/res/values-pa/strings.xml +++ b/packages/SystemUI/res/values-pa/strings.xml @@ -778,7 +778,7 @@ "ਟਾਇਲਾਂ ਸ਼ਾਮਲ ਕਰਨ ਲਈ ਫੜ੍ਹ ਕੇ ਰੱਖੋ ਅਤੇ ਘਸੀਟੋ" "ਟਾਇਲਾਂ ਨੂੰ ਮੁੜ-ਵਿਵਸਥਿਤ ਕਰਨ ਲਈ ਫੜ੍ਹ ਕੇ ਘਸੀਟੋ" "ਹਟਾਉਣ ਲਈ ਇੱਥੇ ਘਸੀਟੋ" - "ਤੁਹਾਨੂੰ ਘੱਟੋ-ਘੱਟ 6 ਟਾਇਲਾਂ ਦੀ ਲੋੜ ਪਵੇਗੀ" + "ਤੁਹਾਨੂੰ ਘੱਟੋ-ਘੱਟ %1$d ਟਾਇਲਾਂ ਦੀ ਲੋੜ ਪਵੇਗੀ" "ਸੰਪਾਦਨ ਕਰੋ" "ਸਮਾਂ" From 6686f1f916f65d167fca3b69e2af0eeefbd58826 Mon Sep 17 00:00:00 2001 From: Matt Pape Date: Tue, 9 Jul 2019 10:41:20 -0700 Subject: [PATCH 04/12] Update Mainline rollback lifetime from 2 days to 14 days. Test: atest RollbackTest atest RollbackE2EHostTestCases Bug: 137094406 Change-Id: I587d9fca25ead8b7edb76550703837642db545e4 --- .../android/server/rollback/RollbackManagerServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java index e107c9aedf38b..03c3830c205fa 100644 --- a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java +++ b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java @@ -86,9 +86,9 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub { private static final String TAG = "RollbackManager"; - // Rollbacks expire after 48 hours. + // Rollbacks expire after 14 days. private static final long DEFAULT_ROLLBACK_LIFETIME_DURATION_MILLIS = - TimeUnit.HOURS.toMillis(48); + TimeUnit.DAYS.toMillis(14); // Lock used to synchronize accesses to in-memory rollback data // structures. By convention, methods with the suffix "Locked" require From 5e955861f98c31329ff7fa17c3f2f1091de2c9f2 Mon Sep 17 00:00:00 2001 From: Lei Yu Date: Tue, 9 Jul 2019 15:17:49 -0700 Subject: [PATCH 05/12] Use old API to build NetworkTemplate Use old API to be consistent with NetworkPolicyManagerService Bug: 135105735 Test: RunSettingsLibRoboTests & Manual test Change-Id: I5d04cfd962c3d09cac7d33a97f847771074ab258 --- .../settingslib/net/DataUsageUtils.java | 25 +++---------------- .../settingslib/net/DataUsageUtilsTest.java | 19 +++----------- 2 files changed, 7 insertions(+), 37 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/net/DataUsageUtils.java b/packages/SettingsLib/src/com/android/settingslib/net/DataUsageUtils.java index de38e8a366b4a..b15ea980ae15d 100644 --- a/packages/SettingsLib/src/com/android/settingslib/net/DataUsageUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/net/DataUsageUtils.java @@ -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 groupInfos = subscriptionManager.getSubscriptionsInGroup( - groupUuid); - final List 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()); } } diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/DataUsageUtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/DataUsageUtilsTest.java index dc33cfe4b2f84..821c0b3a23f71 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/DataUsageUtilsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/DataUsageUtilsTest.java @@ -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); From 17bfed91ccf43d5856ed74e52b60af5d480babac Mon Sep 17 00:00:00 2001 From: Richard Uhler Date: Wed, 10 Jul 2019 15:00:09 +0100 Subject: [PATCH 06/12] Fix NullPointerException. Fix a NullPointerException that can occur if a package with a recently created rollback is no longer installed on device when the device boots. Bug: 137135842 Test: atest CtsRollbackManagerHostTestCases Change-Id: Ic007e44264647793c6271c3923c13c9e1736a9de --- .../android/server/rollback/RollbackManagerServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java index e107c9aedf38b..c7e2ca899d4e4 100644 --- a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java +++ b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java @@ -1289,7 +1289,8 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub { private boolean packageVersionsEqual(VersionedPackage a, VersionedPackage b) { - return a.getPackageName().equals(b.getPackageName()) + return a != null && b != null + && a.getPackageName().equals(b.getPackageName()) && a.getLongVersionCode() == b.getLongVersionCode(); } From 42a6af7a11842cea3faa97d24dba209a97101bb3 Mon Sep 17 00:00:00 2001 From: Mihai Popa Date: Tue, 25 Jun 2019 11:15:18 +0100 Subject: [PATCH 07/12] Fix Layout.primaryIsTrailingPreviousAllLineOffsets The CL fixes a crash in Layout.primaryIsTrailingPreviousAllLineOffsets. The crash was happening when the method was called for a line beginning with an empty bidi run. This could happen, for example, for empty text - I was unable to find any other case. The CL improves the existing test for the method with this case, which was previously crashing. The CL also fixes a potential crash in getLineHorizontals. However, this bug could never happen as in the current code path clamped is always false (and kept as parameter for parity with getHorizontal). Bug: 135444178 Bug: 78464361 Test: atest FrameworksCoreTests:android.text.LayoutTest\#testPrimaryIsTrailingPrevious Change-Id: I47157abe1d74675884734e3810628a566e40c1b4 (cherry picked from commit 7ad499d00716f45fffdf7331493ed21d1b8d9b77) --- core/java/android/text/Layout.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java index 84ef9435f64ce..8f9233f068397 100644 --- a/core/java/android/text/Layout.java +++ b/core/java/android/text/Layout.java @@ -1070,6 +1070,9 @@ public abstract class Layout { if (limit > lineEnd) { limit = lineEnd; } + if (limit == start) { + continue; + } level[limit - lineStart - 1] = (byte) ((runs[i + 1] >>> RUN_LEVEL_SHIFT) & RUN_LEVEL_MASK); } @@ -1165,8 +1168,8 @@ public abstract class Layout { } /** - * Computes in linear time the results of calling - * #getHorizontal for all offsets on a line. + * Computes in linear time the results of calling #getHorizontal for all offsets on a line. + * * @param line The line giving the offsets we compute information for * @param clamped Whether to clamp the results to the width of the layout * @param primary Whether the results should be the primary or the secondary horizontal @@ -1201,7 +1204,7 @@ public abstract class Layout { TextLine.recycle(tl); if (clamped) { - for (int offset = 0; offset <= wid.length; ++offset) { + for (int offset = 0; offset < wid.length; ++offset) { if (wid[offset] > mWidth) { wid[offset] = mWidth; } From 9109ce6b0af6fc94b79cf855a10d85e107c768c2 Mon Sep 17 00:00:00 2001 From: Mihai Popa Date: Tue, 25 Jun 2019 11:15:18 +0100 Subject: [PATCH 08/12] Fix Layout.primaryIsTrailingPreviousAllLineOffsets The CL fixes a crash in Layout.primaryIsTrailingPreviousAllLineOffsets. The crash was happening when the method was called for a line beginning with an empty bidi run. This could happen, for example, for empty text - I was unable to find any other case. The CL improves the existing test for the method with this case, which was previously crashing. The CL also fixes a potential crash in getLineHorizontals. However, this bug could never happen as in the current code path clamped is always false (and kept as parameter for parity with getHorizontal). Bug: 135444178 Bug: 78464361 Test: atest FrameworksCoreTests:android.text.LayoutTest\#testPrimaryIsTrailingPrevious Change-Id: I47157abe1d74675884734e3810628a566e40c1b4 (cherry picked from commit 7ad499d00716f45fffdf7331493ed21d1b8d9b77) --- core/java/android/text/Layout.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java index c6f73cb47576c..c02f7ef65a777 100644 --- a/core/java/android/text/Layout.java +++ b/core/java/android/text/Layout.java @@ -1099,6 +1099,9 @@ public abstract class Layout { if (limit > lineEnd) { limit = lineEnd; } + if (limit == start) { + continue; + } level[limit - lineStart - 1] = (byte) ((runs[i + 1] >>> RUN_LEVEL_SHIFT) & RUN_LEVEL_MASK); } @@ -1194,8 +1197,8 @@ public abstract class Layout { } /** - * Computes in linear time the results of calling - * #getHorizontal for all offsets on a line. + * Computes in linear time the results of calling #getHorizontal for all offsets on a line. + * * @param line The line giving the offsets we compute information for * @param clamped Whether to clamp the results to the width of the layout * @param primary Whether the results should be the primary or the secondary horizontal @@ -1230,7 +1233,7 @@ public abstract class Layout { TextLine.recycle(tl); if (clamped) { - for (int offset = 0; offset <= wid.length; ++offset) { + for (int offset = 0; offset < wid.length; ++offset) { if (wid[offset] > mWidth) { wid[offset] = mWidth; } From 209c0e824980630c7738c219eb4fe7d9504b9bf0 Mon Sep 17 00:00:00 2001 From: Mihai Popa Date: Tue, 25 Jun 2019 11:15:18 +0100 Subject: [PATCH 09/12] Fix Layout.primaryIsTrailingPreviousAllLineOffsets The CL fixes a crash in Layout.primaryIsTrailingPreviousAllLineOffsets. The crash was happening when the method was called for a line beginning with an empty bidi run. This could happen, for example, for empty text - I was unable to find any other case. The CL improves the existing test for the method with this case, which was previously crashing. The CL also fixes a potential crash in getLineHorizontals. However, this bug could never happen as in the current code path clamped is always false (and kept as parameter for parity with getHorizontal). Bug: 135444178 Bug: 78464361 Test: atest FrameworksCoreTests:android.text.LayoutTest\#testPrimaryIsTrailingPrevious Change-Id: I47157abe1d74675884734e3810628a566e40c1b4 (cherry picked from commit 7ad499d00716f45fffdf7331493ed21d1b8d9b77) --- core/java/android/text/Layout.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java index 84ef9435f64ce..8f9233f068397 100644 --- a/core/java/android/text/Layout.java +++ b/core/java/android/text/Layout.java @@ -1070,6 +1070,9 @@ public abstract class Layout { if (limit > lineEnd) { limit = lineEnd; } + if (limit == start) { + continue; + } level[limit - lineStart - 1] = (byte) ((runs[i + 1] >>> RUN_LEVEL_SHIFT) & RUN_LEVEL_MASK); } @@ -1165,8 +1168,8 @@ public abstract class Layout { } /** - * Computes in linear time the results of calling - * #getHorizontal for all offsets on a line. + * Computes in linear time the results of calling #getHorizontal for all offsets on a line. + * * @param line The line giving the offsets we compute information for * @param clamped Whether to clamp the results to the width of the layout * @param primary Whether the results should be the primary or the secondary horizontal @@ -1201,7 +1204,7 @@ public abstract class Layout { TextLine.recycle(tl); if (clamped) { - for (int offset = 0; offset <= wid.length; ++offset) { + for (int offset = 0; offset < wid.length; ++offset) { if (wid[offset] > mWidth) { wid[offset] = mWidth; } From d3e81cd63f91533915feb159e0b4241729592963 Mon Sep 17 00:00:00 2001 From: Mihai Popa Date: Tue, 25 Jun 2019 11:15:18 +0100 Subject: [PATCH 10/12] Fix Layout.primaryIsTrailingPreviousAllLineOffsets The CL fixes a crash in Layout.primaryIsTrailingPreviousAllLineOffsets. The crash was happening when the method was called for a line beginning with an empty bidi run. This could happen, for example, for empty text - I was unable to find any other case. The CL improves the existing test for the method with this case, which was previously crashing. The CL also fixes a potential crash in getLineHorizontals. However, this bug could never happen as in the current code path clamped is always false (and kept as parameter for parity with getHorizontal). Bug: 135444178 Bug: 78464361 Test: atest FrameworksCoreTests:android.text.LayoutTest\#testPrimaryIsTrailingPrevious Change-Id: I47157abe1d74675884734e3810628a566e40c1b4 (cherry picked from commit 7ad499d00716f45fffdf7331493ed21d1b8d9b77) --- core/java/android/text/Layout.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java index 3bc9390c58151..0999b982d9900 100644 --- a/core/java/android/text/Layout.java +++ b/core/java/android/text/Layout.java @@ -919,6 +919,9 @@ public abstract class Layout { if (limit > lineEnd) { limit = lineEnd; } + if (limit == start) { + continue; + } level[limit - lineStart - 1] = (byte) ((runs[i + 1] >>> RUN_LEVEL_SHIFT) & RUN_LEVEL_MASK); } @@ -1014,8 +1017,8 @@ public abstract class Layout { } /** - * Computes in linear time the results of calling - * #getHorizontal for all offsets on a line. + * Computes in linear time the results of calling #getHorizontal for all offsets on a line. + * * @param line The line giving the offsets we compute information for * @param clamped Whether to clamp the results to the width of the layout * @param primary Whether the results should be the primary or the secondary horizontal @@ -1050,7 +1053,7 @@ public abstract class Layout { TextLine.recycle(tl); if (clamped) { - for (int offset = 0; offset <= wid.length; ++offset) { + for (int offset = 0; offset < wid.length; ++offset) { if (wid[offset] > mWidth) { wid[offset] = mWidth; } From 2778b1e49d4263f47e4dc7e3e3e29cf1b423618c Mon Sep 17 00:00:00 2001 From: Mihai Popa Date: Tue, 25 Jun 2019 11:15:18 +0100 Subject: [PATCH 11/12] Fix Layout.primaryIsTrailingPreviousAllLineOffsets The CL fixes a crash in Layout.primaryIsTrailingPreviousAllLineOffsets. The crash was happening when the method was called for a line beginning with an empty bidi run. This could happen, for example, for empty text - I was unable to find any other case. The CL improves the existing test for the method with this case, which was previously crashing. The CL also fixes a potential crash in getLineHorizontals. However, this bug could never happen as in the current code path clamped is always false (and kept as parameter for parity with getHorizontal). Bug: 135444178 Bug: 78464361 Test: atest FrameworksCoreTests:android.text.LayoutTest\#testPrimaryIsTrailingPrevious Change-Id: I47157abe1d74675884734e3810628a566e40c1b4 (cherry picked from commit 7ad499d00716f45fffdf7331493ed21d1b8d9b77) --- core/java/android/text/Layout.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java index 3bc9390c58151..0999b982d9900 100644 --- a/core/java/android/text/Layout.java +++ b/core/java/android/text/Layout.java @@ -919,6 +919,9 @@ public abstract class Layout { if (limit > lineEnd) { limit = lineEnd; } + if (limit == start) { + continue; + } level[limit - lineStart - 1] = (byte) ((runs[i + 1] >>> RUN_LEVEL_SHIFT) & RUN_LEVEL_MASK); } @@ -1014,8 +1017,8 @@ public abstract class Layout { } /** - * Computes in linear time the results of calling - * #getHorizontal for all offsets on a line. + * Computes in linear time the results of calling #getHorizontal for all offsets on a line. + * * @param line The line giving the offsets we compute information for * @param clamped Whether to clamp the results to the width of the layout * @param primary Whether the results should be the primary or the secondary horizontal @@ -1050,7 +1053,7 @@ public abstract class Layout { TextLine.recycle(tl); if (clamped) { - for (int offset = 0; offset <= wid.length; ++offset) { + for (int offset = 0; offset < wid.length; ++offset) { if (wid[offset] > mWidth) { wid[offset] = mWidth; } From 7d6c02de04b576703fa29a3efc2469ede6d5f826 Mon Sep 17 00:00:00 2001 From: Mihai Popa Date: Tue, 25 Jun 2019 11:15:18 +0100 Subject: [PATCH 12/12] Fix Layout.primaryIsTrailingPreviousAllLineOffsets The CL fixes a crash in Layout.primaryIsTrailingPreviousAllLineOffsets. The crash was happening when the method was called for a line beginning with an empty bidi run. This could happen, for example, for empty text - I was unable to find any other case. The CL improves the existing test for the method with this case, which was previously crashing. The CL also fixes a potential crash in getLineHorizontals. However, this bug could never happen as in the current code path clamped is always false (and kept as parameter for parity with getHorizontal). Bug: 135444178 Bug: 78464361 Test: atest FrameworksCoreTests:android.text.LayoutTest\#testPrimaryIsTrailingPrevious Change-Id: I47157abe1d74675884734e3810628a566e40c1b4 (cherry picked from commit 7ad499d00716f45fffdf7331493ed21d1b8d9b77) --- core/java/android/text/Layout.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java index 3bc9390c58151..0999b982d9900 100644 --- a/core/java/android/text/Layout.java +++ b/core/java/android/text/Layout.java @@ -919,6 +919,9 @@ public abstract class Layout { if (limit > lineEnd) { limit = lineEnd; } + if (limit == start) { + continue; + } level[limit - lineStart - 1] = (byte) ((runs[i + 1] >>> RUN_LEVEL_SHIFT) & RUN_LEVEL_MASK); } @@ -1014,8 +1017,8 @@ public abstract class Layout { } /** - * Computes in linear time the results of calling - * #getHorizontal for all offsets on a line. + * Computes in linear time the results of calling #getHorizontal for all offsets on a line. + * * @param line The line giving the offsets we compute information for * @param clamped Whether to clamp the results to the width of the layout * @param primary Whether the results should be the primary or the secondary horizontal @@ -1050,7 +1053,7 @@ public abstract class Layout { TextLine.recycle(tl); if (clamped) { - for (int offset = 0; offset <= wid.length; ++offset) { + for (int offset = 0; offset < wid.length; ++offset) { if (wid[offset] > mWidth) { wid[offset] = mWidth; }