blob: b47cb6b7450a3e322037ab783b28793c930c8efc [file] [log] [blame]
Joe Onoratod636ea12024-05-23 12:25:27 -07001#!/bin/bash
2
3# Copyright (C) 2024 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# adb install a module's apk, as cached in module-info.json. If any build change
18# is made, and it should be reflected in the output, you should run 'refreshmod' first.
19# Usage: installmod [adb install arguments] <module>
20# For example: installmod -r Dialer -> adb install -r /path/to/Dialer.apk
21
22function _impl() {
23 local prepend=''
24 local append=''
25 if [ "$1" = "--exact" ]; then
26 prepend=' '
27 append='$'
28 shift
29 elif [ "$1" = "--help" -o "$1" = "-h" ]; then
30 echo "usage: qpid [[--exact] <process name|pid>"
31 return 255
32 fi
33
34 local EXE="$1"
35 if [ "$EXE" ] ; then
36 _impl | \grep "$prepend$EXE$append"
37 else
38 adb shell ps \
39 | tr -d '\r' \
40 | sed -e 1d -e 's/^[^ ]* *\([0-9]*\).* \([^ ]*\)$/\1 \2/'
41 fi
42}
43
44_impl "$@"