From 5925cd6bfc92185dec4208217f8ef277492a7dc6 Mon Sep 17 00:00:00 2001 From: francescotescari <36578133+francescotescari@users.noreply.github.com> Date: Thu, 25 Mar 2021 09:21:39 +0100 Subject: [PATCH] remove feedback feature in open source code --- LiveFeedback.proto | 28 - .../com/xiaomitool/v2/engine/ToolManager.java | 13 +- .../v2/engine/actions/ActionsDynamic.java | 15 - .../v2/engine/actions/ActionsStatic.java | 2 - .../com/xiaomitool/v2/gui/WindowManager.java | 2 - .../v2/gui/controller/SettingsController.java | 22 +- .../v2/logging/feedback/LiveFeedback.java | 1657 ----------------- .../v2/logging/feedback/LiveFeedbackEasy.java | 145 -- .../v2/logging/feedback/LogSender.java | 208 --- .../v2/procedure/ProcedureRunner.java | 9 +- .../v2/procedure/install/GenericInstall.java | 3 - 11 files changed, 9 insertions(+), 2095 deletions(-) delete mode 100644 LiveFeedback.proto delete mode 100644 src/main/java/com/xiaomitool/v2/logging/feedback/LiveFeedback.java delete mode 100644 src/main/java/com/xiaomitool/v2/logging/feedback/LiveFeedbackEasy.java delete mode 100644 src/main/java/com/xiaomitool/v2/logging/feedback/LogSender.java diff --git a/LiveFeedback.proto b/LiveFeedback.proto deleted file mode 100644 index 811c672..0000000 --- a/LiveFeedback.proto +++ /dev/null @@ -1,28 +0,0 @@ -syntax = "proto2"; - -package feedback; - -option java_package = "com.xiaomitool.v2.logging.feedback"; -option java_outer_classname = "LiveFeedback"; - -enum FeedbackType { - ERROR = 0; - SUCCESS = 1; - LOG = 2; - OPEN = 3; - CLOSE = 4; - } - -message Feedback { - required FeedbackType type = 1; - required int64 time = 2; - optional string quickMessage = 3; - optional string longMessage = 4; - -} - -message MultiFeedback { - repeated Feedback feedbacks = 1; - required string istanceId = 2; -} - diff --git a/src/main/java/com/xiaomitool/v2/engine/ToolManager.java b/src/main/java/com/xiaomitool/v2/engine/ToolManager.java index 9e026a3..cbdc4c4 100644 --- a/src/main/java/com/xiaomitool/v2/engine/ToolManager.java +++ b/src/main/java/com/xiaomitool/v2/engine/ToolManager.java @@ -8,8 +8,6 @@ import com.xiaomitool.v2.gui.drawable.DrawableManager; import com.xiaomitool.v2.language.Lang; import com.xiaomitool.v2.logging.Log; -import com.xiaomitool.v2.logging.feedback.LiveFeedbackEasy; -import com.xiaomitool.v2.logging.feedback.LogSender; import com.xiaomitool.v2.resources.ResourcesConst; import com.xiaomitool.v2.resources.ResourcesManager; import com.xiaomitool.v2.utility.RunnableMessage; @@ -18,10 +16,8 @@ import com.xiaomitool.v2.utility.utils.StrUtils; import com.xiaomitool.v2.utility.utils.UpdateUtils; import com.xiaomitool.v2.xiaomi.XiaomiKeystore; -import javafx.application.Application; import javafx.application.Platform; import javafx.stage.Stage; -import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; @@ -43,10 +39,6 @@ public class ToolManager { @Override public int run() throws InterruptedException { ToolManager.setOnExitAskForFeedback(false); - if (LogSender.isLogCooldown()) { - return 0; - } - ActionsStatic.ASK_FOR_FEEDBACK().run(); return 0; } }; @@ -119,9 +111,8 @@ public synchronized static void exit(int code) { return; } exiting = true; - LiveFeedbackEasy.sendClose(); saveOptions(); - LiveFeedbackEasy.runOnFeedbackSent(() -> { + Platform.runLater(() -> { for (Stage stage : activeStages) { Platform.runLater(new Runnable() { @Override @@ -139,7 +130,7 @@ public void run() { } }); System.exit(code); - }, Platform.isFxApplicationThread()); + }); } private static void saveOptions() { diff --git a/src/main/java/com/xiaomitool/v2/engine/actions/ActionsDynamic.java b/src/main/java/com/xiaomitool/v2/engine/actions/ActionsDynamic.java index 50a7474..b05aa0b 100644 --- a/src/main/java/com/xiaomitool/v2/engine/actions/ActionsDynamic.java +++ b/src/main/java/com/xiaomitool/v2/engine/actions/ActionsDynamic.java @@ -20,7 +20,6 @@ import com.xiaomitool.v2.gui.visual.*; import com.xiaomitool.v2.language.LRes; import com.xiaomitool.v2.logging.Log; -import com.xiaomitool.v2.logging.feedback.LiveFeedbackEasy; import com.xiaomitool.v2.procedure.ProcedureRunner; import com.xiaomitool.v2.procedure.RInstall; import com.xiaomitool.v2.procedure.RMessage; @@ -581,20 +580,6 @@ public static RunnableMessage START_PROCEDURE(Device device, RInstall startFromH return new RunnableMessage() { @Override public int run() throws InterruptedException { - if (startFromHere == null && device != null) { - try { - DeviceProperties properties = device.getDeviceProperties(); - HashMap logginProps = new HashMap<>(); - logginProps.put("d", String.valueOf(properties.getCodename(false))); - logginProps.put("c", String.valueOf(properties.get(DeviceProperties.CODEBASE))); - logginProps.put("v", String.valueOf(properties.get(DeviceProperties.FULL_VERSION))); - logginProps.put("bs", String.valueOf(device.getAnswers().getUnlockStatus())); - logginProps.put("sn", String.valueOf(device.getAnswers().getSerialNumber())); - logginProps.put("rg", String.valueOf(SettingsUtils.getRegion())); - LiveFeedbackEasy.sendLog("DATA", new JSONObject(logginProps).toString()); - } catch (Exception ignored) { - } - } Log.info("Starting installation part main procedure"); InstallPane installPane; ProcedureRunner thisRunner; diff --git a/src/main/java/com/xiaomitool/v2/engine/actions/ActionsStatic.java b/src/main/java/com/xiaomitool/v2/engine/actions/ActionsStatic.java index 3f3bc97..1959cc6 100644 --- a/src/main/java/com/xiaomitool/v2/engine/actions/ActionsStatic.java +++ b/src/main/java/com/xiaomitool/v2/engine/actions/ActionsStatic.java @@ -16,7 +16,6 @@ import com.xiaomitool.v2.language.LRes; import com.xiaomitool.v2.language.Lang; import com.xiaomitool.v2.logging.Log; -import com.xiaomitool.v2.logging.feedback.LiveFeedbackEasy; import com.xiaomitool.v2.procedure.install.GenericInstall; import com.xiaomitool.v2.resources.ResourcesConst; import com.xiaomitool.v2.resources.ResourcesManager; @@ -66,7 +65,6 @@ public static RunnableMessage MAIN() { System.exit(0); return 0; } - LiveFeedbackEasy.sendOpen(ResourcesConst.getLogString(), null); Log.info("Disclaimer accepted"); CHECK_FOR_UPDATES_V2().run(); REQUIRE_REGION().run(); diff --git a/src/main/java/com/xiaomitool/v2/gui/WindowManager.java b/src/main/java/com/xiaomitool/v2/gui/WindowManager.java index 73f3235..20d009d 100644 --- a/src/main/java/com/xiaomitool/v2/gui/WindowManager.java +++ b/src/main/java/com/xiaomitool/v2/gui/WindowManager.java @@ -1,7 +1,6 @@ package com.xiaomitool.v2.gui; import com.xiaomitool.v2.engine.ToolManager; -import com.xiaomitool.v2.engine.actions.ActionsStatic; import com.xiaomitool.v2.gui.controller.*; import com.xiaomitool.v2.gui.drawable.DrawableManager; import com.xiaomitool.v2.gui.fxml.FxmlManager; @@ -9,7 +8,6 @@ import com.xiaomitool.v2.gui.visual.ToastPane; import com.xiaomitool.v2.gui.visual.VisiblePane; import com.xiaomitool.v2.logging.Log; -import com.xiaomitool.v2.logging.feedback.LogSender; import com.xiaomitool.v2.utility.Pointer; import com.xiaomitool.v2.utility.RunnableMessage; import com.xiaomitool.v2.utility.SilentCompleteFuture; diff --git a/src/main/java/com/xiaomitool/v2/gui/controller/SettingsController.java b/src/main/java/com/xiaomitool/v2/gui/controller/SettingsController.java index 0d0b809..39fdd5d 100644 --- a/src/main/java/com/xiaomitool/v2/gui/controller/SettingsController.java +++ b/src/main/java/com/xiaomitool/v2/gui/controller/SettingsController.java @@ -11,38 +11,26 @@ import com.xiaomitool.v2.language.LRes; import com.xiaomitool.v2.language.Lang; import com.xiaomitool.v2.logging.Log; -import com.xiaomitool.v2.logging.feedback.LogSender; import com.xiaomitool.v2.utility.Pair; import com.xiaomitool.v2.utility.RunnableMessage; import com.xiaomitool.v2.utility.utils.SettingsUtils; import javafx.application.Platform; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; import javafx.collections.ObservableListBase; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.geometry.Pos; -import javafx.scene.Cursor; import javafx.scene.control.*; import javafx.scene.image.ImageView; -import javafx.scene.input.Clipboard; -import javafx.scene.input.ClipboardContent; -import javafx.scene.input.MouseEvent; import javafx.scene.layout.*; import javafx.scene.text.Font; import javafx.scene.text.Text; -import javafx.scene.text.TextAlignment; import javafx.stage.DirectoryChooser; -import javafx.util.Callback; import java.io.File; import java.io.IOException; import java.nio.file.Path; -import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; public class SettingsController extends DefaultController { private static final OverlayPane settingsOverlayPane = new OverlayPane(); @@ -63,6 +51,7 @@ public class SettingsController extends DefaultController { @FXML private ComboBox REGION_COMBO, LANG_COMBO; + public static PopupWindow getFeedbackPopupWindow() { if (feedbackPopup == null) { feedbackPopup = new PopupWindow(500, 400); @@ -71,11 +60,12 @@ public static PopupWindow getFeedbackPopupWindow() { TextArea textArea = new TextArea(); textArea.setPrefHeight(180); textArea.setFont(Font.font(14)); - textArea.setPromptText("Please explain your problem here.\r\nWrite in English or leave blank if you just want to send the log.\r\n" + LRes.FEEDBACK_ONLY_ONE.toEnglish()); + textArea.setPromptText("Sending feedback is not available in this build"); textArea.setTextFormatter(new TextFormatter(change -> change.getControlNewText().length() <= 500 ? change : null)); CustomButton button = new CustomButton(LRes.SEND_FEEDBACK); button.setFont(Font.font(15)); + button.setDisable(true); textArea.setFocusTraversable(false); CheckBox checkBox = new CheckBox(LRes.INCLUDE_LOG_FILES.toString()); checkBox.setSelected(true); @@ -109,9 +99,9 @@ public void run() { ToastPane feedbackToast = feedbackPopup.getToastPane(); ToastPane settingsToast = settingsToastPane; try { - if (!LogSender.uploadFeedback(text, sendLogFile)) { + /* if (!LogSender.uploadFeedback(text, sendLogFile)) { throw new Exception("Failed to uplaod the feedback, check the log file"); - } + }*/ ToolManager.setOnExitAskForFeedback(false); feedbackPopup.getController().closeWindow(); Platform.runLater(() -> settingsToast.toast(LRes.FEEDBACK_SENT.toString())); @@ -122,7 +112,7 @@ public void run() { Platform.runLater(() -> feedbackToast.toast(LRes.FEEDBACK_ERROR.toString())); } } - LogSender.cooldownCounter(button); + //LogSender.cooldownCounter(button); } }).start(); } diff --git a/src/main/java/com/xiaomitool/v2/logging/feedback/LiveFeedback.java b/src/main/java/com/xiaomitool/v2/logging/feedback/LiveFeedback.java deleted file mode 100644 index d910481..0000000 --- a/src/main/java/com/xiaomitool/v2/logging/feedback/LiveFeedback.java +++ /dev/null @@ -1,1657 +0,0 @@ -package com.xiaomitool.v2.logging.feedback; - -public final class LiveFeedback { - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_feedback_Feedback_descriptor; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_feedback_MultiFeedback_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_feedback_Feedback_fieldAccessorTable; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_feedback_MultiFeedback_fieldAccessorTable; - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - - static { - java.lang.String[] descriptorData = { - "\n\022LiveFeedback.proto\022\010feedback\"i\n\010Feedba" + - "ck\022$\n\004type\030\001 \002(\0162\026.feedback.FeedbackType" + - "\022\014\n\004time\030\002 \002(\003\022\024\n\014quickMessage\030\003 \001(\t\022\023\n\013" + - "longMessage\030\004 \001(\t\"I\n\rMultiFeedback\022%\n\tfe" + - "edbacks\030\001 \003(\0132\022.feedback.Feedback\022\021\n\tist" + - "anceId\030\002 \002(\t*D\n\014FeedbackType\022\t\n\005ERROR\020\000\022" + - "\013\n\007SUCCESS\020\001\022\007\n\003LOG\020\002\022\010\n\004OPEN\020\003\022\t\n\005CLOSE" + - "\020\004B2\n\"com.xiaomitool.v2.logging.feedback" + - "B\014LiveFeedback" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[]{ - }, assigner); - internal_static_feedback_Feedback_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_feedback_Feedback_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_feedback_Feedback_descriptor, - new java.lang.String[]{"Type", "Time", "QuickMessage", "LongMessage",}); - internal_static_feedback_MultiFeedback_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_feedback_MultiFeedback_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_feedback_MultiFeedback_descriptor, - new java.lang.String[]{"Feedbacks", "IstanceId",}); - } - - private LiveFeedback() { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - - public enum FeedbackType - implements com.google.protobuf.ProtocolMessageEnum { - ERROR(0, 0), - SUCCESS(1, 1), - LOG(2, 2), - OPEN(3, 3), - CLOSE(4, 4), - ; - public static final int ERROR_VALUE = 0; - public static final int SUCCESS_VALUE = 1; - public static final int LOG_VALUE = 2; - public static final int OPEN_VALUE = 3; - public static final int CLOSE_VALUE = 4; - private static final FeedbackType[] VALUES = values(); - private static com.google.protobuf.Internal.EnumLiteMap - internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public FeedbackType findValueByNumber(int number) { - return FeedbackType.valueOf(number); - } - }; - private final int index; - private final int value; - - FeedbackType(int index, int value) { - this.index = index; - this.value = value; - } - - public static FeedbackType valueOf(int value) { - switch (value) { - case 0: - return ERROR; - case 1: - return SUCCESS; - case 2: - return LOG; - case 3: - return OPEN; - case 4: - return CLOSE; - default: - return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return com.xiaomitool.v2.logging.feedback.LiveFeedback.getDescriptor().getEnumTypes().get(0); - } - - public static FeedbackType valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - return VALUES[desc.getIndex()]; - } - - public final int getNumber() { - return value; - } - - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(index); - } - - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - } - - public interface FeedbackOrBuilder extends - com.google.protobuf.MessageOrBuilder { - boolean hasType(); - - com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackType getType(); - - boolean hasTime(); - - long getTime(); - - boolean hasQuickMessage(); - - java.lang.String getQuickMessage(); - - com.google.protobuf.ByteString - getQuickMessageBytes(); - - boolean hasLongMessage(); - - java.lang.String getLongMessage(); - - com.google.protobuf.ByteString - getLongMessageBytes(); - } - - public interface MultiFeedbackOrBuilder extends - com.google.protobuf.MessageOrBuilder { - java.util.List - getFeedbacksList(); - - com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback getFeedbacks(int index); - - int getFeedbacksCount(); - - java.util.List - getFeedbacksOrBuilderList(); - - com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackOrBuilder getFeedbacksOrBuilder( - int index); - - boolean hasIstanceId(); - - java.lang.String getIstanceId(); - - com.google.protobuf.ByteString - getIstanceIdBytes(); - } - - public static final class Feedback extends - com.google.protobuf.GeneratedMessage implements - FeedbackOrBuilder { - public static final int TYPE_FIELD_NUMBER = 1; - public static final int TIME_FIELD_NUMBER = 2; - public static final int QUICKMESSAGE_FIELD_NUMBER = 3; - public static final int LONGMESSAGE_FIELD_NUMBER = 4; - private static final Feedback defaultInstance; - private static final long serialVersionUID = 0L; - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Feedback parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Feedback(input, extensionRegistry); - } - }; - - static { - defaultInstance = new Feedback(true); - defaultInstance.initFields(); - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - private int bitField0_; - private com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackType type_; - private long time_; - private java.lang.Object quickMessage_; - private java.lang.Object longMessage_; - private byte memoizedIsInitialized = -1; - private int memoizedSerializedSize = -1; - - private Feedback(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - - private Feedback(boolean noInit) { - this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - - private Feedback( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - int rawValue = input.readEnum(); - com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackType value = com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackType.valueOf(rawValue); - if (value == null) { - unknownFields.mergeVarintField(1, rawValue); - } else { - bitField0_ |= 0x00000001; - type_ = value; - } - break; - } - case 16: { - bitField0_ |= 0x00000002; - time_ = input.readInt64(); - break; - } - case 26: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000004; - quickMessage_ = bs; - break; - } - case 34: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000008; - longMessage_ = bs; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static Feedback getDefaultInstance() { - return defaultInstance; - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.xiaomitool.v2.logging.feedback.LiveFeedback.internal_static_feedback_Feedback_descriptor; - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { - return Builder.create(); - } - - public static Builder newBuilder(com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback prototype) { - return newBuilder().mergeFrom(prototype); - } - - public Feedback getDefaultInstanceForType() { - return defaultInstance; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.xiaomitool.v2.logging.feedback.LiveFeedback.internal_static_feedback_Feedback_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.class, com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.Builder.class); - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public boolean hasType() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackType getType() { - return type_; - } - - public boolean hasTime() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - - public long getTime() { - return time_; - } - - public boolean hasQuickMessage() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - - public java.lang.String getQuickMessage() { - java.lang.Object ref = quickMessage_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - quickMessage_ = s; - } - return s; - } - } - - public com.google.protobuf.ByteString - getQuickMessageBytes() { - java.lang.Object ref = quickMessage_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - quickMessage_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public boolean hasLongMessage() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - - public java.lang.String getLongMessage() { - java.lang.Object ref = longMessage_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - longMessage_ = s; - } - return s; - } - } - - public com.google.protobuf.ByteString - getLongMessageBytes() { - java.lang.Object ref = longMessage_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - longMessage_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private void initFields() { - type_ = com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackType.ERROR; - time_ = 0L; - quickMessage_ = ""; - longMessage_ = ""; - } - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - if (!hasType()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasTime()) { - memoizedIsInitialized = 0; - return false; - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeEnum(1, type_.getNumber()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeInt64(2, time_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeBytes(3, getQuickMessageBytes()); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - output.writeBytes(4, getLongMessageBytes()); - } - getUnknownFields().writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(1, type_.getNumber()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(2, time_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(3, getQuickMessageBytes()); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(4, getLongMessageBytes()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public Builder toBuilder() { - return newBuilder(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackOrBuilder { - private int bitField0_; - private com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackType type_ = com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackType.ERROR; - private long time_; - private java.lang.Object quickMessage_ = ""; - private java.lang.Object longMessage_ = ""; - - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.xiaomitool.v2.logging.feedback.LiveFeedback.internal_static_feedback_Feedback_descriptor; - } - - private static Builder create() { - return new Builder(); - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.xiaomitool.v2.logging.feedback.LiveFeedback.internal_static_feedback_Feedback_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.class, com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.Builder.class); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - - public Builder clear() { - super.clear(); - type_ = com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackType.ERROR; - bitField0_ = (bitField0_ & ~0x00000001); - time_ = 0L; - bitField0_ = (bitField0_ & ~0x00000002); - quickMessage_ = ""; - bitField0_ = (bitField0_ & ~0x00000004); - longMessage_ = ""; - bitField0_ = (bitField0_ & ~0x00000008); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.xiaomitool.v2.logging.feedback.LiveFeedback.internal_static_feedback_Feedback_descriptor; - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback getDefaultInstanceForType() { - return com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.getDefaultInstance(); - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback build() { - com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback buildPartial() { - com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback result = new com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.type_ = type_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.time_ = time_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.quickMessage_ = quickMessage_; - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { - to_bitField0_ |= 0x00000008; - } - result.longMessage_ = longMessage_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback) { - return mergeFrom((com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback other) { - if (other == com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.getDefaultInstance()) return this; - if (other.hasType()) { - setType(other.getType()); - } - if (other.hasTime()) { - setTime(other.getTime()); - } - if (other.hasQuickMessage()) { - bitField0_ |= 0x00000004; - quickMessage_ = other.quickMessage_; - onChanged(); - } - if (other.hasLongMessage()) { - bitField0_ |= 0x00000008; - longMessage_ = other.longMessage_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - if (!hasType()) { - return false; - } - return hasTime(); - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - public boolean hasType() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackType getType() { - return type_; - } - - public Builder setType(com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackType value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - type_ = value; - onChanged(); - return this; - } - - public Builder clearType() { - bitField0_ = (bitField0_ & ~0x00000001); - type_ = com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackType.ERROR; - onChanged(); - return this; - } - - public boolean hasTime() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - - public long getTime() { - return time_; - } - - public Builder setTime(long value) { - bitField0_ |= 0x00000002; - time_ = value; - onChanged(); - return this; - } - - public Builder clearTime() { - bitField0_ = (bitField0_ & ~0x00000002); - time_ = 0L; - onChanged(); - return this; - } - - public boolean hasQuickMessage() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - - public java.lang.String getQuickMessage() { - java.lang.Object ref = quickMessage_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - quickMessage_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - - public Builder setQuickMessage( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; - quickMessage_ = value; - onChanged(); - return this; - } - - public com.google.protobuf.ByteString - getQuickMessageBytes() { - java.lang.Object ref = quickMessage_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - quickMessage_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public Builder setQuickMessageBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; - quickMessage_ = value; - onChanged(); - return this; - } - - public Builder clearQuickMessage() { - bitField0_ = (bitField0_ & ~0x00000004); - quickMessage_ = getDefaultInstance().getQuickMessage(); - onChanged(); - return this; - } - - public boolean hasLongMessage() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - - public java.lang.String getLongMessage() { - java.lang.Object ref = longMessage_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - longMessage_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - - public Builder setLongMessage( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000008; - longMessage_ = value; - onChanged(); - return this; - } - - public com.google.protobuf.ByteString - getLongMessageBytes() { - java.lang.Object ref = longMessage_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - longMessage_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public Builder setLongMessageBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000008; - longMessage_ = value; - onChanged(); - return this; - } - - public Builder clearLongMessage() { - bitField0_ = (bitField0_ & ~0x00000008); - longMessage_ = getDefaultInstance().getLongMessage(); - onChanged(); - return this; - } - } - } - - public static final class MultiFeedback extends - com.google.protobuf.GeneratedMessage implements - MultiFeedbackOrBuilder { - public static final int FEEDBACKS_FIELD_NUMBER = 1; - public static final int ISTANCEID_FIELD_NUMBER = 2; - private static final MultiFeedback defaultInstance; - private static final long serialVersionUID = 0L; - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public MultiFeedback parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new MultiFeedback(input, extensionRegistry); - } - }; - - static { - defaultInstance = new MultiFeedback(true); - defaultInstance.initFields(); - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - private int bitField0_; - private java.util.List feedbacks_; - private java.lang.Object istanceId_; - private byte memoizedIsInitialized = -1; - private int memoizedSerializedSize = -1; - - private MultiFeedback(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - - private MultiFeedback(boolean noInit) { - this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - - private MultiFeedback( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - feedbacks_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - feedbacks_.add(input.readMessage(com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.PARSER, extensionRegistry)); - break; - } - case 18: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000001; - istanceId_ = bs; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - feedbacks_ = java.util.Collections.unmodifiableList(feedbacks_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static MultiFeedback getDefaultInstance() { - return defaultInstance; - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.xiaomitool.v2.logging.feedback.LiveFeedback.internal_static_feedback_MultiFeedback_descriptor; - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - - public static com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { - return Builder.create(); - } - - public static Builder newBuilder(com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback prototype) { - return newBuilder().mergeFrom(prototype); - } - - public MultiFeedback getDefaultInstanceForType() { - return defaultInstance; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.xiaomitool.v2.logging.feedback.LiveFeedback.internal_static_feedback_MultiFeedback_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback.class, com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback.Builder.class); - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public java.util.List getFeedbacksList() { - return feedbacks_; - } - - public java.util.List - getFeedbacksOrBuilderList() { - return feedbacks_; - } - - public int getFeedbacksCount() { - return feedbacks_.size(); - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback getFeedbacks(int index) { - return feedbacks_.get(index); - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackOrBuilder getFeedbacksOrBuilder( - int index) { - return feedbacks_.get(index); - } - - public boolean hasIstanceId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - - public java.lang.String getIstanceId() { - java.lang.Object ref = istanceId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - istanceId_ = s; - } - return s; - } - } - - public com.google.protobuf.ByteString - getIstanceIdBytes() { - java.lang.Object ref = istanceId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - istanceId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private void initFields() { - feedbacks_ = java.util.Collections.emptyList(); - istanceId_ = ""; - } - - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - if (!hasIstanceId()) { - memoizedIsInitialized = 0; - return false; - } - for (int i = 0; i < getFeedbacksCount(); i++) { - if (!getFeedbacks(i).isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - for (int i = 0; i < feedbacks_.size(); i++) { - output.writeMessage(1, feedbacks_.get(i)); - } - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeBytes(2, getIstanceIdBytes()); - } - getUnknownFields().writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - size = 0; - for (int i = 0; i < feedbacks_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, feedbacks_.get(i)); - } - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, getIstanceIdBytes()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public Builder toBuilder() { - return newBuilder(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedbackOrBuilder { - private int bitField0_; - private java.util.List feedbacks_ = - java.util.Collections.emptyList(); - private com.google.protobuf.RepeatedFieldBuilder< - com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback, com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.Builder, com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackOrBuilder> feedbacksBuilder_; - private java.lang.Object istanceId_ = ""; - - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.xiaomitool.v2.logging.feedback.LiveFeedback.internal_static_feedback_MultiFeedback_descriptor; - } - - private static Builder create() { - return new Builder(); - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.xiaomitool.v2.logging.feedback.LiveFeedback.internal_static_feedback_MultiFeedback_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback.class, com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback.Builder.class); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getFeedbacksFieldBuilder(); - } - } - - public Builder clear() { - super.clear(); - if (feedbacksBuilder_ == null) { - feedbacks_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - feedbacksBuilder_.clear(); - } - istanceId_ = ""; - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.xiaomitool.v2.logging.feedback.LiveFeedback.internal_static_feedback_MultiFeedback_descriptor; - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback getDefaultInstanceForType() { - return com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback.getDefaultInstance(); - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback build() { - com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback buildPartial() { - com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback result = new com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (feedbacksBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - feedbacks_ = java.util.Collections.unmodifiableList(feedbacks_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.feedbacks_ = feedbacks_; - } else { - result.feedbacks_ = feedbacksBuilder_.build(); - } - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000001; - } - result.istanceId_ = istanceId_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback) { - return mergeFrom((com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback other) { - if (other == com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback.getDefaultInstance()) - return this; - if (feedbacksBuilder_ == null) { - if (!other.feedbacks_.isEmpty()) { - if (feedbacks_.isEmpty()) { - feedbacks_ = other.feedbacks_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureFeedbacksIsMutable(); - feedbacks_.addAll(other.feedbacks_); - } - onChanged(); - } - } else { - if (!other.feedbacks_.isEmpty()) { - if (feedbacksBuilder_.isEmpty()) { - feedbacksBuilder_.dispose(); - feedbacksBuilder_ = null; - feedbacks_ = other.feedbacks_; - bitField0_ = (bitField0_ & ~0x00000001); - feedbacksBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getFeedbacksFieldBuilder() : null; - } else { - feedbacksBuilder_.addAllMessages(other.feedbacks_); - } - } - } - if (other.hasIstanceId()) { - bitField0_ |= 0x00000002; - istanceId_ = other.istanceId_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - if (!hasIstanceId()) { - return false; - } - for (int i = 0; i < getFeedbacksCount(); i++) { - if (!getFeedbacks(i).isInitialized()) { - return false; - } - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.xiaomitool.v2.logging.feedback.LiveFeedback.MultiFeedback) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private void ensureFeedbacksIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - feedbacks_ = new java.util.ArrayList(feedbacks_); - bitField0_ |= 0x00000001; - } - } - - public java.util.List getFeedbacksList() { - if (feedbacksBuilder_ == null) { - return java.util.Collections.unmodifiableList(feedbacks_); - } else { - return feedbacksBuilder_.getMessageList(); - } - } - - public int getFeedbacksCount() { - if (feedbacksBuilder_ == null) { - return feedbacks_.size(); - } else { - return feedbacksBuilder_.getCount(); - } - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback getFeedbacks(int index) { - if (feedbacksBuilder_ == null) { - return feedbacks_.get(index); - } else { - return feedbacksBuilder_.getMessage(index); - } - } - - public Builder setFeedbacks( - int index, com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback value) { - if (feedbacksBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureFeedbacksIsMutable(); - feedbacks_.set(index, value); - onChanged(); - } else { - feedbacksBuilder_.setMessage(index, value); - } - return this; - } - - public Builder setFeedbacks( - int index, com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.Builder builderForValue) { - if (feedbacksBuilder_ == null) { - ensureFeedbacksIsMutable(); - feedbacks_.set(index, builderForValue.build()); - onChanged(); - } else { - feedbacksBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - - public Builder addFeedbacks(com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback value) { - if (feedbacksBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureFeedbacksIsMutable(); - feedbacks_.add(value); - onChanged(); - } else { - feedbacksBuilder_.addMessage(value); - } - return this; - } - - public Builder addFeedbacks( - int index, com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback value) { - if (feedbacksBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureFeedbacksIsMutable(); - feedbacks_.add(index, value); - onChanged(); - } else { - feedbacksBuilder_.addMessage(index, value); - } - return this; - } - - public Builder addFeedbacks( - com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.Builder builderForValue) { - if (feedbacksBuilder_ == null) { - ensureFeedbacksIsMutable(); - feedbacks_.add(builderForValue.build()); - onChanged(); - } else { - feedbacksBuilder_.addMessage(builderForValue.build()); - } - return this; - } - - public Builder addFeedbacks( - int index, com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.Builder builderForValue) { - if (feedbacksBuilder_ == null) { - ensureFeedbacksIsMutable(); - feedbacks_.add(index, builderForValue.build()); - onChanged(); - } else { - feedbacksBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - - public Builder addAllFeedbacks( - java.lang.Iterable values) { - if (feedbacksBuilder_ == null) { - ensureFeedbacksIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, feedbacks_); - onChanged(); - } else { - feedbacksBuilder_.addAllMessages(values); - } - return this; - } - - public Builder clearFeedbacks() { - if (feedbacksBuilder_ == null) { - feedbacks_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - feedbacksBuilder_.clear(); - } - return this; - } - - public Builder removeFeedbacks(int index) { - if (feedbacksBuilder_ == null) { - ensureFeedbacksIsMutable(); - feedbacks_.remove(index); - onChanged(); - } else { - feedbacksBuilder_.remove(index); - } - return this; - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.Builder getFeedbacksBuilder( - int index) { - return getFeedbacksFieldBuilder().getBuilder(index); - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackOrBuilder getFeedbacksOrBuilder( - int index) { - if (feedbacksBuilder_ == null) { - return feedbacks_.get(index); - } else { - return feedbacksBuilder_.getMessageOrBuilder(index); - } - } - - public java.util.List - getFeedbacksOrBuilderList() { - if (feedbacksBuilder_ != null) { - return feedbacksBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(feedbacks_); - } - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.Builder addFeedbacksBuilder() { - return getFeedbacksFieldBuilder().addBuilder( - com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.getDefaultInstance()); - } - - public com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.Builder addFeedbacksBuilder( - int index) { - return getFeedbacksFieldBuilder().addBuilder( - index, com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.getDefaultInstance()); - } - - public java.util.List - getFeedbacksBuilderList() { - return getFeedbacksFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback, com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.Builder, com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackOrBuilder> - getFeedbacksFieldBuilder() { - if (feedbacksBuilder_ == null) { - feedbacksBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback, com.xiaomitool.v2.logging.feedback.LiveFeedback.Feedback.Builder, com.xiaomitool.v2.logging.feedback.LiveFeedback.FeedbackOrBuilder>( - feedbacks_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - feedbacks_ = null; - } - return feedbacksBuilder_; - } - - public boolean hasIstanceId() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - - public java.lang.String getIstanceId() { - java.lang.Object ref = istanceId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - istanceId_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - - public Builder setIstanceId( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - istanceId_ = value; - onChanged(); - return this; - } - - public com.google.protobuf.ByteString - getIstanceIdBytes() { - java.lang.Object ref = istanceId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - istanceId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public Builder setIstanceIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - istanceId_ = value; - onChanged(); - return this; - } - - public Builder clearIstanceId() { - bitField0_ = (bitField0_ & ~0x00000002); - istanceId_ = getDefaultInstance().getIstanceId(); - onChanged(); - return this; - } - } - } -} diff --git a/src/main/java/com/xiaomitool/v2/logging/feedback/LiveFeedbackEasy.java b/src/main/java/com/xiaomitool/v2/logging/feedback/LiveFeedbackEasy.java deleted file mode 100644 index c1164de..0000000 --- a/src/main/java/com/xiaomitool/v2/logging/feedback/LiveFeedbackEasy.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.xiaomitool.v2.logging.feedback; - -import com.xiaomitool.v2.engine.ToolManager; -import com.xiaomitool.v2.logging.Log; -import com.xiaomitool.v2.procedure.ProcedureRunner; -import com.xiaomitool.v2.procedure.install.InstallException; -import com.xiaomitool.v2.utility.WaitSemaphore; -import com.xiaomitool.v2.utility.utils.CompressUtils; -import com.xiaomitool.v2.utility.utils.StrUtils; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.time.Duration; -import java.time.Instant; -import java.util.concurrent.ConcurrentLinkedQueue; - -public class LiveFeedbackEasy { - private static final ConcurrentLinkedQueue QUEUED_FEEDBACKS = new ConcurrentLinkedQueue<>(); - private static boolean isOpen = false; - private static Instant lastFeedbackInstant = null; - private static WaitSemaphore feedbackSent = new WaitSemaphore(1); - - private LiveFeedbackEasy() { - } - - public static void sendError(String error, String additionalInfo) { - send(error, additionalInfo, LiveFeedback.FeedbackType.ERROR); - } - - public static void sendSuccess(String message, String additionalInfo) { - send(message, additionalInfo, LiveFeedback.FeedbackType.SUCCESS); - } - - public static void sendOpen(String message, String additionalInfo) { - isOpen = true; - send(message, additionalInfo, LiveFeedback.FeedbackType.OPEN); - } - - public static void sendClose() { - sendClose(null, null); - } - - public static void sendClose(String message, String additionalInfo) { - send(message, additionalInfo, LiveFeedback.FeedbackType.CLOSE); - isOpen = false; - } - - public static void sendLog(String message, String additionalInfo) { - send(message, additionalInfo, LiveFeedback.FeedbackType.LOG); - } - - public static void sendInstallException(InstallException e, ProcedureRunner runner) { - sendError(e.getCode().toString(), e.getMessage() + StrUtils.exceptionToString(e) + "\n\n" + runner.getStackStrace()); - } - - public static void waitFeedbackSent() throws InterruptedException { - feedbackSent.waitOnce(); - } - - public static void runOnFeedbackSent(Runnable runnable, boolean newThread) { - Runnable exec = new Runnable() { - @Override - public void run() { - try { - waitFeedbackSent(); - } catch (InterruptedException e) { - Log.error("Failed to wait feedbackClosure"); - } - runnable.run(); - } - }; - if (newThread) { - new Thread(exec).start(); - } else { - exec.run(); - } - } - - private static synchronized void send(String quickMessage, String additionalInfo, LiveFeedback.FeedbackType type) { - feedbackSent.setPermits(0); - feedbackSent.increase(); - if (true){ - //TODO live feedback is not wanted anymore - return; - } - - try { - if (!isOpen) { - return; - } - feedbackSent.setPermits(0); - new Thread(new Runnable() { - @Override - public void run() { - try { - LiveFeedback.MultiFeedback multiFeedback; - synchronized (QUEUED_FEEDBACKS) { - QUEUED_FEEDBACKS.add(newMessage(quickMessage, additionalInfo, type)); - boolean shouldSendNow = LiveFeedback.FeedbackType.CLOSE.equals(type) || lastFeedbackInstant == null; - if (!shouldSendNow) { - Duration duration = Duration.between(lastFeedbackInstant, Instant.now()); - if (duration.getSeconds() > 60) { - shouldSendNow = true; - } - } - if (!shouldSendNow) { - return; - } - multiFeedback = LiveFeedback.MultiFeedback.newBuilder().addAllFeedbacks(QUEUED_FEEDBACKS).setIstanceId(ToolManager.getRunningInstanceId()).build(); - QUEUED_FEEDBACKS.clear(); - } - final byte[] dataToSend = getSendableMessage(multiFeedback.toByteArray()); - LogSender.sendSingleLog(dataToSend); - } catch (Exception e) { - Log.log("LOG", "Failed to send single log: " + e.getMessage(), false); - } finally { - feedbackSent.increase(); - } - } - }).start(); - } catch (Throwable t) { - Log.warn("Failed to send live feedback: " + t.getMessage()); - } - } - - private static LiveFeedback.Feedback newMessage(String message, String additionalInfo, LiveFeedback.FeedbackType type) { - LiveFeedback.Feedback.Builder liveFeedback = LiveFeedback.Feedback.newBuilder().setTime(System.currentTimeMillis()); - if (message != null) { - liveFeedback.setQuickMessage(message); - } - if (additionalInfo != null) { - liveFeedback.setLongMessage(additionalInfo); - } - liveFeedback.setType(type); - return liveFeedback.build(); - } - - private static byte[] getSendableMessage(byte[] originalMessage) throws IOException { - byte[] compressed = CompressUtils.paddedCompress(originalMessage, 4); - int len = compressed.length - 4; - ByteBuffer buffer = ByteBuffer.wrap(compressed, 0, 4); - buffer.putInt(len); - return compressed; - } -} diff --git a/src/main/java/com/xiaomitool/v2/logging/feedback/LogSender.java b/src/main/java/com/xiaomitool/v2/logging/feedback/LogSender.java deleted file mode 100644 index 22347fb..0000000 --- a/src/main/java/com/xiaomitool/v2/logging/feedback/LogSender.java +++ /dev/null @@ -1,208 +0,0 @@ -package com.xiaomitool.v2.logging.feedback; - -import com.xiaomitool.v2.crypto.Hash; -import com.xiaomitool.v2.engine.ToolManager; -import com.xiaomitool.v2.gui.visual.CustomButton; -import com.xiaomitool.v2.inet.CustomHttpException; -import com.xiaomitool.v2.inet.CustomHttpRequest; -import com.xiaomitool.v2.inet.EasyHttp; -import com.xiaomitool.v2.inet.EasyResponse; -import com.xiaomitool.v2.language.LRes; -import com.xiaomitool.v2.logging.Debugger; -import com.xiaomitool.v2.logging.Log; -import com.xiaomitool.v2.resources.ResourcesConst; -import com.xiaomitool.v2.utility.FeedbackOutputStream; -import com.xiaomitool.v2.utility.utils.SettingsUtils; -import com.xiaomitool.v2.utility.utils.StrUtils; -import com.xiaomitool.v2.utility.utils.ThreadUtils; -import javafx.application.Platform; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.IOUtils; -import org.apache.commons.io.output.NullOutputStream; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.time.Duration; -import java.time.Instant; -import java.util.zip.Inflater; -import java.util.zip.InflaterInputStream; - -public class LogSender { - private static final String SALT_RESPONSE = "response_good"; - private static final String HOST_PATH = ToolManager.getFeedbackUrl(); - private static Instant lastSendSuccessInstant = null; - private static int WAIT_BEFORE_SENDING = 300; - private static boolean logSendCooldown; - - private static String getUploadToken() throws CustomHttpException { - return getUploadToken(ToolManager.getRunningInstanceId()); - } - - private static String getUploadToken(String instanceId) throws CustomHttpException { - if (StrUtils.isNullOrEmpty(instanceId)) { - return null; - } - String url = HOST_PATH + "/utok.php?iid=" + instanceId; - EasyResponse response = EasyHttp.get(url); - Log.log("LOG", "Feedback token request result: " + response.getCode() + " - " + response.getBody(), false); - if (!response.isAllRight()) { - return null; - } - String token = response.getBody(); - if (token.length() < 96) { - return null; - } - if (!Hash.md5Hex(instanceId + SALT_RESPONSE).equalsIgnoreCase(token.substring(0, 32))) { - return null; - } - return token.substring(32); - } - - private static boolean sendFeedback(String token, String userFeedback, Debugger feedback) throws IOException, CustomHttpException { - if (token == null || token.length() != 64) { - Log.log("LOG", "Invalid token to send log: " + token, false); - return false; - } - if (getTimeFromLastSend() != -1) { - Log.log("LOG", "Not enough time between log sending: " + getTimeFromLastSend(), false); - return false; - } - String instanceId = ToolManager.getRunningInstanceId(); - if (userFeedback != null && !userFeedback.trim().isEmpty()) { - userFeedback += "\n"; - } else { - userFeedback = null; - } - Log.log("LOG", "Sending feedback with token: " + token, false); - InputStream inputStream = null; - if (feedback == null) { - if (userFeedback != null && !userFeedback.isEmpty()) { - FeedbackOutputStream oStream = new FeedbackOutputStream(); - oStream.setUserMessage(userFeedback); - inputStream = oStream.getReadInputStream(); - } - } else { - inputStream = feedback.getFeedbackData(userFeedback); - } - String url = HOST_PATH + "/ufed.php?iid=" + instanceId + "&t=" + token; - CustomHttpRequest httpRequest = new CustomHttpRequest(url); - httpRequest.setPostData(inputStream); - if (Log.ADVANCED_LOG) { - httpRequest.setProxy("127.0.0.1", 8888); - } - httpRequest.execute(); - Log.log("LOG", "Feedback send result: " + httpRequest.getResponseCode() + " - " + httpRequest.getResponseBody(), false); - boolean res = httpRequest.getResponseCode() == 200; - if (res) { - lastSendSuccessInstant = Instant.now(); - } - return res; - } - - static boolean sendSingleLog(byte[] data) throws Exception { - String token = getUploadToken(SettingsUtils.requireHashedPCId()); - return sendSingleLog(token, data); - } - - private static boolean sendSingleLog(String token, byte[] data) throws CustomHttpException { - if (token == null || token.length() != 64) { - Log.log("LOG", "Invalid token to send log: " + token, false); - return false; - } - if (data == null || data.length < 4) { - Log.log("LOG", "Invalid length data", false); - return false; - } - String instanceId = SettingsUtils.requireHashedPCId(); - String url = HOST_PATH + "/uliv.php?iid=" + instanceId + "&t=" + token; - CustomHttpRequest httpRequest = new CustomHttpRequest(url); - httpRequest.setPostData(data); - if (Log.ADVANCED_LOG) { - httpRequest.setProxy("127.0.0.1", 8888); - } - httpRequest.execute(); - Log.log("LOG", "Feedback send result: " + httpRequest.getResponseCode() + " - " + httpRequest.getResponseBody(), false); - return httpRequest.getResponseCode() == 200; - } - - private static byte[] byteMerge(byte[]... toMerge) { - int size = 0; - for (byte[] d : toMerge) { - size += d.length; - } - byte[] result = new byte[size]; - size = 0; - for (byte[] d : toMerge) { - System.arraycopy(d, 0, result, size, d.length); - size += d.length; - } - return result; - } - - public static boolean uploadFeedback(String userFeedback, Debugger feedback) throws Exception { - String token = getUploadToken(); - return sendFeedback(token, userFeedback, feedback); - } - - public static boolean uploadFeedback(String userFeedback, boolean sendLogFile) throws Exception { - return uploadFeedback(userFeedback, sendLogFile ? Log.getDebugger() : null); - } - - public static boolean isLogCooldown() { - return logSendCooldown; - } - - public static Thread cooldownCounter(CustomButton button) { - logSendCooldown = false; - if (getTimeFromLastSend() == -1) { - Platform.runLater(() -> { - button.setText(LRes.SEND_FEEDBACK.toString()); - button.setDisable(false); - }); - } else { - logSendCooldown = true; - Thread res = new Thread(new Runnable() { - @Override - public void run() { - int seconds = 0; - while (seconds != -1) { - seconds = getTimeFromLastSend(); - if (seconds <= 0) { - break; - } - final String text = LRes.PLEASE_WAIT_X_SECONDS.toString(seconds); - Platform.runLater(() -> { - button.setText(text); - button.setDisable(true); - }); - ThreadUtils.sleepSilently(1000); - } - logSendCooldown = false; - Platform.runLater(() -> { - button.setText(LRes.SEND_FEEDBACK.toString()); - button.setDisable(false); - }); - } - }); - res.start(); - return res; - } - return null; - } - - private static int getTimeFromLastSend() { - try { - if (lastSendSuccessInstant == null) { - return -1; - } - Duration duration = Duration.between(lastSendSuccessInstant, Instant.now()); - long seconds = duration.getSeconds(); - return seconds < WAIT_BEFORE_SENDING ? (WAIT_BEFORE_SENDING - Math.toIntExact(seconds)) : -1; - } catch (Exception e) { - return -1; - } - } -} diff --git a/src/main/java/com/xiaomitool/v2/procedure/ProcedureRunner.java b/src/main/java/com/xiaomitool/v2/procedure/ProcedureRunner.java index 2f822a4..031e604 100644 --- a/src/main/java/com/xiaomitool/v2/procedure/ProcedureRunner.java +++ b/src/main/java/com/xiaomitool/v2/procedure/ProcedureRunner.java @@ -4,11 +4,9 @@ import com.xiaomitool.v2.adb.device.DeviceManager; import com.xiaomitool.v2.gui.visual.InstallPane; import com.xiaomitool.v2.logging.Log; -import com.xiaomitool.v2.logging.feedback.LiveFeedbackEasy; import com.xiaomitool.v2.procedure.install.GenericInstall; import com.xiaomitool.v2.procedure.install.InstallException; import com.xiaomitool.v2.rom.Installable; -import com.xiaomitool.v2.utility.CommandClass; import com.xiaomitool.v2.utility.CommandClass.Command; import com.xiaomitool.v2.utility.utils.StrUtils; import javafx.scene.layout.Pane; @@ -25,7 +23,6 @@ public class ProcedureRunner extends GuiListener { private GuiListenerAbstract listener; private Pane afterExeptionPane; private RInstall runnableInstall; - private boolean sendFeedback = true; private RInstall restarter = null; private int spaces = 0; private HashMap context = new HashMap<>(); @@ -95,11 +92,7 @@ public Command handleException(InstallException exception, RInstall cause) throw } Log.error(this.getStackStrace()); Command out; - if (sendFeedback) { - out = listener.exception(exception, () -> LiveFeedbackEasy.sendInstallException(exceptionFinal, ProcedureRunner.this)); - } else { - out = listener.exception(exception, null); - } + out = listener.exception(exception, null); if (Command.ABORT.equals(out)) { throw new RMessage(out); } diff --git a/src/main/java/com/xiaomitool/v2/procedure/install/GenericInstall.java b/src/main/java/com/xiaomitool/v2/procedure/install/GenericInstall.java index 450710c..2e7fe0b 100644 --- a/src/main/java/com/xiaomitool/v2/procedure/install/GenericInstall.java +++ b/src/main/java/com/xiaomitool/v2/procedure/install/GenericInstall.java @@ -14,7 +14,6 @@ import com.xiaomitool.v2.gui.visual.SmilePane; import com.xiaomitool.v2.language.LRes; import com.xiaomitool.v2.logging.Log; -import com.xiaomitool.v2.logging.feedback.LiveFeedbackEasy; import com.xiaomitool.v2.procedure.*; import com.xiaomitool.v2.procedure.device.ManageDevice; import com.xiaomitool.v2.procedure.device.OtherProcedures; @@ -135,8 +134,6 @@ public static RInstall installationSuccess() { @Override public void run(ProcedureRunner runner) throws InstallException, InterruptedException { ToolManager.setOnExitAskForFeedback(false); - Installable installable = (Installable) runner.getContext(Procedures.INSTALLABLE); - LiveFeedbackEasy.sendSuccess(String.valueOf(installable), runner.getStackStrace()); Log.info("Installation succesful, showing donation message"); DeviceManager.stopScanThreads(); DonationPane donationPane = new DonationPane();