Skip to content

Commit d30612c

Browse files
feat: added api to get installer package
1 parent 7f6a999 commit d30612c

4 files changed

Lines changed: 48 additions & 3 deletions

File tree

package-lock.json

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
"com.foxdebug.acode.rk.customtabs": {},
4141
"com.foxdebug.acode.rk.plugin.plugincontext": {},
4242
"cordova-plugin-system": {},
43-
"com.foxdebug.acode.rk.auth": {}
43+
"com.foxdebug.acode.rk.auth": {},
44+
"cordova-plugin-iap": {},
45+
"com.foxdebug.acode.rk.exec.proot": {}
4446
},
4547
"platforms": [
4648
"android"
@@ -70,6 +72,7 @@
7072
"babel-loader": "^10.0.0",
7173
"com.foxdebug.acode.rk.auth": "file:src/plugins/auth",
7274
"com.foxdebug.acode.rk.customtabs": "file:src/plugins/custom-tabs",
75+
"com.foxdebug.acode.rk.exec.proot": "file:src/plugins/proot",
7376
"com.foxdebug.acode.rk.exec.terminal": "file:src/plugins/terminal",
7477
"com.foxdebug.acode.rk.plugin.plugincontext": "file:src/plugins/pluginContext",
7578
"cordova-android": "^15.0.0",
@@ -80,6 +83,7 @@
8083
"cordova-plugin-device": "^2.1.0",
8184
"cordova-plugin-file": "^8.1.3",
8285
"cordova-plugin-ftp": "file:src/plugins/ftp",
86+
"cordova-plugin-iap": "file:src/plugins/iap",
8387
"cordova-plugin-sdcard": "file:src/plugins/sdcard",
8488
"cordova-plugin-server": "file:src/plugins/server",
8589
"cordova-plugin-sftp": "file:src/plugins/sftp",

src/plugins/system/android/com/foxdebug/system/System.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@
110110
import java.security.MessageDigest;
111111
import java.security.MessageDigest;
112112

113+
import android.content.pm.InstallSourceInfo;
114+
import android.content.pm.PackageManager;
115+
import android.os.Build;
116+
113117

114118

115119
public class System extends CordovaPlugin {
@@ -200,6 +204,7 @@ public boolean execute(
200204
case "decode":
201205
case "encode":
202206
case "copyToUri":
207+
case "getInstaller":
203208
case "compare-file-text":
204209
case "compare-texts":
205210
case "pin-file-shortcut":
@@ -399,6 +404,29 @@ public void run() {
399404
new Runnable() {
400405
public void run() {
401406
switch (action) {
407+
case "getInstaller":
408+
try {
409+
PackageManager pm = context.getPackageManager();
410+
411+
String installer;
412+
413+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
414+
InstallSourceInfo info =
415+
pm.getInstallSourceInfo(context.getPackageName());
416+
417+
installer = info.getInstallingPackageName();
418+
} else {
419+
installer = pm.getInstallerPackageName(
420+
context.getPackageName()
421+
);
422+
}
423+
424+
callbackContext.success(installer);
425+
426+
} catch (Exception e) {
427+
callbackContext.error(e.getMessage());
428+
}
429+
break;
402430
case "copyToUri":
403431
try {
404432
//srcUri is a file

src/plugins/system/www/plugin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ module.exports = {
2727
setExec: function (path, executable, success, error) {
2828
cordova.exec(success, error, 'System', 'setExec', [path, String(executable)]);
2929
},
30+
getInstaller: function (success, error) {
31+
cordova.exec(success, error, 'System', 'getInstaller', []);
32+
},
3033

3134

3235
getNativeLibraryPath: function (success, error) {

0 commit comments

Comments
 (0)