Fix potential exception when reading xposedminversion
This commit is contained in:
parent
0776d49ea3
commit
2c90990625
|
|
@ -66,7 +66,12 @@ public class HandleBindApp extends XC_MethodHook {
|
||||||
Map<String, Object> metaData = MetaDataReader.getMetaData(new File(appInfo.sourceDir));
|
Map<String, Object> metaData = MetaDataReader.getMetaData(new File(appInfo.sourceDir));
|
||||||
isModule = metaData.containsKey("xposedmodule");
|
isModule = metaData.containsKey("xposedmodule");
|
||||||
if (isModule) {
|
if (isModule) {
|
||||||
xposedminversion = (Integer) metaData.get("xposedminversion");
|
Object minVersionRaw = metaData.get("xposedminversion");
|
||||||
|
if (minVersionRaw instanceof Integer) {
|
||||||
|
xposedminversion = (Integer) minVersionRaw;
|
||||||
|
} else if (minVersionRaw instanceof String) {
|
||||||
|
xposedminversion = MetaDataReader.extractIntPart((String) minVersionRaw);
|
||||||
|
}
|
||||||
xposedsharedprefs = metaData.containsKey("xposedsharedprefs");
|
xposedsharedprefs = metaData.containsKey("xposedsharedprefs");
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException | IOException e) {
|
} catch (NumberFormatException | IOException e) {
|
||||||
|
|
|
||||||
|
|
@ -104,4 +104,16 @@ public class MetaDataReader {
|
||||||
super.end();
|
super.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int extractIntPart(String str) {
|
||||||
|
int result = 0, length = str.length();
|
||||||
|
for (int offset = 0; offset < length; offset++) {
|
||||||
|
char c = str.charAt(offset);
|
||||||
|
if ('0' <= c && c <= '9')
|
||||||
|
result = result * 10 + (c - '0');
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,6 @@ import de.robv.android.xposed.services.FileResult;
|
||||||
* This class is basically the same as SharedPreferencesImpl from AOSP, but
|
* This class is basically the same as SharedPreferencesImpl from AOSP, but
|
||||||
* read-only and without listeners support. Instead, it is made to be
|
* read-only and without listeners support. Instead, it is made to be
|
||||||
* compatible with all ROMs.
|
* compatible with all ROMs.
|
||||||
*
|
|
||||||
* @deprecated in Android Pie or later was lost by Google, will not remove
|
|
||||||
*/
|
*/
|
||||||
public final class XSharedPreferences implements SharedPreferences {
|
public final class XSharedPreferences implements SharedPreferences {
|
||||||
private static final String TAG = "XSharedPreferences";
|
private static final String TAG = "XSharedPreferences";
|
||||||
|
|
@ -77,7 +75,12 @@ public final class XSharedPreferences implements SharedPreferences {
|
||||||
Map<String, Object> metaData = MetaDataReader.getMetaData(new File(m));
|
Map<String, Object> metaData = MetaDataReader.getMetaData(new File(m));
|
||||||
isModule = metaData.containsKey("xposedmodule");
|
isModule = metaData.containsKey("xposedmodule");
|
||||||
if (isModule) {
|
if (isModule) {
|
||||||
xposedminversion = (Integer) metaData.get("xposedminversion");
|
Object minVersionRaw = metaData.get("xposedminversion");
|
||||||
|
if (minVersionRaw instanceof Integer) {
|
||||||
|
xposedminversion = (Integer) minVersionRaw;
|
||||||
|
} else if (minVersionRaw instanceof String) {
|
||||||
|
xposedminversion = MetaDataReader.extractIntPart((String) minVersionRaw);
|
||||||
|
}
|
||||||
xposedsharedprefs = metaData.containsKey("xposedsharedprefs");
|
xposedsharedprefs = metaData.containsKey("xposedsharedprefs");
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException | IOException e) {
|
} catch (NumberFormatException | IOException e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue