Skip to content

Commit 154b0f0

Browse files
committed
Add PackageManager and WXApplicationInfo types
Introduces TypeScript interfaces for Android package management, including detailed app metadata (WXApplicationInfo) and methods for querying installed packages, app info, and icons (PackageManager). These types enable structured access to Android app data for inspection and management tools.
1 parent 660fc28 commit 154b0f0

File tree

1 file changed

+169
-0
lines changed

1 file changed

+169
-0
lines changed

ts/src/types/PackageManager.ts

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
/**
2+
* Information about an installed Android application.
3+
*
4+
* This interface represents detailed metadata about an app package,
5+
* including version info, directories, permissions, and various Android-specific settings.
6+
*/
7+
export interface WXApplicationInfo {
8+
/** The unique package name identifier (e.g., "com.example.app") */
9+
packageName: string;
10+
/** The internal name of the application */
11+
name: string | null;
12+
/** The human-readable label/title shown to users */
13+
label: string | null;
14+
/** The version name as a string (e.g., "1.2.3") */
15+
versionName: string | null;
16+
/** The numeric version code for programmatic comparison */
17+
versionCode: number;
18+
/** The non-localized label of the application */
19+
nonLocalizedLabel: string | null;
20+
/** The app component factory class name (Android P+) */
21+
appComponentFactory: string | null;
22+
/** The backup agent class name for app data backup */
23+
backupAgentName: string | null;
24+
/** The app category (e.g., game, productivity) */
25+
category: number;
26+
/** The main activity class name */
27+
className: string | null;
28+
/** Compatible width limit in density-independent pixels */
29+
compatibleWidthLimitDp: number;
30+
/** SDK version the app was compiled against (Android S+) */
31+
compileSdkVersion: number | null;
32+
/** Codename of the SDK version (Android S+) */
33+
compileSdkVersionCodename: string | null;
34+
/** Path to the app's private data directory */
35+
dataDir: string | null;
36+
/** Description of the application */
37+
description: string | null;
38+
/** Path to device-protected data directory */
39+
deviceProtectedDataDir: string | null;
40+
/** Whether the application is enabled */
41+
enabled: boolean;
42+
/** Various flags describing the application properties */
43+
flags: number;
44+
/** Largest width limit in density-independent pixels */
45+
largestWidthLimitDp: number;
46+
/** Activity name for managing app storage space */
47+
manageSpaceActivityName: string | null;
48+
/** Minimum SDK version required by the app */
49+
minSdkVersion: number;
50+
/** Path to the app's native library directory */
51+
nativeLibraryDir: string | null;
52+
/** Permission required to access this app's components */
53+
permission: string | null;
54+
/** Name of the process this app should run in */
55+
processName: string | null;
56+
/** Path to the publicly accessible APK file */
57+
publicSourceDir: string | null;
58+
/** Smallest screen width required in density-independent pixels */
59+
requiresSmallestWidthDp: number;
60+
/** JSON string of shared library files */
61+
sharedLibraryFiles: string | null;
62+
/** Path to the APK file */
63+
sourceDir: string | null;
64+
/** UUID of the storage volume containing the app */
65+
storageUuid: string | null;
66+
/** Target SDK version the app was designed for */
67+
targetSdkVersion: number;
68+
/** Task affinity for activity grouping */
69+
taskAffinity: string | null;
70+
/** Default theme resource ID */
71+
theme: number;
72+
/** UI mode options */
73+
uiOptions: number;
74+
/** User ID associated with this app */
75+
uid: number;
76+
/** JSON string of split APK names */
77+
splitNames: string | null;
78+
/** JSON string of split APK public source directories */
79+
splitPublicSourceDirs: string | null;
80+
/** JSON string of split APK source directories */
81+
splitSourceDirs: string | null;
82+
}
83+
84+
/**
85+
* Provides access to Android package management functionality.
86+
*
87+
* This interface allows you to query information about installed applications,
88+
* retrieve app metadata, get application icons, and list installed packages.
89+
* It's essential for building tools that need to inspect or manage Android apps.
90+
*/
91+
export interface PackageManager {
92+
/**
93+
* Gets detailed information about a specific application package.
94+
*
95+
* @param packageName The package name to look up (e.g., "com.example.app")
96+
* @returns A JSON string containing WXApplicationInfo, or empty object "{}" if not found
97+
*/
98+
getApplicationInfo(packageName: string): string;
99+
100+
/**
101+
* Gets detailed information about a specific application package with flags.
102+
*
103+
* @param packageName The package name to look up
104+
* @param flags Additional flags to control what information is retrieved
105+
* @returns A JSON string containing WXApplicationInfo, or empty object "{}" if not found
106+
*/
107+
getApplicationInfo(packageName: string, flags: number): string;
108+
109+
/**
110+
* Gets detailed information about a specific application package with flags for a specific user.
111+
*
112+
* @param packageName The package name to look up
113+
* @param flags Additional flags to control what information is retrieved
114+
* @param userId The user ID to query packages for (useful for multi-user devices)
115+
* @returns A JSON string containing WXApplicationInfo, or empty object "{}" if not found
116+
*/
117+
getApplicationInfo(packageName: string, flags: number, userId: number): string;
118+
119+
/**
120+
* Gets a list of all installed package names on the device.
121+
*
122+
* @returns A JSON string containing an array of package names
123+
*/
124+
getInstalledPackages(): string;
125+
126+
/**
127+
* Gets a list of all installed package names with specific flags.
128+
*
129+
* @param flags Flags to filter which packages are included in the result
130+
* @returns A JSON string containing an array of package names
131+
*/
132+
getInstalledPackages(flags: number): string;
133+
134+
/**
135+
* Gets a list of all installed package names for a specific user with flags.
136+
*
137+
* @param flags Flags to filter which packages are included in the result
138+
* @param userId The user ID to query packages for
139+
* @returns A JSON string containing an array of package names
140+
*/
141+
getInstalledPackages(flags: number, userId: number): string;
142+
143+
/**
144+
* Gets the application icon as a base64-encoded string.
145+
*
146+
* @param packageName The package name whose icon to retrieve
147+
* @returns Base64-encoded image string, or null if the icon cannot be retrieved
148+
*/
149+
getApplicationIcon(packageName: string): string | null;
150+
151+
/**
152+
* Gets the application icon as a base64-encoded string with flags.
153+
*
154+
* @param packageName The package name whose icon to retrieve
155+
* @param flags Additional flags for icon retrieval
156+
* @returns Base64-encoded image string, or null if the icon cannot be retrieved
157+
*/
158+
getApplicationIcon(packageName: string, flags: number): string | null;
159+
160+
/**
161+
* Gets the application icon as a base64-encoded string for a specific user.
162+
*
163+
* @param packageName The package name whose icon to retrieve
164+
* @param flags Additional flags for icon retrieval
165+
* @param userId The user ID to query the icon for
166+
* @returns Base64-encoded image string, or null if the icon cannot be retrieved
167+
*/
168+
getApplicationIcon(packageName: string, flags: number, userId: number): string | null;
169+
}

0 commit comments

Comments
 (0)