Allows you to get information about packages that are installed on a device.
Exemple #1
0
        public void InstallRemotePackageTest()
        {
            var adbClient = new DummyAdbClient();

            adbClient.Commands.Add("pm list packages -f", "package:/system/app/Gallery2/Gallery2.apk=com.android.gallery3d");
            adbClient.Commands.Add("pm install /data/test.apk", string.Empty);
            adbClient.Commands.Add("pm install -r /data/test.apk", string.Empty);

            AdbClient.Instance = adbClient;

            DeviceData device = new DeviceData()
            {
                State = DeviceState.Online
            };

            PackageManager manager = new PackageManager(device);
            manager.InstallRemotePackage("/data/test.apk", false);

            Assert.AreEqual(2, adbClient.ReceivedCommands.Count);
            Assert.AreEqual("pm install /data/test.apk", adbClient.ReceivedCommands[1]);

            manager.InstallRemotePackage("/data/test.apk", true);

            Assert.AreEqual(3, adbClient.ReceivedCommands.Count);
            Assert.AreEqual("pm install -r /data/test.apk", adbClient.ReceivedCommands[2]);
        }
Exemple #2
0
        public void InstallPackageTest()
        {
            var syncService = new DummySyncService();
            Factories.SyncServiceFactory = (d) => syncService;

            var adbClient = new DummyAdbClient();

            adbClient.Commands.Add("pm list packages -f", "package:/system/app/Gallery2/Gallery2.apk=com.android.gallery3d");
            adbClient.Commands.Add("pm install /storage/sdcard0/tmp/test.txt", string.Empty);
            adbClient.Commands.Add("rm /storage/sdcard0/tmp/test.txt", string.Empty);

            AdbClient.Instance = adbClient;

            DeviceData device = new DeviceData()
            {
                State = DeviceState.Online
            };

            PackageManager manager = new PackageManager(device);
            manager.InstallPackage("test.txt", false);
            Assert.AreEqual(3, adbClient.ReceivedCommands.Count);
            Assert.AreEqual("pm install /storage/sdcard0/tmp/test.txt", adbClient.ReceivedCommands[1]);
            Assert.AreEqual("rm /storage/sdcard0/tmp/test.txt", adbClient.ReceivedCommands[2]);

            Assert.AreEqual(1, syncService.UploadedFiles.Count);
            Assert.IsTrue(syncService.UploadedFiles.ContainsKey("/storage/sdcard0/tmp/test.txt"));
        }
 /// <summary>
 /// Uninstalls a package from the device.
 /// </summary>
 /// <param name="device">
 /// The device on which to uninstall the package.
 /// </param>
 /// <param name="packageName">
 /// The name of the package to uninstall.
 /// </param>
 public static void UninstallPackage(this DeviceData device, string packageName)
 {
     PackageManager manager = new PackageManager(device);
     manager.UninstallPackage(packageName);
 }
 /// <summary>
 /// Requests the version information from the device.
 /// </summary>
 /// <param name="device">
 /// The device on which to uninstall the package.
 /// </param>
 /// <param name="packageName">
 /// The name of the package from which to get the application version.
 /// </param>
 public static VersionInfo GetPackageVersion(this DeviceData device, string packageName)
 {
     PackageManager manager = new PackageManager(device);
     return manager.GetVersionInfo(packageName);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PackageManagerReceiver"/> class.
 /// </summary>
 /// <param name="device">
 /// The device for which the package information is being received.
 /// </param>
 /// <param name="packageManager">
 /// The parent package manager.
 /// </param>
 public PackageManagerReceiver(DeviceData device, PackageManager packageManager)
 {
     this.Device         = device;
     this.PackageManager = packageManager;
 }
Exemple #6
0
        /// <summary>
        /// Requests the version information from the device.
        /// </summary>
        /// <param name="device">
        /// The device on which to uninstall the package.
        /// </param>
        /// <param name="packageName">
        /// The name of the package from which to get the application version.
        /// </param>
        public static VersionInfo GetPackageVersion(this DeviceData device, string packageName)
        {
            PackageManager manager = new PackageManager(device);

            return(manager.GetVersionInfo(packageName));
        }
Exemple #7
0
        /// <summary>
        /// Uninstalls a package from the device.
        /// </summary>
        /// <param name="device">
        /// The device on which to uninstall the package.
        /// </param>
        /// <param name="packageName">
        /// The name of the package to uninstall.
        /// </param>
        public static void UninstallPackage(this DeviceData device, string packageName)
        {
            PackageManager manager = new PackageManager(device);

            manager.UninstallPackage(packageName);
        }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PackageManagerReceiver"/> class.
 /// </summary>
 /// <param name="device">
 /// The device for which the package information is being received.
 /// </param>
 /// <param name="packageManager">
 /// The parent package manager.
 /// </param>
 public PackageManagerReceiver(DeviceData device, PackageManager packageManager)
 {
     this.Device = device;
     this.PackageManager = packageManager;
 }
Exemple #9
0
        public void PackagesPropertyTest2()
        {
            DeviceData device = new DeviceData()
            {
                State = DeviceState.Online
            };

            DummyAdbClient client = new DummyAdbClient();
            client.Commands.Add("pm list packages -f", "package:mwc2015.be");
            AdbClient.Instance = client;
            PackageManager manager = new PackageManager(device);

            Assert.IsTrue(manager.Packages.ContainsKey("mwc2015.be"));
            Assert.AreEqual(null, manager.Packages["mwc2015.be"]);
        }
Exemple #10
0
        public void PackagesPropertyTest()
        {
            DeviceData device = new DeviceData()
            {
                State = DeviceState.Online
            };

            DummyAdbClient client = new DummyAdbClient();
            client.Commands.Add("pm list packages -f", "package:/system/app/Gallery2/Gallery2.apk=com.android.gallery3d");
            AdbClient.Instance = client;
            PackageManager manager = new PackageManager(device);

            Assert.IsTrue(manager.Packages.ContainsKey("com.android.gallery3d"));
            Assert.AreEqual("/system/app/Gallery2/Gallery2.apk", manager.Packages["com.android.gallery3d"]);
        }
Exemple #11
0
        public void UninstallPackageTest()
        {
            DeviceData device = new DeviceData()
            {
                State = DeviceState.Online
            };

            DummyAdbClient client = new DummyAdbClient();
            client.Commands.Add("pm list packages -f", "package:/system/app/Gallery2/Gallery2.apk=com.android.gallery3d");
            client.Commands.Add("pm uninstall com.android.gallery3d", "Success");
            AdbClient.Instance = client;
            PackageManager manager = new PackageManager(device);

            // Command should execute correctly; if the wrong command is passed an exception
            // would be thrown.
            manager.UninstallPackage("com.android.gallery3d");
        }