Merge "Check null for before using LockSettingsService" am: 964fccfefd
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1674887 Change-Id: I90dee9936f4ad8ef17fcb4850e0e29de63411416
This commit is contained in:
@@ -27,6 +27,7 @@ import static android.os.UserHandle.USER_SYSTEM;
|
|||||||
import static android.ota.nano.OtaPackageMetadata.ApexMetadata;
|
import static android.ota.nano.OtaPackageMetadata.ApexMetadata;
|
||||||
|
|
||||||
import static com.android.internal.widget.LockSettingsInternal.ARM_REBOOT_ERROR_NONE;
|
import static com.android.internal.widget.LockSettingsInternal.ARM_REBOOT_ERROR_NONE;
|
||||||
|
import static com.android.internal.widget.LockSettingsInternal.ARM_REBOOT_ERROR_NO_PROVIDER;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.apex.CompressedApexInfo;
|
import android.apex.CompressedApexInfo;
|
||||||
@@ -398,7 +399,13 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void onSystemServicesReady() {
|
void onSystemServicesReady() {
|
||||||
mInjector.getLockSettingsService().setRebootEscrowListener(this);
|
LockSettingsInternal lockSettings = mInjector.getLockSettingsService();
|
||||||
|
if (lockSettings == null) {
|
||||||
|
Slog.e(TAG, "Failed to get lock settings service, skipping set"
|
||||||
|
+ " RebootEscrowListener");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lockSettings.setRebootEscrowListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
@@ -564,12 +571,18 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
|
|||||||
case ROR_NEED_PREPARATION:
|
case ROR_NEED_PREPARATION:
|
||||||
final long origId = Binder.clearCallingIdentity();
|
final long origId = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
boolean result = mInjector.getLockSettingsService().prepareRebootEscrow();
|
LockSettingsInternal lockSettings = mInjector.getLockSettingsService();
|
||||||
// Clear the RoR preparation state if lock settings reports an failure.
|
if (lockSettings == null) {
|
||||||
if (!result) {
|
Slog.e(TAG, "Failed to get lock settings service, skipping"
|
||||||
clearRoRPreparationState();
|
+ " prepareRebootEscrow");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return result;
|
// Clear the RoR preparation state if lock settings reports an failure.
|
||||||
|
if (!lockSettings.prepareRebootEscrow()) {
|
||||||
|
clearRoRPreparationState();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(origId);
|
Binder.restoreCallingIdentity(origId);
|
||||||
}
|
}
|
||||||
@@ -684,7 +697,14 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
|
|||||||
case ROR_REQUESTED_NEED_CLEAR:
|
case ROR_REQUESTED_NEED_CLEAR:
|
||||||
final long origId = Binder.clearCallingIdentity();
|
final long origId = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
return mInjector.getLockSettingsService().clearRebootEscrow();
|
LockSettingsInternal lockSettings = mInjector.getLockSettingsService();
|
||||||
|
if (lockSettings == null) {
|
||||||
|
Slog.e(TAG, "Failed to get lock settings service, skipping"
|
||||||
|
+ " clearRebootEscrow");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lockSettings.clearRebootEscrow();
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(origId);
|
Binder.restoreCallingIdentity(origId);
|
||||||
}
|
}
|
||||||
@@ -778,7 +798,15 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
|
|||||||
final long origId = Binder.clearCallingIdentity();
|
final long origId = Binder.clearCallingIdentity();
|
||||||
int providerErrorCode;
|
int providerErrorCode;
|
||||||
try {
|
try {
|
||||||
providerErrorCode = mInjector.getLockSettingsService().armRebootEscrow();
|
LockSettingsInternal lockSettings = mInjector.getLockSettingsService();
|
||||||
|
if (lockSettings == null) {
|
||||||
|
Slog.e(TAG, "Failed to get lock settings service, skipping"
|
||||||
|
+ " armRebootEscrow");
|
||||||
|
return new RebootPreparationError(
|
||||||
|
RESUME_ON_REBOOT_REBOOT_ERROR_PROVIDER_PREPARATION_FAILURE,
|
||||||
|
ARM_REBOOT_ERROR_NO_PROVIDER);
|
||||||
|
}
|
||||||
|
providerErrorCode = lockSettings.armRebootEscrow();
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(origId);
|
Binder.restoreCallingIdentity(origId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user