Loading src/java/com/android/internal/telephony/CarrierKeyDownloadManager.java +34 −12 Original line number Diff line number Diff line Loading @@ -146,9 +146,9 @@ public class CarrierKeyDownloadManager extends Handler { .createForSubscriptionId(mPhone.getSubId()); if (Flags.imsiKeyRetryDownloadOnPhoneUnlock()) { mKeyguardManager = mContext.getSystemService(KeyguardManager.class); } else { mUserManager = mContext.getSystemService(UserManager.class); } mUserManager = mContext.getSystemService(UserManager.class); CarrierConfigManager carrierConfigManager = mContext.getSystemService( CarrierConfigManager.class); // Callback which directly handle config change should be executed on handler thread Loading Loading @@ -180,13 +180,19 @@ public class CarrierKeyDownloadManager extends Handler { updateSimOperator(); // If device is screen locked do not proceed to handle // EVENT_ALARM_OR_CONFIG_CHANGE if (mKeyguardManager.isDeviceLocked()) { logd("Device is Locked"); printDeviceLockStatus(); if (Flags.ignoreCarrieridResetForSimRemoval()) { if (!mUserManager.isUserUnlocked()) { mIsRequiredToHandleUnlock = true; } else { return; } } else if (mKeyguardManager.isDeviceLocked()) { mIsRequiredToHandleUnlock = true; return; } logd("Carrier Config changed: slotIndex=" + slotIndex); sendEmptyMessage(EVENT_ALARM_OR_CONFIG_CHANGE); } } } else { boolean isUserUnlocked = mUserManager.isUserUnlocked(); Loading @@ -205,6 +211,11 @@ public class CarrierKeyDownloadManager extends Handler { mConnectivityManager = mContext.getSystemService(ConnectivityManager.class); } private void printDeviceLockStatus() { logd(" Device Status: isDeviceLocked = " + mKeyguardManager.isDeviceLocked() + " iss User unlocked = " + mUserManager.isUserUnlocked()); } // TODO remove this method upon imsiKeyRetryDownloadOnPhoneUnlock enabled. private final BroadcastReceiver mUserUnlockedReceiver = new BroadcastReceiver() { @Override Loading Loading @@ -313,11 +324,16 @@ public class CarrierKeyDownloadManager extends Handler { if (downloadStartedSuccessfully) { unregisterDefaultNetworkCb(slotIndex); } else { // If download fails due to the device lock, we will reattempt once the // device is unlocked. // If download fails due to the device user lock, we will reattempt once // the device is unlocked. if (Flags.ignoreCarrieridResetForSimRemoval()) { mIsRequiredToHandleUnlock = !mUserManager.isUserUnlocked(); } else { mIsRequiredToHandleUnlock = mKeyguardManager.isDeviceLocked(); } loge("hasActiveDataConnection = " + hasActiveDataNetwork + " isDeviceLocked = " + mIsRequiredToHandleUnlock); + " isDeviceUserLocked = " + mIsRequiredToHandleUnlock); if (!hasActiveDataNetwork) { registerDefaultNetworkCb(slotIndex); } Loading Loading @@ -544,14 +560,19 @@ public class CarrierKeyDownloadManager extends Handler { carrierKeyDownloadIdentifier); } parseJsonAndPersistKey(jsonStr, mccMnc, carrierId); logd("Completed downloading keys"); } catch (Exception e) { loge( "Error in download:" + carrierKeyDownloadIdentifier + ". " + e); } finally { mDownloadManager.remove(carrierKeyDownloadIdentifier); } } else { loge("Download Failed reason = " + cursor.getInt(columnIndex) + "Failed Status reason" + cursor.getInt( cursor.getColumnIndex(DownloadManager.COLUMN_REASON))); printDeviceLockStatus(); } logd("Completed downloading keys"); } cursor.close(); } Loading Loading @@ -802,6 +823,7 @@ public class CarrierKeyDownloadManager extends Handler { } catch (Exception e) { loge( "exception trying to download key from url: " + mURL + ", Exception = " + e.getMessage()); printDeviceLockStatus(); return false; } return true; Loading Loading
src/java/com/android/internal/telephony/CarrierKeyDownloadManager.java +34 −12 Original line number Diff line number Diff line Loading @@ -146,9 +146,9 @@ public class CarrierKeyDownloadManager extends Handler { .createForSubscriptionId(mPhone.getSubId()); if (Flags.imsiKeyRetryDownloadOnPhoneUnlock()) { mKeyguardManager = mContext.getSystemService(KeyguardManager.class); } else { mUserManager = mContext.getSystemService(UserManager.class); } mUserManager = mContext.getSystemService(UserManager.class); CarrierConfigManager carrierConfigManager = mContext.getSystemService( CarrierConfigManager.class); // Callback which directly handle config change should be executed on handler thread Loading Loading @@ -180,13 +180,19 @@ public class CarrierKeyDownloadManager extends Handler { updateSimOperator(); // If device is screen locked do not proceed to handle // EVENT_ALARM_OR_CONFIG_CHANGE if (mKeyguardManager.isDeviceLocked()) { logd("Device is Locked"); printDeviceLockStatus(); if (Flags.ignoreCarrieridResetForSimRemoval()) { if (!mUserManager.isUserUnlocked()) { mIsRequiredToHandleUnlock = true; } else { return; } } else if (mKeyguardManager.isDeviceLocked()) { mIsRequiredToHandleUnlock = true; return; } logd("Carrier Config changed: slotIndex=" + slotIndex); sendEmptyMessage(EVENT_ALARM_OR_CONFIG_CHANGE); } } } else { boolean isUserUnlocked = mUserManager.isUserUnlocked(); Loading @@ -205,6 +211,11 @@ public class CarrierKeyDownloadManager extends Handler { mConnectivityManager = mContext.getSystemService(ConnectivityManager.class); } private void printDeviceLockStatus() { logd(" Device Status: isDeviceLocked = " + mKeyguardManager.isDeviceLocked() + " iss User unlocked = " + mUserManager.isUserUnlocked()); } // TODO remove this method upon imsiKeyRetryDownloadOnPhoneUnlock enabled. private final BroadcastReceiver mUserUnlockedReceiver = new BroadcastReceiver() { @Override Loading Loading @@ -313,11 +324,16 @@ public class CarrierKeyDownloadManager extends Handler { if (downloadStartedSuccessfully) { unregisterDefaultNetworkCb(slotIndex); } else { // If download fails due to the device lock, we will reattempt once the // device is unlocked. // If download fails due to the device user lock, we will reattempt once // the device is unlocked. if (Flags.ignoreCarrieridResetForSimRemoval()) { mIsRequiredToHandleUnlock = !mUserManager.isUserUnlocked(); } else { mIsRequiredToHandleUnlock = mKeyguardManager.isDeviceLocked(); } loge("hasActiveDataConnection = " + hasActiveDataNetwork + " isDeviceLocked = " + mIsRequiredToHandleUnlock); + " isDeviceUserLocked = " + mIsRequiredToHandleUnlock); if (!hasActiveDataNetwork) { registerDefaultNetworkCb(slotIndex); } Loading Loading @@ -544,14 +560,19 @@ public class CarrierKeyDownloadManager extends Handler { carrierKeyDownloadIdentifier); } parseJsonAndPersistKey(jsonStr, mccMnc, carrierId); logd("Completed downloading keys"); } catch (Exception e) { loge( "Error in download:" + carrierKeyDownloadIdentifier + ". " + e); } finally { mDownloadManager.remove(carrierKeyDownloadIdentifier); } } else { loge("Download Failed reason = " + cursor.getInt(columnIndex) + "Failed Status reason" + cursor.getInt( cursor.getColumnIndex(DownloadManager.COLUMN_REASON))); printDeviceLockStatus(); } logd("Completed downloading keys"); } cursor.close(); } Loading Loading @@ -802,6 +823,7 @@ public class CarrierKeyDownloadManager extends Handler { } catch (Exception e) { loge( "exception trying to download key from url: " + mURL + ", Exception = " + e.getMessage()); printDeviceLockStatus(); return false; } return true; Loading