From 75c1f5cd0b269445b14a3c30ff6e5b81c6280948 Mon Sep 17 00:00:00 2001 From: linyuh Date: Mon, 8 Jan 2018 11:23:45 -0800 Subject: Add "delete" option in the 3-dot menu of the new call log Bug: 69639422 Test: DeleteCallLogItemModuleTest, ModulesTest, and Manual PiperOrigin-RevId: 181191883 Change-Id: I86c19e8a402b03a58c6b236b9ca54fd81f0b6f9a --- .../calllog/ui/menu/DeleteCallLogItemModule.java | 123 +++++++++++++++++++++ .../android/dialer/calllog/ui/menu/Modules.java | 2 + .../dialer/calllog/ui/menu/res/values/strings.xml | 3 + 3 files changed, 128 insertions(+) create mode 100644 java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java diff --git a/java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java b/java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java new file mode 100644 index 000000000..ac2e3b3da --- /dev/null +++ b/java/com/android/dialer/calllog/ui/menu/DeleteCallLogItemModule.java @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.dialer.calllog.ui.menu; + +import android.Manifest.permission; +import android.content.Context; +import android.provider.CallLog; +import android.provider.CallLog.Calls; +import android.support.annotation.Nullable; +import android.support.annotation.RequiresPermission; +import com.android.dialer.CoalescedIds; +import com.android.dialer.common.Assert; +import com.android.dialer.common.LogUtil; +import com.android.dialer.common.concurrent.DialerExecutor.Worker; +import com.android.dialer.common.concurrent.DialerExecutorComponent; +import com.android.dialer.common.database.Selection; +import com.android.dialer.contactactions.ContactActionModule; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; + +/** {@link ContactActionModule} for deleting a call log item in the new call log. */ +public final class DeleteCallLogItemModule implements ContactActionModule { + private static final String TAG = DeleteCallLogItemModule.class.getName(); + + private final Context context; + private final CoalescedIds coalescedIds; + + public DeleteCallLogItemModule(Context context, CoalescedIds coalescedIds) { + this.context = context; + this.coalescedIds = coalescedIds; + } + + @Override + public int getStringId() { + return R.string.delete; + } + + @Override + public int getDrawableId() { + return R.drawable.quantum_ic_delete_vd_theme_24; + } + + @Override + public boolean onClick() { + DialerExecutorComponent.get(context) + .dialerExecutorFactory() + .createNonUiTaskBuilder(new CallLogItemDeletionWorker(context)) + .build() + .executeSerial(coalescedIds); + return true; + } + + /** + * A {@link Worker} that deletes a call log item. + * + *

It takes as input the IDs of all call log records that are coalesced into the item to be + * deleted. + */ + private static class CallLogItemDeletionWorker implements Worker { + private final WeakReference contextWeakReference; + + CallLogItemDeletionWorker(Context context) { + contextWeakReference = new WeakReference<>(context); + } + + @Nullable + @Override + @RequiresPermission(value = permission.WRITE_CALL_LOG) + public Void doInBackground(CoalescedIds coalescedIds) throws Throwable { + Context context = contextWeakReference.get(); + if (context == null) { + LogUtil.e(TAG, "Unable to delete an call log item due to null context."); + return null; + } + + Selection selection = + Selection.builder() + .and(Selection.column(CallLog.Calls._ID).in(getCallLogIdsAsStrings(coalescedIds))) + .build(); + int numRowsDeleted = + context + .getContentResolver() + .delete(Calls.CONTENT_URI, selection.getSelection(), selection.getSelectionArgs()); + + if (numRowsDeleted != coalescedIds.getCoalescedIdCount()) { + LogUtil.e( + TAG, + "Deleting call log item is unsuccessful. %d of %d rows are deleted.", + numRowsDeleted, + coalescedIds.getCoalescedIdCount()); + } + + return null; + } + + private static List getCallLogIdsAsStrings(CoalescedIds coalescedIds) { + Assert.checkArgument(coalescedIds.getCoalescedIdCount() > 0); + + List idStrings = new ArrayList<>(coalescedIds.getCoalescedIdCount()); + + for (long callLogId : coalescedIds.getCoalescedIdList()) { + idStrings.add(String.valueOf(callLogId)); + } + + return idStrings; + } + } +} diff --git a/java/com/android/dialer/calllog/ui/menu/Modules.java b/java/com/android/dialer/calllog/ui/menu/Modules.java index d62cc2082..3d667fc79 100644 --- a/java/com/android/dialer/calllog/ui/menu/Modules.java +++ b/java/com/android/dialer/calllog/ui/menu/Modules.java @@ -64,6 +64,8 @@ final class Modules { // it use a ContactPrimaryActionInfo instead? addModuleForAccessingCallDetails(context, modules, row); + modules.add(new DeleteCallLogItemModule(context, row.coalescedIds())); + return modules; } diff --git a/java/com/android/dialer/calllog/ui/menu/res/values/strings.xml b/java/com/android/dialer/calllog/ui/menu/res/values/strings.xml index 46fbae3bc..7c1835f1b 100644 --- a/java/com/android/dialer/calllog/ui/menu/res/values/strings.xml +++ b/java/com/android/dialer/calllog/ui/menu/res/values/strings.xml @@ -21,4 +21,7 @@ can view details for the call log entry. [CHAR LIMIT=30] --> Call details + + Delete + \ No newline at end of file -- cgit v1.2.3 From 15d15cf079f8dc6fc810ed0fec7cd9a0d446b316 Mon Sep 17 00:00:00 2001 From: zachh Date: Mon, 8 Jan 2018 11:58:07 -0800 Subject: Automated rollback of changelist 178323108 Test: tap PiperOrigin-RevId: 181196939 Change-Id: I97405c5356814fe3ad02d498cfa96c210921c477 --- .../common/concurrent/DialerFutureSerializer.java | 73 +++++++++++++++++++--- 1 file changed, 66 insertions(+), 7 deletions(-) diff --git a/java/com/android/dialer/common/concurrent/DialerFutureSerializer.java b/java/com/android/dialer/common/concurrent/DialerFutureSerializer.java index de37a2915..2629abbbe 100644 --- a/java/com/android/dialer/common/concurrent/DialerFutureSerializer.java +++ b/java/com/android/dialer/common/concurrent/DialerFutureSerializer.java @@ -16,24 +16,83 @@ package com.android.dialer.common.concurrent; +import static com.google.common.util.concurrent.Futures.immediateCancelledFuture; +import static com.google.common.util.concurrent.Futures.immediateFuture; +import static com.google.common.util.concurrent.MoreExecutors.directExecutor; + import com.google.common.util.concurrent.AsyncCallable; +import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; +import java.util.concurrent.Callable; import java.util.concurrent.Executor; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; /** * Serializes execution of a set of operations. This class guarantees that a submitted callable will * not be called before previously submitted callables have completed. */ public final class DialerFutureSerializer { + /** This reference acts as a pointer tracking the head of a linked list of ListenableFutures. */ + private final AtomicReference> ref = + new AtomicReference<>(immediateFuture(null)); /** Enqueues a task to run when the previous task (if any) completes. */ + public ListenableFuture submit(final Callable callable, Executor executor) { + return submitAsync(() -> immediateFuture(callable.call()), executor); + } + + /** + * Enqueues a task to run when the previous task (if any) completes. + * + *

Cancellation does not propagate from the output future to the future returned from {@code + * callable}, but if the output future is cancelled before {@link AsyncCallable#call()} is + * invoked, {@link AsyncCallable#call()} will not be invoked. + */ public ListenableFuture submitAsync(final AsyncCallable callable, Executor executor) { - // TODO(zachh): This is just a dummy implementation until we fix guava API level issues. - try { - return callable.call(); - } catch (Exception e) { - e.printStackTrace(); - } - return null; + AtomicBoolean wasCancelled = new AtomicBoolean(false); + final AsyncCallable task = + () -> { + if (wasCancelled.get()) { + return immediateCancelledFuture(); + } + return callable.call(); + }; + /* + * Three futures are at play here: + * taskFuture is the future that comes from the callable. + * newFuture is the future we use to track the serialization of our task. + * oldFuture is the previous task's newFuture. + * + * newFuture is guaranteed to only complete once all tasks previously submitted to this instance + * once the futures returned from those submissions have completed. + */ + final SettableFuture newFuture = SettableFuture.create(); + + final ListenableFuture oldFuture = ref.getAndSet(newFuture); + + // Invoke our task once the previous future completes. + final ListenableFuture taskFuture = + Futures.nonCancellationPropagating( + Futures.submitAsync(task, runnable -> oldFuture.addListener(runnable, executor))); + // newFuture's lifetime is determined by taskFuture, unless taskFuture is cancelled, in which + // case it falls back to oldFuture's. This is to ensure that if the future we return is + // cancelled, we don't begin execution of the next task until after oldFuture completes. + taskFuture.addListener( + () -> { + if (taskFuture.isCancelled()) { + // Since the value of oldFuture can only ever be immediateFuture(null) or setFuture of a + // future that eventually came from immediateFuture(null), this doesn't leak throwables + // or completion values. + wasCancelled.set(true); + newFuture.setFuture(oldFuture); + } else { + newFuture.set(null); + } + }, + directExecutor()); + + return taskFuture; } } -- cgit v1.2.3 From 0dcfaa21bf1ffc1d99524907469f73dde3e54e42 Mon Sep 17 00:00:00 2001 From: uabdullah Date: Mon, 8 Jan 2018 13:32:21 -0800 Subject: Initial setup of voicemail error messages This CL setups the initial adapter logic to be able to display voicemail error messages. The errors and the code to display those errors will be shown in a follow up CL. Bug: 71700117 Test: N/A PiperOrigin-RevId: 181210330 Change-Id: I5b9e9e675ad7a4825692fb93ca4237d05b0407f0 --- .../voicemail/listui/NewVoicemailAdapter.java | 64 ++++++++++++++++++---- .../listui/NewVoicemailAlertViewHolder.java | 36 ++++++++++++ .../res/layout/new_voicemail_entry_alert.xml | 30 ++++++++++ 3 files changed, 120 insertions(+), 10 deletions(-) create mode 100644 java/com/android/dialer/voicemail/listui/NewVoicemailAlertViewHolder.java create mode 100644 java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java index 93d5cda3e..32c5b6991 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java @@ -55,12 +55,14 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter /** IntDef for the different types of rows that can be shown in the call log. */ @Retention(RetentionPolicy.SOURCE) - @IntDef({RowType.HEADER, RowType.VOICEMAIL_ENTRY}) + @IntDef({RowType.HEADER, RowType.VOICEMAIL_ENTRY, RowType.VOICEMAIL_ALERT}) @interface RowType { + /** A row representing a voicemail alert. */ + int VOICEMAIL_ALERT = 1; /** Header that displays "Today" or "Older". */ - int HEADER = 1; + int HEADER = 2; /** A row representing a voicemail entry. */ - int VOICEMAIL_ENTRY = 2; + int VOICEMAIL_ENTRY = 3; } private Cursor cursor; @@ -70,6 +72,8 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter private int todayHeaderPosition = Integer.MAX_VALUE; /** {@link Integer#MAX_VALUE} when the "Older" header should not be displayed. */ private int olderHeaderPosition = Integer.MAX_VALUE; + /** {@link Integer#MAX_VALUE} when the voicemail alert message should not be displayed. */ + private int voicemailAlertPosition = Integer.MAX_VALUE; private final FragmentManager fragmentManager; /** A valid id for {@link VoicemailEntry} is greater than 0 */ @@ -113,16 +117,26 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter private void updateHeaderPositions() { LogUtil.i( "NewVoicemailAdapter.updateHeaderPositions", - "before updating todayPos:%d, olderPos:%d", + "before updating todayPos:%d, olderPos:%d, alertPos:%d", todayHeaderPosition, - olderHeaderPosition); + olderHeaderPosition, + voicemailAlertPosition); + + int alertOffSet = 0; + if (voicemailAlertPosition != Integer.MAX_VALUE) { + Assert.checkArgument( + voicemailAlertPosition == 0, "voicemail alert can only be 0, when showing"); + alertOffSet = 1; + } + // Calculate header adapter positions by reading cursor. long currentTimeMillis = clock.currentTimeMillis(); if (cursor.moveToNext()) { long firstTimestamp = VoicemailCursorLoader.getTimestamp(cursor); if (CallLogDates.isSameDay(currentTimeMillis, firstTimestamp)) { - this.todayHeaderPosition = 0; - int adapterPosition = 2; // Accounted for "Today" header and first row. + this.todayHeaderPosition = 0 + alertOffSet; + int adapterPosition = + 2 + alertOffSet; // Accounted for the "Alert", "Today" header and first row. while (cursor.moveToNext()) { long timestamp = VoicemailCursorLoader.getTimestamp(cursor); @@ -144,9 +158,11 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter } LogUtil.i( "NewVoicemailAdapter.updateHeaderPositions", - "after updating todayPos:%d, olderPos:%d", + "after updating todayPos:%d, olderPos:%d, alertOffSet:%d, alertPos:%d", todayHeaderPosition, - olderHeaderPosition); + olderHeaderPosition, + alertOffSet, + voicemailAlertPosition); } private void initializeMediaPlayerListeners() { @@ -169,6 +185,9 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext()); View view; switch (viewType) { + case RowType.VOICEMAIL_ALERT: + view = inflater.inflate(R.layout.new_voicemail_entry_alert, viewGroup, false); + return new NewVoicemailAlertViewHolder(view); case RowType.HEADER: view = inflater.inflate(R.layout.new_voicemail_entry_header, viewGroup, false); return new NewVoicemailHeaderViewHolder(view); @@ -223,14 +242,33 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter return; } + if (viewHolder instanceof NewVoicemailAlertViewHolder) { + LogUtil.i( + "NewVoicemailAdapter.onBindViewHolder", "view holder at pos:%d is a alert", position); + NewVoicemailAlertViewHolder alertViewHolder = (NewVoicemailAlertViewHolder) viewHolder; + @RowType int viewType = getItemViewType(position); + Assert.checkArgument(position == 0); + if (position == voicemailAlertPosition) { + // TODO(a bug): Update this with the alert messages + alertViewHolder.setHeader("Temporary placeholder, update this with the alert messages"); + } else { + throw Assert.createIllegalStateFailException( + "Unexpected view type " + viewType + " at position: " + position); + } + return; + } + LogUtil.i( "NewVoicemailAdapter.onBindViewHolder", - "view holder at pos:%d is a not a header", + "view holder at pos:%d is a not a header or an alert", position); NewVoicemailViewHolder newVoicemailViewHolder = (NewVoicemailViewHolder) viewHolder; int previousHeaders = 0; + if (voicemailAlertPosition != Integer.MAX_VALUE && position > voicemailAlertPosition) { + previousHeaders++; + } if (todayHeaderPosition != Integer.MAX_VALUE && position > todayHeaderPosition) { previousHeaders++; } @@ -826,6 +864,9 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter // TODO(uabdullah): a bug Remove logging, temporarily here for debugging. LogUtil.enterBlock("NewVoicemailAdapter.getItemCount"); int numberOfHeaders = 0; + if (voicemailAlertPosition != Integer.MAX_VALUE) { + numberOfHeaders++; + } if (todayHeaderPosition != Integer.MAX_VALUE) { numberOfHeaders++; } @@ -846,6 +887,9 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter @Override public int getItemViewType(int position) { LogUtil.enterBlock("NewVoicemailAdapter.getItemViewType"); + if (voicemailAlertPosition != Integer.MAX_VALUE && position == voicemailAlertPosition) { + return RowType.VOICEMAIL_ALERT; + } if (todayHeaderPosition != Integer.MAX_VALUE && position == todayHeaderPosition) { return RowType.HEADER; } diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailAlertViewHolder.java b/java/com/android/dialer/voicemail/listui/NewVoicemailAlertViewHolder.java new file mode 100644 index 000000000..ec603b5c8 --- /dev/null +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailAlertViewHolder.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.dialer.voicemail.listui; + +import android.support.v7.widget.RecyclerView.ViewHolder; +import android.view.View; +import android.widget.TextView; + +/** ViewHolder for {@link NewVoicemailAdapter} to display voicemail error states. */ +final class NewVoicemailAlertViewHolder extends ViewHolder { + + private final TextView errorTextView; + + NewVoicemailAlertViewHolder(View view) { + super(view); + errorTextView = view.findViewById(R.id.new_voicemail_alert_text); + } + + void setHeader(String error) { + errorTextView.setText(error); + } +} diff --git a/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml new file mode 100644 index 000000000..e8dcd02d6 --- /dev/null +++ b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml @@ -0,0 +1,30 @@ + + + + + + -- cgit v1.2.3 From adf511ea99847bba50bca1e664cac24c0e48b05f Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Mon, 8 Jan 2018 13:39:35 -0800 Subject: Updated T9 search bolding to include wrapping to the next word. T9 bolding now works when the query continues past a single name and extends to the next. For example, a query of "2226" would bold "[AAA M]om". This was supported in the old search. Bug: 71384038 Test: existing + new PiperOrigin-RevId: 181211263 Change-Id: I7d7fe8be794f410e697ddbcb26c6bc10c7893e5a --- .../searchfragment/common/QueryBoldingUtil.java | 25 +++++++++---- .../searchfragment/common/QueryFilteringUtil.java | 42 ++++++++++++++++++++-- 2 files changed, 57 insertions(+), 10 deletions(-) diff --git a/java/com/android/dialer/searchfragment/common/QueryBoldingUtil.java b/java/com/android/dialer/searchfragment/common/QueryBoldingUtil.java index 9ac6e7c5e..5fbcc97fe 100644 --- a/java/com/android/dialer/searchfragment/common/QueryBoldingUtil.java +++ b/java/com/android/dialer/searchfragment/common/QueryBoldingUtil.java @@ -24,6 +24,7 @@ import android.text.SpannableString; import android.text.Spanned; import android.text.TextUtils; import android.text.style.StyleSpan; +import com.android.dialer.common.LogUtil; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -39,6 +40,7 @@ public class QueryBoldingUtil { *
  • "query" would bold "John [query] Smith" *
  • "222" would bold "[AAA] Mom" *
  • "222" would bold "[A]llen [A]lex [A]aron" + *
  • "2226" would bold "[AAA M]om" * * *

    Some examples of non-matches: @@ -71,15 +73,18 @@ public class QueryBoldingUtil { } } - Pattern pattern = Pattern.compile("(^|\\s)" + Pattern.quote(query.toLowerCase())); - Matcher matcher = pattern.matcher(QueryFilteringUtil.getT9Representation(name, context)); - if (matcher.find()) { + int indexOfT9Match = QueryFilteringUtil.getIndexOfT9Substring(query, name, context); + if (indexOfT9Match != -1) { // query matches the start of a T9 name (i.e. 75 -> "Jessica [Jo]nes") - int index = matcher.start(); - // TODO(calderwoodra): investigate why this is consistently off by one. - index = index == 0 ? 0 : index + 1; - return getBoldedString(name, index, query.length()); + int numBolded = query.length(); + // Bold an extra character for each non-letter + for (int i = indexOfT9Match; i <= indexOfT9Match + numBolded && i < name.length(); i++) { + if (!Character.isLetter(name.charAt(i))) { + numBolded++; + } + } + return getBoldedString(name, indexOfT9Match, numBolded); } else { // query match the T9 initials (i.e. 222 -> "[A]l [B]ob [C]harlie") return getNameWithInitialsBolded(query, name, context); @@ -148,6 +153,12 @@ public class QueryBoldingUtil { } private static SpannableString getBoldedString(String s, int index, int numBolded) { + if (numBolded + index > s.length()) { + LogUtil.e( + "QueryBoldingUtil#getBoldedString", + "number of bolded characters exceeded length of string."); + numBolded = s.length() - index; + } SpannableString span = new SpannableString(s); span.setSpan( new StyleSpan(Typeface.BOLD), index, index + numBolded, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); diff --git a/java/com/android/dialer/searchfragment/common/QueryFilteringUtil.java b/java/com/android/dialer/searchfragment/common/QueryFilteringUtil.java index c4ff27545..9add44c8a 100644 --- a/java/com/android/dialer/searchfragment/common/QueryFilteringUtil.java +++ b/java/com/android/dialer/searchfragment/common/QueryFilteringUtil.java @@ -69,9 +69,7 @@ public class QueryFilteringUtil { } query = digitsOnly(query); - Pattern pattern = Pattern.compile("(^|\\s)" + Pattern.quote(query)); - if (pattern.matcher(getT9Representation(name, context)).find()) { - // query matches the start of a T9 name (i.e. 75 -> "Jessica [Jo]nes") + if (getIndexOfT9Substring(query, name, context) != -1) { return true; } @@ -93,6 +91,44 @@ public class QueryFilteringUtil { return queryIndex == query.length(); } + /** + * Returns the index where query is contained in the T9 representation of the name. + * + *

    Examples: + * + *

      + *
    • #getIndexOfT9Substring("76", "John Smith") returns 5, 76 -> 'Sm' + *
    • #nameMatchesT9Query("2226", "AAA Mom") returns 0, 2226 -> 'AAAM' + *
    • #nameMatchesT9Query("2", "Jessica Jones") returns -1, Neither 'Jessica' nor 'Jones' start + * with A, B or C + *
    + */ + public static int getIndexOfT9Substring(String query, String name, Context context) { + query = digitsOnly(query); + String t9Name = getT9Representation(name, context); + String t9NameDigitsOnly = digitsOnly(t9Name); + if (t9NameDigitsOnly.startsWith(query)) { + return 0; + } + + int nonLetterCount = 0; + for (int i = 1; i < t9NameDigitsOnly.length(); i++) { + char cur = t9Name.charAt(i); + if (!Character.isDigit(cur)) { + nonLetterCount++; + continue; + } + + // If the previous character isn't a digit and the current is, check for a match + char prev = t9Name.charAt(i - 1); + int offset = i - nonLetterCount; + if (!Character.isDigit(prev) && t9NameDigitsOnly.startsWith(query, offset)) { + return i; + } + } + return -1; + } + /** * Returns true if the subparts of the name (split by white space) begin with the query. * -- cgit v1.2.3 From fdbf2a0d7124af3e3026acbe39873bd2deea13ed Mon Sep 17 00:00:00 2001 From: wangqi Date: Mon, 8 Jan 2018 13:41:40 -0800 Subject: Add RTT call chat window. This change add a mock in simulator with a type bot that's simulating remote typing. The integration into incall UI will be in following changes. Bug: 67596257 Test: RttChatMessageTest PiperOrigin-RevId: 181211591 Change-Id: If6cdcb010afc0c25e90d3a44fe349920d5a856c6 --- .../res/drawable/quantum_ic_done_vd_theme_24.xml | 25 +++ .../drawable/quantum_ic_mic_off_vd_theme_24.xml | 25 +++ .../dialer/simulator/impl/SimulatorMainMenu.java | 6 + .../android/incallui/rtt/impl/AndroidManifest.xml | 26 +++ .../android/incallui/rtt/impl/RttChatActivity.java | 41 ++++ .../android/incallui/rtt/impl/RttChatAdapter.java | 218 +++++++++++++++++++++ .../android/incallui/rtt/impl/RttChatFragment.java | 176 +++++++++++++++++ .../android/incallui/rtt/impl/RttChatMessage.java | 132 +++++++++++++ .../rtt/impl/RttChatMessageViewHolder.java | 65 ++++++ .../rtt/impl/res/color/message_bubble_color.xml | 21 ++ .../res/color/submit_button_background_color.xml | 21 ++ .../rtt/impl/res/color/submit_button_color.xml | 21 ++ .../impl/res/drawable/input_bubble_background.xml | 74 +++++++ .../rtt/impl/res/drawable/message_bubble.xml | 21 ++ .../rtt/impl/res/drawable/pill_background.xml | 22 +++ .../incallui/rtt/impl/res/layout/activity_rtt.xml | 26 +++ .../incallui/rtt/impl/res/layout/frag_rtt_chat.xml | 69 +++++++ .../incallui/rtt/impl/res/layout/rtt_banner.xml | 91 +++++++++ .../rtt/impl/res/layout/rtt_chat_list_item.xml | 48 +++++ .../incallui/rtt/impl/res/values/colors.xml | 19 ++ .../incallui/rtt/impl/res/values/dimens.xml | 20 ++ .../incallui/rtt/impl/res/values/strings.xml | 29 +++ .../incallui/rtt/impl/res/values/styles.xml | 35 ++++ packages.mk | 1 + 24 files changed, 1232 insertions(+) create mode 100644 assets/quantum/res/drawable/quantum_ic_done_vd_theme_24.xml create mode 100644 assets/quantum/res/drawable/quantum_ic_mic_off_vd_theme_24.xml create mode 100644 java/com/android/incallui/rtt/impl/AndroidManifest.xml create mode 100644 java/com/android/incallui/rtt/impl/RttChatActivity.java create mode 100644 java/com/android/incallui/rtt/impl/RttChatAdapter.java create mode 100644 java/com/android/incallui/rtt/impl/RttChatFragment.java create mode 100644 java/com/android/incallui/rtt/impl/RttChatMessage.java create mode 100644 java/com/android/incallui/rtt/impl/RttChatMessageViewHolder.java create mode 100644 java/com/android/incallui/rtt/impl/res/color/message_bubble_color.xml create mode 100644 java/com/android/incallui/rtt/impl/res/color/submit_button_background_color.xml create mode 100644 java/com/android/incallui/rtt/impl/res/color/submit_button_color.xml create mode 100644 java/com/android/incallui/rtt/impl/res/drawable/input_bubble_background.xml create mode 100644 java/com/android/incallui/rtt/impl/res/drawable/message_bubble.xml create mode 100644 java/com/android/incallui/rtt/impl/res/drawable/pill_background.xml create mode 100644 java/com/android/incallui/rtt/impl/res/layout/activity_rtt.xml create mode 100644 java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml create mode 100644 java/com/android/incallui/rtt/impl/res/layout/rtt_banner.xml create mode 100644 java/com/android/incallui/rtt/impl/res/layout/rtt_chat_list_item.xml create mode 100644 java/com/android/incallui/rtt/impl/res/values/colors.xml create mode 100644 java/com/android/incallui/rtt/impl/res/values/dimens.xml create mode 100644 java/com/android/incallui/rtt/impl/res/values/strings.xml create mode 100644 java/com/android/incallui/rtt/impl/res/values/styles.xml diff --git a/assets/quantum/res/drawable/quantum_ic_done_vd_theme_24.xml b/assets/quantum/res/drawable/quantum_ic_done_vd_theme_24.xml new file mode 100644 index 000000000..bd1887e5c --- /dev/null +++ b/assets/quantum/res/drawable/quantum_ic_done_vd_theme_24.xml @@ -0,0 +1,25 @@ + + + + \ No newline at end of file diff --git a/assets/quantum/res/drawable/quantum_ic_mic_off_vd_theme_24.xml b/assets/quantum/res/drawable/quantum_ic_mic_off_vd_theme_24.xml new file mode 100644 index 000000000..0519c555c --- /dev/null +++ b/assets/quantum/res/drawable/quantum_ic_mic_off_vd_theme_24.xml @@ -0,0 +1,25 @@ + + + + \ No newline at end of file diff --git a/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java b/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java index c48e2836e..4ef579f06 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java +++ b/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java @@ -31,6 +31,7 @@ import com.android.dialer.databasepopulator.VoicemailPopulator; import com.android.dialer.enrichedcall.simulator.EnrichedCallSimulatorActivity; import com.android.dialer.persistentlog.PersistentLogger; import com.android.dialer.preferredsim.PreferredSimFallbackContract; +import com.android.incallui.rtt.impl.RttChatActivity; /** Implements the top level simulator menu. */ final class SimulatorMainMenu { @@ -40,6 +41,7 @@ final class SimulatorMainMenu { .addItem("Voice call", SimulatorVoiceCall.getActionProvider(activity)) .addItem( "IMS video", SimulatorVideoCall.getActionProvider(activity.getApplicationContext())) + .addItem("Rtt call mock", () -> simulateRttCallMock(activity.getApplicationContext())) .addItem( "Notifications", SimulatorNotifications.getActionProvider(activity.getApplicationContext())) @@ -61,6 +63,10 @@ final class SimulatorMainMenu { EnrichedCallSimulatorActivity.newIntent(activity.getApplicationContext()))); } + private static void simulateRttCallMock(@NonNull Context context) { + context.startActivity(new Intent(context, RttChatActivity.class)); + } + private static void populateDatabase(@NonNull Context context) { DialerExecutorComponent.get(context) .dialerExecutorFactory() diff --git a/java/com/android/incallui/rtt/impl/AndroidManifest.xml b/java/com/android/incallui/rtt/impl/AndroidManifest.xml new file mode 100644 index 000000000..fc0705d7e --- /dev/null +++ b/java/com/android/incallui/rtt/impl/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + diff --git a/java/com/android/incallui/rtt/impl/RttChatActivity.java b/java/com/android/incallui/rtt/impl/RttChatActivity.java new file mode 100644 index 000000000..96056f746 --- /dev/null +++ b/java/com/android/incallui/rtt/impl/RttChatActivity.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.incallui.rtt.impl; + +import android.os.Bundle; +import android.os.SystemClock; +import android.support.annotation.Nullable; +import android.support.v4.app.FragmentActivity; +import android.view.View; + +/** Activity to for RTT chat window. */ +public class RttChatActivity extends FragmentActivity { + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_rtt); + getSupportFragmentManager() + .beginTransaction() + .add( + R.id.fragment_rtt, + RttChatFragment.newInstance("", "Jane Williamson", SystemClock.elapsedRealtime())) + .commit(); + getWindow().setStatusBarColor(getColor(R.color.rtt_status_bar_color)); + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + } +} diff --git a/java/com/android/incallui/rtt/impl/RttChatAdapter.java b/java/com/android/incallui/rtt/impl/RttChatAdapter.java new file mode 100644 index 000000000..1db4c6bad --- /dev/null +++ b/java/com/android/incallui/rtt/impl/RttChatAdapter.java @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.incallui.rtt.impl; + +import android.content.Context; +import android.support.annotation.MainThread; +import android.support.v7.widget.RecyclerView; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import com.android.dialer.common.Assert; +import com.android.dialer.common.LogUtil; +import com.android.dialer.common.concurrent.ThreadUtil; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Random; + +/** Adapter class for holding RTT chat data. */ +public class RttChatAdapter extends RecyclerView.Adapter { + + interface MessageListener { + void newMessageAdded(); + } + + private final Context context; + private final List rttMessages = new ArrayList<>(); + private int lastIndexOfLocalMessage = -1; + private int lastIndexOfRemoteMessage = -1; + private final TypeBot typeBot; + private final MessageListener messageListener; + + RttChatAdapter(Context context, MessageListener listener) { + this.context = context; + this.messageListener = listener; + typeBot = new TypeBot(text -> ThreadUtil.postOnUiThread(() -> addRemoteMessage(text))); + } + + @Override + public RttChatMessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + LayoutInflater layoutInflater = LayoutInflater.from(context); + View view = layoutInflater.inflate(R.layout.rtt_chat_list_item, parent, false); + return new RttChatMessageViewHolder(view); + } + + @Override + public int getItemViewType(int position) { + return super.getItemViewType(position); + } + + @Override + public void onBindViewHolder(RttChatMessageViewHolder rttChatMessageViewHolder, int i) { + boolean isSameGroup = false; + if (i > 0) { + isSameGroup = rttMessages.get(i).isRemote == rttMessages.get(i - 1).isRemote; + } + rttChatMessageViewHolder.setMessage(rttMessages.get(i), isSameGroup); + } + + @Override + public int getItemCount() { + return rttMessages.size(); + } + + private void updateCurrentRemoteMessage(String newText) { + RttChatMessage rttChatMessage = null; + if (lastIndexOfRemoteMessage >= 0) { + rttChatMessage = rttMessages.get(lastIndexOfRemoteMessage); + } + RttChatMessage[] newMessages = RttChatMessage.getRemoteRttChatMessage(rttChatMessage, newText); + + if (rttChatMessage == null) { + lastIndexOfRemoteMessage = rttMessages.size(); + rttMessages.add(lastIndexOfRemoteMessage, newMessages[0]); + rttMessages.addAll(Arrays.asList(newMessages).subList(1, newMessages.length)); + notifyItemRangeInserted(lastIndexOfRemoteMessage, newMessages.length); + lastIndexOfRemoteMessage = rttMessages.size() - 1; + } else { + rttMessages.set(lastIndexOfRemoteMessage, newMessages[0]); + int lastIndex = rttMessages.size(); + rttMessages.addAll(Arrays.asList(newMessages).subList(1, newMessages.length)); + + notifyItemChanged(lastIndexOfRemoteMessage); + notifyItemRangeInserted(lastIndex, newMessages.length); + } + if (rttMessages.get(lastIndexOfRemoteMessage).isFinished()) { + lastIndexOfRemoteMessage = -1; + } + } + + private void updateCurrentLocalMessage(String newMessage) { + RttChatMessage rttChatMessage = null; + if (lastIndexOfLocalMessage >= 0) { + rttChatMessage = rttMessages.get(lastIndexOfLocalMessage); + } + if (rttChatMessage == null || rttChatMessage.isFinished()) { + rttChatMessage = new RttChatMessage(); + rttChatMessage.append(newMessage); + rttMessages.add(rttChatMessage); + lastIndexOfLocalMessage = rttMessages.size() - 1; + notifyItemInserted(lastIndexOfLocalMessage); + } else { + rttChatMessage.append(newMessage); + notifyItemChanged(lastIndexOfLocalMessage); + } + } + + void addLocalMessage(String message) { + LogUtil.enterBlock("RttChatAdapater.addLocalMessage"); + updateCurrentLocalMessage(message); + if (messageListener != null) { + messageListener.newMessageAdded(); + } + } + + void submitLocalMessage() { + LogUtil.enterBlock("RttChatAdapater.submitLocalMessage"); + rttMessages.get(lastIndexOfLocalMessage).finish(); + notifyItemChanged(lastIndexOfLocalMessage); + lastIndexOfLocalMessage = -1; + startChatBot(); + } + + void addRemoteMessage(String message) { + LogUtil.enterBlock("RttChatAdapater.addRemoteMessage"); + if (TextUtils.isEmpty(message)) { + return; + } + updateCurrentRemoteMessage(message); + if (messageListener != null) { + messageListener.newMessageAdded(); + } + } + + private void startChatBot() { + typeBot.scheduleMessage(); + } + + // TODO(wangqi): Move this out of this class once a bug is fixed. + private static class TypeBot { + interface Callback { + void type(String text); + } + + private static final String[] CANDIDATE_MESSAGES = + new String[] { + "To RTT or not to RTT, that is the question...", + "Making TTY great again!", + "I would be more comfortable with real \"Thyme\" chatting." + + " I don't know how to end this pun", + "お疲れ様でした", + "The FCC has mandated that I respond... I will do so begrudgingly", + "😂😂😂💯" + }; + private final Random random = new Random(); + private final Callback callback; + private final List messageQueue = new ArrayList<>(); + private int currentTypingPosition = -1; + private String currentTypingMessage = null; + + TypeBot(Callback callback) { + this.callback = callback; + } + + @MainThread + public void scheduleMessage() { + Assert.isMainThread(); + if (random.nextDouble() < 0.5) { + return; + } + + String text = CANDIDATE_MESSAGES[random.nextInt(CANDIDATE_MESSAGES.length)]; + messageQueue.add(text); + typeMessage(); + } + + @MainThread + private void typeMessage() { + Assert.isMainThread(); + if (currentTypingPosition < 0 || currentTypingMessage == null) { + if (messageQueue.size() <= 0) { + return; + } + currentTypingMessage = messageQueue.remove(0); + currentTypingPosition = 0; + } + if (currentTypingPosition < currentTypingMessage.length()) { + int size = random.nextInt(currentTypingMessage.length() - currentTypingPosition + 1); + callback.type( + currentTypingMessage.substring(currentTypingPosition, currentTypingPosition + size)); + currentTypingPosition = currentTypingPosition + size; + // Wait up to 2s between typing. + ThreadUtil.postDelayedOnUiThread(this::typeMessage, 200 * random.nextInt(10)); + } else { + callback.type(RttChatMessage.BUBBLE_BREAKER); + currentTypingPosition = -1; + currentTypingMessage = null; + // Wait 1-11s between two messages. + ThreadUtil.postDelayedOnUiThread(this::typeMessage, 1000 * (1 + random.nextInt(10))); + } + } + } +} diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java new file mode 100644 index 000000000..0b0ad2a8e --- /dev/null +++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.incallui.rtt.impl; + +import android.os.Bundle; +import android.os.SystemClock; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.RecyclerView.OnScrollListener; +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; +import android.widget.Chronometer; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.TextView; +import android.widget.TextView.OnEditorActionListener; +import com.android.incallui.rtt.impl.RttChatAdapter.MessageListener; + +/** RTT chat fragment to show chat bubbles. */ +public class RttChatFragment extends Fragment + implements OnClickListener, OnEditorActionListener, TextWatcher, MessageListener { + + private static final String ARG_CALL_ID = "call_id"; + private static final String ARG_NAME_OR_NUMBER = "name_or_number"; + private static final String ARG_SESSION_START_TIME = "session_start_time"; + + private RecyclerView recyclerView; + private RttChatAdapter adapter; + private EditText editText; + private ImageButton submitButton; + private boolean isClearingInput; + + private final OnScrollListener onScrollListener = + new OnScrollListener() { + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + if (dy < 0) { + hideKeyboard(); + } + } + }; + + /** + * Create a new instance of RttChatFragment. + * + * @param callId call id of the RTT call. + * @param nameOrNumber name or number of the caller to be displayed + * @param sessionStartTimeMillis start time of RTT session in terms of {@link + * SystemClock#elapsedRealtime}. + * @return new RttChatFragment + */ + public static RttChatFragment newInstance( + String callId, String nameOrNumber, long sessionStartTimeMillis) { + Bundle bundle = new Bundle(); + bundle.putString(ARG_CALL_ID, callId); + bundle.putString(ARG_NAME_OR_NUMBER, nameOrNumber); + bundle.putLong(ARG_SESSION_START_TIME, sessionStartTimeMillis); + RttChatFragment instance = new RttChatFragment(); + instance.setArguments(bundle); + return instance; + } + + @Nullable + @Override + public View onCreateView( + LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.frag_rtt_chat, container, false); + editText = view.findViewById(R.id.rtt_chat_input); + editText.setOnEditorActionListener(this); + editText.addTextChangedListener(this); + recyclerView = view.findViewById(R.id.rtt_recycler_view); + LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); + layoutManager.setStackFromEnd(true); + recyclerView.setLayoutManager(layoutManager); + recyclerView.setHasFixedSize(false); + adapter = new RttChatAdapter(getContext(), this); + recyclerView.setAdapter(adapter); + recyclerView.addOnScrollListener(onScrollListener); + submitButton = view.findViewById(R.id.rtt_chat_submit_button); + submitButton.setOnClickListener(this); + submitButton.setEnabled(false); + + String nameOrNumber = null; + Bundle bundle = getArguments(); + if (bundle != null) { + nameOrNumber = bundle.getString(ARG_NAME_OR_NUMBER, getString(R.string.unknown)); + } + TextView nameTextView = view.findViewById(R.id.rtt_name_or_number); + nameTextView.setText(nameOrNumber); + + long sessionStartTime = SystemClock.elapsedRealtime(); + if (bundle != null) { + sessionStartTime = bundle.getLong(ARG_SESSION_START_TIME, sessionStartTime); + } + Chronometer chronometer = view.findViewById(R.id.rtt_timer); + chronometer.setBase(sessionStartTime); + chronometer.start(); + return view; + } + + @Override + public void onClick(View v) { + if (v.getId() == R.id.rtt_chat_submit_button) { + adapter.submitLocalMessage(); + isClearingInput = true; + editText.setText(""); + isClearingInput = false; + } + } + + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_DONE) { + submitButton.performClick(); + return true; + } + return false; + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + if (isClearingInput) { + return; + } + adapter.addLocalMessage(RttChatMessage.getChangedString(s, start, before, count)); + } + + @Override + public void afterTextChanged(Editable s) { + if (TextUtils.isEmpty(s)) { + submitButton.setEnabled(false); + } else { + submitButton.setEnabled(true); + } + } + + @Override + public void newMessageAdded() { + recyclerView.smoothScrollToPosition(adapter.getItemCount()); + } + + private void hideKeyboard() { + InputMethodManager inputMethodManager = getContext().getSystemService(InputMethodManager.class); + if (inputMethodManager.isAcceptingText()) { + inputMethodManager.hideSoftInputFromWindow( + getActivity().getCurrentFocus().getWindowToken(), 0); + } + } +} diff --git a/java/com/android/incallui/rtt/impl/RttChatMessage.java b/java/com/android/incallui/rtt/impl/RttChatMessage.java new file mode 100644 index 000000000..85b045183 --- /dev/null +++ b/java/com/android/incallui/rtt/impl/RttChatMessage.java @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.incallui.rtt.impl; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.text.TextWatcher; +import com.google.common.base.Splitter; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** Message class that holds one RTT chat content. */ +final class RttChatMessage { + + static final String BUBBLE_BREAKER = "\n\n"; + private static final Splitter SPLITTER = Splitter.on(BUBBLE_BREAKER); + + boolean isRemote; + public boolean hasAvatar; + private final StringBuilder content = new StringBuilder(); + private boolean isFinished; + + public boolean isFinished() { + return isFinished; + } + + public void finish() { + isFinished = true; + } + + public void append(String text) { + for (int i = 0; i < text.length(); i++) { + char c = text.charAt(i); + if (c != '\b') { + content.append(c); + } else if (content.length() > 0) { + content.deleteCharAt(content.length() - 1); + } + } + } + + public String getContent() { + return content.toString(); + } + + /** + * Generates delta change to a text. + * + *

    This is used to track text change of input. See more details in {@link + * TextWatcher#onTextChanged} + * + *

    e.g. "hello world" -> "hello" : "\b\b\b\b\b\b" + * + *

    "hello world" -> "hello mom!" : "\b\b\b\b\bmom!" + * + *

    "hello world" -> "hello d" : "\b\b\b\b\bd" + * + *

    "hello world" -> "hello new world" : "\b\b\b\b\bnew world" + */ + static String getChangedString(CharSequence s, int start, int before, int count) { + StringBuilder modify = new StringBuilder(); + if (before > count) { + int deleteStart = start + count; + int deleted = before - count; + int numberUnModifiedCharsAfterDeleted = s.length() - start - count; + char c = '\b'; + for (int i = 0; i < deleted + numberUnModifiedCharsAfterDeleted; i++) { + modify.append(c); + } + modify.append(s, deleteStart, s.length()); + } else { + int insertStart = start + before; + int numberUnModifiedCharsAfterInserted = s.length() - start - count; + char c = '\b'; + for (int i = 0; i < numberUnModifiedCharsAfterInserted; i++) { + modify.append(c); + } + modify.append(s, insertStart, s.length()); + } + return modify.toString(); + } + + /** Convert remote input text into an array of {@code RttChatMessage}. */ + static RttChatMessage[] getRemoteRttChatMessage( + @Nullable RttChatMessage currentMessage, @NonNull String text) { + Iterator splitText = SPLITTER.split(text).iterator(); + List messageList = new ArrayList<>(); + + String firstMessageContent = splitText.next(); + RttChatMessage firstMessage = currentMessage; + if (firstMessage == null) { + firstMessage = new RttChatMessage(); + firstMessage.isRemote = true; + } + firstMessage.append(firstMessageContent); + if (splitText.hasNext() || text.endsWith(BUBBLE_BREAKER)) { + firstMessage.finish(); + } + messageList.add(firstMessage); + + while (splitText.hasNext()) { + String singleMessageContent = splitText.next(); + if (singleMessageContent.isEmpty()) { + continue; + } + RttChatMessage message = new RttChatMessage(); + message.append(singleMessageContent); + message.isRemote = true; + if (splitText.hasNext()) { + message.finish(); + } + messageList.add(message); + } + + return messageList.toArray(new RttChatMessage[0]); + } +} diff --git a/java/com/android/incallui/rtt/impl/RttChatMessageViewHolder.java b/java/com/android/incallui/rtt/impl/RttChatMessageViewHolder.java new file mode 100644 index 000000000..c88786aa4 --- /dev/null +++ b/java/com/android/incallui/rtt/impl/RttChatMessageViewHolder.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.incallui.rtt.impl; + +import android.content.res.Resources; +import android.support.v7.widget.RecyclerView.ViewHolder; +import android.view.Gravity; +import android.view.View; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.LinearLayout.LayoutParams; +import android.widget.TextView; + +/** ViewHolder class for RTT chat message bubble. */ +public class RttChatMessageViewHolder extends ViewHolder { + + private final TextView messageTextView; + private final Resources resources; + private final ImageView avatarImageView; + private final View container; + + RttChatMessageViewHolder(View view) { + super(view); + container = view.findViewById(R.id.rtt_chat_message_container); + messageTextView = view.findViewById(R.id.rtt_chat_message); + avatarImageView = view.findViewById(R.id.rtt_chat_avatar); + resources = view.getResources(); + } + + void setMessage(RttChatMessage message, boolean isSameGroup) { + messageTextView.setText(message.getContent()); + LinearLayout.LayoutParams params = (LayoutParams) container.getLayoutParams(); + params.gravity = message.isRemote ? Gravity.START : Gravity.END; + params.topMargin = + isSameGroup + ? resources.getDimensionPixelSize(R.dimen.rtt_same_group_message_margin_top) + : resources.getDimensionPixelSize(R.dimen.rtt_message_margin_top); + container.setLayoutParams(params); + messageTextView.setEnabled(message.isRemote); + if (message.isRemote) { + if (isSameGroup) { + avatarImageView.setVisibility(View.INVISIBLE); + } else { + avatarImageView.setVisibility(View.VISIBLE); + avatarImageView.setImageResource(R.drawable.product_logo_avatar_anonymous_white_color_120); + } + } else { + avatarImageView.setVisibility(View.GONE); + } + } +} diff --git a/java/com/android/incallui/rtt/impl/res/color/message_bubble_color.xml b/java/com/android/incallui/rtt/impl/res/color/message_bubble_color.xml new file mode 100644 index 000000000..b3729ee20 --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/color/message_bubble_color.xml @@ -0,0 +1,21 @@ + + + + + + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/color/submit_button_background_color.xml b/java/com/android/incallui/rtt/impl/res/color/submit_button_background_color.xml new file mode 100644 index 000000000..0da2c374a --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/color/submit_button_background_color.xml @@ -0,0 +1,21 @@ + + + + + + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/color/submit_button_color.xml b/java/com/android/incallui/rtt/impl/res/color/submit_button_color.xml new file mode 100644 index 000000000..2fe748f77 --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/color/submit_button_color.xml @@ -0,0 +1,21 @@ + + + + + + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/drawable/input_bubble_background.xml b/java/com/android/incallui/rtt/impl/res/drawable/input_bubble_background.xml new file mode 100644 index 000000000..ae372332e --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/drawable/input_bubble_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/drawable/message_bubble.xml b/java/com/android/incallui/rtt/impl/res/drawable/message_bubble.xml new file mode 100644 index 000000000..2b01f62f9 --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/drawable/message_bubble.xml @@ -0,0 +1,21 @@ + + + + + + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/drawable/pill_background.xml b/java/com/android/incallui/rtt/impl/res/drawable/pill_background.xml new file mode 100644 index 000000000..cfad8df57 --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/drawable/pill_background.xml @@ -0,0 +1,22 @@ + + + + + + + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/layout/activity_rtt.xml b/java/com/android/incallui/rtt/impl/res/layout/activity_rtt.xml new file mode 100644 index 000000000..b48e8d43f --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/layout/activity_rtt.xml @@ -0,0 +1,26 @@ + + + + + + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml b/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml new file mode 100644 index 000000000..7ba6a09e3 --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/layout/rtt_banner.xml b/java/com/android/incallui/rtt/impl/res/layout/rtt_banner.xml new file mode 100644 index 000000000..7d9cd6fc8 --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/layout/rtt_banner.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/layout/rtt_chat_list_item.xml b/java/com/android/incallui/rtt/impl/res/layout/rtt_chat_list_item.xml new file mode 100644 index 000000000..54b0f4f6a --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/layout/rtt_chat_list_item.xml @@ -0,0 +1,48 @@ + + + + + + + + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/values/colors.xml b/java/com/android/incallui/rtt/impl/res/values/colors.xml new file mode 100644 index 000000000..402cac4a0 --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/values/colors.xml @@ -0,0 +1,19 @@ + + + + #E0E0E0 + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/values/dimens.xml b/java/com/android/incallui/rtt/impl/res/values/dimens.xml new file mode 100644 index 000000000..a3f230c08 --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/values/dimens.xml @@ -0,0 +1,20 @@ + + + + 16dp + 2dp + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/values/strings.xml b/java/com/android/incallui/rtt/impl/res/values/strings.xml new file mode 100644 index 000000000..79377acda --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/values/strings.xml @@ -0,0 +1,29 @@ + + + + + Go ahead + + + Close RTT chat + + + Type a message + + + Avatar + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/values/styles.xml b/java/com/android/incallui/rtt/impl/res/values/styles.xml new file mode 100644 index 000000000..b4bb91474 --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/values/styles.xml @@ -0,0 +1,35 @@ + + + + + + + + + \ No newline at end of file diff --git a/packages.mk b/packages.mk index 03268fd57..d01b3f15a 100644 --- a/packages.mk +++ b/packages.mk @@ -75,6 +75,7 @@ LOCAL_AAPT_FLAGS := \ com.android.incallui.hold \ com.android.incallui.incall.impl \ com.android.incallui.maps.impl \ + com.android.incallui.rtt.impl \ com.android.incallui.sessiondata \ com.android.incallui.spam \ com.android.incallui.speakerbuttonlogic \ -- cgit v1.2.3 From c40c2d996479d926b174777d7186347e7776ccc5 Mon Sep 17 00:00:00 2001 From: zachh Date: Mon, 8 Jan 2018 14:13:07 -0800 Subject: Use ContactsContract.PhoneLookup for invalid numbers in Cp2PhoneLookup. "Invalid" numbers are identified according to PhoneNumberUtil.isValidNumber. This is necessary to support loose matching for such numbers. However, ContactsContract.PhoneLookup only supports looking up individual numbers, which means that we cannot issue batch queries and must issue individiual queries for each invalid number. The hope is that these numbers won't appear frequently so performance should still be acceptable. However, as a failsafe, if there are more than 5 invalid numbers we just give up trying to bulk update the invalid numbers and signal that those numbers are INCOMPLETE so that the UI can query for their CP2 information on the fly (the UI will be updated in a future CL). It was necessary to convert much of the class to use futures to support parallelization of the queries. Bug: 71504246 Test: unit PiperOrigin-RevId: 181216674 Change-Id: I3bec477d305772b4ca3e46d0bd326cfebf9fa313 --- .../dialer/phonelookup/cp2/Cp2PhoneLookup.java | 895 +++++++++++++-------- .../dialer/phonelookup/phone_lookup_info.proto | 6 + .../phonenumberproto/DialerPhoneNumberUtil.java | 26 +- 3 files changed, 587 insertions(+), 340 deletions(-) diff --git a/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java b/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java index 307e0a434..0d312cbbe 100644 --- a/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java +++ b/java/com/android/dialer/phonelookup/cp2/Cp2PhoneLookup.java @@ -19,6 +19,8 @@ package com.android.dialer.phonelookup.cp2; import android.content.Context; import android.content.SharedPreferences; import android.database.Cursor; +import android.net.Uri; +import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.DeletedContacts; @@ -31,6 +33,7 @@ import com.android.dialer.DialerPhoneNumber; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor; +import com.android.dialer.common.concurrent.Annotations.LightweightExecutor; import com.android.dialer.inject.ApplicationContext; import com.android.dialer.phonelookup.PhoneLookup; import com.android.dialer.phonelookup.PhoneLookupInfo; @@ -43,12 +46,18 @@ import com.android.dialer.telecom.TelecomCallUtil; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; import com.google.protobuf.InvalidProtocolBufferException; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.concurrent.Callable; import javax.inject.Inject; /** PhoneLookup implementation for local contacts. */ @@ -57,7 +66,8 @@ public final class Cp2PhoneLookup implements PhoneLookup { private static final String PREF_LAST_TIMESTAMP_PROCESSED = "cp2PhoneLookupLastTimestampProcessed"; - private static final String[] CP2_INFO_PROJECTION = + /** Projection for performing batch lookups based on E164 numbers using the PHONE table. */ + private static final String[] PHONE_PROJECTION = new String[] { Phone.DISPLAY_NAME_PRIMARY, // 0 Phone.PHOTO_THUMBNAIL_URI, // 1 @@ -65,24 +75,44 @@ public final class Cp2PhoneLookup implements PhoneLookup { Phone.TYPE, // 3 Phone.LABEL, // 4 Phone.NORMALIZED_NUMBER, // 5 - Phone.NUMBER, // 6 - Phone.CONTACT_ID, // 7 - Phone.LOOKUP_KEY // 8 + Phone.CONTACT_ID, // 6 + Phone.LOOKUP_KEY // 7 }; + /** + * Projection for performing individual lookups of non-E164 numbers using the PHONE_LOOKUP table. + */ + private static final String[] PHONE_LOOKUP_PROJECTION = + new String[] { + ContactsContract.PhoneLookup.DISPLAY_NAME_PRIMARY, // 0 + ContactsContract.PhoneLookup.PHOTO_THUMBNAIL_URI, // 1 + ContactsContract.PhoneLookup.PHOTO_ID, // 2 + ContactsContract.PhoneLookup.TYPE, // 3 + ContactsContract.PhoneLookup.LABEL, // 4 + ContactsContract.PhoneLookup.NORMALIZED_NUMBER, // 5 + ContactsContract.PhoneLookup.CONTACT_ID, // 6 + ContactsContract.PhoneLookup.LOOKUP_KEY // 7 + }; + + // The following indexes should match both PHONE_PROJECTION and PHONE_LOOKUP_PROJECTION above. private static final int CP2_INFO_NAME_INDEX = 0; private static final int CP2_INFO_PHOTO_URI_INDEX = 1; private static final int CP2_INFO_PHOTO_ID_INDEX = 2; private static final int CP2_INFO_TYPE_INDEX = 3; private static final int CP2_INFO_LABEL_INDEX = 4; private static final int CP2_INFO_NORMALIZED_NUMBER_INDEX = 5; - private static final int CP2_INFO_NUMBER_INDEX = 6; - private static final int CP2_INFO_CONTACT_ID_INDEX = 7; - private static final int CP2_INFO_LOOKUP_KEY_INDEX = 8; + private static final int CP2_INFO_CONTACT_ID_INDEX = 6; + private static final int CP2_INFO_LOOKUP_KEY_INDEX = 7; + + // We cannot efficiently process invalid numbers because batch queries cannot be constructed which + // accomplish the necessary loose matching. We'll attempt to process a limited number of them, + // but if there are too many we fall back to querying CP2 at render time. + private static final int MAX_SUPPORTED_INVALID_NUMBERS = 5; private final Context appContext; private final SharedPreferences sharedPreferences; private final ListeningExecutorService backgroundExecutorService; + private final ListeningExecutorService lightweightExecutorService; @Nullable private Long currentLastTimestampProcessed; @@ -90,10 +120,12 @@ public final class Cp2PhoneLookup implements PhoneLookup { Cp2PhoneLookup( @ApplicationContext Context appContext, @Unencrypted SharedPreferences sharedPreferences, - @BackgroundExecutor ListeningExecutorService backgroundExecutorService) { + @BackgroundExecutor ListeningExecutorService backgroundExecutorService, + @LightweightExecutor ListeningExecutorService lightweightExecutorService) { this.appContext = appContext; this.sharedPreferences = sharedPreferences; this.backgroundExecutorService = backgroundExecutorService; + this.lightweightExecutorService = lightweightExecutorService; } @Override @@ -108,10 +140,12 @@ public final class Cp2PhoneLookup implements PhoneLookup { } Optional e164 = TelecomCallUtil.getE164Number(appContext, call); Set cp2ContactInfos = new ArraySet<>(); + // Note: It would make sense to use PHONE_LOOKUP for E164 numbers as well, but we use PHONE to + // ensure consistency when the batch methods are used to update data. try (Cursor cursor = e164.isPresent() - ? queryPhoneTableBasedOnE164(CP2_INFO_PROJECTION, ImmutableSet.of(e164.get())) - : queryPhoneTableBasedOnRawNumber(CP2_INFO_PROJECTION, ImmutableSet.of(rawNumber))) { + ? queryPhoneTableBasedOnE164(PHONE_PROJECTION, ImmutableSet.of(e164.get())) + : queryPhoneLookup(PHONE_LOOKUP_PROJECTION, rawNumber)) { if (cursor == null) { LogUtil.w("Cp2PhoneLookup.lookupInternal", "null cursor"); return Cp2Info.getDefaultInstance(); @@ -125,133 +159,203 @@ public final class Cp2PhoneLookup implements PhoneLookup { @Override public ListenableFuture isDirty(ImmutableSet phoneNumbers) { - return backgroundExecutorService.submit(() -> isDirtyInternal(phoneNumbers)); - } - - private boolean isDirtyInternal(ImmutableSet phoneNumbers) { - long lastModified = sharedPreferences.getLong(PREF_LAST_TIMESTAMP_PROCESSED, 0L); - // We are always going to need to do this check and it is pretty cheap so do it first. - if (anyContactsDeletedSince(lastModified)) { - return true; - } - // Hopefully the most common case is there are no contacts updated; we can detect this cheaply. - if (noContactsModifiedSince(lastModified)) { - return false; - } - // This method is more expensive but is probably the most likely scenario; we are looking for - // changes to contacts which have been called. - if (contactsUpdated(queryPhoneTableForContactIds(phoneNumbers), lastModified)) { - return true; - } - // This is the most expensive method so do it last; the scenario is that a contact which has - // been called got disassociated with a number and we need to clear their information. - if (contactsUpdated(queryPhoneLookupHistoryForContactIds(), lastModified)) { - return true; - } - return false; + PartitionedNumbers partitionedNumbers = new PartitionedNumbers(phoneNumbers); + if (partitionedNumbers.unformattableNumbers().size() > MAX_SUPPORTED_INVALID_NUMBERS) { + // If there are N invalid numbers, we can't determine determine dirtiness without running N + // queries; since running this many queries is not feasible for the (lightweight) isDirty + // check, simply return true. The expectation is that this should rarely be the case as the + // vast majority of numbers in call logs should be valid. + return Futures.immediateFuture(true); + } + + ListenableFuture lastModifiedFuture = + backgroundExecutorService.submit( + () -> sharedPreferences.getLong(PREF_LAST_TIMESTAMP_PROCESSED, 0L)); + return Futures.transformAsync( + lastModifiedFuture, + lastModified -> { + // We are always going to need to do this check and it is pretty cheap so do it first. + ListenableFuture anyContactsDeletedFuture = + anyContactsDeletedSince(lastModified); + return Futures.transformAsync( + anyContactsDeletedFuture, + anyContactsDeleted -> { + if (anyContactsDeleted) { + return Futures.immediateFuture(true); + } + // Hopefully the most common case is there are no contacts updated; we can detect + // this cheaply. + ListenableFuture noContactsModifiedSinceFuture = + noContactsModifiedSince(lastModified); + return Futures.transformAsync( + noContactsModifiedSinceFuture, + noContactsModifiedSince -> { + if (noContactsModifiedSince) { + return Futures.immediateFuture(false); + } + // This method is more expensive but is probably the most likely scenario; we + // are looking for changes to contacts which have been called. + ListenableFuture> contactIdsFuture = + queryPhoneTableForContactIds(phoneNumbers); + ListenableFuture contactsUpdatedFuture = + Futures.transformAsync( + contactIdsFuture, + contactIds -> contactsUpdated(contactIds, lastModified), + MoreExecutors.directExecutor()); + return Futures.transformAsync( + contactsUpdatedFuture, + contactsUpdated -> { + if (contactsUpdated) { + return Futures.immediateFuture(true); + } + // This is the most expensive method so do it last; the scenario is that + // a contact which has been called got disassociated with a number and + // we need to clear their information. + ListenableFuture> phoneLookupContactIdsFuture = + queryPhoneLookupHistoryForContactIds(); + return Futures.transformAsync( + phoneLookupContactIdsFuture, + phoneLookupContactIds -> + contactsUpdated(phoneLookupContactIds, lastModified), + MoreExecutors.directExecutor()); + }, + MoreExecutors.directExecutor()); + }, + MoreExecutors.directExecutor()); + }, + MoreExecutors.directExecutor()); + }, + MoreExecutors.directExecutor()); } /** * Returns set of contact ids that correspond to {@code dialerPhoneNumbers} if the contact exists. */ - private Set queryPhoneTableForContactIds( + private ListenableFuture> queryPhoneTableForContactIds( ImmutableSet dialerPhoneNumbers) { - Set contactIds = new ArraySet<>(); - PartitionedNumbers partitionedNumbers = new PartitionedNumbers(dialerPhoneNumbers); + List>> queryFutures = new ArrayList<>(); + // First use the E164 numbers to query the NORMALIZED_NUMBER column. - contactIds.addAll( + queryFutures.add( queryPhoneTableForContactIdsBasedOnE164(partitionedNumbers.validE164Numbers())); - // Then run a separate query using the NUMBER column to handle numbers that can't be formatted. - contactIds.addAll( - queryPhoneTableForContactIdsBasedOnRawNumber(partitionedNumbers.unformattableNumbers())); - - return contactIds; + // Then run a separate query for each invalid number. Separate queries are done to accomplish + // loose matching which couldn't be accomplished with a batch query. + Assert.checkState( + partitionedNumbers.unformattableNumbers().size() <= MAX_SUPPORTED_INVALID_NUMBERS); + for (String invalidNumber : partitionedNumbers.unformattableNumbers()) { + queryFutures.add(queryPhoneLookupTableForContactIdsBasedOnRawNumber(invalidNumber)); + } + return Futures.transform( + Futures.allAsList(queryFutures), + listOfSets -> { + Set contactIds = new ArraySet<>(); + for (Set ids : listOfSets) { + contactIds.addAll(ids); + } + return contactIds; + }, + lightweightExecutorService); } /** Gets all of the contact ids from PhoneLookupHistory. */ - private Set queryPhoneLookupHistoryForContactIds() { - Set contactIds = new ArraySet<>(); - try (Cursor cursor = - appContext - .getContentResolver() - .query( - PhoneLookupHistory.CONTENT_URI, - new String[] { - PhoneLookupHistory.PHONE_LOOKUP_INFO, - }, - null, - null, - null)) { - - if (cursor == null) { - LogUtil.w("Cp2PhoneLookup.queryPhoneLookupHistoryForContactIds", "null cursor"); - return contactIds; - } - - if (cursor.moveToFirst()) { - int phoneLookupInfoColumn = - cursor.getColumnIndexOrThrow(PhoneLookupHistory.PHONE_LOOKUP_INFO); - do { - PhoneLookupInfo phoneLookupInfo; - try { - phoneLookupInfo = PhoneLookupInfo.parseFrom(cursor.getBlob(phoneLookupInfoColumn)); - } catch (InvalidProtocolBufferException e) { - throw new IllegalStateException(e); - } - for (Cp2ContactInfo info : phoneLookupInfo.getCp2Info().getCp2ContactInfoList()) { - contactIds.add(info.getContactId()); + private ListenableFuture> queryPhoneLookupHistoryForContactIds() { + return backgroundExecutorService.submit( + () -> { + Set contactIds = new ArraySet<>(); + try (Cursor cursor = + appContext + .getContentResolver() + .query( + PhoneLookupHistory.CONTENT_URI, + new String[] { + PhoneLookupHistory.PHONE_LOOKUP_INFO, + }, + null, + null, + null)) { + + if (cursor == null) { + LogUtil.w("Cp2PhoneLookup.queryPhoneLookupHistoryForContactIds", "null cursor"); + return contactIds; + } + + if (cursor.moveToFirst()) { + int phoneLookupInfoColumn = + cursor.getColumnIndexOrThrow(PhoneLookupHistory.PHONE_LOOKUP_INFO); + do { + PhoneLookupInfo phoneLookupInfo; + try { + phoneLookupInfo = + PhoneLookupInfo.parseFrom(cursor.getBlob(phoneLookupInfoColumn)); + } catch (InvalidProtocolBufferException e) { + throw new IllegalStateException(e); + } + for (Cp2ContactInfo info : phoneLookupInfo.getCp2Info().getCp2ContactInfoList()) { + contactIds.add(info.getContactId()); + } + } while (cursor.moveToNext()); + } } - } while (cursor.moveToNext()); - } - } - - return contactIds; + return contactIds; + }); } - private Set queryPhoneTableForContactIdsBasedOnE164(Set validE164Numbers) { - Set contactIds = new ArraySet<>(); - if (validE164Numbers.isEmpty()) { - return contactIds; - } - try (Cursor cursor = - queryPhoneTableBasedOnE164(new String[] {Phone.CONTACT_ID}, validE164Numbers)) { - if (cursor == null) { - LogUtil.w("Cp2PhoneLookup.queryPhoneTableForContactIdsBasedOnE164", "null cursor"); - return contactIds; - } - while (cursor.moveToNext()) { - contactIds.add(cursor.getLong(0 /* columnIndex */)); - } - } - return contactIds; + private ListenableFuture> queryPhoneTableForContactIdsBasedOnE164( + Set validE164Numbers) { + return backgroundExecutorService.submit( + () -> { + Set contactIds = new ArraySet<>(); + if (validE164Numbers.isEmpty()) { + return contactIds; + } + try (Cursor cursor = + queryPhoneTableBasedOnE164(new String[] {Phone.CONTACT_ID}, validE164Numbers)) { + if (cursor == null) { + LogUtil.w("Cp2PhoneLookup.queryPhoneTableForContactIdsBasedOnE164", "null cursor"); + return contactIds; + } + while (cursor.moveToNext()) { + contactIds.add(cursor.getLong(0 /* columnIndex */)); + } + } + return contactIds; + }); } - private Set queryPhoneTableForContactIdsBasedOnRawNumber(Set unformattableNumbers) { - Set contactIds = new ArraySet<>(); - if (unformattableNumbers.isEmpty()) { - return contactIds; - } - try (Cursor cursor = - queryPhoneTableBasedOnRawNumber(new String[] {Phone.CONTACT_ID}, unformattableNumbers)) { - if (cursor == null) { - LogUtil.w("Cp2PhoneLookup.queryPhoneTableForContactIdsBasedOnE164", "null cursor"); - return contactIds; - } - while (cursor.moveToNext()) { - contactIds.add(cursor.getLong(0 /* columnIndex */)); - } - } - return contactIds; + private ListenableFuture> queryPhoneLookupTableForContactIdsBasedOnRawNumber( + String rawNumber) { + return backgroundExecutorService.submit( + () -> { + Set contactIds = new ArraySet<>(); + try (Cursor cursor = + queryPhoneLookup( + new String[] {android.provider.ContactsContract.PhoneLookup.CONTACT_ID}, + rawNumber)) { + if (cursor == null) { + LogUtil.w( + "Cp2PhoneLookup.queryPhoneLookupTableForContactIdsBasedOnRawNumber", + "null cursor"); + return contactIds; + } + while (cursor.moveToNext()) { + contactIds.add(cursor.getLong(0 /* columnIndex */)); + } + } + return contactIds; + }); } /** Returns true if any contacts were modified after {@code lastModified}. */ - private boolean contactsUpdated(Set contactIds, long lastModified) { - try (Cursor cursor = queryContactsTableForContacts(contactIds, lastModified)) { - return cursor.getCount() > 0; - } + private ListenableFuture contactsUpdated(Set contactIds, long lastModified) { + return backgroundExecutorService.submit( + () -> { + try (Cursor cursor = queryContactsTableForContacts(contactIds, lastModified)) { + return cursor.getCount() > 0; + } + }); } private Cursor queryContactsTableForContacts(Set contactIds, long lastModified) { @@ -282,47 +386,47 @@ public final class Cp2PhoneLookup implements PhoneLookup { null); } - private boolean noContactsModifiedSince(long lastModified) { - try (Cursor cursor = - appContext - .getContentResolver() - .query( - Contacts.CONTENT_URI, - new String[] {Contacts._ID}, - Contacts.CONTACT_LAST_UPDATED_TIMESTAMP + " > ?", - new String[] {Long.toString(lastModified)}, - Contacts._ID + " limit 1")) { - if (cursor == null) { - LogUtil.w("Cp2PhoneLookup.noContactsModifiedSince", "null cursor"); - return false; - } - return cursor.getCount() == 0; - } + private ListenableFuture noContactsModifiedSince(long lastModified) { + return backgroundExecutorService.submit( + () -> { + try (Cursor cursor = + appContext + .getContentResolver() + .query( + Contacts.CONTENT_URI, + new String[] {Contacts._ID}, + Contacts.CONTACT_LAST_UPDATED_TIMESTAMP + " > ?", + new String[] {Long.toString(lastModified)}, + Contacts._ID + " limit 1")) { + if (cursor == null) { + LogUtil.w("Cp2PhoneLookup.noContactsModifiedSince", "null cursor"); + return false; + } + return cursor.getCount() == 0; + } + }); } /** Returns true if any contacts were deleted after {@code lastModified}. */ - private boolean anyContactsDeletedSince(long lastModified) { - try (Cursor cursor = - appContext - .getContentResolver() - .query( - DeletedContacts.CONTENT_URI, - new String[] {DeletedContacts.CONTACT_DELETED_TIMESTAMP}, - DeletedContacts.CONTACT_DELETED_TIMESTAMP + " > ?", - new String[] {Long.toString(lastModified)}, - DeletedContacts.CONTACT_DELETED_TIMESTAMP + " limit 1")) { - if (cursor == null) { - LogUtil.w("Cp2PhoneLookup.anyContactsDeletedSince", "null cursor"); - return false; - } - return cursor.getCount() > 0; - } - } - - @Override - public ListenableFuture> getMostRecentInfo( - ImmutableMap existingInfoMap) { - return backgroundExecutorService.submit(() -> getMostRecentInfoInternal(existingInfoMap)); + private ListenableFuture anyContactsDeletedSince(long lastModified) { + return backgroundExecutorService.submit( + () -> { + try (Cursor cursor = + appContext + .getContentResolver() + .query( + DeletedContacts.CONTENT_URI, + new String[] {DeletedContacts.CONTACT_DELETED_TIMESTAMP}, + DeletedContacts.CONTACT_DELETED_TIMESTAMP + " > ?", + new String[] {Long.toString(lastModified)}, + DeletedContacts.CONTACT_DELETED_TIMESTAMP + " limit 1")) { + if (cursor == null) { + LogUtil.w("Cp2PhoneLookup.anyContactsDeletedSince", "null cursor"); + return false; + } + return cursor.getCount() > 0; + } + }); } @Override @@ -335,46 +439,96 @@ public final class Cp2PhoneLookup implements PhoneLookup { return phoneLookupInfo.getCp2Info(); } - private ImmutableMap getMostRecentInfoInternal( + @Override + public ListenableFuture> getMostRecentInfo( ImmutableMap existingInfoMap) { currentLastTimestampProcessed = null; - long lastModified = sharedPreferences.getLong(PREF_LAST_TIMESTAMP_PROCESSED, 0L); - - // Build a set of each DialerPhoneNumber that was associated with a contact, and is no longer - // associated with that same contact. - Set deletedPhoneNumbers = - getDeletedPhoneNumbers(existingInfoMap, lastModified); - - // For each DialerPhoneNumber that was associated with a contact or added to a contact, - // build a map of those DialerPhoneNumbers to a set Cp2ContactInfos, where each Cp2ContactInfo - // represents a contact. - Map> updatedContacts = - buildMapForUpdatedOrAddedContacts(existingInfoMap, lastModified, deletedPhoneNumbers); - - // Start build a new map of updated info. This will replace existing info. - ImmutableMap.Builder newInfoMapBuilder = ImmutableMap.builder(); - // For each DialerPhoneNumber in existing info... - for (Entry entry : existingInfoMap.entrySet()) { - DialerPhoneNumber dialerPhoneNumber = entry.getKey(); - Cp2Info existingInfo = entry.getValue(); - - // Build off the existing info - Cp2Info.Builder infoBuilder = Cp2Info.newBuilder(existingInfo); - - // If the contact was updated, replace the Cp2ContactInfo list - if (updatedContacts.containsKey(dialerPhoneNumber)) { - infoBuilder.clear().addAllCp2ContactInfo(updatedContacts.get(dialerPhoneNumber)); + ListenableFuture lastModifiedFuture = + backgroundExecutorService.submit( + () -> sharedPreferences.getLong(PREF_LAST_TIMESTAMP_PROCESSED, 0L)); + return Futures.transformAsync( + lastModifiedFuture, + lastModified -> { + // Build a set of each DialerPhoneNumber that was associated with a contact, and is no + // longer associated with that same contact. + ListenableFuture> deletedPhoneNumbersFuture = + getDeletedPhoneNumbers(existingInfoMap, lastModified); + + return Futures.transformAsync( + deletedPhoneNumbersFuture, + deletedPhoneNumbers -> { + + // If there are too many invalid numbers, just defer the work to render time. + ArraySet unprocessableNumbers = + findUnprocessableNumbers(existingInfoMap); + Map existingInfoMapToProcess = existingInfoMap; + if (!unprocessableNumbers.isEmpty()) { + existingInfoMapToProcess = + Maps.filterKeys( + existingInfoMap, number -> !unprocessableNumbers.contains(number)); + } + + // For each DialerPhoneNumber that was associated with a contact or added to a + // contact, build a map of those DialerPhoneNumbers to a set Cp2ContactInfos, where + // each Cp2ContactInfo represents a contact. + ListenableFuture>> + updatedContactsFuture = + buildMapForUpdatedOrAddedContacts( + existingInfoMapToProcess, lastModified, deletedPhoneNumbers); + + return Futures.transform( + updatedContactsFuture, + updatedContacts -> { + + // Start build a new map of updated info. This will replace existing info. + ImmutableMap.Builder newInfoMapBuilder = + ImmutableMap.builder(); + + // For each DialerPhoneNumber in existing info... + for (Entry entry : existingInfoMap.entrySet()) { + DialerPhoneNumber dialerPhoneNumber = entry.getKey(); + Cp2Info existingInfo = entry.getValue(); + + // Build off the existing info + Cp2Info.Builder infoBuilder = Cp2Info.newBuilder(existingInfo); + + // If the contact was updated, replace the Cp2ContactInfo list + if (updatedContacts.containsKey(dialerPhoneNumber)) { + infoBuilder + .clear() + .addAllCp2ContactInfo(updatedContacts.get(dialerPhoneNumber)); + // If it was deleted and not added to a new contact, clear all the CP2 + // information. + } else if (deletedPhoneNumbers.contains(dialerPhoneNumber)) { + infoBuilder.clear(); + } else if (unprocessableNumbers.contains(dialerPhoneNumber)) { + infoBuilder.clear().setIsIncomplete(true); + } + + // If the DialerPhoneNumber didn't change, add the unchanged existing info. + newInfoMapBuilder.put(dialerPhoneNumber, infoBuilder.build()); + } + return newInfoMapBuilder.build(); + }, + lightweightExecutorService); + }, + lightweightExecutorService); + }, + lightweightExecutorService); + } - // If it was deleted and not added to a new contact, clear all the CP2 information. - } else if (deletedPhoneNumbers.contains(dialerPhoneNumber)) { - infoBuilder.clear(); + private ArraySet findUnprocessableNumbers( + ImmutableMap existingInfoMap) { + ArraySet unprocessableNumbers = new ArraySet<>(); + PartitionedNumbers partitionedNumbers = new PartitionedNumbers(existingInfoMap.keySet()); + if (partitionedNumbers.unformattableNumbers().size() > MAX_SUPPORTED_INVALID_NUMBERS) { + for (String invalidNumber : partitionedNumbers.unformattableNumbers()) { + unprocessableNumbers.addAll( + partitionedNumbers.dialerPhoneNumbersForUnformattable(invalidNumber)); } - - // If the DialerPhoneNumber didn't change, add the unchanged existing info. - newInfoMapBuilder.put(dialerPhoneNumber, infoBuilder.build()); } - return newInfoMapBuilder.build(); + return unprocessableNumbers; } @Override @@ -391,6 +545,77 @@ public final class Cp2PhoneLookup implements PhoneLookup { }); } + private ListenableFuture> findNumbersToUpdate( + Map existingInfoMap, + long lastModified, + Set deletedPhoneNumbers) { + return backgroundExecutorService.submit( + () -> { + Set updatedNumbers = new ArraySet<>(); + Set contactIds = new ArraySet<>(); + for (Entry entry : existingInfoMap.entrySet()) { + DialerPhoneNumber dialerPhoneNumber = entry.getKey(); + Cp2Info existingInfo = entry.getValue(); + + // If the number was deleted, we need to check if it was added to a new contact. + if (deletedPhoneNumbers.contains(dialerPhoneNumber)) { + updatedNumbers.add(dialerPhoneNumber); + continue; + } + + // When the PhoneLookupHistory contains no information for a number, because for + // example the user just upgraded to the new UI, or cleared data, we need to check for + // updated info. + if (existingInfo.getCp2ContactInfoCount() == 0) { + updatedNumbers.add(dialerPhoneNumber); + } else { + // For each Cp2ContactInfo for each existing DialerPhoneNumber... + // Store the contact id if it exist, else automatically add the DialerPhoneNumber to + // our set of DialerPhoneNumbers we want to update. + for (Cp2ContactInfo cp2ContactInfo : existingInfo.getCp2ContactInfoList()) { + long existingContactId = cp2ContactInfo.getContactId(); + if (existingContactId == 0) { + // If the number doesn't have a contact id, for various reasons, we need to look + // up the number to check if any exists. The various reasons this might happen + // are: + // - An existing contact that wasn't in the call log is now in the call log. + // - A number was in the call log before but has now been added to a contact. + // - A number is in the call log, but isn't associated with any contact. + updatedNumbers.add(dialerPhoneNumber); + } else { + contactIds.add(cp2ContactInfo.getContactId()); + } + } + } + } + + // Query the contacts table and get those that whose + // Contacts.CONTACT_LAST_UPDATED_TIMESTAMP is after lastModified, such that Contacts._ID + // is in our set of contact IDs we build above. + if (!contactIds.isEmpty()) { + try (Cursor cursor = queryContactsTableForContacts(contactIds, lastModified)) { + int contactIdIndex = cursor.getColumnIndex(Contacts._ID); + int lastUpdatedIndex = cursor.getColumnIndex(Contacts.CONTACT_LAST_UPDATED_TIMESTAMP); + cursor.moveToPosition(-1); + while (cursor.moveToNext()) { + // Find the DialerPhoneNumber for each contact id and add it to our updated numbers + // set. These, along with our number not associated with any Cp2ContactInfo need to + // be updated. + long contactId = cursor.getLong(contactIdIndex); + updatedNumbers.addAll( + findDialerPhoneNumbersContainingContactId(existingInfoMap, contactId)); + long lastUpdatedTimestamp = cursor.getLong(lastUpdatedIndex); + if (currentLastTimestampProcessed == null + || currentLastTimestampProcessed < lastUpdatedTimestamp) { + currentLastTimestampProcessed = lastUpdatedTimestamp; + } + } + } + } + return updatedNumbers; + }); + } + @Override public void registerContentObservers( Context appContext, ContentObserverCallbacks contentObserverCallbacks) { @@ -406,131 +631,139 @@ public final class Cp2PhoneLookup implements PhoneLookup { * @return Map of {@link DialerPhoneNumber} to {@link Cp2Info} with updated {@link * Cp2ContactInfo}. */ - private Map> buildMapForUpdatedOrAddedContacts( - ImmutableMap existingInfoMap, - long lastModified, - Set deletedPhoneNumbers) { - - // Start building a set of DialerPhoneNumbers that we want to update. - Set updatedNumbers = new ArraySet<>(); + private ListenableFuture>> + buildMapForUpdatedOrAddedContacts( + Map existingInfoMap, + long lastModified, + Set deletedPhoneNumbers) { + // Start by building a set of DialerPhoneNumbers that we want to update. + ListenableFuture> updatedNumbersFuture = + findNumbersToUpdate(existingInfoMap, lastModified, deletedPhoneNumbers); + + return Futures.transformAsync( + updatedNumbersFuture, + updatedNumbers -> { + if (updatedNumbers.isEmpty()) { + return Futures.immediateFuture(new ArrayMap<>()); + } - Set contactIds = new ArraySet<>(); - for (Entry entry : existingInfoMap.entrySet()) { - DialerPhoneNumber dialerPhoneNumber = entry.getKey(); - Cp2Info existingInfo = entry.getValue(); + // Divide the numbers into those we can format to E164 and those we can't. Issue a single + // batch query for the E164 numbers against the PHONE table, and in parallel issue + // individual queries against PHONE_LOOKUP for each non-E164 number. + // TODO(zachh): These queries are inefficient without a lastModified column to filter on. + PartitionedNumbers partitionedNumbers = + new PartitionedNumbers(ImmutableSet.copyOf(updatedNumbers)); - // If the number was deleted, we need to check if it was added to a new contact. - if (deletedPhoneNumbers.contains(dialerPhoneNumber)) { - updatedNumbers.add(dialerPhoneNumber); - continue; - } + ListenableFuture>> e164Future = + batchQueryForValidNumbers(partitionedNumbers.validE164Numbers()); - /// When the PhoneLookupHistory contains no information for a number, because for example the - // user just upgraded to the new UI, or cleared data, we need to check for updated info. - if (existingInfo.getCp2ContactInfoCount() == 0) { - updatedNumbers.add(dialerPhoneNumber); - } else { - // For each Cp2ContactInfo for each existing DialerPhoneNumber... - // Store the contact id if it exist, else automatically add the DialerPhoneNumber to our - // set of DialerPhoneNumbers we want to update. - for (Cp2ContactInfo cp2ContactInfo : existingInfo.getCp2ContactInfoList()) { - long existingContactId = cp2ContactInfo.getContactId(); - if (existingContactId == 0) { - // If the number doesn't have a contact id, for various reasons, we need to look up the - // number to check if any exists. The various reasons this might happen are: - // - An existing contact that wasn't in the call log is now in the call log. - // - A number was in the call log before but has now been added to a contact. - // - A number is in the call log, but isn't associated with any contact. - updatedNumbers.add(dialerPhoneNumber); - } else { - contactIds.add(cp2ContactInfo.getContactId()); + List>> nonE164FuturesList = new ArrayList<>(); + for (String invalidNumber : partitionedNumbers.unformattableNumbers()) { + nonE164FuturesList.add(individualQueryForInvalidNumber(invalidNumber)); } - } - } - } - // Query the contacts table and get those that whose Contacts.CONTACT_LAST_UPDATED_TIMESTAMP is - // after lastModified, such that Contacts._ID is in our set of contact IDs we build above. - if (!contactIds.isEmpty()) { - try (Cursor cursor = queryContactsTableForContacts(contactIds, lastModified)) { - int contactIdIndex = cursor.getColumnIndex(Contacts._ID); - int lastUpdatedIndex = cursor.getColumnIndex(Contacts.CONTACT_LAST_UPDATED_TIMESTAMP); - cursor.moveToPosition(-1); - while (cursor.moveToNext()) { - // Find the DialerPhoneNumber for each contact id and add it to our updated numbers set. - // These, along with our number not associated with any Cp2ContactInfo need to be updated. - long contactId = cursor.getLong(contactIdIndex); - updatedNumbers.addAll( - findDialerPhoneNumbersContainingContactId(existingInfoMap, contactId)); - long lastUpdatedTimestamp = cursor.getLong(lastUpdatedIndex); - if (currentLastTimestampProcessed == null - || currentLastTimestampProcessed < lastUpdatedTimestamp) { - currentLastTimestampProcessed = lastUpdatedTimestamp; - } - } - } - } + ListenableFuture>> nonE164Future = + Futures.allAsList(nonE164FuturesList); + + Callable>> computeMap = + () -> { + // These get() calls are safe because we are using whenAllSucceed below. + Map> e164Result = e164Future.get(); + List> non164Results = nonE164Future.get(); + + Map> map = new ArrayMap<>(); + + // First update the map with the E164 results. + for (Entry> entry : e164Result.entrySet()) { + String e164Number = entry.getKey(); + Set cp2ContactInfos = entry.getValue(); + + Set dialerPhoneNumbers = + partitionedNumbers.dialerPhoneNumbersForE164(e164Number); + + addInfo(map, dialerPhoneNumbers, cp2ContactInfos); + + // We are going to remove the numbers that we've handled so that we later can + // detect numbers that weren't handled and therefore need to have their contact + // information removed. + updatedNumbers.removeAll(dialerPhoneNumbers); + } + + // Next update the map with the non-E164 results. + int i = 0; + for (String unformattableNumber : partitionedNumbers.unformattableNumbers()) { + Set cp2Infos = non164Results.get(i++); + Set dialerPhoneNumbers = + partitionedNumbers.dialerPhoneNumbersForUnformattable(unformattableNumber); + + addInfo(map, dialerPhoneNumbers, cp2Infos); + + // We are going to remove the numbers that we've handled so that we later can + // detect numbers that weren't handled and therefore need to have their contact + // information removed. + updatedNumbers.removeAll(dialerPhoneNumbers); + } + + // The leftovers in updatedNumbers that weren't removed are numbers that were + // previously associated with contacts, but are no longer. Remove the contact + // information for them. + for (DialerPhoneNumber dialerPhoneNumber : updatedNumbers) { + map.put(dialerPhoneNumber, ImmutableSet.of()); + } + return map; + }; + return Futures.whenAllSucceed(e164Future, nonE164Future) + .call(computeMap, lightweightExecutorService); + }, + lightweightExecutorService); + } - if (updatedNumbers.isEmpty()) { - return new ArrayMap<>(); - } + private ListenableFuture>> batchQueryForValidNumbers( + Set e164Numbers) { + return backgroundExecutorService.submit( + () -> { + Map> cp2ContactInfosByNumber = new ArrayMap<>(); + if (e164Numbers.isEmpty()) { + return cp2ContactInfosByNumber; + } + try (Cursor cursor = queryPhoneTableBasedOnE164(PHONE_PROJECTION, e164Numbers)) { + if (cursor == null) { + LogUtil.w("Cp2PhoneLookup.batchQueryForValidNumbers", "null cursor"); + } else { + while (cursor.moveToNext()) { + String e164Number = cursor.getString(CP2_INFO_NORMALIZED_NUMBER_INDEX); + Set cp2ContactInfos = cp2ContactInfosByNumber.get(e164Number); + if (cp2ContactInfos == null) { + cp2ContactInfos = new ArraySet<>(); + cp2ContactInfosByNumber.put(e164Number, cp2ContactInfos); + } + cp2ContactInfos.add(buildCp2ContactInfoFromPhoneCursor(appContext, cursor)); + } + } + } + return cp2ContactInfosByNumber; + }); + } - Map> map = new ArrayMap<>(); - - // Divide the numbers into those we can format to E164 and those we can't. Then run separate - // queries against the contacts table using the NORMALIZED_NUMBER and NUMBER columns. - // TODO(zachh): These queries are inefficient without a lastModified column to filter on. - PartitionedNumbers partitionedNumbers = - new PartitionedNumbers(ImmutableSet.copyOf(updatedNumbers)); - if (!partitionedNumbers.validE164Numbers().isEmpty()) { - try (Cursor cursor = - queryPhoneTableBasedOnE164(CP2_INFO_PROJECTION, partitionedNumbers.validE164Numbers())) { - if (cursor == null) { - LogUtil.w("Cp2PhoneLookup.buildMapForUpdatedOrAddedContacts", "null cursor"); - } else { - while (cursor.moveToNext()) { - String e164Number = cursor.getString(CP2_INFO_NORMALIZED_NUMBER_INDEX); - Set dialerPhoneNumbers = - partitionedNumbers.dialerPhoneNumbersForE164(e164Number); - Cp2ContactInfo info = buildCp2ContactInfoFromPhoneCursor(appContext, cursor); - addInfo(map, dialerPhoneNumbers, info); - - // We are going to remove the numbers that we've handled so that we later can detect - // numbers that weren't handled and therefore need to have their contact information - // removed. - updatedNumbers.removeAll(dialerPhoneNumbers); + private ListenableFuture> individualQueryForInvalidNumber( + String invalidNumber) { + return backgroundExecutorService.submit( + () -> { + Set cp2ContactInfos = new ArraySet<>(); + if (invalidNumber.isEmpty()) { + return cp2ContactInfos; } - } - } - } - if (!partitionedNumbers.unformattableNumbers().isEmpty()) { - try (Cursor cursor = - queryPhoneTableBasedOnRawNumber( - CP2_INFO_PROJECTION, partitionedNumbers.unformattableNumbers())) { - if (cursor == null) { - LogUtil.w("Cp2PhoneLookup.buildMapForUpdatedOrAddedContacts", "null cursor"); - } else { - while (cursor.moveToNext()) { - String unformattableNumber = cursor.getString(CP2_INFO_NUMBER_INDEX); - Set dialerPhoneNumbers = - partitionedNumbers.dialerPhoneNumbersForUnformattable(unformattableNumber); - Cp2ContactInfo info = buildCp2ContactInfoFromPhoneCursor(appContext, cursor); - addInfo(map, dialerPhoneNumbers, info); - - // We are going to remove the numbers that we've handled so that we later can detect - // numbers that weren't handled and therefore need to have their contact information - // removed. - updatedNumbers.removeAll(dialerPhoneNumbers); + try (Cursor cursor = queryPhoneLookup(PHONE_LOOKUP_PROJECTION, invalidNumber)) { + if (cursor == null) { + LogUtil.w("Cp2PhoneLookup.individualQueryForInvalidNumber", "null cursor"); + } else { + while (cursor.moveToNext()) { + cp2ContactInfos.add(buildCp2ContactInfoFromPhoneCursor(appContext, cursor)); + } + } } - } - } - } - // The leftovers in updatedNumbers that weren't removed are numbers that were previously - // associated with contacts, but are no longer. Remove the contact information for them. - for (DialerPhoneNumber dialerPhoneNumber : updatedNumbers) { - map.put(dialerPhoneNumber, ImmutableSet.of()); - } - return map; + return cp2ContactInfos; + }); } /** @@ -540,15 +773,14 @@ public final class Cp2PhoneLookup implements PhoneLookup { private static void addInfo( Map> map, Set dialerPhoneNumbers, - Cp2ContactInfo cp2ContactInfo) { + Set cp2ContactInfos) { for (DialerPhoneNumber dialerPhoneNumber : dialerPhoneNumbers) { - if (map.containsKey(dialerPhoneNumber)) { - map.get(dialerPhoneNumber).add(cp2ContactInfo); - } else { - Set cp2ContactInfos = new ArraySet<>(); - cp2ContactInfos.add(cp2ContactInfo); - map.put(dialerPhoneNumber, cp2ContactInfos); + Set existingInfos = map.get(dialerPhoneNumber); + if (existingInfos == null) { + existingInfos = new ArraySet<>(); + map.put(dialerPhoneNumber, existingInfos); } + existingInfos.addAll(cp2ContactInfos); } } @@ -563,20 +795,15 @@ public final class Cp2PhoneLookup implements PhoneLookup { null); } - private Cursor queryPhoneTableBasedOnRawNumber( - String[] projection, Set unformattableNumbers) { - return appContext - .getContentResolver() - .query( - Phone.CONTENT_URI, - projection, - Phone.NUMBER + " IN (" + questionMarks(unformattableNumbers.size()) + ")", - unformattableNumbers.toArray(new String[unformattableNumbers.size()]), - null); + private Cursor queryPhoneLookup(String[] projection, String rawNumber) { + Uri uri = + Uri.withAppendedPath( + ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(rawNumber)); + return appContext.getContentResolver().query(uri, projection, null, null, null); } /** - * @param cursor with projection {@link #CP2_INFO_PROJECTION}. + * @param cursor with projection {@link #PHONE_PROJECTION}. * @return new {@link Cp2ContactInfo} based on current row of {@code cursor}. */ private static Cp2ContactInfo buildCp2ContactInfoFromPhoneCursor( @@ -613,17 +840,21 @@ public final class Cp2PhoneLookup implements PhoneLookup { } /** Returns set of DialerPhoneNumbers that were associated with now deleted contacts. */ - private Set getDeletedPhoneNumbers( + private ListenableFuture> getDeletedPhoneNumbers( ImmutableMap existingInfoMap, long lastModified) { - // Build set of all contact IDs from our existing data. We're going to use this set to query - // against the DeletedContacts table and see if any of them were deleted. - Set contactIds = findContactIdsIn(existingInfoMap); - - // Start building a set of DialerPhoneNumbers that were associated with now deleted contacts. - try (Cursor cursor = queryDeletedContacts(contactIds, lastModified)) { - // We now have a cursor/list of contact IDs that were associated with deleted contacts. - return findDeletedPhoneNumbersIn(existingInfoMap, cursor); - } + return backgroundExecutorService.submit( + () -> { + // Build set of all contact IDs from our existing data. We're going to use this set to + // query against the DeletedContacts table and see if any of them were deleted. + Set contactIds = findContactIdsIn(existingInfoMap); + + // Start building a set of DialerPhoneNumbers that were associated with now deleted + // contacts. + try (Cursor cursor = queryDeletedContacts(contactIds, lastModified)) { + // We now have a cursor/list of contact IDs that were associated with deleted contacts. + return findDeletedPhoneNumbersIn(existingInfoMap, cursor); + } + }); } private Set findContactIdsIn(ImmutableMap map) { @@ -683,7 +914,7 @@ public final class Cp2PhoneLookup implements PhoneLookup { } private static Set findDialerPhoneNumbersContainingContactId( - ImmutableMap existingInfoMap, long contactId) { + Map existingInfoMap, long contactId) { Set matches = new ArraySet<>(); for (Entry entry : existingInfoMap.entrySet()) { for (Cp2ContactInfo cp2ContactInfo : entry.getValue().getCp2ContactInfoList()) { diff --git a/java/com/android/dialer/phonelookup/phone_lookup_info.proto b/java/com/android/dialer/phonelookup/phone_lookup_info.proto index 75423b9ee..6662646aa 100644 --- a/java/com/android/dialer/phonelookup/phone_lookup_info.proto +++ b/java/com/android/dialer/phonelookup/phone_lookup_info.proto @@ -43,6 +43,12 @@ message PhoneLookupInfo { // // Empty if there is no CP2 contact information for the number. repeated Cp2ContactInfo cp2_contact_info = 1; + + // The information for this number is incomplete. This can happen when the + // call log is requested to be updated but there are many invalid numbers + // and the update cannot be performed efficiently. In this case, the call + // log needs to query for the CP2 information at render time. + optional bool is_incomplete = 2; } optional Cp2Info cp2_info = 1; diff --git a/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java b/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java index d23b5a19d..8cb4557cb 100644 --- a/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java +++ b/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java @@ -20,6 +20,7 @@ import android.support.annotation.AnyThread; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; +import android.telephony.PhoneNumberUtils; import com.android.dialer.DialerInternalPhoneNumber; import com.android.dialer.DialerPhoneNumber; import com.android.dialer.DialerPhoneNumber.RawInput; @@ -128,29 +129,38 @@ public class DialerPhoneNumberUtil { } /** - * Formats the provided number to e164 format or return raw number if number is unparseable. + * Formats the provided number to E164 format or return a normalized version of the raw number if + * the number is not valid according to {@link PhoneNumberUtil#isValidNumber(PhoneNumber)}. * - * @see PhoneNumberUtil#format(PhoneNumber, PhoneNumberFormat) + * @see #formatToE164(DialerPhoneNumber) + * @see PhoneNumberUtils#normalizeNumber(String) */ @WorkerThread public String normalizeNumber(DialerPhoneNumber number) { Assert.isWorkerThread(); - return formatToE164(number).or(number.getRawInput().getNumber()); + return formatToE164(number) + .or(PhoneNumberUtils.normalizeNumber(number.getRawInput().getNumber())); } /** - * Formats the provided number to e164 format if possible. + * If the provided number is "valid" (see {@link PhoneNumberUtil#isValidNumber(PhoneNumber)}), + * formats it to E.164. Otherwise, returns {@link Optional#absent()}. + * + *

    This method is analogous to {@link PhoneNumberUtils#formatNumberToE164(String, String)} (but + * works with an already parsed {@link DialerPhoneNumber} object). * + * @see PhoneNumberUtil#isValidNumber(PhoneNumber) * @see PhoneNumberUtil#format(PhoneNumber, PhoneNumberFormat) + * @see PhoneNumberUtils#formatNumberToE164(String, String) */ @WorkerThread public Optional formatToE164(DialerPhoneNumber number) { Assert.isWorkerThread(); if (number.hasDialerInternalPhoneNumber()) { - return Optional.of( - phoneNumberUtil.format( - Converter.protoToPojo(number.getDialerInternalPhoneNumber()), - PhoneNumberFormat.E164)); + PhoneNumber phoneNumber = Converter.protoToPojo(number.getDialerInternalPhoneNumber()); + if (phoneNumberUtil.isValidNumber(phoneNumber)) { + return Optional.fromNullable(phoneNumberUtil.format(phoneNumber, PhoneNumberFormat.E164)); + } } return Optional.absent(); } -- cgit v1.2.3 From d886c96011340fb05d73b806ce2745d8049d81ca Mon Sep 17 00:00:00 2001 From: Android Dialer Date: Mon, 8 Jan 2018 15:54:26 -0800 Subject: Updating Dialer v16 licenses. Bug: 71713599 Test: 'N/A' PiperOrigin-RevId: 181231841 Change-Id: I810699487db763f9afebabff9ae55e9767afd9fa --- .../about/res/raw/third_party_license_metadata | 19 +- .../dialer/about/res/raw/third_party_licenses | 2308 ++++++++++++-------- 2 files changed, 1374 insertions(+), 953 deletions(-) diff --git a/java/com/android/dialer/about/res/raw/third_party_license_metadata b/java/com/android/dialer/about/res/raw/third_party_license_metadata index 49c22731f..73b34437a 100755 --- a/java/com/android/dialer/about/res/raw/third_party_license_metadata +++ b/java/com/android/dialer/about/res/raw/third_party_license_metadata @@ -31,12 +31,13 @@ 332972:11358 Volley 344341:10695 bubble 355050:11358 gRPC Java -366427:10173 libphonenumber -376619:10699 shortcutbadger -387334:16013 Android SDK -403366:1096 Animal Sniffer -404472:4771 Glide -409255:1602 JSR 305 -410875:12847 jibercsclient -423733:18982 mime4j -442732:12847 rcsclientlib +366426:12847 jibercsclient +379292:10173 libphonenumber +389476:18982 mime4j +408475:12847 rcsclientlib +421341:10699 shortcutbadger +432056:16013 Android SDK +448079:4771 Glide +452869:1096 Animal Sniffer +453987:22655 Checker Framework +476654:1602 JSR 305 diff --git a/java/com/android/dialer/about/res/raw/third_party_licenses b/java/com/android/dialer/about/res/raw/third_party_licenses index 64f7dc780..8fb021a87 100755 --- a/java/com/android/dialer/about/res/raw/third_party_licenses +++ b/java/com/android/dialer/about/res/raw/third_party_licenses @@ -6625,7 +6625,32 @@ gRPC Java: limitations under the License. -libphonenumber: +jibercsclient: + +These components + com.google.android.rcs.core, + com.google.android.rcs.core.utils.CaseInsensitiveMap, + com.google.android.rcs.core.utils.DateTime, + com.google.android.rcs.core.utils.InetAddresses, + com.google.android.rcs.core.network.ConnectivityMonitor, + com.google.android.rcs.client.PrivateDataStorage, + com.google.android.rcs.client.utils.FastXmlSerializer, + com.google.android.rcs.client.utils.XmlUtils, + com.google.android.rcs.client.utils.QueuedWork +are licensed under Apache v2. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + Apache License Version 2.0, January 2004 @@ -6804,22 +6829,43 @@ libphonenumber: END OF TERMS AND CONDITIONS +=============================================================================== -shortcutbadger: +These components + com.google.android.rcs.core.utils.FastBase64, + com.google.android.rcs.core.utils.LibraryLoaderHelper +are licensed under BSD. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: - http://www.apache.org/licenses/LICENSE-2.0 + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +libphonenumber: + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -6998,447 +7044,611 @@ limitations under the License. END OF TERMS AND CONDITIONS -Android SDK: - -ANDROID SOFTWARE DEVELOPMENT KIT +mime4j: -Terms and Conditions + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -This is the Android Software Development Kit License Agreement. + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION -1. Introduction + 1. Definitions. -1.1 The Android Software Development Kit (referred to in this License Agreement as the "SDK" and -specifically including the Android system files, packaged APIs, and Google APIs add-ons) is -licensed to you subject to the terms of this License Agreement. This License Agreement forms a -legally binding contract between you and Google in relation to your use of the SDK. + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. -1.2 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600 -Amphitheatre Parkway, Mountain View, CA 94043, United States. + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. -2. Accepting this License Agreement + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. -2.1 In order to use the SDK, you must first agree to this License Agreement. You may not use the -SDK if you do not accept this License Agreement. + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. -2.2 You can accept this License Agreement by: + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. -(A) clicking to accept or agree to this License Agreement, where this option is made available to -you; or + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. -(B) by actually using the SDK. In this case, you agree that use of the SDK constitutes acceptance of -the Licensing Agreement from that point onwards. + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). -2.3 You may not use the SDK and may not accept the Licensing Agreement if you are a person barred -from receiving the SDK under the laws of the United States or other countries including the country -in which you are resident or from which you use the SDK. + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. -2.4 If you are agreeing to be bound by this License Agreement on behalf of your employer or other -entity, you represent and warrant that you have full legal authority to bind your employer or such -entity to this License Agreement. If you do not have the requisite authority, you may not accept -the Licensing Agreement or use the SDK on behalf of your employer or other entity. + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." -3. SDK License from Google + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. -3.1 Subject to the terms of this License Agreement, Google grants you a limited, worldwide, -royalty-free, non- assignable and non-exclusive license to use the SDK solely to develop -applications to run on the Android platform. + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. -3.2 You agree that Google or third parties own all legal right, title and interest in and to the -SDK, including any Intellectual Property Rights that subsist in the SDK. "Intellectual Property -Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law, -and any and all other proprietary rights. Google reserves all rights not expressly granted to you. + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. -3.3 Except to the extent required by applicable third party licenses, you may not copy (except for -backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create -derivative works of the SDK or any part of the SDK. Except to the extent required by applicable -third party licenses, you may not load any part of the SDK onto a mobile handset or any other -hardware device except a personal computer, combine any part of the SDK with other software, or -distribute any software or device incorporating a part of the SDK. + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: -3.4 Use, reproduction and distribution of components of the SDK licensed under an open source -software license are governed solely by the terms of that open source software license and not -this License Agreement. + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and -3.5 You agree that the form and nature of the SDK that Google provides may change without prior -notice to you and that future versions of the SDK may be incompatible with applications developed -on previous versions of the SDK. You agree that Google may stop (permanently or temporarily) -providing the SDK (or any features within the SDK) to you or to users generally at Google's sole -discretion, without prior notice to you. + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and -3.6 Nothing in this License Agreement gives you a right to use any of Google's trade names, -trademarks, service marks, logos, domain names, or other distinctive brand features. + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and -3.7 You agree that you will not remove, obscure, or alter any proprietary rights notices (including -copyright and trademark notices) that may be affixed to or contained within the SDK. + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. -4. Use of the SDK by You + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. -4.1 Google agrees that it obtains no right, title or interest from you (or your licensors) under -this License Agreement in or to any software applications that you develop using the SDK, including -any intellectual property rights that subsist in those applications. + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. -4.2 You agree to use the SDK and write applications only for purposes that are permitted by (a) this -License Agreement and (b) any applicable law, regulation or generally accepted practices or -guidelines in the relevant jurisdictions (including any laws regarding the export of data or -software to and from the United States or other relevant countries). + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. -4.3 You agree that if you use the SDK to develop applications for general public users, you will -protect the privacy and legal rights of those users. If the users provide you with user names, -passwords, or other login information or personal information, your must make the users aware that -the information will be available to your application, and you must provide legally adequate privacy -notice and protection for those users. If your application stores personal or sensitive information -provided by users, it must do so securely. If the user provides your application with Google Account -information, your application may only use that information to access the user's Google Account -when, and for the limited purposes for which, the user has given you permission to do so. - -4.4 You agree that you will not engage in any activity with the SDK, including the development or -distribution of an application, that interferes with, disrupts, damages, or accesses in an -unauthorized manner the servers, networks, or other properties or services of any third party -including, but not limited to, Google or any mobile communications carrier. - -4.5 You agree that you are solely responsible for (and that Google has no responsibility to you or -to any third party for) any data, content, or resources that you create, transmit or display through -the Android platform and/or applications for the Android platform, and for the consequences of your -actions (including any loss or damage which Google may suffer) by doing so. - -4.6 You agree that you are solely responsible for (and that Google has no responsibility to you or -to any third party for) any breach of your obligations under this License Agreement, any applicable -third party contract or Terms of Service, or any applicable law or regulation, and for the -consequences (including any loss or damage which Google or any third party may suffer) of any such -breach. - -5. Your Developer Credentials - -5.1 You agree that you are responsible for maintaining the confidentiality of any developer -credentials that may be issued to you by Google or which you may choose yourself and that you will -be solely responsible for all applications that are developed under your developer credentials. - -6. Privacy and Information - -6.1 In order to continually innovate and improve the SDK, Google may collect certain usage -statistics from the software including but not limited to a unique identifier, associated IP -address, version number of the software, and information on which tools and/or services in the SDK -are being used and how they are being used. Before any of this information is collected, the SDK -will notify you and seek your consent. If you withhold consent, the information will not be -collected. - -6.2 The data collected is examined in the aggregate to improve the SDK and is maintained in -accordance with Google's Privacy Policy. - -7. Third Party Applications for the Android Platform - -7.1 If you use the SDK to run applications developed by a third party or that access data, content -or resources provided by a third party, you agree that Google is not responsible for those -applications, data, content, or resources. You understand that all data, content or resources which -you may access through such third party applications are the sole responsibility of the person from -which they originated and that Google is not liable for any loss or damage that you may experience -as a result of the use or access of any of those third party applications, data, content, or -resources. - -7.2 You should be aware the data, content, and resources presented to you through such a third party -application may be protected by intellectual property rights which are owned by the providers (or by -other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute -or create derivative works based on these data, content, or resources (either in whole or in part) -unless you have been specifically given permission to do so by the relevant owners. - -7.3 You acknowledge that your use of such third party applications, data, content, or resources may -be subject to separate terms between you and the relevant third party. In that case, this License -Agreement does not affect your legal relationship with these third parties. - -8. Using Android APIs - -8.1 Google Data APIs - -8.1.1 If you use any API to retrieve data from Google, you acknowledge that the data may be -protected by intellectual property rights which are owned by Google or those parties that provide -the data (or by other persons or companies on their behalf). Your use of any such API may be subject -to additional Terms of Service. You may not modify, rent, lease, loan, sell, distribute or create -derivative works based on this data (either in whole or in part) unless allowed by the relevant -Terms of Service. - -8.1.2 If you use any API to retrieve a user's data from Google, you acknowledge and agree that you -shall retrieve data only with the user's explicit consent and only when, and for the limited -purposes for which, the user has given you permission to do so. - -9. Terminating this License Agreement - -9.1 This License Agreement will continue to apply until terminated by either you or Google as set -out below. - -9.2 If you want to terminate this License Agreement, you may do so by ceasing your use of the SDK -and any relevant developer credentials. - -9.3 Google may at any time, terminate this License Agreement with you if: - -(A) you have breached any provision of this License Agreement; or - -(B) Google is required to do so by law; or - -(C) the partner with whom Google offered certain parts of SDK (such as APIs) to you has terminated -its relationship with Google or ceased to offer certain parts of the SDK to you; or - -(D) Google decides to no longer providing the SDK or certain parts of the SDK to users in the -country in which you are resident or from which you use the service, or the provision of the SDK or -certain SDK services to you by Google is, in Google's sole discretion, no longer commercially -viable. - -9.4 When this License Agreement comes to an end, all of the legal rights, obligations and -liabilities that you and Google have benefited from, been subject to (or which have accrued over -time whilst this License Agreement has been in force) or which are expressed to continue -indefinitely, shall be unaffected by this cessation, and the provisions of paragraph 14.7 shall -continue to apply to such rights, obligations and liabilities indefinitely. - -10. DISCLAIMER OF WARRANTIES - -10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SDK IS AT YOUR SOLE RISK AND THAT THE -SDK IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM GOOGLE. - -10.2 YOUR USE OF THE SDK AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE -SDK IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR -COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE. - -10.3 GOOGLE FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - -11. LIMITATION OF LIABILITY - -11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT GOOGLE, ITS SUBSIDIARIES AND AFFILIATES, AND ITS -LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY -LOSS OF DATA, WHETHER OR NOT GOOGLE OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN -AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING. - -12. Indemnification - -12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless -Google, its affiliates and their respective directors, officers, employees and agents from and -against any and all claims, actions, suits or proceedings, as well as any and all losses, -liabilities, damages, costs and expenses (including reasonable attorneys fees) arising out of or -accruing from (a) your use of the SDK, (b) any application you develop on the SDK that infringes any -copyright, trademark, trade secret, trade dress, patent or other intellectual property right of any -person or defames any person or violates their rights of publicity or privacy, and (c) any -non-compliance by you with this License Agreement. - -13. Changes to the License Agreement - -13.1 Google may make changes to the License Agreement as it distributes new versions of the SDK. -When these changes are made, Google will make a new version of the License Agreement available on -the website where the SDK is made available. - -14. General Legal Terms - -14.1 This License Agreement constitute the whole legal agreement between you and Google and govern -your use of the SDK (excluding any services which Google may provide to you under a separate written -agreement), and completely replace any prior agreements between you and Google in relation to the -SDK. + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. -14.2 You agree that if Google does not exercise or enforce any legal right or remedy which is -contained in this License Agreement (or which Google has the benefit of under any applicable law), -this will not be taken to be a formal waiver of Google's rights and that those rights or remedies -will still be available to Google. + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. -14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision -of this License Agreement is invalid, then that provision will be removed from this License -Agreement without affecting the rest of this License Agreement. The remaining provisions of this -License Agreement will continue to be valid and enforceable. + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. -14.4 You acknowledge and agree that each member of the group of companies of which Google is the -parent shall be third party beneficiaries to this License Agreement and that such other companies -shall be entitled to directly enforce, and rely upon, any provision of this License Agreement that -confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall -be third party beneficiaries to this License Agreement. + END OF TERMS AND CONDITIONS + + + -14.5 EXPORT RESTRICTIONS. THE SDK IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST -COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE SDK. THESE -LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END USE. + THIS PRODUCT ALSO INCLUDES THIRD PARTY SOFTWARE REDISTRIBUTED UNDER THE + FOLLOWING LICENSES: -14.6 The rights granted in this License Agreement may not be assigned or transferred by either you -or Google without the prior written approval of the other party. Neither you nor Google shall be -permitted to delegate their responsibilities or obligations under this License Agreement without the -prior written approval of the other party. + Apache Commons Logging, + The Apache Software License, Version 1.1 (commons-logging-1.1.1.jar) + + The Apache Software License, Version 1.1 + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + 3. The end-user documentation included with the redistribution, + if any, must include the following acknowledgment: + "This product includes software developed by the + Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, + if and wherever such third-party acknowledgments normally appear. + + 4. The names "Apache" and "Apache Software Foundation" must + not be used to endorse or promote products derived from this + software without prior written permission. For written + permission, please contact apache@apache.org. + + 5. Products derived from this software may not be called "Apache", + nor may "Apache" appear in their name, without prior written + permission of the Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + -14.7 This License Agreement, and your relationship with Google under this License Agreement, shall -be governed by the laws of the State of California without regard to its conflict of laws -provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located -within the county of Santa Clara, California to resolve any legal matter arising from this License -Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for -injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction. + Test messages from the Perl-MIME-Tools project, + + The "Artistic License" + + Preamble + + The intent of this document is to state the conditions under which a + Package may be copied, such that the Copyright Holder maintains some + semblance of artistic control over the development of the package, + while giving the users of the package the right to use and distribute + the Package in a more-or-less customary fashion, plus the right to make + reasonable modifications. + + Definitions: + + "Package" refers to the collection of files distributed by the + Copyright Holder, and derivatives of that collection of files + created through textual modification. + + "Standard Version" refers to such a Package if it has not been + modified, or has been modified in accordance with the wishes + of the Copyright Holder as specified below. + + "Copyright Holder" is whoever is named in the copyright or + copyrights for the package. + + "You" is you, if you're thinking about copying or distributing + this Package. + + "Reasonable copying fee" is whatever you can justify on the + basis of media cost, duplication charges, time of people involved, + and so on. (You will not be required to justify it to the + Copyright Holder, but only to the computing community at large + as a market that must bear the fee.) + + "Freely Available" means that no fee is charged for the item + itself, though there may be fees involved in handling the item. + It also means that recipients of the item may redistribute it + under the same conditions they received it. + + 1. You may make and give away verbatim copies of the source form of the + Standard Version of this Package without restriction, provided that you + duplicate all of the original copyright notices and associated disclaimers. + + 2. You may apply bug fixes, portability fixes and other modifications + derived from the Public Domain or from the Copyright Holder. A Package + modified in such a way shall still be considered the Standard Version. + + 3. You may otherwise modify your copy of this Package in any way, provided + that you insert a prominent notice in each changed file stating how and + when you changed that file, and provided that you do at least ONE of the + following: + + a) place your modifications in the Public Domain or otherwise make them + Freely Available, such as by posting said modifications to Usenet or + an equivalent medium, or placing the modifications on a major archive + site such as uunet.uu.net, or by allowing the Copyright Holder to include + your modifications in the Standard Version of the Package. + + b) use the modified Package only within your corporation or organization. + + c) rename any non-standard executables so the names do not conflict + with standard executables, which must also be provided, and provide + a separate manual page for each non-standard executable that clearly + documents how it differs from the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + + 4. You may distribute the programs of this Package in object code or + executable form, provided that you do at least ONE of the following: + + a) distribute a Standard Version of the executables and library files, + together with instructions (in the manual page or equivalent) on where + to get the Standard Version. + + b) accompany the distribution with the machine-readable source of + the Package with your modifications. + + c) give non-standard executables non-standard names, and clearly + document the differences in manual pages (or equivalent), together + with instructions on where to get the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + + 5. You may charge a reasonable copying fee for any distribution of this + Package. You may charge any fee you choose for support of this + Package. You may not charge a fee for this Package itself. However, + you may distribute this Package in aggregate with other (possibly + commercial) programs as part of a larger (possibly commercial) software + distribution provided that you do not advertise this Package as a + product of your own. You may embed this Package's interpreter within + an executable of yours (by linking); this shall be construed as a mere + form of aggregation, provided that the complete Standard Version of the + interpreter is so embedded. + + 6. The scripts and library files supplied as input to or produced as + output from the programs of this Package do not automatically fall + under the copyright of this Package, but belong to whoever generated + them, and may be sold commercially, and may be aggregated with this + Package. If such scripts or library files are aggregated with this + Package via the so-called "undump" or "unexec" methods of producing a + binary executable image, then distribution of such an image shall + neither be construed as a distribution of this Package nor shall it + fall under the restrictions of Paragraphs 3 and 4, provided that you do + not represent such an executable image as a Standard Version of this + Package. + + 7. C subroutines (or comparably compiled subroutines in other + languages) supplied by you and linked into this Package in order to + emulate subroutines and variables of the language defined by this + Package shall not be considered part of this Package, but are the + equivalent of input as in Paragraph 6, provided these subroutines do + not change the language in any way that would cause it to fail the + regression tests for the language. + + 8. Aggregation of this Package with a commercial distribution is always + permitted provided that the use of this Package is embedded; that is, + when no overt attempt is made to make this Package's interfaces visible + to the end user of the commercial distribution. Such use shall not be + construed as a distribution of this Package. + + 9. The name of the Copyright Holder may not be used to endorse or promote + products derived from this software without specific prior written permission. + + 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + The End -April 10, 2009 + + +rcsclientlib: -Animal Sniffer: +These components + com.google.android.rcs.core, + com.google.android.rcs.core.utils.CaseInsensitiveMap, + com.google.android.rcs.core.utils.DateTime, + com.google.android.rcs.core.utils.InetAddresses, + com.google.android.rcs.core.network.ConnectivityMonitor, + com.google.android.rcs.client.PrivateDataStorage, + com.google.android.rcs.client.utils.FastXmlSerializer, + com.google.android.rcs.client.utils.XmlUtils, + com.google.android.rcs.client.utils.QueuedWork +are licensed under Apache v2. -The MIT License +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at -Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. + http://www.apache.org/licenses/LICENSE-2.0 -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION -Glide: + 1. Definitions. -Covers library/ + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. -Copyright 2014 Google, Inc. All rights reserved. + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. -Redistribution and use in source and binary forms, with or without modification, are -permitted provided that the following conditions are met: + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. - 1. Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. - 2. Redistributions in binary form must reproduce the above copyright notice, this list - of conditions and the following disclaimer in the documentation and/or other materials - provided with the distribution. + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. -THIS SOFTWARE IS PROVIDED BY GOOGLE, INC. ``AS IS'' AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE, INC. OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. -The views and conclusions contained in the software and documentation are those of the -authors and should not be interpreted as representing official policies, either expressed -or implied, of Google, Inc. + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). --------------------------------------------------------------------------- -Covers third_party/gif_decoder + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. -Copyright (c) 2013 Xcellent Creations, Inc. + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. --------------------------------------------------------------------------- -Covers third_party/disklrucache + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: -Copyright 2012 Jake Wharton -Copyright 2011 The Android Open Source Project + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and - http://www.apache.org/licenses/LICENSE-2.0 + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. --------------------------------------------------------------------------- -Covers third_party/gif_encoder/AnimatedGifEncoder.java and -third_party/gif_encoder/LZWEncoder.java: + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. -No copyright asserted on the source code of this class. May be used for any -purpose, however, refer to the Unisys LZW patent for restrictions on use of -the associated LZWEncoder class. Please forward any corrections to -kweiner@fmsware.com. + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. ------------------------------------------------------------------------------ -Covers third_party/gif_encoder/NeuQuant.java + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. -Copyright (c) 1994 Anthony Dekker + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. -NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See -"Kohonen neural networks for optimal colour quantization" in "Network: -Computation in Neural Systems" Vol. 5 (1994) pp 351-367. for a discussion of -the algorithm. + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. -Any party obtaining a copy of these files from the author, directly or -indirectly, is granted, free of charge, a full and unrestricted irrevocable, -world-wide, paid up, royalty-free, nonexclusive right and license to deal in -this software and documentation files (the "Software"), including without -limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons who -receive copies from any such party to do so, with the only requirement being -that this copyright notice remain intact. + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. -JSR 305: + END OF TERMS AND CONDITIONS -Copyright (c) 2007-2009, JSR305 expert group -All rights reserved. +=============================================================================== -http://www.opensource.org/licenses/bsd-license.php +These components + com.google.android.rcs.core.utils.FastBase64, + com.google.android.rcs.core.utils.LibraryLoaderHelper +are licensed under BSD. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the JSR305 expert group nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -jibercsclient: -These components - com.google.android.rcs.core, - com.google.android.rcs.core.utils.CaseInsensitiveMap, - com.google.android.rcs.core.utils.DateTime, - com.google.android.rcs.core.utils.InetAddresses, - com.google.android.rcs.core.network.ConnectivityMonitor, - com.google.android.rcs.client.PrivateDataStorage, - com.google.android.rcs.client.utils.FastXmlSerializer, - com.google.android.rcs.client.utils.XmlUtils, - com.google.android.rcs.client.utils.QueuedWork -are licensed under Apache v2. +shortcutbadger: Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -7617,653 +7827,863 @@ limitations under the License. other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + +Android SDK: + +ANDROID SOFTWARE DEVELOPMENT KIT + +Terms and Conditions + +This is the Android Software Development Kit License Agreement. + +1. Introduction + +1.1 The Android Software Development Kit (referred to in this License Agreement as the "SDK" and +specifically including the Android system files, packaged APIs, and Google APIs add-ons) is +licensed to you subject to the terms of this License Agreement. This License Agreement forms a +legally binding contract between you and Google in relation to your use of the SDK. + +1.2 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600 +Amphitheatre Parkway, Mountain View, CA 94043, United States. + +2. Accepting this License Agreement + +2.1 In order to use the SDK, you must first agree to this License Agreement. You may not use the +SDK if you do not accept this License Agreement. + +2.2 You can accept this License Agreement by: + +(A) clicking to accept or agree to this License Agreement, where this option is made available to +you; or + +(B) by actually using the SDK. In this case, you agree that use of the SDK constitutes acceptance of +the Licensing Agreement from that point onwards. + +2.3 You may not use the SDK and may not accept the Licensing Agreement if you are a person barred +from receiving the SDK under the laws of the United States or other countries including the country +in which you are resident or from which you use the SDK. + +2.4 If you are agreeing to be bound by this License Agreement on behalf of your employer or other +entity, you represent and warrant that you have full legal authority to bind your employer or such +entity to this License Agreement. If you do not have the requisite authority, you may not accept +the Licensing Agreement or use the SDK on behalf of your employer or other entity. + +3. SDK License from Google + +3.1 Subject to the terms of this License Agreement, Google grants you a limited, worldwide, +royalty-free, non- assignable and non-exclusive license to use the SDK solely to develop +applications to run on the Android platform. + +3.2 You agree that Google or third parties own all legal right, title and interest in and to the +SDK, including any Intellectual Property Rights that subsist in the SDK. "Intellectual Property +Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law, +and any and all other proprietary rights. Google reserves all rights not expressly granted to you. + +3.3 Except to the extent required by applicable third party licenses, you may not copy (except for +backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create +derivative works of the SDK or any part of the SDK. Except to the extent required by applicable +third party licenses, you may not load any part of the SDK onto a mobile handset or any other +hardware device except a personal computer, combine any part of the SDK with other software, or +distribute any software or device incorporating a part of the SDK. + +3.4 Use, reproduction and distribution of components of the SDK licensed under an open source +software license are governed solely by the terms of that open source software license and not +this License Agreement. + +3.5 You agree that the form and nature of the SDK that Google provides may change without prior +notice to you and that future versions of the SDK may be incompatible with applications developed +on previous versions of the SDK. You agree that Google may stop (permanently or temporarily) +providing the SDK (or any features within the SDK) to you or to users generally at Google's sole +discretion, without prior notice to you. + +3.6 Nothing in this License Agreement gives you a right to use any of Google's trade names, +trademarks, service marks, logos, domain names, or other distinctive brand features. + +3.7 You agree that you will not remove, obscure, or alter any proprietary rights notices (including +copyright and trademark notices) that may be affixed to or contained within the SDK. + +4. Use of the SDK by You + +4.1 Google agrees that it obtains no right, title or interest from you (or your licensors) under +this License Agreement in or to any software applications that you develop using the SDK, including +any intellectual property rights that subsist in those applications. + +4.2 You agree to use the SDK and write applications only for purposes that are permitted by (a) this +License Agreement and (b) any applicable law, regulation or generally accepted practices or +guidelines in the relevant jurisdictions (including any laws regarding the export of data or +software to and from the United States or other relevant countries). + +4.3 You agree that if you use the SDK to develop applications for general public users, you will +protect the privacy and legal rights of those users. If the users provide you with user names, +passwords, or other login information or personal information, your must make the users aware that +the information will be available to your application, and you must provide legally adequate privacy +notice and protection for those users. If your application stores personal or sensitive information +provided by users, it must do so securely. If the user provides your application with Google Account +information, your application may only use that information to access the user's Google Account +when, and for the limited purposes for which, the user has given you permission to do so. + +4.4 You agree that you will not engage in any activity with the SDK, including the development or +distribution of an application, that interferes with, disrupts, damages, or accesses in an +unauthorized manner the servers, networks, or other properties or services of any third party +including, but not limited to, Google or any mobile communications carrier. + +4.5 You agree that you are solely responsible for (and that Google has no responsibility to you or +to any third party for) any data, content, or resources that you create, transmit or display through +the Android platform and/or applications for the Android platform, and for the consequences of your +actions (including any loss or damage which Google may suffer) by doing so. + +4.6 You agree that you are solely responsible for (and that Google has no responsibility to you or +to any third party for) any breach of your obligations under this License Agreement, any applicable +third party contract or Terms of Service, or any applicable law or regulation, and for the +consequences (including any loss or damage which Google or any third party may suffer) of any such +breach. + +5. Your Developer Credentials + +5.1 You agree that you are responsible for maintaining the confidentiality of any developer +credentials that may be issued to you by Google or which you may choose yourself and that you will +be solely responsible for all applications that are developed under your developer credentials. + +6. Privacy and Information + +6.1 In order to continually innovate and improve the SDK, Google may collect certain usage +statistics from the software including but not limited to a unique identifier, associated IP +address, version number of the software, and information on which tools and/or services in the SDK +are being used and how they are being used. Before any of this information is collected, the SDK +will notify you and seek your consent. If you withhold consent, the information will not be +collected. + +6.2 The data collected is examined in the aggregate to improve the SDK and is maintained in +accordance with Google's Privacy Policy. + +7. Third Party Applications for the Android Platform + +7.1 If you use the SDK to run applications developed by a third party or that access data, content +or resources provided by a third party, you agree that Google is not responsible for those +applications, data, content, or resources. You understand that all data, content or resources which +you may access through such third party applications are the sole responsibility of the person from +which they originated and that Google is not liable for any loss or damage that you may experience +as a result of the use or access of any of those third party applications, data, content, or +resources. + +7.2 You should be aware the data, content, and resources presented to you through such a third party +application may be protected by intellectual property rights which are owned by the providers (or by +other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute +or create derivative works based on these data, content, or resources (either in whole or in part) +unless you have been specifically given permission to do so by the relevant owners. + +7.3 You acknowledge that your use of such third party applications, data, content, or resources may +be subject to separate terms between you and the relevant third party. In that case, this License +Agreement does not affect your legal relationship with these third parties. + +8. Using Android APIs + +8.1 Google Data APIs + +8.1.1 If you use any API to retrieve data from Google, you acknowledge that the data may be +protected by intellectual property rights which are owned by Google or those parties that provide +the data (or by other persons or companies on their behalf). Your use of any such API may be subject +to additional Terms of Service. You may not modify, rent, lease, loan, sell, distribute or create +derivative works based on this data (either in whole or in part) unless allowed by the relevant +Terms of Service. + +8.1.2 If you use any API to retrieve a user's data from Google, you acknowledge and agree that you +shall retrieve data only with the user's explicit consent and only when, and for the limited +purposes for which, the user has given you permission to do so. + +9. Terminating this License Agreement + +9.1 This License Agreement will continue to apply until terminated by either you or Google as set +out below. - END OF TERMS AND CONDITIONS +9.2 If you want to terminate this License Agreement, you may do so by ceasing your use of the SDK +and any relevant developer credentials. -=============================================================================== +9.3 Google may at any time, terminate this License Agreement with you if: -These components - com.google.android.rcs.core.utils.FastBase64, - com.google.android.rcs.core.utils.LibraryLoaderHelper -are licensed under BSD. +(A) you have breached any provision of this License Agreement; or -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: +(B) Google is required to do so by law; or - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. +(C) the partner with whom Google offered certain parts of SDK (such as APIs) to you has terminated +its relationship with Google or ceased to offer certain parts of the SDK to you; or - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. +(D) Google decides to no longer providing the SDK or certain parts of the SDK to users in the +country in which you are resident or from which you use the service, or the provision of the SDK or +certain SDK services to you by Google is, in Google's sole discretion, no longer commercially +viable. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +9.4 When this License Agreement comes to an end, all of the legal rights, obligations and +liabilities that you and Google have benefited from, been subject to (or which have accrued over +time whilst this License Agreement has been in force) or which are expressed to continue +indefinitely, shall be unaffected by this cessation, and the provisions of paragraph 14.7 shall +continue to apply to such rights, obligations and liabilities indefinitely. +10. DISCLAIMER OF WARRANTIES -mime4j: +10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SDK IS AT YOUR SOLE RISK AND THAT THE +SDK IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM GOOGLE. - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ +10.2 YOUR USE OF THE SDK AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE +SDK IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR +COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE. - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION +10.3 GOOGLE FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - 1. Definitions. +11. LIMITATION OF LIABILITY - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. +11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT GOOGLE, ITS SUBSIDIARIES AND AFFILIATES, AND ITS +LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY +LOSS OF DATA, WHETHER OR NOT GOOGLE OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN +AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING. - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. +12. Indemnification - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. +12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless +Google, its affiliates and their respective directors, officers, employees and agents from and +against any and all claims, actions, suits or proceedings, as well as any and all losses, +liabilities, damages, costs and expenses (including reasonable attorneys fees) arising out of or +accruing from (a) your use of the SDK, (b) any application you develop on the SDK that infringes any +copyright, trademark, trade secret, trade dress, patent or other intellectual property right of any +person or defames any person or violates their rights of publicity or privacy, and (c) any +non-compliance by you with this License Agreement. - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. +13. Changes to the License Agreement - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. +13.1 Google may make changes to the License Agreement as it distributes new versions of the SDK. +When these changes are made, Google will make a new version of the License Agreement available on +the website where the SDK is made available. - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. +14. General Legal Terms - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). +14.1 This License Agreement constitute the whole legal agreement between you and Google and govern +your use of the SDK (excluding any services which Google may provide to you under a separate written +agreement), and completely replace any prior agreements between you and Google in relation to the +SDK. - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. +14.2 You agree that if Google does not exercise or enforce any legal right or remedy which is +contained in this License Agreement (or which Google has the benefit of under any applicable law), +this will not be taken to be a formal waiver of Google's rights and that those rights or remedies +will still be available to Google. - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." +14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision +of this License Agreement is invalid, then that provision will be removed from this License +Agreement without affecting the rest of this License Agreement. The remaining provisions of this +License Agreement will continue to be valid and enforceable. - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. +14.4 You acknowledge and agree that each member of the group of companies of which Google is the +parent shall be third party beneficiaries to this License Agreement and that such other companies +shall be entitled to directly enforce, and rely upon, any provision of this License Agreement that +confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall +be third party beneficiaries to this License Agreement. - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. +14.5 EXPORT RESTRICTIONS. THE SDK IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST +COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE SDK. THESE +LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END USE. - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. +14.6 The rights granted in this License Agreement may not be assigned or transferred by either you +or Google without the prior written approval of the other party. Neither you nor Google shall be +permitted to delegate their responsibilities or obligations under this License Agreement without the +prior written approval of the other party. - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: +14.7 This License Agreement, and your relationship with Google under this License Agreement, shall +be governed by the laws of the State of California without regard to its conflict of laws +provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located +within the county of Santa Clara, California to resolve any legal matter arising from this License +Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for +injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction. - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and +April 10, 2009 - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and +Glide: - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. +Covers library/ - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. +Copyright 2014 Google, Inc. All rights reserved. - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. +Redistribution and use in source and binary forms, with or without modification, are +permitted provided that the following conditions are met: - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. + 1. Redistributions of source code must retain the above copyright notice, this list of + conditions and the following disclaimer. - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. + 2. Redistributions in binary form must reproduce the above copyright notice, this list + of conditions and the following disclaimer in the documentation and/or other materials + provided with the distribution. - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. +THIS SOFTWARE IS PROVIDED BY GOOGLE, INC. ``AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE, INC. OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. +The views and conclusions contained in the software and documentation are those of the +authors and should not be interpreted as representing official policies, either expressed +or implied, of Google, Inc. - END OF TERMS AND CONDITIONS - - - +-------------------------------------------------------------------------- +Covers third_party/gif_decoder - THIS PRODUCT ALSO INCLUDES THIRD PARTY SOFTWARE REDISTRIBUTED UNDER THE - FOLLOWING LICENSES: +Copyright (c) 2013 Xcellent Creations, Inc. - Apache Commons Logging, - The Apache Software License, Version 1.1 (commons-logging-1.1.1.jar) - - The Apache Software License, Version 1.1 - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - 3. The end-user documentation included with the redistribution, - if any, must include the following acknowledgment: - "This product includes software developed by the - Apache Software Foundation (http://www.apache.org/)." - Alternately, this acknowledgment may appear in the software itself, - if and wherever such third-party acknowledgments normally appear. - - 4. The names "Apache" and "Apache Software Foundation" must - not be used to endorse or promote products derived from this - software without prior written permission. For written - permission, please contact apache@apache.org. - - 5. Products derived from this software may not be called "Apache", - nor may "Apache" appear in their name, without prior written - permission of the Apache Software Foundation. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: - Test messages from the Perl-MIME-Tools project, - - The "Artistic License" - - Preamble - - The intent of this document is to state the conditions under which a - Package may be copied, such that the Copyright Holder maintains some - semblance of artistic control over the development of the package, - while giving the users of the package the right to use and distribute - the Package in a more-or-less customary fashion, plus the right to make - reasonable modifications. - - Definitions: - - "Package" refers to the collection of files distributed by the - Copyright Holder, and derivatives of that collection of files - created through textual modification. - - "Standard Version" refers to such a Package if it has not been - modified, or has been modified in accordance with the wishes - of the Copyright Holder as specified below. - - "Copyright Holder" is whoever is named in the copyright or - copyrights for the package. - - "You" is you, if you're thinking about copying or distributing - this Package. - - "Reasonable copying fee" is whatever you can justify on the - basis of media cost, duplication charges, time of people involved, - and so on. (You will not be required to justify it to the - Copyright Holder, but only to the computing community at large - as a market that must bear the fee.) - - "Freely Available" means that no fee is charged for the item - itself, though there may be fees involved in handling the item. - It also means that recipients of the item may redistribute it - under the same conditions they received it. - - 1. You may make and give away verbatim copies of the source form of the - Standard Version of this Package without restriction, provided that you - duplicate all of the original copyright notices and associated disclaimers. - - 2. You may apply bug fixes, portability fixes and other modifications - derived from the Public Domain or from the Copyright Holder. A Package - modified in such a way shall still be considered the Standard Version. - - 3. You may otherwise modify your copy of this Package in any way, provided - that you insert a prominent notice in each changed file stating how and - when you changed that file, and provided that you do at least ONE of the - following: - - a) place your modifications in the Public Domain or otherwise make them - Freely Available, such as by posting said modifications to Usenet or - an equivalent medium, or placing the modifications on a major archive - site such as uunet.uu.net, or by allowing the Copyright Holder to include - your modifications in the Standard Version of the Package. - - b) use the modified Package only within your corporation or organization. - - c) rename any non-standard executables so the names do not conflict - with standard executables, which must also be provided, and provide - a separate manual page for each non-standard executable that clearly - documents how it differs from the Standard Version. - - d) make other distribution arrangements with the Copyright Holder. - - 4. You may distribute the programs of this Package in object code or - executable form, provided that you do at least ONE of the following: - - a) distribute a Standard Version of the executables and library files, - together with instructions (in the manual page or equivalent) on where - to get the Standard Version. - - b) accompany the distribution with the machine-readable source of - the Package with your modifications. - - c) give non-standard executables non-standard names, and clearly - document the differences in manual pages (or equivalent), together - with instructions on where to get the Standard Version. - - d) make other distribution arrangements with the Copyright Holder. - - 5. You may charge a reasonable copying fee for any distribution of this - Package. You may charge any fee you choose for support of this - Package. You may not charge a fee for this Package itself. However, - you may distribute this Package in aggregate with other (possibly - commercial) programs as part of a larger (possibly commercial) software - distribution provided that you do not advertise this Package as a - product of your own. You may embed this Package's interpreter within - an executable of yours (by linking); this shall be construed as a mere - form of aggregation, provided that the complete Standard Version of the - interpreter is so embedded. - - 6. The scripts and library files supplied as input to or produced as - output from the programs of this Package do not automatically fall - under the copyright of this Package, but belong to whoever generated - them, and may be sold commercially, and may be aggregated with this - Package. If such scripts or library files are aggregated with this - Package via the so-called "undump" or "unexec" methods of producing a - binary executable image, then distribution of such an image shall - neither be construed as a distribution of this Package nor shall it - fall under the restrictions of Paragraphs 3 and 4, provided that you do - not represent such an executable image as a Standard Version of this - Package. - - 7. C subroutines (or comparably compiled subroutines in other - languages) supplied by you and linked into this Package in order to - emulate subroutines and variables of the language defined by this - Package shall not be considered part of this Package, but are the - equivalent of input as in Paragraph 6, provided these subroutines do - not change the language in any way that would cause it to fail the - regression tests for the language. - - 8. Aggregation of this Package with a commercial distribution is always - permitted provided that the use of this Package is embedded; that is, - when no overt attempt is made to make this Package's interfaces visible - to the end user of the commercial distribution. Such use shall not be - construed as a distribution of this Package. - - 9. The name of the Copyright Holder may not be used to endorse or promote - products derived from this software without specific prior written permission. - - 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - - The End +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. - - +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -rcsclientlib: +-------------------------------------------------------------------------- +Covers third_party/disklrucache -These components - com.google.android.rcs.core, - com.google.android.rcs.core.utils.CaseInsensitiveMap, - com.google.android.rcs.core.utils.DateTime, - com.google.android.rcs.core.utils.InetAddresses, - com.google.android.rcs.core.network.ConnectivityMonitor, - com.google.android.rcs.client.PrivateDataStorage, - com.google.android.rcs.client.utils.FastXmlSerializer, - com.google.android.rcs.client.utils.XmlUtils, - com.google.android.rcs.client.utils.QueuedWork -are licensed under Apache v2. +Copyright 2012 Jake Wharton +Copyright 2011 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. +-------------------------------------------------------------------------- +Covers third_party/gif_encoder/AnimatedGifEncoder.java and +third_party/gif_encoder/LZWEncoder.java: +No copyright asserted on the source code of this class. May be used for any +purpose, however, refer to the Unisys LZW patent for restrictions on use of +the associated LZWEncoder class. Please forward any corrections to +kweiner@fmsware.com. - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION +----------------------------------------------------------------------------- +Covers third_party/gif_encoder/NeuQuant.java - 1. Definitions. +Copyright (c) 1994 Anthony Dekker - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. +NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See +"Kohonen neural networks for optimal colour quantization" in "Network: +Computation in Neural Systems" Vol. 5 (1994) pp 351-367. for a discussion of +the algorithm. - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. +Any party obtaining a copy of these files from the author, directly or +indirectly, is granted, free of charge, a full and unrestricted irrevocable, +world-wide, paid up, royalty-free, nonexclusive right and license to deal in +this software and documentation files (the "Software"), including without +limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons who +receive copies from any such party to do so, with the only requirement being +that this copyright notice remain intact. - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. +Animal Sniffer: - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. +The MIT License - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. +Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. +Checker Framework: - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. +The Checker Framework is licensed under the GNU General Public License, +version 2 (GPL2), with the classpath exception. The text of this license +appears below. This is the same license used for OpenJDK. - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: +A few parts of the Checker Framework have more permissive licenses. - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and + * The annotations are licensed under the MIT License. (The text of this + license appears below.) More specifically, all the parts of the Checker + Framework that you might want to include with your own program use the + MIT License. This is the checker-qual.jar file and all the files that + appear in it: every file in a qual/ directory, plus NullnessUtils.java + and RegexUtil.java. In addition, the cleanroom implementations of + third-party annotations, which the Checker Framework recognizes as + aliases for its own annotations, are licensed under the MIT License. - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and + * The Maven plugin is dual-licensed (you may use whichever you prefer) + under GPL2 and the Apache License, version 2.0 (Apache2). The text of + Apache2 appears in file maven-plugin/LICENSE.txt. Maven itself uses + Apache2. + + * The Eclipse plugin is dual-licensed (you may use whichever you prefer) + under GPL2 and the Eclipse Public License Version 1.0 (EPL). EPL + appears http://www.eclipse.org/org/documents/epl-v10.php. Eclipse + itself uses EPL. + +Some external libraries that are included with the Checker Framework have +different licenses. + + * javaparser is licensed under the LGPL. (The javaparser source code + contains a file with the text of the GPL, but it is not clear why, since + javaparser does not use the GPL.) See file javaparser/COPYING.LESSER + and the source code of all its files. + + * junit is licensed under the Common Public License v1.0 (see + http://www.junit.org/license), with parts (Hamcrest) licensed under the + BSD License (see LICENSE.txt in checkers/tests/junit.jar ). + + * plume-lib is licensed under the MIT License. + +The Checker Framework includes annotations for several libraries, in +directory checkers/jdk/. The only one that uses a different license than +the GPL is Google Guava, which uses Apache2. + +=========================================================================== + +The GNU General Public License (GPL) + +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public License is intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. This General Public License applies to +most of the Free Software Foundation's software and to any other program whose +authors commit to using it. (Some other Free Software Foundation software is +covered by the GNU Library General Public License instead.) You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our +General Public Licenses are designed to make sure that you have the freedom to +distribute copies of free software (and charge for this service if you wish), +that you receive source code or can get it if you want it, that you can change +the software or use pieces of it in new free programs; and that you know you +can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny +you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of the +software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for +a fee, you must give the recipients all the rights that you have. You must +make sure that they, too, receive or can get the source code. And you must +show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) +offer you this license which gives you legal permission to copy, distribute +and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that +everyone understands that there is no warranty for this free software. If the +software is modified by someone else and passed on, we want its recipients to +know that what they have is not the original, so that any problems introduced +by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We +wish to avoid the danger that redistributors of a free program will +individually obtain patent licenses, in effect making the program proprietary. +To prevent this, we have made it clear that any patent must be licensed for +everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification +follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice +placed by the copyright holder saying it may be distributed under the terms of +this General Public License. The "Program", below, refers to any such program +or work, and a "work based on the Program" means either the Program or any +derivative work under copyright law: that is to say, a work containing the +Program or a portion of it, either verbatim or with modifications and/or +translated into another language. (Hereinafter, translation is included +without limitation in the term "modification".) Each licensee is addressed as +"you". + +Activities other than copying, distribution and modification are not covered by +this License; they are outside its scope. The act of running the Program is +not restricted, and the output from the Program is covered only if its contents +constitute a work based on the Program (independent of having been made by +running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as +you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this License +and to the absence of any warranty; and give any other recipients of the +Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may +at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus +forming a work based on the Program, and copy and distribute such modifications +or work under the terms of Section 1 above, provided that you also meet all of +these conditions: + + a) You must cause the modified files to carry prominent notices stating + that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or + in part contains or is derived from the Program or any part thereof, to be + licensed as a whole at no charge to all third parties under the terms of + this License. + + c) If the modified program normally reads commands interactively when run, + you must cause it, when started running for such interactive use in the + most ordinary way, to print or display an announcement including an + appropriate copyright notice and a notice that there is no warranty (or + else, saying that you provide a warranty) and that users may redistribute + the program under these conditions, and telling the user how to view a copy + of this License. (Exception: if the Program itself is interactive but does + not normally print such an announcement, your work based on the Program is + not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Program, and can be reasonably +considered independent and separate works in themselves, then this License, and +its terms, do not apply to those sections when you distribute them as separate +works. But when you distribute the same sections as part of a whole which is a +work based on the Program, the distribution of the whole must be on the terms +of this License, whose permissions for other licensees extend to the entire +whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise the +right to control the distribution of derivative or collective works based on +the Program. + +In addition, mere aggregation of another work not based on the Program with the +Program (or with a work based on the Program) on a volume of a storage or +distribution medium does not bring the other work under the scope of this +License. + +3. You may copy and distribute the Program (or a work based on it, under +Section 2) in object code or executable form under the terms of Sections 1 and +2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source + code, which must be distributed under the terms of Sections 1 and 2 above + on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to + give any third party, for a charge no more than your cost of physically + performing source distribution, a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of Sections 1 + and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to + distribute corresponding source code. (This alternative is allowed only + for noncommercial distribution and only if you received the program in + object code or executable form with such an offer, in accord with + Subsection b above.) + +The source code for a work means the preferred form of the work for making +modifications to it. For an executable work, complete source code means all +the source code for all modules it contains, plus any associated interface +definition files, plus the scripts used to control compilation and installation +of the executable. However, as a special exception, the source code +distributed need not include anything that is normally distributed (in either +source or binary form) with the major components (compiler, kernel, and so on) +of the operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the source +code from the same place counts as distribution of the source code, even though +third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as +expressly provided under this License. Any attempt otherwise to copy, modify, +sublicense or distribute the Program is void, and will automatically terminate +your rights under this License. However, parties who have received copies, or +rights, from you under this License will not have their licenses terminated so +long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. +However, nothing else grants you permission to modify or distribute the Program +or its derivative works. These actions are prohibited by law if you do not +accept this License. Therefore, by modifying or distributing the Program (or +any work based on the Program), you indicate your acceptance of this License to +do so, and all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), +the recipient automatically receives a license from the original licensor to +copy, distribute or modify the Program subject to these terms and conditions. +You may not impose any further restrictions on the recipients' exercise of the +rights granted herein. You are not responsible for enforcing compliance by +third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), conditions +are imposed on you (whether by court order, agreement or otherwise) that +contradict the conditions of this License, they do not excuse you from the +conditions of this License. If you cannot distribute so as to satisfy +simultaneously your obligations under this License and any other pertinent +obligations, then as a consequence you may not distribute the Program at all. +For example, if a patent license would not permit royalty-free redistribution +of the Program by all those who receive copies directly or indirectly through +you, then the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply and +the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or +other property right claims or to contest validity of any such claims; this +section has the sole purpose of protecting the integrity of the free software +distribution system, which is implemented by public license practices. Many +people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose that +choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain +countries either by patents or by copyrighted interfaces, the original +copyright holder who places the Program under this License may add an explicit +geographical distribution limitation excluding those countries, so that +distribution is permitted only in or among countries not thus excluded. In +such case, this License incorporates the limitation as if written in the body +of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the +General Public License from time to time. Such new versions will be similar in +spirit to the present version, but may differ in detail to address new problems +or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any later +version", you have the option of following the terms and conditions either of +that version or of any later version published by the Free Software Foundation. +If the Program does not specify a version number of this License, you may +choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs +whose distribution conditions are different, write to the author to ask for +permission. For software which is copyrighted by the Free Software Foundation, +write to the Free Software Foundation; we sometimes make exceptions for this. +Our decision will be guided by the two goals of preserving the free status of +all derivatives of our free software and of promoting the sharing and reuse of +software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR +THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE +PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, +YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL +ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE +PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR +INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA +BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER +OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible +use to the public, the best way to achieve this is to make it free software +which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach +them to the start of each source file to most effectively convey the exclusion +of warranty; and each file should have at least the "copyright" line and a +pointer to where the full notice is found. + + One line to give the program's name and a brief idea of what it does. + + Copyright (C) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., 59 + Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it +starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes + with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free + software, and you are welcome to redistribute it under certain conditions; + type 'show c' for details. + +The hypothetical commands 'show w' and 'show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may be +called something other than 'show w' and 'show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the program, if necessary. Here +is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + 'Gnomovision' (which makes passes at compilers) written by James Hacker. + + signature of Ty Coon, 1 April 1989 + + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General Public +License instead of this License. + + +"CLASSPATH" EXCEPTION TO THE GPL + +Certain source files distributed by Oracle America and/or its affiliates are +subject to the following clarification and special exception to the GPL, but +only where Oracle has expressly included in the particular source file's header +the words "Oracle designates this particular file as subject to the "Classpath" +exception as provided by Oracle in the LICENSE file that accompanied this code." - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and + Linking this library statically or dynamically with other modules is making + a combined work based on this library. Thus, the terms and conditions of + the GNU General Public License cover the whole combination. - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent modules, + and to copy and distribute the resulting executable under terms of your + choice, provided that you also meet, for each linked independent module, + the terms and conditions of the license of that module. An independent + module is a module which is not derived from or based on this library. If + you modify this library, you may extend this exception to your version of + the library, but you are not obligated to do so. If you do not wish to do + so, delete this exception statement from your version. - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. +=========================================================================== - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. +MIT License: - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. +=========================================================================== - END OF TERMS AND CONDITIONS -=============================================================================== +JSR 305: -These components - com.google.android.rcs.core.utils.FastBase64, - com.google.android.rcs.core.utils.LibraryLoaderHelper -are licensed under BSD. +Copyright (c) 2007-2009, JSR305 expert group +All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: +http://www.opensource.org/licenses/bsd-license.php - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the JSR305 expert group nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. -- cgit v1.2.3 From e29b98635ce078c61029e9068504c9b96ce99e74 Mon Sep 17 00:00:00 2001 From: linyuh Date: Mon, 8 Jan 2018 15:55:39 -0800 Subject: Simplifying implementation of the coalescing logic in the new call log. Bug: 70388714 Test: Existing tests PiperOrigin-RevId: 181231987 Change-Id: I0c7386f60e92f7087f9f5ad1b1f454b43b7227e7 --- .../android/dialer/calllog/database/Coalescer.java | 51 ++++++++++++---------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/java/com/android/dialer/calllog/database/Coalescer.java b/java/com/android/dialer/calllog/database/Coalescer.java index f4ef02a25..9b788140a 100644 --- a/java/com/android/dialer/calllog/database/Coalescer.java +++ b/java/com/android/dialer/calllog/database/Coalescer.java @@ -80,40 +80,45 @@ public class Coalescer { CoalescedAnnotatedCallLog.ALL_COLUMNS, Assert.isNotNull(allAnnotatedCallLogRowsSortedByTimestampDesc).getCount()); - if (allAnnotatedCallLogRowsSortedByTimestampDesc.moveToFirst()) { - int coalescedRowId = 0; - - List currentRowGroup = new ArrayList<>(); + if (!allAnnotatedCallLogRowsSortedByTimestampDesc.moveToFirst()) { + return allCoalescedRowsMatrixCursor; + } - do { - ContentValues currentRow = - cursorRowToContentValues(allAnnotatedCallLogRowsSortedByTimestampDesc); + int coalescedRowId = 0; + List currentRowGroup = new ArrayList<>(); - if (currentRowGroup.isEmpty()) { - currentRowGroup.add(currentRow); - continue; - } + ContentValues firstRow = cursorRowToContentValues(allAnnotatedCallLogRowsSortedByTimestampDesc); + currentRowGroup.add(firstRow); - ContentValues previousRow = currentRowGroup.get(currentRowGroup.size() - 1); + while (!currentRowGroup.isEmpty()) { + // Group consecutive rows + ContentValues firstRowInGroup = currentRowGroup.get(0); + ContentValues currentRow = null; + while (allAnnotatedCallLogRowsSortedByTimestampDesc.moveToNext()) { + currentRow = cursorRowToContentValues(allAnnotatedCallLogRowsSortedByTimestampDesc); - if (!rowsShouldBeCombined(dialerPhoneNumberUtil, previousRow, currentRow)) { - ContentValues coalescedRow = coalesceRowsForAllDataSources(currentRowGroup); - coalescedRow.put( - CoalescedAnnotatedCallLog.COALESCED_IDS, - getCoalescedIds(currentRowGroup).toByteArray()); - addContentValuesToMatrixCursor( - coalescedRow, allCoalescedRowsMatrixCursor, coalescedRowId++); - currentRowGroup.clear(); + if (!rowsShouldBeCombined(dialerPhoneNumberUtil, firstRowInGroup, currentRow)) { + break; } + currentRowGroup.add(currentRow); - } while (allAnnotatedCallLogRowsSortedByTimestampDesc.moveToNext()); + } - // Deal with leftover rows. + // Coalesce the group into a single row ContentValues coalescedRow = coalesceRowsForAllDataSources(currentRowGroup); coalescedRow.put( CoalescedAnnotatedCallLog.COALESCED_IDS, getCoalescedIds(currentRowGroup).toByteArray()); - addContentValuesToMatrixCursor(coalescedRow, allCoalescedRowsMatrixCursor, coalescedRowId); + addContentValuesToMatrixCursor(coalescedRow, allCoalescedRowsMatrixCursor, coalescedRowId++); + + // Clear the current group after the rows are coalesced. + currentRowGroup.clear(); + + // Add the first of the remaining rows to the current group. + if (!allAnnotatedCallLogRowsSortedByTimestampDesc.isAfterLast()) { + currentRowGroup.add(currentRow); + } } + return allCoalescedRowsMatrixCursor; } -- cgit v1.2.3 From 0cbbf4a7e6be836c24f6257fbdee8a03d70d927b Mon Sep 17 00:00:00 2001 From: maxwelb Date: Mon, 8 Jan 2018 16:43:06 -0800 Subject: Hide emergency calls in the call log Bug: 38494024,66926712 Test: CallLogAdapterTest, manually checked UI PiperOrigin-RevId: 181238101 Change-Id: I1b718e30a4bc874e098e30a3aaae39bdd69d0c9a --- java/com/android/dialer/app/calllog/CallLogAdapter.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index 261b0ec94..963967ffc 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -39,6 +39,7 @@ import android.support.v7.app.AlertDialog; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView.ViewHolder; import android.telecom.PhoneAccountHandle; +import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; @@ -802,7 +803,7 @@ public class CallLogAdapter extends GroupingListAdapter int groupSize = getGroupSize(position); CallDetailsEntries callDetailsEntries = createCallDetailsEntries(c, groupSize); PhoneCallDetails details = createPhoneCallDetails(c, groupSize, views); - if (hiddenRowIds.contains(c.getLong(CallLogQuery.ID))) { + if (isHiddenRow(views.number, c.getLong(CallLogQuery.ID))) { views.callLogEntryView.setVisibility(View.GONE); views.dayGroupHeader.setVisibility(View.GONE); return; @@ -827,6 +828,16 @@ public class CallLogAdapter extends GroupingListAdapter } } + private boolean isHiddenRow(@Nullable String number, long rowId) { + if (number != null && PhoneNumberUtils.isEmergencyNumber(number)) { + return true; + } + if (hiddenRowIds.contains(rowId)) { + return true; + } + return false; + } + private void loadAndRender( final CallLogListItemViewHolder viewHolder, final long rowId, -- cgit v1.2.3 From 517fbff5c15c9270323b4099a39514d2487eec99 Mon Sep 17 00:00:00 2001 From: roldenburg Date: Mon, 8 Jan 2018 17:07:28 -0800 Subject: Update strings for Duo "Set up" and "Invite" buttons Bug: 70034799 Test: manual PiperOrigin-RevId: 181241050 Change-Id: Iddf5ef331741f8ab8500eeb3d5481598ef5caca4 --- java/com/android/dialer/app/res/values/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/com/android/dialer/app/res/values/strings.xml b/java/com/android/dialer/app/res/values/strings.xml index 99720c2a6..9554fc21b 100644 --- a/java/com/android/dialer/app/res/values/strings.xml +++ b/java/com/android/dialer/app/res/values/strings.xml @@ -351,12 +351,12 @@ - Set up + Set up video calling - Invite + Invite to video call