-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.py
More file actions
141 lines (111 loc) · 3.29 KB
/
Copy pathexamples.py
File metadata and controls
141 lines (111 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Example usages for apk2abb package
"""
This file contains example code snippets showing how to use the apk2abb package.
"""
# Example 1: Basic APK to AAB conversion using CLI
"""
After installing the package with: pip install apk2abb
# Step 1: Download bundletool
apk2abb-setup
# Step 2: Create keystore
apk2abb-cert
# Step 3: Convert APK to AAB
apk2abb-convert path/to/your-app.apk
# Step 4: Analyze the AAB file
apk2abb-analyze output/your-app.aab
"""
# Example 2: Using the Python API
"""
from apk2abb import APKtoAABConverter
# Create converter instance
converter = APKtoAABConverter()
# Convert APK to AAB with signing
converter.process_apk("path/to/your-app.apk", sign=True)
# Convert without signing
converter.process_apk("path/to/your-app.apk", sign=False)
"""
# Example 3: Custom keystore configuration
"""
from apk2abb import APKtoAABConverter
converter = APKtoAABConverter()
# Use custom keystore
converter.keystore_path = "path/to/custom.keystore"
converter.keystore_pass = "your-secure-password"
converter.key_alias = "your-key-alias"
converter.key_pass = "your-key-password"
# Process with custom keystore
converter.process_apk("your-app.apk")
"""
# Example 4: Create a custom keystore
"""
from apk2abb import create_keystore
# Create a new keystore
create_keystore(
keystore_path="my-app.keystore",
keystore_pass="my-secure-password",
alias="my-app-key",
alias_pass="my-key-password",
validity_days=25550 # ~70 years
)
"""
# Example 5: Validate an existing keystore
"""
from apk2abb import validate_keystore, list_keystore_info
# Validate keystore
is_valid = validate_keystore(
keystore_path="certs/iot_marketplace_app.keystore",
keystore_pass="iot_app_12345",
alias="iot_marketplace"
)
if is_valid:
# List keystore information
list_keystore_info(
keystore_path="certs/iot_marketplace_app.keystore",
keystore_pass="iot_app_12345"
)
"""
# Example 6: Check prerequisites
"""
from apk2abb import check_java, download_bundletool
# Check if Java is installed
if check_java():
print("Java is ready!")
# Download bundletool if needed
download_bundletool()
else:
print("Please install Java 11 or higher")
"""
# Example 7: Batch conversion
"""
from apk2abb import APKtoAABConverter
from pathlib import Path
converter = APKtoAABConverter()
# Convert multiple APK files
apk_directory = Path("apks")
for apk_file in apk_directory.glob("*.apk"):
print(f"Converting {apk_file.name}...")
converter.process_apk(str(apk_file), sign=True)
print(f"✓ Completed {apk_file.name}")
"""
# Example 8: Environment-based configuration
"""
import os
from apk2abb import APKtoAABConverter
converter = APKtoAABConverter()
# Use environment variables for sensitive data
converter.keystore_pass = os.getenv("KEYSTORE_PASSWORD", "default-password")
converter.key_pass = os.getenv("KEY_PASSWORD", "default-password")
# Process APK
converter.process_apk("your-app.apk")
"""
if __name__ == "__main__":
print("=" * 60)
print("apk2abb Package - Example Usage")
print("=" * 60)
print("\nThis file contains example code snippets.")
print("Read the file contents to see various usage examples.")
print("\nFor more information, see:")
print(" - README.md")
print(" - QUICKSTART.md")
print(" - PUBLISHING.md")
print("=" * 60)