From 66de282468c51f9dac25b05593775e97663260f6 Mon Sep 17 00:00:00 2001 From: Ruijie Bai Date: Mon, 13 Aug 2018 15:14:27 +0800 Subject: [PATCH] Returns null not empty string if MEID is not available TelephonyManager#getMeid is defined to return null if MEID is not available. However, it may return an empty string. Because Modem returns an empty string if a device doesn't support CDMA. Therefore, change to return null if MEID is empty. Test: cts-tradefed run cts -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement Bug: 140472124 Change-Id: I822c352854516e898bbe3d7a6710ecb085991b1b --- telephony/java/android/telephony/TelephonyManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 7e6e8f4024d9e..387e3aed941a1 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -1812,7 +1812,12 @@ public class TelephonyManager { if (telephony == null) return null; try { - return telephony.getMeidForSlot(slotIndex, getOpPackageName()); + String meid = telephony.getMeidForSlot(slotIndex, getOpPackageName()); + if (TextUtils.isEmpty(meid)) { + Log.d(TAG, "getMeid: return null because MEID is not available"); + return null; + } + return meid; } catch (RemoteException ex) { return null; } catch (NullPointerException ex) {