From fa3107020faf298da35c6f1d7e9a6e5b4f124df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=A4=B4?= <48025211@qq.com> Date: Wed, 22 May 2019 15:26:26 +0800 Subject: [PATCH] oppo --- .../main/java/com/mylhyl/acp/os/HuaWei.java | 20 ++++----- .../main/java/com/mylhyl/acp/os/Native.java | 2 + .../src/main/java/com/mylhyl/acp/os/Oppo.java | 44 +++++++++++++++---- .../main/java/com/mylhyl/acp/os/OsHelper.java | 2 +- .../src/main/java/com/mylhyl/acp/os/Vivo.java | 29 +++++++----- 5 files changed, 66 insertions(+), 31 deletions(-) diff --git a/library/src/main/java/com/mylhyl/acp/os/HuaWei.java b/library/src/main/java/com/mylhyl/acp/os/HuaWei.java index 2e2b54c..3c7bfdc 100644 --- a/library/src/main/java/com/mylhyl/acp/os/HuaWei.java +++ b/library/src/main/java/com/mylhyl/acp/os/HuaWei.java @@ -9,8 +9,6 @@ */ public class HuaWei implements SettingPage { - private static final String PKG = "com.huawei.systemmanager"; - private static final String MAIN_CLS = "com.huawei.permissionmanager.ui.MainActivity"; private Context context; public HuaWei(Context context) { @@ -19,17 +17,17 @@ public HuaWei(Context context) { @Override public Intent createIntent() throws PackageManager.NameNotFoundException { -// Intent intent = new Intent("android.intent.action.MANAGE_APP_PERMISSIONS"); -// Uri uri = Uri.fromParts(EXTRA_PKG, context.getPackageName(), null); -// intent.setData(uri); - //intent.setClassName("com.android.packageinstaller", "com.android.packageinstaller.permission.ui - // .ManagePermissionsActivity"); + Intent intent = new Intent(); - intent.setClassName(PKG, MAIN_CLS); + intent.putExtra("packageName", context.getPackageName()); intent.putExtra(EXTRA_PKG_NAME, context.getPackageName()); - if (OsHelper.isActivityExported(context, intent)) { - intent = null; + intent.putExtra(EXTRA_PKG, context.getPackageName()); + + intent.setClassName("com.huawei.systemmanager", "com.huawei.permissionmanager.ui.MainActivity"); + if (OsHelper.isIntentAvailable(context, intent) && OsHelper.isActivityExported(context, intent)) { + return intent; } - return intent; + + return null; } } diff --git a/library/src/main/java/com/mylhyl/acp/os/Native.java b/library/src/main/java/com/mylhyl/acp/os/Native.java index ea244ed..a907a8a 100644 --- a/library/src/main/java/com/mylhyl/acp/os/Native.java +++ b/library/src/main/java/com/mylhyl/acp/os/Native.java @@ -18,9 +18,11 @@ public Native(Context context) { @Override public Intent createIntent() { + Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts(EXTRA_PKG, context.getPackageName(), null); intent.setData(uri); + return intent; } } diff --git a/library/src/main/java/com/mylhyl/acp/os/Oppo.java b/library/src/main/java/com/mylhyl/acp/os/Oppo.java index ede054a..c418d97 100644 --- a/library/src/main/java/com/mylhyl/acp/os/Oppo.java +++ b/library/src/main/java/com/mylhyl/acp/os/Oppo.java @@ -1,18 +1,14 @@ package com.mylhyl.acp.os; -import android.content.ActivityNotFoundException; -import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; /** * Created by hupei on 2019/5/21 20:36. */ public class Oppo implements SettingPage { - private final String PKG = "com.coloros.safecenter"; - private final String MAIN_CLS = "com.coloros.safecenter.permission.singlepage.PermissionSinglePageActivity"; - private Context context; public Oppo(Context context) { @@ -20,11 +16,41 @@ public Oppo(Context context) { } @Override - public Intent createIntent() throws ActivityNotFoundException { + public Intent createIntent() throws PackageManager.NameNotFoundException { + Intent intent = new Intent(); - intent.setComponent(new ComponentName(PKG, MAIN_CLS)); + intent.putExtra("packageName", context.getPackageName()); + intent.putExtra(EXTRA_PKG_NAME, context.getPackageName()); intent.putExtra(EXTRA_PKG, context.getPackageName()); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - return intent; + + intent.setClassName("com.color.safecenter", "com.color.safecenter.permission.PermissionManagerActivity"); + if (OsHelper.isIntentAvailable(context, intent) && OsHelper.isActivityExported(context, intent)) { + return intent; + } + + intent.setClassName("com.oppo.safe", "com.oppo.safe.permission.PermissionAppListActivity"); + if (OsHelper.isIntentAvailable(context, intent) && OsHelper.isActivityExported(context, intent)) { + return intent; + } + + intent.setClassName("com.coloros.safecenter" + , "com.coloros.safecenter.permission.singlepage.PermissionSinglePageActivity"); + if (OsHelper.isIntentAvailable(context, intent) && OsHelper.isActivityExported(context, intent)) { + return intent; + } + + + intent.setClassName("com.coloros.securitypermission" + , "com.coloros.securitypermission.permission.PermissionGroupsActivity"); + if (OsHelper.isIntentAvailable(context, intent) && OsHelper.isActivityExported(context, intent)) { + return intent; + } + + intent.setClassName("com.coloros.securitypermission" + , "com.coloros.securitypermission.permission.PermissionAppAllPermissionActivity"); + if (OsHelper.isIntentAvailable(context, intent) && OsHelper.isActivityExported(context, intent)) { + return intent; + } + return null; } } diff --git a/library/src/main/java/com/mylhyl/acp/os/OsHelper.java b/library/src/main/java/com/mylhyl/acp/os/OsHelper.java index 413bc8f..84bd0f4 100644 --- a/library/src/main/java/com/mylhyl/acp/os/OsHelper.java +++ b/library/src/main/java/com/mylhyl/acp/os/OsHelper.java @@ -85,6 +85,6 @@ static boolean isActivityExported(Context context, Intent intent) throws Package PackageManager packageManager = context.getPackageManager(); ActivityInfo activityInfo = packageManager.getActivityInfo(intent.getComponent() , PackageManager.MATCH_DEFAULT_ONLY); - return activityInfo != null && !activityInfo.exported; + return activityInfo != null && activityInfo.exported; } } diff --git a/library/src/main/java/com/mylhyl/acp/os/Vivo.java b/library/src/main/java/com/mylhyl/acp/os/Vivo.java index 9c5ca10..1970205 100644 --- a/library/src/main/java/com/mylhyl/acp/os/Vivo.java +++ b/library/src/main/java/com/mylhyl/acp/os/Vivo.java @@ -9,8 +9,6 @@ */ public class Vivo implements SettingPage { - private static final String PKG = "com.iqoo.secure"; - private Context context; public Vivo(Context context) { @@ -19,19 +17,30 @@ public Vivo(Context context) { @Override public Intent createIntent() throws PackageManager.NameNotFoundException { + Intent intent = new Intent(); + intent.putExtra("packageName", context.getPackageName()); + intent.putExtra(EXTRA_PKG_NAME, context.getPackageName()); + intent.putExtra(EXTRA_PKG, context.getPackageName()); + intent.setClassName("com.vivo.permissionmanager" , "com.vivo.permissionmanager.activity.SoftPermissionDetailActivity"); - if (!OsHelper.isIntentAvailable(context, intent)) { - intent.setClassName(PKG, "com.iqoo.secure.safeguard.SoftPermissionDetailActivity"); - } else if (!OsHelper.isIntentAvailable(context, intent)) { - intent.setClassName(PKG, "com.iqoo.secure.MainActivity"); + if (OsHelper.isIntentAvailable(context, intent) && OsHelper.isActivityExported(context, intent)) { + return intent; } - intent.putExtra(EXTRA_PKG_NAME, context.getPackageName()); - if (OsHelper.isActivityExported(context, intent)) { - intent = null; + + intent.setClassName("com.iqoo.secure" + , "com.iqoo.secure.safeguard.SoftPermissionDetailActivity"); + if (OsHelper.isIntentAvailable(context, intent) && OsHelper.isActivityExported(context, intent)) { + return intent; + } + + intent.setClassName("com.iqoo.secure", "com.iqoo.secure.MainActivity"); + if (OsHelper.isIntentAvailable(context, intent) && OsHelper.isActivityExported(context, intent)) { + return intent; } - return intent; + + return null; } }