summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/bluetooth/BluetoothAdapter.java18
-rw-r--r--core/java/android/bluetooth/IBluetooth.aidl1
-rw-r--r--core/java/android/bluetooth/le/BluetoothLeAdvertiser.java3
-rw-r--r--core/java/android/content/res/ResourcesKey.java13
-rw-r--r--core/java/android/net/NetworkCapabilities.java19
-rw-r--r--core/java/android/provider/CallLog.java69
-rw-r--r--core/java/com/android/internal/widget/AccountItemView.java102
-rw-r--r--core/java/com/android/internal/widget/AccountViewAdapter.java127
8 files changed, 274 insertions, 78 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index 5564af7..f2e03cf 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -465,7 +465,8 @@ public final class BluetoothAdapter {
if (getState() != STATE_ON) {
return null;
}
- if (!isMultipleAdvertisementSupported()) {
+ if (!isMultipleAdvertisementSupported() && !isPeripheralModeSupported()) {
+ Log.e(TAG, "bluetooth le advertising not supported");
return null;
}
synchronized(mLock) {
@@ -918,6 +919,21 @@ public final class BluetoothAdapter {
}
/**
+ * Returns whether peripheral mode is supported.
+ *
+ * @hide
+ */
+ public boolean isPeripheralModeSupported() {
+ if (getState() != STATE_ON) return false;
+ try {
+ return mService.isPeripheralModeSupported();
+ } catch (RemoteException e) {
+ Log.e(TAG, "failed to get peripheral mode capability: ", e);
+ }
+ return false;
+ }
+
+ /**
* Return true if offloaded filters are supported
*
* @return true if chipset supports on-chip filtering
diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl
index cf2a343..992f601 100644
--- a/core/java/android/bluetooth/IBluetooth.aidl
+++ b/core/java/android/bluetooth/IBluetooth.aidl
@@ -92,6 +92,7 @@ interface IBluetooth
boolean configHciSnoopLog(boolean enable);
boolean isMultiAdvertisementSupported();
+ boolean isPeripheralModeSupported();
boolean isOffloadedFilteringSupported();
boolean isOffloadedScanBatchingSupported();
boolean isActivityAndEnergyReportingSupported();
diff --git a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
index d468508..a019d5c 100644
--- a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
+++ b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
@@ -111,7 +111,8 @@ public final class BluetoothLeAdvertiser {
if (callback == null) {
throw new IllegalArgumentException("callback cannot be null");
}
- if (!mBluetoothAdapter.isMultipleAdvertisementSupported()) {
+ if (!mBluetoothAdapter.isMultipleAdvertisementSupported() &&
+ !mBluetoothAdapter.isPeripheralModeSupported()) {
postStartFailure(callback,
AdvertiseCallback.ADVERTISE_FAILED_FEATURE_UNSUPPORTED);
return;
diff --git a/core/java/android/content/res/ResourcesKey.java b/core/java/android/content/res/ResourcesKey.java
index e0f1b3a..4ae3825 100644
--- a/core/java/android/content/res/ResourcesKey.java
+++ b/core/java/android/content/res/ResourcesKey.java
@@ -62,10 +62,15 @@ public final class ResourcesKey {
return false;
}
ResourcesKey peer = (ResourcesKey) obj;
- if (mResDir != peer.mResDir) {
- if (mResDir == null || peer.mResDir == null) {
- return false;
- } else if (!mResDir.equals(peer.mResDir)) {
+
+ if ((mResDir == null) && (peer.mResDir != null)) {
+ return false;
+ }
+ if ((mResDir != null) && (peer.mResDir == null)) {
+ return false;
+ }
+ if ((mResDir != null) && (peer.mResDir != null)) {
+ if (!mResDir.equals(peer.mResDir)) {
return false;
}
}
diff --git a/core/java/android/net/NetworkCapabilities.java b/core/java/android/net/NetworkCapabilities.java
index 53f9fcd..1efe478 100644
--- a/core/java/android/net/NetworkCapabilities.java
+++ b/core/java/android/net/NetworkCapabilities.java
@@ -19,16 +19,7 @@ package android.net;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
-import android.util.Log;
-
import java.lang.IllegalArgumentException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
/**
* This class represents the capabilities of a network. This is used both to specify
@@ -36,15 +27,12 @@ import java.util.Set;
*
* Note that this replaces the old {@link ConnectivityManager#TYPE_MOBILE} method
* of network selection. Rather than indicate a need for Wi-Fi because an application
- * needs high bandwidth and risk obselence when a new, fast network appears (like LTE),
+ * needs high bandwidth and risk obsolescence when a new, fast network appears (like LTE),
* the application should specify it needs high bandwidth. Similarly if an application
* needs an unmetered network for a bulk transfer it can specify that rather than assuming
* all cellular based connections are metered and all Wi-Fi based connections are not.
*/
public final class NetworkCapabilities implements Parcelable {
- private static final String TAG = "NetworkCapabilities";
- private static final boolean DBG = false;
-
/**
* @hide
*/
@@ -541,9 +529,11 @@ public final class NetworkCapabilities implements Parcelable {
(TextUtils.isEmpty(mNetworkSpecifier) ? 0 : mNetworkSpecifier.hashCode() * 17));
}
+ @Override
public int describeContents() {
return 0;
}
+ @Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(mNetworkCapabilities);
dest.writeLong(mTransportTypes);
@@ -553,6 +543,7 @@ public final class NetworkCapabilities implements Parcelable {
}
public static final Creator<NetworkCapabilities> CREATOR =
new Creator<NetworkCapabilities>() {
+ @Override
public NetworkCapabilities createFromParcel(Parcel in) {
NetworkCapabilities netCap = new NetworkCapabilities();
@@ -563,11 +554,13 @@ public final class NetworkCapabilities implements Parcelable {
netCap.mNetworkSpecifier = in.readString();
return netCap;
}
+ @Override
public NetworkCapabilities[] newArray(int size) {
return new NetworkCapabilities[size];
}
};
+ @Override
public String toString() {
int[] types = getTransportTypes();
String transports = (types.length > 0 ? " Transports: " : "");
diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java
index c8d0fd5..3e80ed0 100644
--- a/core/java/android/provider/CallLog.java
+++ b/core/java/android/provider/CallLog.java
@@ -24,17 +24,13 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.UserInfo;
import android.database.Cursor;
-import android.location.Country;
-import android.location.CountryDetector;
import android.net.Uri;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.ContactsContract.CommonDataKinds.Callable;
import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.DataUsageFeedback;
import android.telecom.PhoneAccountHandle;
-import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import com.android.internal.telephony.CallerInfo;
@@ -387,10 +383,12 @@ public class CallLog {
public static Uri addCall(CallerInfo ci, Context context, String number,
int presentation, int callType, int features, PhoneAccountHandle accountHandle,
long start, int duration, Long dataUsage) {
+ // FIXME using -1 as subId instead of SubscriptionManager.INVALID_SUB_ID
return addCall(ci, context, number, presentation, callType, features, accountHandle,
start, duration, dataUsage, false);
}
+
/**
* Adds a call to the call log.
*
@@ -406,6 +404,7 @@ public class CallLog {
* @param accountHandle The accountHandle object identifying the provider of the call
* @param start time stamp for the call in milliseconds
* @param duration call duration in seconds
+ * @param subId the subscription id.
* @param dataUsage data usage for the call in bytes, null if data usage was not tracked for
* the call.
* @param addForAllUsers If true, the call is added to the call log of all currently
@@ -463,6 +462,7 @@ public class CallLog {
values.put(PHONE_ACCOUNT_COMPONENT_NAME, accountComponentString);
values.put(PHONE_ACCOUNT_ID, accountId);
values.put(NEW, Integer.valueOf(1));
+
if (callType == MISSED_TYPE) {
values.put(IS_READ, Integer.valueOf(0));
}
@@ -503,13 +503,12 @@ public class CallLog {
if (cursor != null) {
try {
if (cursor.getCount() > 0 && cursor.moveToFirst()) {
- final String dataId = cursor.getString(0);
- updateDataUsageStatForData(resolver, dataId);
- if (duration >= MIN_DURATION_FOR_NORMALIZED_NUMBER_UPDATE_MS
- && callType == Calls.OUTGOING_TYPE
- && TextUtils.isEmpty(ci.normalizedNumber)) {
- updateNormalizedNumber(context, resolver, dataId, number);
- }
+ final Uri feedbackUri = DataUsageFeedback.FEEDBACK_URI.buildUpon()
+ .appendPath(cursor.getString(0))
+ .appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
+ DataUsageFeedback.USAGE_TYPE_CALL)
+ .build();
+ resolver.update(feedbackUri, new ContentValues(), null, null);
}
} finally {
cursor.close();
@@ -582,53 +581,5 @@ public class CallLog {
+ " LIMIT -1 OFFSET 500)", null);
return result;
}
-
- private static void updateDataUsageStatForData(ContentResolver resolver, String dataId) {
- final Uri feedbackUri = DataUsageFeedback.FEEDBACK_URI.buildUpon()
- .appendPath(dataId)
- .appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
- DataUsageFeedback.USAGE_TYPE_CALL)
- .build();
- resolver.update(feedbackUri, new ContentValues(), null, null);
- }
-
- /**
- * Update the normalized phone number for the given dataId in the ContactsProvider, based
- * on the user's current country.
- */
- private static void updateNormalizedNumber(Context context, ContentResolver resolver,
- String dataId, String number) {
- if (TextUtils.isEmpty(number) || TextUtils.isEmpty(dataId)) {
- return;
- }
-
- final String countryIso = getCurrentCountryIso(context);
- if (TextUtils.isEmpty(countryIso)) {
- return;
- }
-
- final String normalizedNumber = PhoneNumberUtils.formatNumberToE164(number,
- getCurrentCountryIso(context));
- if (TextUtils.isEmpty(normalizedNumber)) {
- return;
- }
-
- final ContentValues values = new ContentValues();
- values.put(Phone.NORMALIZED_NUMBER, normalizedNumber);
- resolver.update(Data.CONTENT_URI, values, Data._ID + "=?", new String[] {dataId});
- }
-
- private static String getCurrentCountryIso(Context context) {
- String countryIso = null;
- final CountryDetector detector = (CountryDetector) context.getSystemService(
- Context.COUNTRY_DETECTOR);
- if (detector != null) {
- final Country country = detector.detectCountry();
- if (country != null) {
- countryIso = country.getCountryIso();
- }
- }
- return countryIso;
- }
}
}
diff --git a/core/java/com/android/internal/widget/AccountItemView.java b/core/java/com/android/internal/widget/AccountItemView.java
new file mode 100644
index 0000000..a521428
--- /dev/null
+++ b/core/java/com/android/internal/widget/AccountItemView.java
@@ -0,0 +1,102 @@
+/*
+* Copyright (C) 2011-2014 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.internal.widget;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.android.internal.R;
+import com.android.internal.widget.AccountViewAdapter.AccountElements;
+
+
+/**
+ * An LinearLayout view, to show Accounts elements.
+ */
+public class AccountItemView extends LinearLayout {
+
+ private ImageView mAccountIcon;
+ private TextView mAccountName;
+ private TextView mAccountNumber;
+
+ /**
+ * Constructor.
+ */
+ public AccountItemView(Context context) {
+ this(context, null);
+ }
+
+ /**
+ * Constructor.
+ */
+ public AccountItemView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ LayoutInflater inflator = (LayoutInflater)
+ context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ View view = inflator.inflate(R.layout.simple_account_item, null);
+ addView(view);
+ initViewItem(view);
+ }
+
+ private void initViewItem(View view) {
+ mAccountIcon = (ImageView)view.findViewById(android.R.id.icon);
+ mAccountName = (TextView)view.findViewById(android.R.id.title);
+ mAccountNumber = (TextView)view.findViewById(android.R.id.summary);
+ }
+
+ public void setViewItem(AccountElements element) {
+ Drawable drawable = element.getDrawable();
+ if (drawable != null) {
+ setAccountIcon(drawable);
+ } else {
+ setAccountIcon(element.getIcon());
+ }
+ setAccountName(element.getName());
+ setAccountNumber(element.getNumber());
+ }
+
+ public void setAccountIcon(int resId) {
+ mAccountIcon.setImageResource(resId);
+ }
+
+ public void setAccountIcon(Drawable drawable) {
+ mAccountIcon.setBackgroundDrawable(drawable);
+ }
+
+ public void setAccountName(String name) {
+ setText(mAccountName, name);
+ }
+
+ public void setAccountNumber(String number) {
+ setText(mAccountNumber, number);
+ }
+
+ private void setText(TextView view, String text) {
+ if (TextUtils.isEmpty(text)) {
+ view.setVisibility(View.GONE);
+ } else {
+ view.setText(text);
+ view.setVisibility(View.VISIBLE);
+ }
+ }
+}
diff --git a/core/java/com/android/internal/widget/AccountViewAdapter.java b/core/java/com/android/internal/widget/AccountViewAdapter.java
new file mode 100644
index 0000000..8a7a9a6
--- /dev/null
+++ b/core/java/com/android/internal/widget/AccountViewAdapter.java
@@ -0,0 +1,127 @@
+/*
+* Copyright (C) 2011-2014 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.internal.widget;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+
+import java.util.List;
+
+public class AccountViewAdapter extends BaseAdapter {
+
+ private List<AccountElements> mData;
+ private Context mContext;
+
+ /**
+ * Constructor
+ *
+ * @param context The context where the View associated with this Adapter is running
+ * @param data A list with AccountElements data type. The list contains the data of each
+ * account and the each member of AccountElements will correspond to one item view.
+ */
+ public AccountViewAdapter(Context context, final List<AccountElements> data) {
+ mContext = context;
+ mData = data;
+ }
+
+ @Override
+ public int getCount() {
+ return mData.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return mData.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ public void updateData(final List<AccountElements> data) {
+ mData = data;
+ notifyDataSetChanged();
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ AccountItemView view;
+ if (convertView == null) {
+ view = new AccountItemView(mContext);
+ } else {
+ view = (AccountItemView) convertView;
+ }
+ AccountElements elements = (AccountElements) getItem(position);
+ view.setViewItem(elements);
+ return view;
+ }
+
+ public static class AccountElements {
+ private int mIcon;
+ private Drawable mDrawable;
+ private String mName;
+ private String mNumber;
+
+ /**
+ * Constructor
+ * A structure with basic element of an Account, icon, name and number
+ *
+ * @param icon Account icon id
+ * @param name Account name
+ * @param num Account number
+ */
+ public AccountElements(int icon, String name, String number) {
+ this(icon, null, name, number);
+ }
+
+ /**
+ * Constructor
+ * A structure with basic element of an Account, drawable, name and number
+ *
+ * @param drawable Account drawable
+ * @param name Account name
+ * @param num Account number
+ */
+ public AccountElements(Drawable drawable, String name, String number) {
+ this(0, drawable, name, number);
+ }
+
+ private AccountElements(int icon, Drawable drawable, String name, String number) {
+ mIcon = icon;
+ mDrawable = drawable;
+ mName = name;
+ mNumber = number;
+ }
+
+ public int getIcon() {
+ return mIcon;
+ }
+ public String getName() {
+ return mName;
+ }
+ public String getNumber() {
+ return mNumber;
+ }
+ public Drawable getDrawable() {
+ return mDrawable;
+ }
+ }
+}