mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-25 14:35:40 +03:00
Attempt to fix Xiaomi
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
2b2ec99e2d
commit
c59a003d2a
1 changed files with 5 additions and 16 deletions
|
@ -22,13 +22,11 @@ package com.nextcloud.talk.utils;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
@ -48,20 +46,11 @@ public class DeviceUtils {
|
|||
if (result instanceof Integer) {
|
||||
Integer integerResult = (Integer) result;
|
||||
if (integerResult == 0) {
|
||||
Class<ApplicationInfo> clazz = ApplicationInfo.class;
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true);
|
||||
if (field.getName().equals("FLAG_DISABLE_AUTOSTART")) {
|
||||
int value = field.getInt(ApplicationInfo.class);
|
||||
if (value != 0) {
|
||||
field.setInt(ApplicationInfo.class, 0);
|
||||
field.setAccessible(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
field.setAccessible(false);
|
||||
Method setApplicationAutoStartMethod = aClass.getDeclaredMethod("setApplicationAutoStart",
|
||||
Context.class, String.class, Boolean.TYPE);
|
||||
if (setApplicationAutoStartMethod != null) {
|
||||
setApplicationAutoStartMethod.invoke(aClass, applicationContext, applicationContext.getPackageName(),
|
||||
Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue