@simplysm/capacitor-plugin-auto-update 12.16.18 → 12.16.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/android/build.gradle
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
apply plugin: 'com.android.library'
|
|
2
|
-
|
|
3
|
-
android {
|
|
4
|
-
namespace "kr.co.simplysm.capacitor.apkinstaller"
|
|
5
|
-
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
6
|
-
defaultConfig {
|
|
7
|
-
minSdk project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
dependencies {
|
|
12
|
-
implementation project(':capacitor-android')
|
|
13
|
-
}
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
|
|
3
|
+
android {
|
|
4
|
+
namespace "kr.co.simplysm.capacitor.apkinstaller"
|
|
5
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
6
|
+
defaultConfig {
|
|
7
|
+
minSdk project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
dependencies {
|
|
12
|
+
implementation project(':capacitor-android')
|
|
13
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
-
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
|
4
|
-
</manifest>
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
+
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
|
4
|
+
</manifest>
|
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
package kr.co.simplysm.capacitor.apkinstaller;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.content.Intent;
|
|
5
|
-
import android.content.pm.PackageInfo;
|
|
6
|
-
import android.content.pm.PackageManager;
|
|
7
|
-
import android.net.Uri;
|
|
8
|
-
import android.os.Build;
|
|
9
|
-
import android.provider.Settings;
|
|
10
|
-
import android.util.Log;
|
|
11
|
-
|
|
12
|
-
import com.getcapacitor.JSObject;
|
|
13
|
-
import com.getcapacitor.Plugin;
|
|
14
|
-
import com.getcapacitor.PluginCall;
|
|
15
|
-
import com.getcapacitor.PluginMethod;
|
|
16
|
-
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
17
|
-
|
|
18
|
-
@CapacitorPlugin(name = "ApkInstaller")
|
|
19
|
-
public class ApkInstallerPlugin extends Plugin {
|
|
20
|
-
|
|
21
|
-
private static final String TAG = "ApkInstallerPlugin";
|
|
22
|
-
|
|
23
|
-
@PluginMethod
|
|
24
|
-
public void install(PluginCall call) {
|
|
25
|
-
String uriStr = call.getString("uri");
|
|
26
|
-
if (uriStr == null) {
|
|
27
|
-
call.reject("uri is required");
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
Uri apkUri = Uri.parse(uriStr);
|
|
33
|
-
|
|
34
|
-
Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
35
|
-
intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
|
|
36
|
-
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
37
|
-
|
|
38
|
-
getContext().startActivity(intent);
|
|
39
|
-
call.resolve();
|
|
40
|
-
} catch (Exception e) {
|
|
41
|
-
Log.e(TAG, "install failed", e);
|
|
42
|
-
call.reject("Install failed: " + e.getMessage());
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@PluginMethod
|
|
47
|
-
public void hasPermission(PluginCall call) {
|
|
48
|
-
boolean granted;
|
|
49
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
50
|
-
granted = getContext().getPackageManager().canRequestPackageInstalls();
|
|
51
|
-
} else {
|
|
52
|
-
granted = true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
JSObject ret = new JSObject();
|
|
56
|
-
ret.put("granted", granted);
|
|
57
|
-
call.resolve(ret);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
@PluginMethod
|
|
61
|
-
public void requestPermission(PluginCall call) {
|
|
62
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
63
|
-
Context context = getContext();
|
|
64
|
-
Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES);
|
|
65
|
-
intent.setData(Uri.parse("package:" + context.getPackageName()));
|
|
66
|
-
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
67
|
-
context.startActivity(intent);
|
|
68
|
-
}
|
|
69
|
-
call.resolve();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
@PluginMethod
|
|
73
|
-
public void hasPermissionManifest(PluginCall call) {
|
|
74
|
-
try {
|
|
75
|
-
Context context = getContext();
|
|
76
|
-
String targetPermission = "android.permission.REQUEST_INSTALL_PACKAGES";
|
|
77
|
-
|
|
78
|
-
String[] requestedPermissions = context.getPackageManager()
|
|
79
|
-
.getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS)
|
|
80
|
-
.requestedPermissions;
|
|
81
|
-
|
|
82
|
-
boolean declared = false;
|
|
83
|
-
if (requestedPermissions != null) {
|
|
84
|
-
for (String perm : requestedPermissions) {
|
|
85
|
-
if (targetPermission.equals(perm)) {
|
|
86
|
-
declared = true;
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
JSObject ret = new JSObject();
|
|
93
|
-
ret.put("declared", declared);
|
|
94
|
-
call.resolve(ret);
|
|
95
|
-
} catch (Exception e) {
|
|
96
|
-
Log.e(TAG, "hasPermissionManifest failed", e);
|
|
97
|
-
call.reject("Manifest check failed: " + e.getMessage());
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
@PluginMethod
|
|
102
|
-
public void getVersionInfo(PluginCall call) {
|
|
103
|
-
try {
|
|
104
|
-
Context context = getContext();
|
|
105
|
-
PackageManager pm = context.getPackageManager();
|
|
106
|
-
PackageInfo info = pm.getPackageInfo(context.getPackageName(), 0);
|
|
107
|
-
|
|
108
|
-
String versionName = info.versionName;
|
|
109
|
-
long versionCode;
|
|
110
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
111
|
-
versionCode = info.getLongVersionCode();
|
|
112
|
-
} else {
|
|
113
|
-
versionCode = info.versionCode;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
JSObject ret = new JSObject();
|
|
117
|
-
ret.put("versionName", versionName);
|
|
118
|
-
ret.put("versionCode", String.valueOf(versionCode));
|
|
119
|
-
call.resolve(ret);
|
|
120
|
-
} catch (Exception e) {
|
|
121
|
-
Log.e(TAG, "getVersionInfo failed", e);
|
|
122
|
-
call.reject("getVersionInfo failed: " + e.getMessage());
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
1
|
+
package kr.co.simplysm.capacitor.apkinstaller;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.Intent;
|
|
5
|
+
import android.content.pm.PackageInfo;
|
|
6
|
+
import android.content.pm.PackageManager;
|
|
7
|
+
import android.net.Uri;
|
|
8
|
+
import android.os.Build;
|
|
9
|
+
import android.provider.Settings;
|
|
10
|
+
import android.util.Log;
|
|
11
|
+
|
|
12
|
+
import com.getcapacitor.JSObject;
|
|
13
|
+
import com.getcapacitor.Plugin;
|
|
14
|
+
import com.getcapacitor.PluginCall;
|
|
15
|
+
import com.getcapacitor.PluginMethod;
|
|
16
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
17
|
+
|
|
18
|
+
@CapacitorPlugin(name = "ApkInstaller")
|
|
19
|
+
public class ApkInstallerPlugin extends Plugin {
|
|
20
|
+
|
|
21
|
+
private static final String TAG = "ApkInstallerPlugin";
|
|
22
|
+
|
|
23
|
+
@PluginMethod
|
|
24
|
+
public void install(PluginCall call) {
|
|
25
|
+
String uriStr = call.getString("uri");
|
|
26
|
+
if (uriStr == null) {
|
|
27
|
+
call.reject("uri is required");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
Uri apkUri = Uri.parse(uriStr);
|
|
33
|
+
|
|
34
|
+
Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
35
|
+
intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
|
|
36
|
+
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
37
|
+
|
|
38
|
+
getContext().startActivity(intent);
|
|
39
|
+
call.resolve();
|
|
40
|
+
} catch (Exception e) {
|
|
41
|
+
Log.e(TAG, "install failed", e);
|
|
42
|
+
call.reject("Install failed: " + e.getMessage());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@PluginMethod
|
|
47
|
+
public void hasPermission(PluginCall call) {
|
|
48
|
+
boolean granted;
|
|
49
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
50
|
+
granted = getContext().getPackageManager().canRequestPackageInstalls();
|
|
51
|
+
} else {
|
|
52
|
+
granted = true;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
JSObject ret = new JSObject();
|
|
56
|
+
ret.put("granted", granted);
|
|
57
|
+
call.resolve(ret);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@PluginMethod
|
|
61
|
+
public void requestPermission(PluginCall call) {
|
|
62
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
63
|
+
Context context = getContext();
|
|
64
|
+
Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES);
|
|
65
|
+
intent.setData(Uri.parse("package:" + context.getPackageName()));
|
|
66
|
+
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
67
|
+
context.startActivity(intent);
|
|
68
|
+
}
|
|
69
|
+
call.resolve();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@PluginMethod
|
|
73
|
+
public void hasPermissionManifest(PluginCall call) {
|
|
74
|
+
try {
|
|
75
|
+
Context context = getContext();
|
|
76
|
+
String targetPermission = "android.permission.REQUEST_INSTALL_PACKAGES";
|
|
77
|
+
|
|
78
|
+
String[] requestedPermissions = context.getPackageManager()
|
|
79
|
+
.getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS)
|
|
80
|
+
.requestedPermissions;
|
|
81
|
+
|
|
82
|
+
boolean declared = false;
|
|
83
|
+
if (requestedPermissions != null) {
|
|
84
|
+
for (String perm : requestedPermissions) {
|
|
85
|
+
if (targetPermission.equals(perm)) {
|
|
86
|
+
declared = true;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
JSObject ret = new JSObject();
|
|
93
|
+
ret.put("declared", declared);
|
|
94
|
+
call.resolve(ret);
|
|
95
|
+
} catch (Exception e) {
|
|
96
|
+
Log.e(TAG, "hasPermissionManifest failed", e);
|
|
97
|
+
call.reject("Manifest check failed: " + e.getMessage());
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@PluginMethod
|
|
102
|
+
public void getVersionInfo(PluginCall call) {
|
|
103
|
+
try {
|
|
104
|
+
Context context = getContext();
|
|
105
|
+
PackageManager pm = context.getPackageManager();
|
|
106
|
+
PackageInfo info = pm.getPackageInfo(context.getPackageName(), 0);
|
|
107
|
+
|
|
108
|
+
String versionName = info.versionName;
|
|
109
|
+
long versionCode;
|
|
110
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
111
|
+
versionCode = info.getLongVersionCode();
|
|
112
|
+
} else {
|
|
113
|
+
versionCode = info.versionCode;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
JSObject ret = new JSObject();
|
|
117
|
+
ret.put("versionName", versionName);
|
|
118
|
+
ret.put("versionCode", String.valueOf(versionCode));
|
|
119
|
+
call.resolve(ret);
|
|
120
|
+
} catch (Exception e) {
|
|
121
|
+
Log.e(TAG, "getVersionInfo failed", e);
|
|
122
|
+
call.reject("getVersionInfo failed: " + e.getMessage());
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/capacitor-plugin-auto-update",
|
|
3
|
-
"version": "12.16.
|
|
3
|
+
"version": "12.16.19",
|
|
4
4
|
"description": "심플리즘 패키지 - Capacitor Plugin Auto Update",
|
|
5
5
|
"author": "김석래",
|
|
6
6
|
"repository": {
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@simplysm/sd-core-common": "12.16.
|
|
22
|
-
"@simplysm/sd-service-client": "12.16.
|
|
23
|
-
"@simplysm/sd-service-common": "12.16.
|
|
21
|
+
"@simplysm/sd-core-common": "12.16.19",
|
|
22
|
+
"@simplysm/sd-service-client": "12.16.19",
|
|
23
|
+
"@simplysm/sd-service-common": "12.16.19",
|
|
24
24
|
"semver": "^7.7.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@capacitor/core": "^7.4.4",
|
|
28
|
-
"@simplysm/capacitor-plugin-file-system": "12.16.
|
|
28
|
+
"@simplysm/capacitor-plugin-file-system": "12.16.19",
|
|
29
29
|
"@types/semver": "^7.7.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@capacitor/core": "^7.0.0",
|
|
33
|
-
"@simplysm/capacitor-plugin-file-system": "12.16.
|
|
33
|
+
"@simplysm/capacitor-plugin-file-system": "12.16.19"
|
|
34
34
|
}
|
|
35
35
|
}
|