Skip to content

Commit

Permalink
fix(inventory): check permission to prevent securityException
Browse files Browse the repository at this point in the history
Signed-off-by: Teclib <skita@teclib.com>
  • Loading branch information
stonebuzz committed Oct 22, 2019
1 parent 810c7f5 commit ac3b161
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion inventory/src/main/java/org/flyve/inventory/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
package org.flyve.inventory;

import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Environment;
import android.telephony.TelephonyManager;
Expand Down Expand Up @@ -188,7 +189,8 @@ protected static String createJSON(Context context, ArrayList<Categories> catego
jsonQuery.put("versionClient", appVersion);
jsonQuery.put("deviceId", getDeviceId());
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) {
if (telephonyManager != null &&
(context.checkPermission(android.Manifest.permission.READ_PHONE_STATE, android.os.Process.myPid(), android.os.Process.myUid())) == PackageManager.PERMISSION_GRANTED) {
jsonQuery.put("IMEI", telephonyManager.getDeviceId());
}
jsonQuery.put("content", content);
Expand Down

0 comments on commit ac3b161

Please sign in to comment.