automatically extend single compound entry logs

This commit is contained in:
Vincent Breitmoser 2014-10-08 15:14:35 +02:00
parent adcc07ca65
commit 2d438fbc27
2 changed files with 14 additions and 14 deletions

View File

@ -313,12 +313,7 @@ public class KeychainIntentService extends IntentService implements Progressable
DecryptVerifyResult decryptVerifyResult = builder.build().execute(); DecryptVerifyResult decryptVerifyResult = builder.build().execute();
resultData.putParcelable(DecryptVerifyResult.EXTRA_RESULT, decryptVerifyResult); sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, decryptVerifyResult);
/* Output */
Log.logDebugBundle(resultData, "resultData");
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, resultData);
} catch (Exception e) { } catch (Exception e) {
sendErrorToHandler(e); sendErrorToHandler(e);
} }
@ -512,11 +507,7 @@ public class KeychainIntentService extends IntentService implements Progressable
// If the edit operation didn't succeed, exit here // If the edit operation didn't succeed, exit here
if (!modifyResult.success()) { if (!modifyResult.success()) {
// always return SaveKeyringResult, so create one out of the EditKeyResult // always return SaveKeyringResult, so create one out of the EditKeyResult
SaveKeyringResult saveResult = new SaveKeyringResult( sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, modifyResult);
SaveKeyringResult.RESULT_ERROR,
modifyResult.getLog(),
null);
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, saveResult);
return; return;
} }
@ -530,9 +521,9 @@ public class KeychainIntentService extends IntentService implements Progressable
log.add(LogType.MSG_OPERATION_CANCELLED, 0); log.add(LogType.MSG_OPERATION_CANCELLED, 0);
} }
// If so, just stop without saving // If so, just stop without saving
SaveKeyringResult saveResult = new SaveKeyringResult( modifyResult = new EditKeyResult(
SaveKeyringResult.RESULT_CANCELLED, log, null); EditKeyResult.RESULT_CANCELLED, log, null);
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, saveResult); sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, modifyResult);
return; return;
} }

View File

@ -93,6 +93,11 @@ public abstract class OperationResult implements Parcelable {
} }
public OperationLog getLog() { public OperationLog getLog() {
// If there is only a single entry, and it's a compound one, return that log
if (mLog.isSingleCompound()) {
return ((SubLogEntryParcel) mLog.getFirst()).getSubResult().getLog();
}
// Otherwse, return our regular log
return mLog; return mLog;
} }
@ -644,6 +649,10 @@ public abstract class OperationResult implements Parcelable {
mParcels.add(new SubLogEntryParcel(subResult, subLog.getFirst().mType, indent, subLog.getFirst().mParameters)); mParcels.add(new SubLogEntryParcel(subResult, subLog.getFirst().mType, indent, subLog.getFirst().mParameters));
} }
boolean isSingleCompound() {
return mParcels.size() == 1 && getFirst() instanceof SubLogEntryParcel;
}
public void clear() { public void clear() {
mParcels.clear(); mParcels.clear();
} }