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
This commit is contained in:
Ruijie Bai
2018-08-13 15:14:27 +08:00
committed by takeshi tanigawa
parent 0e6683ef7e
commit 66de282468

View File

@@ -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) {