diff options
author | roldenburg <roldenburg@google.com> | 2017-10-03 19:24:14 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-10-03 19:24:14 +0000 |
commit | 7119f5327ffac08231e801fed30168c3a89fab87 (patch) | |
tree | c6112feaf2500903ec0a4cec7f9be6179ec04dd1 | |
parent | 45ea75ca8f3b2f01bc955d39d28fe2ce18a2f254 (diff) | |
parent | 48824769e099659df64449af133b73a8a6f4ac59 (diff) |
Merge changes Ief58171c,Ie48671dc
am: 48824769e0
Change-Id: I947e3bff99b0d92efad5f293413babd8a6eb3ddc
4 files changed, 47 insertions, 41 deletions
diff --git a/java/com/android/contacts/common/list/PhoneNumberListAdapter.java b/java/com/android/contacts/common/list/PhoneNumberListAdapter.java index 741e606ac..8cf54b96c 100644 --- a/java/com/android/contacts/common/list/PhoneNumberListAdapter.java +++ b/java/com/android/contacts/common/list/PhoneNumberListAdapter.java @@ -42,6 +42,7 @@ import com.android.contacts.common.preference.ContactsPreferences; import com.android.contacts.common.util.Constants; import com.android.dialer.common.LogUtil; import com.android.dialer.compat.CompatUtils; +import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.contactphoto.ContactPhotoManager.DefaultImageRequest; import com.android.dialer.dialercontact.DialerContact; import com.android.dialer.enrichedcall.EnrichedCallCapabilities; @@ -500,14 +501,22 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { if (getDirectorySearchMode() == DirectoryListLoader.SEARCH_MODE_NONE) { return; } - final int numExtendedDirectories = mExtendedDirectories.size(); + int numExtendedDirectories = mExtendedDirectories.size(); + + if (ConfigProviderBindings.get(getContext()).getBoolean("p13n_ranker_should_enable", false)) { + // Suggested results wasn't formulated as an extended directory, so manually + // increment the count here when the feature is enabled. Suggestions are + // only shown when the ranker is enabled. + numExtendedDirectories++; + } + if (getPartitionCount() == cursor.getCount() + numExtendedDirectories) { // already added all directories; return; } - // + mFirstExtendedDirectoryId = Long.MAX_VALUE; - if (numExtendedDirectories > 0) { + if (!mExtendedDirectories.isEmpty()) { // The Directory.LOCAL_INVISIBLE is not in the cursor but we can't reuse it's // "special" ID. long maxId = Directory.LOCAL_INVISIBLE; @@ -527,7 +536,7 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { } // Extended directories ID's cannot collide with base directories mFirstExtendedDirectoryId = maxId + 1; - for (int i = 0; i < numExtendedDirectories; i++) { + for (int i = 0; i < mExtendedDirectories.size(); i++) { final long id = mFirstExtendedDirectoryId + i; final DirectoryPartition directory = mExtendedDirectories.get(i); if (getPartitionByDirectoryId(id) == -1) { diff --git a/java/com/android/dialer/strictmode/StrictModeUtils.java b/java/com/android/dialer/strictmode/StrictModeUtils.java index c83beb0b6..5ccd25d93 100644 --- a/java/com/android/dialer/strictmode/StrictModeUtils.java +++ b/java/com/android/dialer/strictmode/StrictModeUtils.java @@ -16,12 +16,17 @@ package com.android.dialer.strictmode; +import android.app.Application; +import android.content.Context; import android.os.Looper; import android.os.StrictMode; import android.os.StrictMode.ThreadPolicy; +import android.preference.PreferenceManager; import android.support.annotation.AnyThread; +import android.support.v4.os.UserManagerCompat; import com.android.dialer.buildtype.BuildType; import com.android.dialer.function.Supplier; +import com.android.dialer.util.DialerUtils; /** Utilities for enforcing strict-mode in an app. */ public final class StrictModeUtils { @@ -88,5 +93,30 @@ public final class StrictModeUtils { return Looper.getMainLooper().equals(Looper.myLooper()); } + /** + * We frequently access shared preferences on the main thread, which causes strict mode + * violations. When strict mode is allowed, warm up the shared preferences so that later uses of + * shared preferences access the in-memory versions and we don't have to bypass strict mode at + * every point in the application where shared preferences are accessed. + */ + public static void warmupSharedPrefs(Application application) { + // From credential-encrypted (CE) storage, i.e.: + // /data/data/com.android.dialer/shared_prefs + + if (UserManagerCompat.isUserUnlocked(application)) { + // <package_name>_preferences.xml + PreferenceManager.getDefaultSharedPreferences(application); + + // <package_name>.xml + application.getSharedPreferences(application.getPackageName(), Context.MODE_PRIVATE); + } + + // From device-encrypted (DE) storage, i.e.: + // /data/user_de/0/com.android.dialer/shared_prefs/ + + // <package_name>_preferences.xml + DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(application); + } + private StrictModeUtils() {} } diff --git a/java/com/android/dialer/strictmode/impl/SystemDialerStrictMode.java b/java/com/android/dialer/strictmode/impl/SystemDialerStrictMode.java index 4d6524123..b974ab18a 100644 --- a/java/com/android/dialer/strictmode/impl/SystemDialerStrictMode.java +++ b/java/com/android/dialer/strictmode/impl/SystemDialerStrictMode.java @@ -17,21 +17,17 @@ package com.android.dialer.strictmode.impl; import android.app.Application; -import android.content.Context; import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.StrictMode; import android.os.StrictMode.ThreadPolicy; import android.os.StrictMode.VmPolicy; -import android.preference.PreferenceManager; import android.support.annotation.MainThread; import android.support.annotation.Nullable; -import android.support.v4.os.UserManagerCompat; -import com.android.dialer.buildtype.BuildType; import com.android.dialer.common.Assert; import com.android.dialer.strictmode.DialerStrictMode; -import com.android.dialer.util.DialerUtils; +import com.android.dialer.strictmode.StrictModeUtils; import com.google.auto.value.AutoValue; import java.util.Map; import javax.inject.Inject; @@ -49,8 +45,8 @@ final class SystemDialerStrictMode implements DialerStrictMode { @MainThread @Override public void onApplicationCreate(Application application) { - if (isStrictModeAllowed()) { - warmupSharedPrefs(application); + if (StrictModeUtils.isStrictModeAllowed()) { + StrictModeUtils.warmupSharedPrefs(application); setRecommendedMainThreadPolicy(THREAD_DEATH_PENALTY); setRecommendedVMPolicy(VM_DEATH_PENALTY); @@ -64,35 +60,6 @@ final class SystemDialerStrictMode implements DialerStrictMode { } /** - * We frequently access shared preferences on the main thread, which causes strict mode - * violations. When strict mode is allowed, warm up the shared preferences so that later uses of - * shared preferences access the in-memory versions and we don't have to bypass strict mode at - * every point in the application where shared preferences are accessed. - */ - private static void warmupSharedPrefs(Application application) { - // From credential-encrypted (CE) storage, i.e.: - // /data/data/com.android.dialer/shared_prefs - - if (UserManagerCompat.isUserUnlocked(application)) { - // <package_name>_preferences.xml - PreferenceManager.getDefaultSharedPreferences(application); - - // <package_name>.xml - application.getSharedPreferences(application.getPackageName(), Context.MODE_PRIVATE); - } - - // From device-encrypted (DE) storage, i.e.: - // /data/user_de/0/com.android.dialer/shared_prefs/ - - // <package_name>_preferences.xml - DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(application); - } - - private static boolean isStrictModeAllowed() { - return BuildType.get() == BuildType.BUGFOOD; - } - - /** * Set the recommended policy for the app. * * @param threadPenalties policy with preferred penalties. Detection bits will be ignored. diff --git a/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java b/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java index 9adc53b0d..3a0ac48d5 100644 --- a/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java +++ b/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java @@ -58,7 +58,7 @@ public class LightbringerTech implements VideoTech, LightbringerListener { @Override public boolean isAvailable(Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { - LogUtil.v("LightbringerTech.isAvailable", "upgrade unavailable, only supported on O+"); + LogUtil.v("LightbringerTech.isAvailable", "upgrade unavailable, only supported on N+"); return false; } |