mirror of
https://github.com/wanxf-shuto/CordovaReadApplicationSignature.git
synced 2026-06-05 00:00:35 +08:00
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
</feature>
|
</feature>
|
||||||
</config-file>
|
</config-file>
|
||||||
<config-file parent="/*" target="AndroidManifest.xml" />
|
<config-file parent="/*" target="AndroidManifest.xml" />
|
||||||
<source-file src="src/android/ReadAppSignature.java" target-dir="src/cordova/plugin/appSignature/ReadAppSignature" />
|
<source-file src="src/android/ReadAppSignature.java" target-dir="src/cordova/plugin/appSignature" />
|
||||||
</platform>
|
</platform>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ You can read more about it on [Android official website](https://source.android.
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
|
||||||
cordova.exec(function success(signature){
|
cordova.plugins.ReadAppSignature.getAppSignature(function(signature){
|
||||||
//Check signature
|
console.debug("signature: %s", signature);
|
||||||
}, function failure(error){
|
}, function(error){
|
||||||
//alert("Something went wrong");
|
console.debug("signature error: %s", JSON.stringify(error));
|
||||||
}, "ReadAppSignature", "getAppSignature", []);
|
});
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package cordova.plugin.appSignature;
|
package cordova.plugin.appSignature;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import org.apache.cordova.CordovaPlugin;
|
import org.apache.cordova.CordovaPlugin;
|
||||||
import org.apache.cordova.CallbackContext;
|
import org.apache.cordova.CallbackContext;
|
||||||
import org.apache.cordova.PluginResult;
|
import org.apache.cordova.PluginResult;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
@@ -22,6 +23,7 @@ import java.security.NoSuchProviderException;
|
|||||||
* This class echoes a string called from JavaScript.
|
* This class echoes a string called from JavaScript.
|
||||||
*/
|
*/
|
||||||
public class ReadAppSignature extends CordovaPlugin {
|
public class ReadAppSignature extends CordovaPlugin {
|
||||||
|
private final String TAG = "ReadAppSignature";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||||
@@ -46,9 +48,10 @@ public class ReadAppSignature extends CordovaPlugin {
|
|||||||
cordova.getActivity().getPackageName(), PackageManager.GET_SIGNATURES);
|
cordova.getActivity().getPackageName(), PackageManager.GET_SIGNATURES);
|
||||||
|
|
||||||
//note sample just checks the first signature
|
//note sample just checks the first signature
|
||||||
for (Signature signature : packageInfo.signatures) {
|
Signature[] signatures = packageInfo.signatures;
|
||||||
// SHA1 the signature
|
if (signatures.length > 0) {
|
||||||
LogUtils.LOGD(TAG, "getAppSignature() called : " + getSHA1(signature.toByteArray()));
|
Signature signature = signatures[0];
|
||||||
|
Log.d(TAG, "getAppSignature() called : " + getSHA1(signature.toByteArray()));
|
||||||
return getSHA1(signature.toByteArray());
|
return getSHA1(signature.toByteArray());
|
||||||
}
|
}
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
var exec = require('cordova/exec');
|
var exec = require('cordova/exec');
|
||||||
|
|
||||||
exports.getAppSignature = function (arg0, success, error) {
|
exports.getAppSignature = function (success, error) {
|
||||||
exec(success, error, 'ReadAppSignature', 'getAppSignature', [arg0]);
|
exec(success, error, 'ReadAppSignature', 'getSignature', []);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user