Merge "Synchronize mutated constant state's drawable constant state"
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 7dd559c..cd86a3c 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -2194,6 +2194,16 @@
public static final String CONTACT_ID = "contact_id";
/**
+ * Persistent unique id for each raw_contact within its account.
+ * This id is provided by its own data source, and can be used to backup metadata
+ * to the server.
+ * This should be unique within each set of account_name/account_type/data_set
+ *
+ * @hide
+ */
+ public static final String BACKUP_ID = "backup_id";
+
+ /**
* The data set within the account that this row belongs to. This allows
* multiple sync adapters for the same account type to distinguish between
* each others' data.
@@ -3986,6 +3996,13 @@
public static final String MIMETYPE = "mimetype";
/**
+ * Hash id on the data fields, used for backup and restore.
+ *
+ * @hide
+ */
+ public static final String HASH_ID = "hash_id";
+
+ /**
* A reference to the {@link RawContacts#_ID}
* that this data belongs to.
*/
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 19c9271..5b26ebb 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -6780,7 +6780,6 @@
@RemotableViewMethod
public void setVisibility(@Visibility int visibility) {
setFlags(visibility, VISIBILITY_MASK);
- if (mBackground != null) mBackground.setVisible(visibility == VISIBLE, false);
}
/**
@@ -8806,20 +8805,28 @@
}
/**
- * Called when the visibility of the view or an ancestor of the view is changed.
- * @param changedView The view whose visibility changed. Could be 'this' or
- * an ancestor view.
- * @param visibility The new visibility of changedView: {@link #VISIBLE},
- * {@link #INVISIBLE} or {@link #GONE}.
+ * Called when the visibility of the view or an ancestor of the view has
+ * changed.
+ *
+ * @param changedView The view whose visibility changed. May be
+ * {@code this} or an ancestor view.
+ * @param visibility The new visibility, one of {@link #VISIBLE},
+ * {@link #INVISIBLE} or {@link #GONE}.
*/
protected void onVisibilityChanged(@NonNull View changedView, @Visibility int visibility) {
- if (visibility == VISIBLE) {
+ final boolean visible = visibility == VISIBLE && getVisibility() == VISIBLE;
+ if (visible) {
if (mAttachInfo != null) {
initialAwakenScrollBars();
} else {
mPrivateFlags |= PFLAG_AWAKEN_SCROLL_BARS_ON_ATTACH;
}
}
+
+ final Drawable dr = mBackground;
+ if (dr != null && visible != dr.isVisible()) {
+ dr.setVisible(visible, false);
+ }
}
/**
diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java
index f208fff..b5782fc 100644
--- a/core/java/android/widget/FrameLayout.java
+++ b/core/java/android/widget/FrameLayout.java
@@ -18,6 +18,7 @@
import java.util.ArrayList;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.content.res.ColorStateList;
@@ -203,11 +204,15 @@
}
@Override
- @RemotableViewMethod
- public void setVisibility(@Visibility int visibility) {
- super.setVisibility(visibility);
- if (mForeground != null) {
- mForeground.setVisible(visibility == VISIBLE, false);
+ protected void onVisibilityChanged(@NonNull View changedView, @Visibility int visibility) {
+ super.onVisibilityChanged(changedView, visibility);
+
+ final Drawable dr = mForeground;
+ if (dr != null) {
+ final boolean visible = visibility == VISIBLE && getVisibility() == VISIBLE;
+ if (visible != dr.isVisible()) {
+ dr.setVisible(visible, false);
+ }
}
}
diff --git a/core/tests/coretests/src/android/content/pm/ParceledListSliceTest.java b/core/tests/coretests/src/android/content/pm/ParceledListSliceTest.java
index e7f4bad..e5a92bf 100644
--- a/core/tests/coretests/src/android/content/pm/ParceledListSliceTest.java
+++ b/core/tests/coretests/src/android/content/pm/ParceledListSliceTest.java
@@ -11,7 +11,7 @@
public void testSmallList() throws Exception {
final int objectCount = 100;
- List<SmallObject> list = new ArrayList<>();
+ List<SmallObject> list = new ArrayList<SmallObject>();
for (int i = 0; i < objectCount; i++) {
list.add(new SmallObject(i * 2, (i * 2) + 1));
}
@@ -20,7 +20,7 @@
Parcel parcel = Parcel.obtain();
try {
- parcel.writeParcelable(new ParceledListSlice<>(list), 0);
+ parcel.writeParcelable(new ParceledListSlice<SmallObject>(list), 0);
parcel.setDataPosition(0);
slice = parcel.readParcelable(getClass().getClassLoader());
} finally {
@@ -56,7 +56,7 @@
final int thresholdBytes = 256 * 1024;
final int objectCount = thresholdBytes / measureLargeObject();
- List<LargeObject> list = new ArrayList<>();
+ List<LargeObject> list = new ArrayList<LargeObject>();
for (int i = 0; i < objectCount; i++) {
list.add(new LargeObject(
i * 5,
@@ -71,7 +71,7 @@
Parcel parcel = Parcel.obtain();
try {
- parcel.writeParcelable(new ParceledListSlice<>(list), 0);
+ parcel.writeParcelable(new ParceledListSlice<LargeObject>(list), 0);
parcel.setDataPosition(0);
slice = parcel.readParcelable(getClass().getClassLoader());
} finally {
@@ -95,7 +95,7 @@
* Test that only homogeneous elements may be unparceled.
*/
public void testHomogeneousElements() throws Exception {
- List<BaseObject> list = new ArrayList<>();
+ List<BaseObject> list = new ArrayList<BaseObject>();
list.add(new LargeObject(0, 1, 2, 3, 4));
list.add(new SmallObject(5, 6));
list.add(new SmallObject(7, 8));
diff --git a/libs/hwui/Fence.h b/libs/hwui/Fence.h
deleted file mode 100644
index fc29f7ac1..0000000
--- a/libs/hwui/Fence.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#ifndef ANDROID_HWUI_FENCE_H
-#define ANDROID_HWUI_FENCE_H
-
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
-namespace android {
-namespace uirenderer {
-
-/**
- * Creating a Fence instance inserts a new sync fence in the OpenGL
- * commands stream. The caller can then wait for the fence to be signaled
- * by calling the wait method.
- */
-class Fence {
-public:
- enum {
- /**
- * Default timeout in nano-seconds for wait()
- */
- kDefaultTimeout = 1000000000
- };
-
- /**
- * Inserts a new sync fence in the OpenGL commands stream.
- */
- Fence() {
- mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- if (mDisplay != EGL_NO_DISPLAY) {
- mFence = eglCreateSyncKHR(mDisplay, EGL_SYNC_FENCE_KHR, nullptr);
- } else {
- mFence = EGL_NO_SYNC_KHR;
- }
- }
-
- /**
- * Destroys the fence. Any caller waiting on the fence will be
- * signaled immediately.
- */
- ~Fence() {
- if (mFence != EGL_NO_SYNC_KHR) {
- eglDestroySyncKHR(mDisplay, mFence);
- }
- }
-
- /**
- * Blocks the calling thread until this fence is signaled, or until
- * <timeout> nanoseconds have passed.
- *
- * Returns true if waiting for the fence was successful, false if
- * a timeout or an error occurred.
- */
- bool wait(EGLTimeKHR timeout = kDefaultTimeout) {
- EGLint waitStatus = eglClientWaitSyncKHR(mDisplay, mFence,
- EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, timeout);
- if (waitStatus == EGL_FALSE) {
- ALOGW("Failed to wait for the fence %#x", eglGetError());
- }
- return waitStatus == EGL_CONDITION_SATISFIED_KHR;
- }
-
-private:
- EGLDisplay mDisplay;
- EGLSyncKHR mFence;
-
-}; // class Fence
-
-/**
- * An AutoFence creates a Fence instance and waits for the fence
- * to be signaled when the AutoFence is destroyed. This is useful
- * to automatically wait for a series of OpenGL commands to be
- * executed. For example:
- *
- * void drawAndWait() {
- * glDrawElements();
- * AutoFence fence;
- * }
- */
-class AutoFence {
-public:
- AutoFence(EGLTimeKHR timeout = Fence::kDefaultTimeout): mTimeout(timeout) {
- }
-
- ~AutoFence() {
- mFence.wait(mTimeout);
- }
-
-private:
- EGLTimeKHR mTimeout;
- Fence mFence;
-
-}; // class AutoFence
-
-}; // namespace uirenderer
-}; // namespace android
-
-#endif // ANDROID_HWUI_FENCE_H
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 2378337..3ee9808 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -20,7 +20,6 @@
#include "DeferredDisplayList.h"
#include "DisplayListRenderer.h"
-#include "Fence.h"
#include "GammaFontRenderer.h"
#include "Patch.h"
#include "PathTessellator.h"
@@ -506,7 +505,7 @@
updateLayers();
flushLayers();
// Wait for all the layer updates to be executed
- AutoFence fence;
+ glFinish();
}
void OpenGLRenderer::markLayersAsBuildLayers() {
diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp
index f2337cb..3afca2f 100644
--- a/libs/hwui/renderthread/EglManager.cpp
+++ b/libs/hwui/renderthread/EglManager.cpp
@@ -22,10 +22,13 @@
#include <cutils/log.h>
#include <cutils/properties.h>
+#include <EGL/eglext.h>
#define PROPERTY_RENDER_DIRTY_REGIONS "debug.hwui.render_dirty_regions"
#define GLES_VERSION 2
+#define WAIT_FOR_GPU_COMPLETION 0
+
// Android-specific addition that is used to show when frames began in systrace
EGLAPI void EGLAPIENTRY eglBeginFrame(EGLDisplay dpy, EGLSurface surface);
@@ -260,6 +263,14 @@
bool EglManager::swapBuffers(EGLSurface surface) {
mInFrame = false;
+
+#if WAIT_FOR_GPU_COMPLETION
+ {
+ ATRACE_NAME("Finishing GPU work");
+ fence();
+ }
+#endif
+
eglSwapBuffers(mEglDisplay, surface);
EGLint err = eglGetError();
if (CC_LIKELY(err == EGL_SUCCESS)) {
@@ -278,6 +289,13 @@
return false;
}
+void EglManager::fence() {
+ EGLSyncKHR fence = eglCreateSyncKHR(mEglDisplay, EGL_SYNC_FENCE_KHR, NULL);
+ eglClientWaitSyncKHR(mEglDisplay, fence,
+ EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR);
+ eglDestroySyncKHR(mEglDisplay, fence);
+}
+
void EglManager::cancelFrame() {
mInFrame = false;
}
diff --git a/libs/hwui/renderthread/EglManager.h b/libs/hwui/renderthread/EglManager.h
index e12db3a..b1a18a9 100644
--- a/libs/hwui/renderthread/EglManager.h
+++ b/libs/hwui/renderthread/EglManager.h
@@ -55,6 +55,8 @@
void setTextureAtlas(const sp<GraphicBuffer>& buffer, int64_t* map, size_t mapSize);
+ void fence();
+
private:
friend class RenderThread;
diff --git a/location/java/android/location/Location.java b/location/java/android/location/Location.java
index fcf222b..bf3387b 100644
--- a/location/java/android/location/Location.java
+++ b/location/java/android/location/Location.java
@@ -170,6 +170,9 @@
* Converts a coordinate to a String representation. The outputType
* may be one of FORMAT_DEGREES, FORMAT_MINUTES, or FORMAT_SECONDS.
* The coordinate must be a valid double between -180.0 and 180.0.
+ * This conversion is performed in a method that is dependent on the
+ * default locale, and so is not guaranteed to round-trip with
+ * {@link #convert(String)}.
*
* @throws IllegalArgumentException if coordinate is less than
* -180.0, greater than 180.0, or is not a number.
@@ -217,7 +220,9 @@
/**
* Converts a String in one of the formats described by
* FORMAT_DEGREES, FORMAT_MINUTES, or FORMAT_SECONDS into a
- * double.
+ * double. This conversion is performed in a locale agnostic
+ * method, and so is not guaranteed to round-trip with
+ * {@link #convert(double, int)}.
*
* @throws NullPointerException if coordinate is null
* @throws IllegalArgumentException if the coordinate is not
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index 974235e..4dacacf 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -423,7 +423,9 @@
}
for (TileRecord record : mRecords) {
- record.tileView.setDual(record.tile.supportsDualTargets());
+ if (record.tileView.setDual(record.tile.supportsDualTargets())) {
+ record.tileView.handleStateChanged(record.tile.getState());
+ }
if (record.tileView.getVisibility() == GONE) continue;
final int cw = record.row == 0 ? mLargeCellWidth : mCellWidth;
final int ch = record.row == 0 ? mLargeCellHeight : mCellHeight;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
index bb353d5..16ae6b4 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
@@ -172,7 +172,7 @@
}
}
- public void setDual(boolean dual) {
+ public boolean setDual(boolean dual) {
final boolean changed = dual != mDual;
mDual = dual;
if (changed) {
@@ -199,6 +199,7 @@
setFocusable(!dual);
mDivider.setVisibility(dual ? VISIBLE : GONE);
postInvalidate();
+ return changed;
}
private void setRipple(RippleDrawable tileBackground) {
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 38a86e4..287cd6f 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1855,9 +1855,14 @@
synchronized (ActivityManagerService.this) {
if (DEBUG_PSS) Slog.d(TAG, "Collected native and kernel memory in "
+ (SystemClock.uptimeMillis()-start) + "ms");
- mProcessStats.addSysMemUsageLocked(memInfo.getCachedSizeKb(),
- memInfo.getFreeSizeKb(), memInfo.getZramTotalSizeKb(),
- memInfo.getKernelUsedSizeKb(), nativeTotalPss);
+ final long cachedKb = memInfo.getCachedSizeKb();
+ final long freeKb = memInfo.getFreeSizeKb();
+ final long zramKb = memInfo.getZramTotalSizeKb();
+ final long kernelKb = memInfo.getKernelUsedSizeKb();
+ EventLogTags.writeAmMeminfo(cachedKb*1024, freeKb*1024, zramKb*1024,
+ kernelKb*1024, nativeTotalPss*1024);
+ mProcessStats.addSysMemUsageLocked(cachedKb, freeKb, zramKb, kernelKb,
+ nativeTotalPss);
}
}
@@ -13902,9 +13907,14 @@
memInfo.readMemInfo();
if (nativeProcTotalPss > 0) {
synchronized (this) {
- mProcessStats.addSysMemUsageLocked(memInfo.getCachedSizeKb(),
- memInfo.getFreeSizeKb(), memInfo.getZramTotalSizeKb(),
- memInfo.getKernelUsedSizeKb(), nativeProcTotalPss);
+ final long cachedKb = memInfo.getCachedSizeKb();
+ final long freeKb = memInfo.getFreeSizeKb();
+ final long zramKb = memInfo.getZramTotalSizeKb();
+ final long kernelKb = memInfo.getKernelUsedSizeKb();
+ EventLogTags.writeAmMeminfo(cachedKb*1024, freeKb*1024, zramKb*1024,
+ kernelKb*1024, nativeProcTotalPss*1024);
+ mProcessStats.addSysMemUsageLocked(cachedKb, freeKb, zramKb, kernelKb,
+ nativeProcTotalPss);
}
}
if (!brief) {
@@ -17107,6 +17117,7 @@
* Record new PSS sample for a process.
*/
void recordPssSample(ProcessRecord proc, int procState, long pss, long uss, long now) {
+ EventLogTags.writeAmPss(proc.pid, proc.uid, proc.processName, pss*1024, uss*1024);
proc.lastPssTime = now;
proc.baseProcessTracker.addPss(pss, uss, true, proc.pkgList);
if (DEBUG_PSS) Slog.d(TAG, "PSS of " + proc.toShortString()
diff --git a/services/core/java/com/android/server/am/EventLogTags.logtags b/services/core/java/com/android/server/am/EventLogTags.logtags
index e43e717..9a645df 100644
--- a/services/core/java/com/android/server/am/EventLogTags.logtags
+++ b/services/core/java/com/android/server/am/EventLogTags.logtags
@@ -98,3 +98,8 @@
# Running pre boot receiver
30045 am_pre_boot (User|1|5),(Package|3)
+
+# Report collection of global memory state
+30046 am_meminfo (CachedKb|2|2),(FreeKb|2|2),(ZramKb|2|2),(KernelKb|2|2),(NativeKb|2|2)
+# Report collection of memory used by a process
+30047 am_pss (Pid|1|5),(UID|1|5),(Process Name|3),(PssKb|2|2),(UssKb|2|2)
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java
index ce52920..a8f6954 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java
@@ -55,10 +55,6 @@
mService.sendCecCommand(HdmiCecMessageBuilder.buildDeviceVendorIdCommand(
mAddress, mService.getVendorId()));
startQueuedActions();
-
- // Switch TV input after bootup.
- setActiveSource(true);
- maySendActiveSource(Constants.ADDR_TV);
}
@Override
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java
index a59505c..07476e3 100644
--- a/telephony/java/android/telephony/PhoneNumberUtils.java
+++ b/telephony/java/android/telephony/PhoneNumberUtils.java
@@ -39,8 +39,6 @@
import android.util.SparseIntArray;
import static com.android.internal.telephony.PhoneConstants.SUBSCRIPTION_KEY;
-import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY;
-import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY;
import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_IDP_STRING;
import java.util.Locale;
@@ -2200,8 +2198,8 @@
if (!TextUtils.isEmpty(dialStr)) {
if (isReallyDialable(dialStr.charAt(0)) &&
isNonSeparator(dialStr)) {
- String currIso = SystemProperties.get(PROPERTY_OPERATOR_ISO_COUNTRY, "");
- String defaultIso = SystemProperties.get(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, "");
+ String currIso = TelephonyManager.getDefault().getNetworkCountryIso();
+ String defaultIso = TelephonyManager.getDefault().getSimCountryIso();
if (!TextUtils.isEmpty(currIso) && !TextUtils.isEmpty(defaultIso)) {
return cdmaCheckAndProcessPlusCodeByNumberFormat(dialStr,
getFormatTypeFromCountryCode(currIso),
@@ -2223,7 +2221,7 @@
public static String cdmaCheckAndProcessPlusCodeForSms(String dialStr) {
if (!TextUtils.isEmpty(dialStr)) {
if (isReallyDialable(dialStr.charAt(0)) && isNonSeparator(dialStr)) {
- String defaultIso = SystemProperties.get(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, "");
+ String defaultIso = TelephonyManager.getDefault().getSimCountryIso();
if (!TextUtils.isEmpty(defaultIso)) {
int format = getFormatTypeFromCountryCode(defaultIso);
return cdmaCheckAndProcessPlusCodeByNumberFormat(dialStr, format, format);
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index c67629d..aca94e9 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -1101,9 +1101,7 @@
// What else can we do?
return false;
}
- // FIXME: use better way to get roaming status instead of reading from system property
- return Boolean.parseBoolean(TelephonyManager.getTelephonyProperty(phoneId,
- TelephonyProperties.PROPERTY_OPERATOR_ISROAMING, null));
+ return TelephonyManager.getDefault().isNetworkRoaming(subId);
}
/**
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 339fc6d..ba5a679 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -1077,7 +1077,7 @@
* on a CDMA network).
*/
public String getNetworkOperator() {
- return getNetworkOperator(getDefaultSubscription());
+ return getNetworkOperatorForPhone(getDefaultPhone());
}
/**
@@ -1091,8 +1091,23 @@
* @param subId
*/
/** {@hide} */
- public String getNetworkOperator(int subId) {
+ public String getNetworkOperatorForSubscription(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
+ return getNetworkOperatorForPhone(phoneId);
+ }
+
+ /**
+ * Returns the numeric name (MCC+MNC) of current registered operator
+ * for a particular subscription.
+ * <p>
+ * Availability: Only when user is registered to a network. Result may be
+ * unreliable on CDMA networks (use {@link #getPhoneType()} to determine if
+ * on a CDMA network).
+ *
+ * @param phoneId
+ * @hide
+ **/
+ public String getNetworkOperatorForPhone(int phoneId) {
return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, "");
}
@@ -1130,7 +1145,7 @@
* on a CDMA network).
*/
public String getNetworkCountryIso() {
- return getNetworkCountryIso(getDefaultSubscription());
+ return getNetworkCountryIsoForPhone(getDefaultPhone());
}
/**
@@ -1144,8 +1159,23 @@
* @param subId for which Network CountryIso is returned
*/
/** {@hide} */
- public String getNetworkCountryIso(int subId) {
+ public String getNetworkCountryIsoForSubscription(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
+ return getNetworkCountryIsoForPhone(phoneId);
+ }
+
+ /**
+ * Returns the ISO country code equivalent of the current registered
+ * operator's MCC (Mobile Country Code) of a subscription.
+ * <p>
+ * Availability: Only when user is registered to a network. Result may be
+ * unreliable on CDMA networks (use {@link #getPhoneType()} to determine if
+ * on a CDMA network).
+ *
+ * @param phoneId for which Network CountryIso is returned
+ */
+ /** {@hide} */
+ public String getNetworkCountryIsoForPhone(int phoneId) {
return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, "");
}
@@ -1537,6 +1567,34 @@
* @see #getSimState
*/
public String getSimOperator() {
+ return getSimOperatorNumeric();
+ }
+
+ /**
+ * Returns the MCC+MNC (mobile country code + mobile network code) of the
+ * provider of the SIM. 5 or 6 decimal digits.
+ * <p>
+ * Availability: SIM state must be {@link #SIM_STATE_READY}
+ *
+ * @see #getSimState
+ *
+ * @param subId for which SimOperator is returned
+ * @hide
+ */
+ public String getSimOperator(int subId) {
+ return getSimOperatorNumericForSubscription(subId);
+ }
+
+ /**
+ * Returns the MCC+MNC (mobile country code + mobile network code) of the
+ * provider of the SIM. 5 or 6 decimal digits.
+ * <p>
+ * Availability: SIM state must be {@link #SIM_STATE_READY}
+ *
+ * @see #getSimState
+ * @hide
+ */
+ public String getSimOperatorNumeric() {
int subId = SubscriptionManager.getDefaultDataSubId();
if (!SubscriptionManager.isUsableSubIdValue(subId)) {
subId = SubscriptionManager.getDefaultSmsSubId();
@@ -1547,8 +1605,8 @@
}
}
}
- Rlog.d(TAG, "getSimOperator(): default subId=" + subId);
- return getSimOperator(subId);
+ Rlog.d(TAG, "getSimOperatorNumeric(): default subId=" + subId);
+ return getSimOperatorNumericForSubscription(subId);
}
/**
@@ -1560,14 +1618,24 @@
* @see #getSimState
*
* @param subId for which SimOperator is returned
+ * @hide
*/
- /** {@hide} */
- public String getSimOperator(int subId) {
+ public String getSimOperatorNumericForSubscription(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
- String operator = getTelephonyProperty(phoneId,
+ return getSimOperatorNumericForPhone(phoneId);
+ }
+
+ /**
+ * Returns the MCC+MNC (mobile country code + mobile network code) of the
+ * provider of the SIM for a particular subscription. 5 or 6 decimal digits.
+ * <p>
+ *
+ * @param phoneId for which SimOperator is returned
+ * @hide
+ */
+ public String getSimOperatorNumericForPhone(int phoneId) {
+ return getTelephonyProperty(phoneId,
TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "");
- Rlog.d(TAG, "getSimOperator: subId=" + subId + " operator=" + operator);
- return operator;
}
/**
@@ -1578,7 +1646,7 @@
* @see #getSimState
*/
public String getSimOperatorName() {
- return getSimOperatorName(getDefaultSubscription());
+ return getSimOperatorNameForPhone(getDefaultPhone());
}
/**
@@ -1589,30 +1657,61 @@
* @see #getSimState
*
* @param subId for which SimOperatorName is returned
+ * @hide
*/
- /** {@hide} */
- public String getSimOperatorName(int subId) {
+ public String getSimOperatorNameForSubscription(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
- return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA, "");
+ return getSimOperatorNameForPhone(phoneId);
+ }
+
+ /**
+ * Returns the Service Provider Name (SPN).
+ *
+ * @hide
+ */
+ public String getSimOperatorNameForPhone(int phoneId) {
+ return getTelephonyProperty(phoneId,
+ TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA, "");
}
/**
* Returns the ISO country code equivalent for the SIM provider's country code.
*/
public String getSimCountryIso() {
- return getSimCountryIso(getDefaultSubscription());
+ return getSimCountryIsoForPhone(getDefaultPhone());
}
/**
* Returns the ISO country code equivalent for the SIM provider's country code.
*
* @param subId for which SimCountryIso is returned
+ *
+ * @hide
*/
- /** {@hide} */
public String getSimCountryIso(int subId) {
+ return getSimCountryIsoForSubscription(subId);
+ }
+
+ /**
+ * Returns the ISO country code equivalent for the SIM provider's country code.
+ *
+ * @param subId for which SimCountryIso is returned
+ *
+ * @hide
+ */
+ public String getSimCountryIsoForSubscription(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
- return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY,
- "");
+ return getSimCountryIsoForPhone(phoneId);
+ }
+
+ /**
+ * Returns the ISO country code equivalent for the SIM provider's country code.
+ *
+ * @hide
+ */
+ public String getSimCountryIsoForPhone(int phoneId) {
+ return getTelephonyProperty(phoneId,
+ TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY, "");
}
/**
@@ -3677,4 +3776,344 @@
return false;
}
}
+
+ /**
+ * Set TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC for the default phone.
+ *
+ * @hide
+ */
+ public void setSimOperatorNumeric(String numeric) {
+ int phoneId = getDefaultPhone();
+ setSimOperatorNumericForPhone(phoneId, numeric);
+ }
+
+ /**
+ * Set TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC for the given phone.
+ *
+ * @hide
+ */
+ public void setSimOperatorNumericForPhone(int phoneId, String numeric) {
+ setTelephonyProperty(phoneId,
+ TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, numeric);
+ }
+
+ /**
+ * Set TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC for the default phone.
+ *
+ * @hide
+ */
+ public void setSimOperatorName(String name) {
+ int phoneId = getDefaultPhone();
+ setSimOperatorNameForPhone(phoneId, name);
+ }
+
+ /**
+ * Set TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC for the given phone.
+ *
+ * @hide
+ */
+ public void setSimOperatorNameForPhone(int phoneId, String name) {
+ setTelephonyProperty(phoneId,
+ TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA, name);
+ }
+
+ /**
+ * Set TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY for the default phone.
+ *
+ * @hide
+ */
+ public void setSimCountryIso(String iso) {
+ int phoneId = getDefaultPhone();
+ setSimCountryIsoForPhone(phoneId, iso);
+ }
+
+ /**
+ * Set TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY for the given phone.
+ *
+ * @hide
+ */
+ public void setSimCountryIsoForPhone(int phoneId, String iso) {
+ setTelephonyProperty(phoneId,
+ TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY, iso);
+ }
+
+ /**
+ * Set TelephonyProperties.PROPERTY_SIM_STATE for the default phone.
+ *
+ * @hide
+ */
+ public void setSimState(String state) {
+ int phoneId = getDefaultPhone();
+ setSimStateForPhone(phoneId, state);
+ }
+
+ /**
+ * Set TelephonyProperties.PROPERTY_SIM_STATE for the given phone.
+ *
+ * @hide
+ */
+ public void setSimStateForPhone(int phoneId, String state) {
+ setTelephonyProperty(phoneId,
+ TelephonyProperties.PROPERTY_SIM_STATE, state);
+ }
+
+ /**
+ * Set baseband version for the default phone.
+ *
+ * @param version baseband version
+ * @hide
+ */
+ public void setBasebandVersion(String version) {
+ int phoneId = getDefaultPhone();
+ setBasebandVersionForPhone(phoneId, version);
+ }
+
+ /**
+ * Set baseband version by phone id.
+ *
+ * @param phoneId for which baseband version is set
+ * @param version baseband version
+ * @hide
+ */
+ public void setBasebandVersionForPhone(int phoneId, String version) {
+ if (SubscriptionManager.isValidPhoneId(phoneId)) {
+ String prop = TelephonyProperties.PROPERTY_BASEBAND_VERSION +
+ ((phoneId == 0) ? "" : Integer.toString(phoneId));
+ SystemProperties.set(prop, version);
+ }
+ }
+
+ /**
+ * Set phone type for the default phone.
+ *
+ * @param type phone type
+ *
+ * @hide
+ */
+ public void setPhoneType(int type) {
+ int phoneId = getDefaultPhone();
+ setPhoneType(phoneId, type);
+ }
+
+ /**
+ * Set phone type by phone id.
+ *
+ * @param phoneId for which phone type is set
+ * @param type phone type
+ *
+ * @hide
+ */
+ public void setPhoneType(int phoneId, int type) {
+ if (SubscriptionManager.isValidPhoneId(phoneId)) {
+ TelephonyManager.setTelephonyProperty(phoneId,
+ TelephonyProperties.CURRENT_ACTIVE_PHONE, String.valueOf(type));
+ }
+ }
+
+ /**
+ * Get OTASP number schema for the default phone.
+ *
+ * @param defaultValue default value
+ * @return OTA SP number schema
+ *
+ * @hide
+ */
+ public String getOtaSpNumberSchema(String defaultValue) {
+ int phoneId = getDefaultPhone();
+ return getOtaSpNumberSchemaForPhone(phoneId, defaultValue);
+ }
+
+ /**
+ * Get OTASP number schema by phone id.
+ *
+ * @param phoneId for which OTA SP number schema is get
+ * @param defaultValue default value
+ * @return OTA SP number schema
+ *
+ * @hide
+ */
+ public String getOtaSpNumberSchemaForPhone(int phoneId, String defaultValue) {
+ if (SubscriptionManager.isValidPhoneId(phoneId)) {
+ return TelephonyManager.getTelephonyProperty(phoneId,
+ TelephonyProperties.PROPERTY_OTASP_NUM_SCHEMA, defaultValue);
+ }
+
+ return defaultValue;
+ }
+
+ /**
+ * Get SMS receive capable from system property for the default phone.
+ *
+ * @param defaultValue default value
+ * @return SMS receive capable
+ *
+ * @hide
+ */
+ public boolean getSmsReceiveCapable(boolean defaultValue) {
+ int phoneId = getDefaultPhone();
+ return getSmsReceiveCapableForPhone(phoneId, defaultValue);
+ }
+
+ /**
+ * Get SMS receive capable from system property by phone id.
+ *
+ * @param phoneId for which SMS receive capable is get
+ * @param defaultValue default value
+ * @return SMS receive capable
+ *
+ * @hide
+ */
+ public boolean getSmsReceiveCapableForPhone(int phoneId, boolean defaultValue) {
+ if (SubscriptionManager.isValidPhoneId(phoneId)) {
+ return Boolean.valueOf(TelephonyManager.getTelephonyProperty(phoneId,
+ TelephonyProperties.PROPERTY_SMS_RECEIVE, String.valueOf(defaultValue)));
+ }
+
+ return defaultValue;
+ }
+
+ /**
+ * Get SMS send capable from system property for the default phone.
+ *
+ * @param defaultValue default value
+ * @return SMS send capable
+ *
+ * @hide
+ */
+ public boolean getSmsSendCapable(boolean defaultValue) {
+ int phoneId = getDefaultPhone();
+ return getSmsSendCapableForPhone(phoneId, defaultValue);
+ }
+
+ /**
+ * Get SMS send capable from system property by phone id.
+ *
+ * @param phoneId for which SMS send capable is get
+ * @param defaultValue default value
+ * @return SMS send capable
+ *
+ * @hide
+ */
+ public boolean getSmsSendCapableForPhone(int phoneId, boolean defaultValue) {
+ if (SubscriptionManager.isValidPhoneId(phoneId)) {
+ return Boolean.valueOf(TelephonyManager.getTelephonyProperty(phoneId,
+ TelephonyProperties.PROPERTY_SMS_SEND, String.valueOf(defaultValue)));
+ }
+
+ return defaultValue;
+ }
+
+ /**
+ * Set the alphabetic name of current registered operator.
+ * @param name the alphabetic name of current registered operator.
+ * @hide
+ */
+ public void setNetworkOperatorName(String name) {
+ int phoneId = getDefaultPhone();
+ setNetworkOperatorNameForPhone(phoneId, name);
+ }
+
+ /**
+ * Set the alphabetic name of current registered operator.
+ * @param phoneId which phone you want to set
+ * @param name the alphabetic name of current registered operator.
+ * @hide
+ */
+ public void setNetworkOperatorNameForPhone(int phoneId, String name) {
+ if (SubscriptionManager.isValidPhoneId(phoneId)) {
+ setTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_ALPHA, name);
+ }
+ }
+
+ /**
+ * Set the numeric name (MCC+MNC) of current registered operator.
+ * @param operator the numeric name (MCC+MNC) of current registered operator
+ * @hide
+ */
+ public void setNetworkOperatorNumeric(String numeric) {
+ int phoneId = getDefaultPhone();
+ setNetworkOperatorNumericForPhone(phoneId, numeric);
+ }
+
+ /**
+ * Set the numeric name (MCC+MNC) of current registered operator.
+ * @param phoneId for which phone type is set
+ * @param operator the numeric name (MCC+MNC) of current registered operator
+ * @hide
+ */
+ public void setNetworkOperatorNumericForPhone(int phoneId, String numeric) {
+ setTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, numeric);
+ }
+
+ /**
+ * Set roaming state of the current network, for GSM purposes.
+ * @param isRoaming is network in romaing state or not
+ * @hide
+ */
+ public void setNetworkRoaming(boolean isRoaming) {
+ int phoneId = getDefaultPhone();
+ setNetworkRoamingForPhone(phoneId, isRoaming);
+ }
+
+ /**
+ * Set roaming state of the current network, for GSM purposes.
+ * @param phoneId which phone you want to set
+ * @param isRoaming is network in romaing state or not
+ * @hide
+ */
+ public void setNetworkRoamingForPhone(int phoneId, boolean isRoaming) {
+ if (SubscriptionManager.isValidPhoneId(phoneId)) {
+ setTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_ISROAMING,
+ isRoaming ? "true" : "false");
+ }
+ }
+
+ /**
+ * Set the ISO country code equivalent of the current registered
+ * operator's MCC (Mobile Country Code).
+ * @param iso the ISO country code equivalent of the current registered
+ * @hide
+ */
+ public void setNetworkCountryIso(String iso) {
+ int phoneId = getDefaultPhone();
+ setNetworkCountryIsoForPhone(phoneId, iso);
+ }
+
+ /**
+ * Set the ISO country code equivalent of the current registered
+ * operator's MCC (Mobile Country Code).
+ * @param phoneId which phone you want to set
+ * @param iso the ISO country code equivalent of the current registered
+ * @hide
+ */
+ public void setNetworkCountryIsoForPhone(int phoneId, String iso) {
+ if (SubscriptionManager.isValidPhoneId(phoneId)) {
+ setTelephonyProperty(phoneId,
+ TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, iso);
+ }
+ }
+
+ /**
+ * Set the network type currently in use on the device for data transmission.
+ * @param type the network type currently in use on the device for data transmission
+ * @hide
+ */
+ public void setDataNetworkType(int type) {
+ int phoneId = getDefaultPhone();
+ setDataNetworkTypeForPhone(phoneId, type);
+ }
+
+ /**
+ * Set the network type currently in use on the device for data transmission.
+ * @param phoneId which phone you want to set
+ * @param type the network type currently in use on the device for data transmission
+ * @hide
+ */
+ public void setDataNetworkTypeForPhone(int phoneId, int type) {
+ if (SubscriptionManager.isValidPhoneId(phoneId)) {
+ setTelephonyProperty(phoneId,
+ TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
+ ServiceState.rilRadioTechnologyToString(type));
+ }
+ }
}