|
@@ -3,6 +3,7 @@ package com.sheep.gamegroup.util;
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
import android.app.Dialog;
|
|
import android.app.Dialog;
|
|
|
import android.app.PendingIntent;
|
|
import android.app.PendingIntent;
|
|
|
|
|
+import android.content.ActivityNotFoundException;
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.BroadcastReceiver;
|
|
|
import android.content.ComponentName;
|
|
import android.content.ComponentName;
|
|
|
import android.content.ContentResolver;
|
|
import android.content.ContentResolver;
|
|
@@ -897,6 +898,10 @@ public class SysAppUtil {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
if(TestUtil.isDev())
|
|
if(TestUtil.isDev())
|
|
|
G.showToast(e);
|
|
G.showToast(e);
|
|
|
|
|
+ } catch (ActivityNotFoundException e){
|
|
|
|
|
+ if(RomUtils.checkIsMiuiRom()){
|
|
|
|
|
+ skipActivity(activity, "com.miui.securitycenter", "com.miui.permcenter.MainAcitivty", null, null);
|
|
|
|
|
+ }
|
|
|
} catch (Exception e){
|
|
} catch (Exception e){
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
if(TestUtil.isDev())
|
|
if(TestUtil.isDev())
|
|
@@ -1018,4 +1023,70 @@ public class SysAppUtil {
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public static boolean skipActivity(Context context, String packageName, String className, String action, String extraPkgName){
|
|
|
|
|
+ Intent intent;
|
|
|
|
|
+ if(TextUtils.isEmpty(action))
|
|
|
|
|
+ intent = new Intent();
|
|
|
|
|
+ else
|
|
|
|
|
+ intent = new Intent(action);
|
|
|
|
|
+ if(!TextUtils.isEmpty(extraPkgName)) {
|
|
|
|
|
+ intent.putExtra("extra_pkgname", extraPkgName);
|
|
|
|
|
+ }
|
|
|
|
|
+ intent.setClassName(packageName, className);
|
|
|
|
|
+ if(QQUtil.isValidIntent(context, intent)){
|
|
|
|
|
+ try{
|
|
|
|
|
+ context.startActivity(intent);
|
|
|
|
|
+ if(TestUtil.isDev())
|
|
|
|
|
+ G.showToast("启动成功");
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ if(TestUtil.isDev())
|
|
|
|
|
+ G.showToast(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if(TestUtil.isDev())
|
|
|
|
|
+ G.showToast("启动失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public static void enableComponentYf() {
|
|
|
|
|
+ new Thread(() -> {
|
|
|
|
|
+ //启用有范商城
|
|
|
|
|
+ ComponentName testComponent = new ComponentName(SheepApp.getInstance(), "com.sheep.gamegroup.view.activity.ActYf");
|
|
|
|
|
+ enableComponent(testComponent, true);
|
|
|
|
|
+ }).start();
|
|
|
|
|
+ }
|
|
|
|
|
+ public static boolean isEnableComponentYf() {
|
|
|
|
|
+ //启用有范商城
|
|
|
|
|
+ ComponentName testComponent = new ComponentName(SheepApp.getInstance(), "com.sheep.gamegroup.view.activity.ActYf");
|
|
|
|
|
+ return isEnableComponent(testComponent);
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 是否已经启用组件
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param componentName
|
|
|
|
|
+ */
|
|
|
|
|
+ private static boolean isEnableComponent(ComponentName componentName) {
|
|
|
|
|
+ PackageManager packageManager = SheepApp.getInstance().getPackageManager();
|
|
|
|
|
+ int state = packageManager.getComponentEnabledSetting(componentName);
|
|
|
|
|
+ return state == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 启用组件或者禁用组件
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param componentName
|
|
|
|
|
+ */
|
|
|
|
|
+ private static void enableComponent(ComponentName componentName, boolean enable) {
|
|
|
|
|
+ PackageManager packageManager = SheepApp.getInstance().getPackageManager();
|
|
|
|
|
+ packageManager.setComponentEnabledSetting(componentName,
|
|
|
|
|
+ enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
|
|
|
|
+ PackageManager.DONT_KILL_APP);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|