|
168 | 168 | import static com.zoffcc.applications.trifa.TrifaToxService.is_tox_started; |
169 | 169 | import static com.zoffcc.applications.trifa.TrifaToxService.orma; |
170 | 170 | import static com.zoffcc.applications.trifa.TrifaToxService.stop_tox_fg_done; |
| 171 | +import static com.zoffcc.applications.trifa.TrifaToxService.trifa_service_thread; |
171 | 172 | import static com.zoffcc.applications.trifa.TrifaToxService.vfs; |
172 | 173 |
|
173 | 174 | public class HelperGeneric |
@@ -5048,75 +5049,109 @@ static public void append_logger_msg(final String logmsg) |
5048 | 5049 | { |
5049 | 5050 | if (DEBUG_USE_LOGFRIEND) |
5050 | 5051 | { |
5051 | | - // Log.i(TAG, "append_logger_msg:000:LOG_FRIEND_TOXID=" + LOG_FRIEND_TOXID + " msg=" + logmsg); |
5052 | | - String log_friend_pubkey = LOG_FRIEND_TOXID; |
5053 | | - if ((log_friend_pubkey == null) || (log_friend_pubkey.length() < 2)) |
| 5052 | + try |
5054 | 5053 | { |
5055 | | - try |
| 5054 | + // Log.i(TAG, "append_logger_msg:000:LOG_FRIEND_TOXID=" + LOG_FRIEND_TOXID + " msg=" + logmsg); |
| 5055 | + String log_friend_pubkey = LOG_FRIEND_TOXID; |
| 5056 | + if ((log_friend_pubkey == null) || (log_friend_pubkey.length() < 2)) |
5056 | 5057 | { |
5057 | | - log_friend_pubkey = get_g_opts(LOGFRIEND_TOXID_DB_KEY); |
5058 | | - if ((log_friend_pubkey == null) || (log_friend_pubkey.length() < 2)) |
| 5058 | + try |
| 5059 | + { |
| 5060 | + log_friend_pubkey = get_g_opts(LOGFRIEND_TOXID_DB_KEY); |
| 5061 | + if ((log_friend_pubkey == null) || (log_friend_pubkey.length() < 2)) |
| 5062 | + { |
| 5063 | + // some error with the TOX PUBKEY of log friend |
| 5064 | + // Log.i(TAG, "append_logger_msg:ret1: LOG_FRIEND_TOXID=" + log_friend_pubkey); |
| 5065 | + return; |
| 5066 | + } |
| 5067 | + // Log.i(TAG, "append_logger_msg: LOG_FRIEND_TOXID=" + log_friend_pubkey); |
| 5068 | + } |
| 5069 | + catch (Exception e) |
5059 | 5070 | { |
5060 | 5071 | // some error with the TOX PUBKEY of log friend |
5061 | | - // Log.i(TAG, "append_logger_msg:ret1: LOG_FRIEND_TOXID=" + log_friend_pubkey); |
| 5072 | + // Log.i(TAG, "append_logger_msg:ret2: LOG_FRIEND_TOXID=" + LOG_FRIEND_TOXID); |
5062 | 5073 | return; |
5063 | 5074 | } |
5064 | | - // Log.i(TAG, "append_logger_msg: LOG_FRIEND_TOXID=" + log_friend_pubkey); |
5065 | 5075 | } |
5066 | | - catch (Exception e) |
5067 | | - { |
5068 | | - // some error with the TOX PUBKEY of log friend |
5069 | | - // Log.i(TAG, "append_logger_msg:ret2: LOG_FRIEND_TOXID=" + LOG_FRIEND_TOXID); |
5070 | | - return; |
5071 | | - } |
5072 | | - } |
5073 | | - |
5074 | | - Log.i(TAG, "append_logger_msg:3:msg=" + logmsg); |
5075 | 5076 |
|
5076 | | - long pin_timestamp = System.currentTimeMillis(); |
5077 | | - Message m = new Message(); |
| 5077 | + Log.i(TAG, "append_logger_msg:3:msg=" + logmsg); |
5078 | 5078 |
|
5079 | | - m.is_new = false; |
5080 | | - m.tox_friendpubkey = log_friend_pubkey; |
5081 | | - m.direction = 0; // msg received |
5082 | | - m.TOX_MESSAGE_TYPE = 0; |
5083 | | - m.TRIFA_MESSAGE_TYPE = TRIFA_MSG_TYPE_TEXT.value; |
5084 | | - m.filetransfer_id = -1; |
5085 | | - m.filedb_id = -1; |
5086 | | - m.state = TOX_FILE_CONTROL_CANCEL.value; |
5087 | | - m.ft_accepted = false; |
5088 | | - m.ft_outgoing_started = false; |
5089 | | - m.ft_outgoing_queued = false; |
5090 | | - m.sent_timestamp = pin_timestamp; |
5091 | | - m.sent_timestamp_ms = 0; |
5092 | | - m.rcvd_timestamp = pin_timestamp; |
5093 | | - m.rcvd_timestamp_ms = 0; |
5094 | | - m.text = logmsg; |
5095 | | - m.msg_version = 0; |
5096 | | - m.resend_count = 0; |
5097 | | - m.sent_push = 0; |
5098 | | - m.msg_idv3_hash = ""; |
5099 | | - m.msg_id_hash = ""; |
5100 | | - m.raw_msgv2_bytes = ""; |
| 5079 | + long pin_timestamp = System.currentTimeMillis(); |
| 5080 | + Message m = new Message(); |
5101 | 5081 |
|
5102 | | - long row_id = -99; |
5103 | | - if (MainActivity.message_list_activity != null) |
5104 | | - { |
5105 | | - final long friend_number_ = tox_friend_by_public_key__wrapper(log_friend_pubkey); |
5106 | | - if (MainActivity.message_list_activity.get_current_friendnum() == friend_number_) |
| 5082 | + m.is_new = false; |
| 5083 | + m.tox_friendpubkey = log_friend_pubkey; |
| 5084 | + m.direction = 0; // msg received |
| 5085 | + m.TOX_MESSAGE_TYPE = 0; |
| 5086 | + m.TRIFA_MESSAGE_TYPE = TRIFA_MSG_TYPE_TEXT.value; |
| 5087 | + m.filetransfer_id = -1; |
| 5088 | + m.filedb_id = -1; |
| 5089 | + m.state = TOX_FILE_CONTROL_CANCEL.value; |
| 5090 | + m.ft_accepted = false; |
| 5091 | + m.ft_outgoing_started = false; |
| 5092 | + m.ft_outgoing_queued = false; |
| 5093 | + m.sent_timestamp = pin_timestamp; |
| 5094 | + m.sent_timestamp_ms = 0; |
| 5095 | + m.rcvd_timestamp = pin_timestamp; |
| 5096 | + m.rcvd_timestamp_ms = 0; |
| 5097 | + m.text = logmsg; |
| 5098 | + m.msg_version = 0; |
| 5099 | + m.resend_count = 0; |
| 5100 | + m.sent_push = 0; |
| 5101 | + m.msg_idv3_hash = ""; |
| 5102 | + m.msg_id_hash = ""; |
| 5103 | + m.raw_msgv2_bytes = ""; |
| 5104 | + |
| 5105 | + long row_id = -99; |
| 5106 | + if (MainActivity.message_list_activity != null) |
5107 | 5107 | { |
5108 | | - row_id = HelperMessage.insert_into_message_db(m, true); |
| 5108 | + final long friend_number_ = tox_friend_by_public_key__wrapper(log_friend_pubkey); |
| 5109 | + if (MainActivity.message_list_activity.get_current_friendnum() == friend_number_) |
| 5110 | + { |
| 5111 | + row_id = HelperMessage.insert_into_message_db(m, true); |
| 5112 | + } |
| 5113 | + else |
| 5114 | + { |
| 5115 | + row_id = HelperMessage.insert_into_message_db(m, false); |
| 5116 | + } |
5109 | 5117 | } |
5110 | 5118 | else |
5111 | 5119 | { |
5112 | 5120 | row_id = HelperMessage.insert_into_message_db(m, false); |
5113 | 5121 | } |
| 5122 | + // Log.i(TAG, "append_logger_msg:row_id=" + row_id); |
5114 | 5123 | } |
5115 | | - else |
| 5124 | + catch(Exception e) |
5116 | 5125 | { |
5117 | | - row_id = HelperMessage.insert_into_message_db(m, false); |
5118 | 5126 | } |
5119 | | - // Log.i(TAG, "append_logger_msg:row_id=" + row_id); |
| 5127 | + } |
| 5128 | + } |
| 5129 | + |
| 5130 | + static public void trigger_proper_wakeup_outside_tox_service_thread() |
| 5131 | + { |
| 5132 | + append_logger_msg(TAG + "::trigger_proper_wakeup_outside_tox_service_thread"); |
| 5133 | + TrifaToxService.need_wakeup_now = true; |
| 5134 | + global_last_activity_for_battery_savings_ts = System.currentTimeMillis(); |
| 5135 | + try |
| 5136 | + { |
| 5137 | + trifa_service_thread.interrupt(); |
| 5138 | + } |
| 5139 | + catch(Exception ignored) |
| 5140 | + { |
| 5141 | + } |
| 5142 | + } |
| 5143 | + |
| 5144 | + static public void trigger_proper_wakeup_from_tox_service_thread() |
| 5145 | + { |
| 5146 | + append_logger_msg(TAG + "::trigger_proper_wakeup_from_tox_service_thread"); |
| 5147 | + TrifaToxService.need_wakeup_now = true; |
| 5148 | + global_last_activity_for_battery_savings_ts = System.currentTimeMillis(); |
| 5149 | + try |
| 5150 | + { |
| 5151 | + trifa_service_thread.interrupt(); |
| 5152 | + } |
| 5153 | + catch(Exception ignored) |
| 5154 | + { |
5120 | 5155 | } |
5121 | 5156 | } |
5122 | 5157 | } |
0 commit comments