summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-02-03 00:01:25 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-02-03 00:01:25 +0000
commitbf528842907ab15b44831848ee4d6ed957ed0140 (patch)
tree4b26d38e5a3747b2a88bc4aef638b8b301a5231f
parent32090564f0a716bcdccdf4fb3e37f116c816ac79 (diff)
parent79fb0a3f55ef499d09cba6327956eccb8f4ddabc (diff)
downloadBuiltInPrintService-simpleperf-release.tar.gz
Snap for 11400057 from 79fb0a3f55ef499d09cba6327956eccb8f4ddabc to simpleperf-releasesimpleperf-release
Change-Id: I5f1858aac5433b5a671f2c098db76fac376c44c0
-rw-r--r--jni/ipphelper/ippstatus_monitor.c9
-rwxr-xr-xjni/lib/lib_wprint.c142
-rw-r--r--res/values-pt-rBR/strings.xml2
-rw-r--r--res/values-pt-rPT/strings.xml4
-rw-r--r--res/values-pt/strings.xml2
-rw-r--r--res/values-zh-rHK/strings.xml2
6 files changed, 50 insertions, 111 deletions
diff --git a/jni/ipphelper/ippstatus_monitor.c b/jni/ipphelper/ippstatus_monitor.c
index 416eab2..2a19976 100644
--- a/jni/ipphelper/ippstatus_monitor.c
+++ b/jni/ipphelper/ippstatus_monitor.c
@@ -62,7 +62,7 @@ typedef struct {
http_t *http;
char printer_uri[1024];
char http_resource[1024];
- unsigned char stop_monitor;
+ volatile unsigned char stop_monitor;
unsigned char monitor_running;
sem_t monitor_sem;
pthread_mutex_t mutex;
@@ -134,6 +134,7 @@ static void _destroy(const ifc_status_monitor_t *this_p) {
pthread_mutex_unlock(&monitor->mutex);
pthread_mutex_destroy(&monitor->mutex);
+ monitor->stop_monitor = 1;
}
if (monitor->http != NULL) {
@@ -327,7 +328,7 @@ static status_t _cancel(const ifc_status_monitor_t *this_p, const char *requesti
LOGD("_cancel(): enter");
monitor = IMPL(ipp_monitor_t, ifc, this_p);
- if (this_p != NULL && monitor != NULL && monitor->initialized) {
+ if (this_p != NULL && monitor != NULL && monitor->initialized && !monitor->stop_monitor) {
pthread_mutex_lock(&monitor->mutex);
do {
if (monitor->stop_monitor) {
@@ -448,7 +449,7 @@ static void _get_job_state(const ifc_status_monitor_t *this_p, job_state_dyn_t *
ipp_monitor_t *monitor = NULL;
monitor = IMPL(ipp_monitor_t, ifc, this_p);
- if (this_p != NULL && monitor != NULL && monitor->initialized) {
+ if (this_p != NULL && monitor != NULL && monitor->initialized && !monitor->stop_monitor) {
pthread_mutex_lock(&monitor->mutex);
do {
@@ -469,4 +470,4 @@ static void _get_job_state(const ifc_status_monitor_t *this_p, job_state_dyn_t *
} while (0);
pthread_mutex_unlock(&monitor->mutex);
}
-} \ No newline at end of file
+}
diff --git a/jni/lib/lib_wprint.c b/jni/lib/lib_wprint.c
index ac39a81..fc3cfb5 100755
--- a/jni/lib/lib_wprint.c
+++ b/jni/lib/lib_wprint.c
@@ -198,6 +198,7 @@ static sem_t _job_start_wait_sem;
static _io_plugin_t _io_plugins[2];
static volatile bool stop_run = false;
+static volatile bool stop_mutex = false;
static printer_capabilities_t g_printer_caps = {0};
@@ -412,14 +413,18 @@ static const ifc_print_job_t *_get_print_ifc(port_t port_num) {
* Lock the semaphore for this module
*/
static void _lock(void) {
- pthread_mutex_lock(&_q_lock);
+ if (!stop_mutex) {
+ pthread_mutex_lock(&_q_lock);
+ }
}
/*
* Unlock the semaphore for this module
*/
static void _unlock(void) {
- pthread_mutex_unlock(&_q_lock);
+ if (!stop_mutex) {
+ pthread_mutex_unlock(&_q_lock);
+ }
}
static wJob_t _get_handle(void) {
@@ -568,75 +573,12 @@ static void _job_status_callback(const printer_state_dyn_t *new_status,
}
break;
+ /* all is well, handled in job status */
case PRINT_STATUS_CANCELLED:
- sem_post(&_job_start_wait_sem);
- if ((jq->print_ifc != NULL) && (jq->print_ifc->enable_timeout != NULL)) {
- jq->print_ifc->enable_timeout(jq->print_ifc, 1);
- }
- if (statusold != PRINT_STATUS_CANCELLED) {
- LOGI("status requested job cancel");
- if (new_status->printer_reasons[0] == PRINT_STATUS_OFFLINE) {
- sem_post(&_job_start_wait_sem);
- sem_post(&_job_end_wait_sem);
- if ((jq->print_ifc != NULL) && (jq->print_ifc->enable_timeout != NULL)) {
- jq->print_ifc->enable_timeout(jq->print_ifc, 1);
- }
- }
- _lock();
- jq->job_params.cancelled = true;
- _unlock();
- }
- if (new_status->printer_reasons[0] == PRINT_STATUS_OFFLINE) {
- sem_post(&_job_start_wait_sem);
- sem_post(&_job_end_wait_sem);
- }
- break;
-
+ /* all is well, handled in job status */
case PRINT_STATUS_PRINTING:
- sem_post(&_job_start_wait_sem);
- _lock();
- if ((jq->job_state != JOB_STATE_RUNNING) || (jq->blocked_reasons != blocked_reasons)) {
- jq->job_state = JOB_STATE_RUNNING;
- jq->blocked_reasons = blocked_reasons;
- if (jq->cb_fn) {
- cb_param.param.state = JOB_RUNNING;
- cb_param.blocked_reasons = jq->blocked_reasons;
- cb_param.job_done_result = OK;
-
- jq->cb_fn(jq->job_handle, (void *) &cb_param);
- }
- }
- _unlock();
- break;
-
+ /* all is well, handled in job status */
case PRINT_STATUS_UNABLE_TO_CONNECT:
- sem_post(&_job_start_wait_sem);
- _lock();
- _stop_status_thread(jq);
-
- jq->blocked_reasons = blocked_reasons;
- jq->job_params.cancelled = true;
- jq->job_state = JOB_STATE_ERROR;
- if (jq->cb_fn) {
- cb_param.param.state = JOB_DONE;
- cb_param.blocked_reasons = blocked_reasons;
- cb_param.job_done_result = ERROR;
-
- jq->cb_fn(jq->job_handle, (void *) &cb_param);
- }
-
- if (jq->print_ifc != NULL) {
- jq->print_ifc->destroy(jq->print_ifc);
- jq->print_ifc = NULL;
- }
-
- if (jq->status_ifc != NULL) {
- jq->status_ifc->destroy(jq->status_ifc);
- jq->status_ifc = NULL;
- }
-
- _unlock();
- sem_post(&_job_end_wait_sem);
break;
default:
@@ -647,13 +589,6 @@ static void _job_status_callback(const printer_state_dyn_t *new_status,
if ((jq->job_state != JOB_STATE_BLOCKED) || (jq->blocked_reasons != blocked_reasons)) {
jq->job_state = JOB_STATE_BLOCKED;
jq->blocked_reasons = blocked_reasons;
- if (jq->cb_fn) {
- cb_param.param.state = JOB_BLOCKED;
- cb_param.blocked_reasons = blocked_reasons;
- cb_param.job_done_result = OK;
-
- jq->cb_fn(jq->job_handle, (void *) &cb_param);
- }
}
_unlock();
break;
@@ -879,7 +814,7 @@ static void _initialize_status_ifc(_job_queue_t *jq) {
* Runs a print job. Contains logic for what to do given different printer statuses.
*/
static void *_job_thread(void *param) {
- wprint_job_callback_params_t cb_param = { 0 };
+ wprint_job_callback_params_t cb_param = {};
_msg_t msg;
wJob_t job_handle;
_job_queue_t *jq;
@@ -975,7 +910,7 @@ static void *_job_thread(void *param) {
if (printer_state.printer_reasons[i] == PRINT_STATUS_MAX_STATE) {
break;
}
- blocked_reasons |= (1 << printer_state.printer_reasons[i]);
+ blocked_reasons |= (LONG_ONE << printer_state.printer_reasons[i]);
}
if (blocked_reasons == 0) {
blocked_reasons |= BLOCKED_REASONS_PRINTER_BUSY;
@@ -986,6 +921,7 @@ static void *_job_thread(void *param) {
jq->job_state = JOB_STATE_BLOCKED;
jq->blocked_reasons = blocked_reasons;
if (jq->cb_fn) {
+ cb_param.id = WPRINT_CB_PARAM_JOB_STATE;
cb_param.param.state = JOB_BLOCKED;
cb_param.blocked_reasons = blocked_reasons;
cb_param.job_done_result = OK;
@@ -1015,7 +951,6 @@ static void *_job_thread(void *param) {
}
}
- _job_status_tid = pthread_self();
if (job_result == OK) {
if (jq->print_ifc) {
job_result = jq->print_ifc->init(jq->print_ifc, jq->printer_addr,
@@ -1025,14 +960,12 @@ static void *_job_thread(void *param) {
}
}
}
- if (job_result == OK) {
- _start_status_thread(jq);
- }
/* call the plugin's start_job method, if no other job is running
use callback to notify the client */
if ((job_result == OK) && jq->cb_fn) {
+ cb_param.id = WPRINT_CB_PARAM_JOB_STATE;
cb_param.param.state = JOB_RUNNING;
cb_param.blocked_reasons = 0;
cb_param.job_done_result = OK;
@@ -1057,6 +990,10 @@ static void *_job_thread(void *param) {
/* PDF format plugin's start_job and end_job are to be called for each copy,
* inside the for-loop for num_copies.
*/
+ if (job_result == OK) {
+ _job_status_tid = pthread_self();
+ _start_status_thread(jq);
+ }
// Do not call start_job unless validate_job returned OK
if ((job_result == OK) && (jq->print_ifc->start_job != NULL) &&
@@ -1377,10 +1314,8 @@ static void *_job_thread(void *param) {
}
LOGI("job_thread(): with job_state value: %d ", jq->job_state);
- if ((jq->job_state == JOB_STATE_COMPLETED) || (jq->job_state == JOB_STATE_ERROR)
- || (jq->job_state == JOB_STATE_CANCELLED)
- || (jq->job_state == JOB_STATE_CORRUPTED)
- || (jq->job_state == JOB_STATE_FREE)) {
+ if (jq->job_state == JOB_STATE_ERROR) {
+ job_result = ERROR;
LOGI("_job_thread(): job finished early: do not send callback again");
} else {
switch (job_result) {
@@ -1417,25 +1352,25 @@ static void *_job_thread(void *param) {
jq->job_state = JOB_STATE_ERROR;
break;
} // job_result
+ }
- // end of job callback
- if (jq->cb_fn) {
- cb_param.param.state = JOB_DONE;
- cb_param.blocked_reasons = jq->blocked_reasons;
- cb_param.job_done_result = job_result;
-
- jq->cb_fn(job_handle, (void *) &cb_param);
- }
+ // end of job callback
+ if (jq->cb_fn) {
+ cb_param.id = WPRINT_CB_PARAM_JOB_STATE;
+ cb_param.param.state = JOB_DONE;
+ cb_param.blocked_reasons = jq->blocked_reasons;
+ cb_param.job_done_result = job_result;
+ jq->cb_fn(job_handle, (void *) &cb_param);
+ }
- if (jq->print_ifc != NULL) {
- jq->print_ifc->destroy(jq->print_ifc);
- jq->print_ifc = NULL;
- }
+ if (jq->print_ifc != NULL) {
+ jq->print_ifc->destroy(jq->print_ifc);
+ jq->print_ifc = NULL;
+ }
- if (jq->status_ifc != NULL) {
- jq->status_ifc->destroy(jq->status_ifc);
- jq->status_ifc = NULL;
- }
+ if (jq->status_ifc != NULL) {
+ jq->status_ifc->destroy(jq->status_ifc);
+ jq->status_ifc = NULL;
}
} else {
LOGI("_job_thread(): job %ld not in queue .. maybe cancelled", job_handle);
@@ -1555,6 +1490,7 @@ int wprintInit(void) {
signal(SIGPIPE, SIG_IGN); // avoid broken pipe process shutdowns
pthread_mutexattr_settype(&_q_lock_attr, PTHREAD_MUTEX_RECURSIVE_NP);
pthread_mutex_init(&_q_lock, &_q_lock_attr);
+ stop_mutex = false;
if (_start_thread() != OK) {
LOGE("could not start job thread");
@@ -2331,7 +2267,9 @@ status_t wprintExit(void) {
sem_destroy(&_job_end_wait_sem);
sem_destroy(&_job_start_wait_sem);
+
pthread_mutex_destroy(&_q_lock);
+ stop_mutex = true;
}
return OK;
@@ -2365,4 +2303,4 @@ bool wprintBlankPageForPwg(const wprint_job_params_t *job_params,
return ((job_params->job_pages_per_set % 2) && (job_params->duplex != DUPLEX_MODE_NONE) &&
!(printer_cap->jobPagesPerSetSupported &&
strcmp(job_params->print_format, PRINT_FORMAT_PWG) == 0));
-}
+} \ No newline at end of file
diff --git a/res/values-pt-rBR/strings.xml b/res/values-pt-rBR/strings.xml
index 40453ee..7f55668 100644
--- a/res/values-pt-rBR/strings.xml
+++ b/res/values-pt-rBR/strings.xml
@@ -57,7 +57,7 @@
<string name="failed_printer_connection" msgid="4196305972749960362">"Não foi possível se conectar à impressora"</string>
<string name="failed_connection" msgid="8068661997318286575">"Não foi possível se conectar à impressora <xliff:g id="PRINTER">%1$s</xliff:g>"</string>
<string name="saved_printers" msgid="4567534965213125526">"Impressoras salvas"</string>
- <string name="forget" msgid="892068061425802502">"Esquecer"</string>
+ <string name="forget" msgid="892068061425802502">"Ignorar"</string>
<string name="connects_via_wifi_direct" msgid="652300632780158437">"Conecta via Wi-Fi Direct"</string>
<string name="connects_via_network" msgid="5990041581556733898">"Conecta via rede atual em <xliff:g id="IP_ADDRESS">%1$s</xliff:g>"</string>
<string name="recommendation_summary" msgid="2979700524954307566">"O serviço de impressão padrão oferece opções básicas. É possível que existam outras opções disponíveis para essa impressora em outro serviço de impressão."</string>
diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml
index b8503d8..096bfc6 100644
--- a/res/values-pt-rPT/strings.xml
+++ b/res/values-pt-rPT/strings.xml
@@ -66,8 +66,8 @@
<string name="recommendation_enable_summary" msgid="3500907868251326224">"Selecione para ativar."</string>
<string name="recommendation_manage" msgid="4683640588502866284">"Gerir serviços"</string>
<string name="security" msgid="2279008326210305401">"Segurança"</string>
- <string name="certificate_update_request" msgid="1314796413107139475">"Esta impressora forneceu um novo certificado de segurança ou outro dispositivo está a roubar a respetiva identidade. Quer aceitar o novo certificado?"</string>
- <string name="not_encrypted_request" msgid="4871472176807381642">"Esta impressora já não aceita tarefas encriptadas. Quer continuar com a impressão?"</string>
+ <string name="certificate_update_request" msgid="1314796413107139475">"Esta impressora forneceu um novo certificado de segurança ou outro dispositivo está a roubar a respetiva identidade. Pretende aceitar o novo certificado?"</string>
+ <string name="not_encrypted_request" msgid="4871472176807381642">"Esta impressora já não aceita tarefas encriptadas. Pretende continuar com a impressão?"</string>
<string name="accept" msgid="4426153292469698134">"Aceitar"</string>
<string name="reject" msgid="24751635160440693">"Rejeitar"</string>
<string name="connections" msgid="8895413761760117180">"Ligações"</string>
diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml
index 40453ee..7f55668 100644
--- a/res/values-pt/strings.xml
+++ b/res/values-pt/strings.xml
@@ -57,7 +57,7 @@
<string name="failed_printer_connection" msgid="4196305972749960362">"Não foi possível se conectar à impressora"</string>
<string name="failed_connection" msgid="8068661997318286575">"Não foi possível se conectar à impressora <xliff:g id="PRINTER">%1$s</xliff:g>"</string>
<string name="saved_printers" msgid="4567534965213125526">"Impressoras salvas"</string>
- <string name="forget" msgid="892068061425802502">"Esquecer"</string>
+ <string name="forget" msgid="892068061425802502">"Ignorar"</string>
<string name="connects_via_wifi_direct" msgid="652300632780158437">"Conecta via Wi-Fi Direct"</string>
<string name="connects_via_network" msgid="5990041581556733898">"Conecta via rede atual em <xliff:g id="IP_ADDRESS">%1$s</xliff:g>"</string>
<string name="recommendation_summary" msgid="2979700524954307566">"O serviço de impressão padrão oferece opções básicas. É possível que existam outras opções disponíveis para essa impressora em outro serviço de impressão."</string>
diff --git a/res/values-zh-rHK/strings.xml b/res/values-zh-rHK/strings.xml
index fc19c26..377ed88 100644
--- a/res/values-zh-rHK/strings.xml
+++ b/res/values-zh-rHK/strings.xml
@@ -52,7 +52,7 @@
<string name="wifi_direct_printing" msgid="8423811041563144048">"Wi-Fi Direct 列印"</string>
<string name="wifi_direct_printers" msgid="541168032444693191">"Wi-Fi Direct 打印機"</string>
<string name="searching" msgid="2114018057619514587">"正在搜尋…"</string>
- <string name="connect_hint_text" msgid="587112503851044234">"你可能需要在打印機的前置面板上核准此連線"</string>
+ <string name="connect_hint_text" msgid="587112503851044234">"您可能需要在打印機的前置面板上核准此連線"</string>
<string name="connecting_to" msgid="2665161014972086194">"正在連接 <xliff:g id="PRINTER">%1$s</xliff:g>"</string>
<string name="failed_printer_connection" msgid="4196305972749960362">"無法連接打印機"</string>
<string name="failed_connection" msgid="8068661997318286575">"無法連接 <xliff:g id="PRINTER">%1$s</xliff:g>"</string>