mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-11 18:10:44 +00:00
Update huawei
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
437063e924
commit
ac96dd8540
@ -80,16 +80,21 @@ public class DeviceUtils {
|
|||||||
@SuppressLint("PrivateApi") Class<?> aClass = Class.forName("com.huawei.systemmanager.optimize.process" +
|
@SuppressLint("PrivateApi") Class<?> aClass = Class.forName("com.huawei.systemmanager.optimize.process" +
|
||||||
".ProtectAppControl");
|
".ProtectAppControl");
|
||||||
if (aClass != null) {
|
if (aClass != null) {
|
||||||
Method isProtected = aClass.getDeclaredMethod("isProtect", String.class);
|
|
||||||
Context applicationContext = NextcloudTalkApplication.getSharedApplication().getApplicationContext();
|
Context applicationContext = NextcloudTalkApplication.getSharedApplication().getApplicationContext();
|
||||||
Object result = isProtected.invoke(aClass, applicationContext.getApplicationContext().getPackageName());
|
|
||||||
|
Method method = aClass.getMethod("getInstance", Context.class);
|
||||||
|
// ProtectAppControl instance
|
||||||
|
Object protectAppControlInstance = method.invoke(null, applicationContext);
|
||||||
|
|
||||||
|
Method isProtected = aClass.getDeclaredMethod("isProtect", String.class);
|
||||||
|
Object result = isProtected.invoke(protectAppControlInstance, applicationContext.getPackageName());
|
||||||
if (result instanceof Boolean) {
|
if (result instanceof Boolean) {
|
||||||
boolean booleanResult = (boolean) result;
|
boolean booleanResult = (boolean) result;
|
||||||
if (!booleanResult) {
|
if (!booleanResult) {
|
||||||
Method setProtect = aClass.getDeclaredMethod("setProtect", List.class);
|
Method setProtect = aClass.getDeclaredMethod("setProtect", List.class);
|
||||||
List<String> appsList = new ArrayList<>();
|
List<String> appsList = new ArrayList<>();
|
||||||
appsList.add(applicationContext.getApplicationContext().getPackageName());
|
appsList.add(applicationContext.getPackageName());
|
||||||
setProtect.invoke(aClass, appsList);
|
setProtect.invoke(protectAppControlInstance, appsList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user