Ich möchte eine SSH-Verbindung zu meinem Telefon herstellen, ein APK herunterladen und es remote installieren. Gibt es einen Befehl auf dem Telefon, mit dem ich dies tun könnte?
Z.B:
wget localhost/file.apk
android_install file.apk
Ich muss eine Installation automatisieren, da ich gerade versehentlich meine SD-Karte und alles darauf gelöscht habe. :(
In der Adb-Shell oder im Terminal-Emulator (und höchstwahrscheinlich über SSH) können Sie das pm
Dienstprogramm verwenden, um Apps zu installieren. Der Befehl lautet:
pm installiere /sdcard/app1.apk
Im Folgenden sind die Schalter von pm
:
usage: pm [list|path|install|uninstall]
pm list packages [-f] [-d] [-e] [-u] [FILTER]
pm list permission-groups
pm list permissions [-g] [-f] [-d] [-u] [GROUP]
pm list instrumentation [-f] [TARGET-PACKAGE]
pm list features
pm list libraries
pm path PACKAGE
pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH
pm uninstall [-k] PACKAGE
pm clear PACKAGE
pm enable PACKAGE_OR_COMPONENT
pm disable PACKAGE_OR_COMPONENT
pm setInstallLocation [0/auto] [1/internal] [2/external]
The list packages command prints all packages, optionally only
those whose package name contains the text in FILTER. Options:
-f: see their associated file.
-d: filter to include disbled packages.
-e: filter to include enabled packages.
-u: also include uninstalled packages.
The list permission-groups command prints all known
permission groups.
The list permissions command prints all known
permissions, optionally only those in GROUP. Options:
-g: organize by group.
-f: print all information.
-s: short summary.
-d: only list dangerous permissions.
-u: list only the permissions users will see.
The list instrumentation command prints all instrumentations,
or only those that target a specified package. Options:
-f: see their associated file.
The list features command prints all features of the system.
The path command prints the path to the .apk of a package.
The install command installs a package to the system. Options:
-l: install the package with FORWARD_LOCK.
-r: reinstall an exisiting app, keeping its data.
-t: allow test .apks to be installed.
-i: specify the installer package name.
-s: install package on sdcard.
-f: install package on internal flash.
The uninstall command removes a package from the system. Options:
-k: keep the data and cache directories around.
after the package removal.
The clear command deletes all data associated with a package.
The enable and disable commands change the enabled state of
a given package or component (written as "package/class").
The getInstallLocation command gets the current install location
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
The setInstallLocation command changes the default install location
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
Beispielsweise können Sie erzwingen, dass die App direkt auf dem externen Speicher installiert wird (Froyo/Gingerbread-Stil).
PS Das wget
Dienstprogramm sollte über BusyBox auf CM7 verfügbar sein. Wenn nicht, können Sie es jederzeit über Android Market installieren .
pm
existiert unter /system/bin/pm
, aber leider über SSH (auch als root) macht es nichts. Das Ausführen eines beliebigen pm
Befehls erzeugt keine Ausgabe. Gibt es etwas, das ich falsch mache? Es funktioniert im Terminalemulator, nur aus irgendeinem Grund nicht über SSH :(adb
funktioniert nur über das USB-Kabel, oder? Und SSH kann über ein drahtloses Netzwerk erfolgen. Auch ssh
ist es überall vorhanden, adb
muss aber installiert werden.Ich würde vorschlagen, dass Sie Ihr Telefon an einen PC anschließen, auf dem das SDK (oder zumindest ADB) installiert und im Debugging-Modus ist. Schreiben Sie danach ein Skript, das Ihre Apps durchgeht und sie über adb installiert, z adb install x:\path\to\app1.apk
.
cp * /data/app && reboot
cat
Befehl möglicherweise (ab)verwenden.pm install /sdcard/app1.apk
macht dasselbe wie adb install
und kann in adb-shell, Terminal-Emulator und höchstwahrscheinlich über SSH ausgeführt werden. Werfen Sie einen Blick auf die Ausgabe von pm
für weitere Optionen. Es gibt sogar einen Schalter, um die App zu zwingen, direkt auf einem externen Speicher zu installieren (Gingerbread-Stil).Ich verwende die gleiche Methode und ja, SSH ist großartig! Aber es scheint, wenn Sie SSH zu Android verwenden, erhält es eine andere Shell als sh. Wenn Sie also sh vor den Befehl setzen, sollte es funktionieren.
Hier ist ein Beispiel:sh /system/bin/pm install app1.apk
Ciro Santilli OurBigBook.com