コード例 #1
0
    def testPathToDexForPlatformVersion_dalvikApiLevel(self):
        sdk_int = version_codes.KITKAT
        paths_to_apk = ['/some/path']
        package_name = 'package.name'
        arch = abis.ARM_64

        device = mock.Mock(build_version_sdk=sdk_int, product_cpu_abi=arch)
        device.GetApplicationPaths = mock.MagicMock(return_value=paths_to_apk)

        with self.assertRaises(list_verification.UnsupportedDeviceError) as _:
            list_verification.FindOdexFiles(device, package_name)
コード例 #2
0
    def testPathToDexForPlatformVersion_lowerApiLevelNoOdexFile(self):
        sdk_int = version_codes.MARSHMALLOW
        package_name = 'package.name'
        paths_to_apk = ['/some/path/{}-1/base.apk'.format(package_name)]
        arch = abis.ARM_64

        device = mock.Mock(build_version_sdk=sdk_int, product_cpu_abi=arch)
        device.GetApplicationPaths = mock.MagicMock(return_value=paths_to_apk)
        device.FileExists = mock.MagicMock(return_value=False)

        with self.assertRaises(list_verification.DeviceOSError) as _:
            list_verification.FindOdexFiles(device, package_name)
コード例 #3
0
    def testPathToDexForPlatformVersion_noPaths(self):
        sdk_int = version_codes.LOLLIPOP
        paths_to_apk = []
        package_name = 'package.name'
        arch = abis.ARM_64

        device = mock.Mock(build_version_sdk=sdk_int, product_cpu_abi=arch)
        device.GetApplicationPaths = mock.MagicMock(return_value=paths_to_apk)

        with self.assertRaises(list_verification.DeviceOSError) as cm:
            list_verification.FindOdexFiles(device, package_name)
        message = str(cm.exception)
        self.assertIn('Could not find data directory', message)
コード例 #4
0
    def testPathToDexForPlatformVersion_mashmallowArm64(self):
        sdk_int = version_codes.MARSHMALLOW
        package_name = 'package.name'
        paths_to_apk = ['/some/path/{}-1/base.apk'.format(package_name)]
        arch = abis.ARM_64

        device = mock.Mock(build_version_sdk=sdk_int, product_cpu_abi=arch)
        device.GetApplicationPaths = mock.MagicMock(return_value=paths_to_apk)
        device.FileExists = mock.MagicMock(return_value=True)

        odex_files = list_verification.FindOdexFiles(device, package_name)
        self.assertEqual(odex_files,
                         ['/some/path/package.name-1/oat/arm64/base.odex'])
コード例 #5
0
    def testPathToDexForPlatformVersion_multiplePaths(self):
        sdk_int = version_codes.LOLLIPOP
        paths_to_apk = ['/first/path', '/second/path']
        package_name = 'package.name'
        arch = abis.ARM_64

        device = mock.Mock(build_version_sdk=sdk_int, product_cpu_abi=arch)
        device.GetApplicationPaths = mock.MagicMock(return_value=paths_to_apk)

        odex_files = list_verification.FindOdexFiles(device, package_name)
        self.assertEqual(odex_files, [
            '/data/dalvik-cache/arm64/data@app@[email protected]@classes.dex',
            '/data/dalvik-cache/arm64/data@app@[email protected]@classes.dex'
        ])
コード例 #6
0
    def testPathToDexForPlatformVersion_lollipopArm(self):
        sdk_int = version_codes.LOLLIPOP
        package_name = 'package.name'
        paths_to_apk = ['/some/path/{}-1/base.apk'.format(package_name)]
        arch = 'arm'

        device = mock.Mock(build_version_sdk=sdk_int, product_cpu_abi=arch)
        device.GetApplicationPaths = mock.MagicMock(return_value=paths_to_apk)
        device.FileExists = mock.MagicMock(return_value=True)

        odex_files = list_verification.FindOdexFiles(device, package_name)
        self.assertEqual(odex_files, [
            '/data/dalvik-cache/arm/data@[email protected]@[email protected]'
        ])
コード例 #7
0
    def testPathToDexForPlatformVersion_pieNoOdexFile(self):
        sdk_int = version_codes.PIE
        package_name = 'package.name'
        paths_to_apk = ['/some/path/{}-1/base.apk'.format(package_name)]
        arch = abis.ARM_64

        device = mock.Mock(build_version_sdk=sdk_int, product_cpu_abi=arch)
        device.GetApplicationPaths = mock.MagicMock(return_value=paths_to_apk)
        device.FileExists = mock.MagicMock(return_value=False)

        with self.assertRaises(list_verification.DeviceOSError) as cm:
            list_verification.FindOdexFiles(device, package_name)
        message = str(cm.exception)
        self.assertIn('you must run dex2oat on debuggable apps on >= P',
                      message)