乐视手机调用自启动管理, 乐视手机调用应用权限管理
2015-11-19 19:34
381 查看
乐视手机
乐视手机调用自启动管理,String ACTION_PERMISSION_AUTOBOOT = “com.letv.android.permissionautoboot”;
乐视手机调用应用权限管理
String ACTION_PERMISSION_AUTOBOOT = “com.letv.android.permissionandapps”;
/*** * 适配乐视手机, 跳转到自启动 * @param ctx */ public void startPermissionAutoBootActivity(Context ctx) { boolean hasLetvsafe = false; try { ApplicationInfo info = ctx.getPackageManager().getApplicationInfo("com.letv.android.letvsafe", PackageManager.GET_UNINSTALLED_PACKAGES); hasLetvsafe = info != null; } catch (PackageManager.NameNotFoundException e) { hasLetvsafe = false; } if (hasLetvsafe) { String ACTION_PERMISSION_AUTOBOOT = "com.letv.android.permissionautoboot"; Intent intent = new Intent(ACTION_PERMISSION_AUTOBOOT); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | // Intent.FLAG_ACTIVITY_NEW_TASK); ctx.startActivity(intent); } } /*** * 适配乐视手机, 跳转到应用权限管理 * @param ctx */ public void startPermissionAppPermission(Context ctx) { boolean hasLetvsafe = false; try { ApplicationInfo info = ctx.getPackageManager().getApplicationInfo("com.letv.android.letvsafe", PackageManager.GET_UNINSTALLED_PACKAGES); hasLetvsafe = info != null; } catch (PackageManager.NameNotFoundException e) { hasLetvsafe = false; } if (hasLetvsafe) { String ACTION_PERMISSION_AUTOBOOT = "com.letv.android.permissionandapps"; Intent intent = new Intent(ACTION_PERMISSION_AUTOBOOT); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | // Intent.FLAG_ACTIVITY_NEW_TASK); ctx.startActivity(intent); } }
小米手机
/** * 主要功能: * <br> 设置自启动管理,主要适用小米手机,其它未考虑 * <br> 步骤 * <br> 1. 先判断是不是MIUI * <br> 2. * @annotation ADRIAN.2015.8.4.18.40 */ public synchronized boolean goTrustList(Context ctx){ if(IS_MIUI){ if("V6".equalsIgnoreCase(miuiVersion)||"V7".equalsIgnoreCase(miuiVersion)){ try{ Intent localIntent = new Intent(); localIntent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")); ctx.startActivity(localIntent); startGuideView(ctx, SetGuideActivity.TYPE_GO_TRUSTLIST_V6); return true; }catch (Exception localException){ } }else{ PackageManager pm = ctx.getPackageManager(); PackageInfo info = null; try { info = pm.getPackageInfo(FS.getInstance().getPackageName(), 0); } catch (NameNotFoundException e) { e.printStackTrace(); } Intent i = new Intent("miui.intent.action.APP_PERM_EDITOR"); i.setClassName("com.android.settings", "com.miui.securitycenter.permission.AppPermissionsEditor"); i.putExtra("extra_package_uid", info.applicationInfo.uid); try { ctx.startActivity(i); startGuideView(ctx, SetGuideActivity.TYPE_GO_TRUSTLIST_V5); } catch (Exception e) { // Toast.makeText(this, "只有MIUI才可以设置哦", Toast.LENGTH_SHORT).show(); } } return true; } else { return false; } } /** * 主要功能: * <br>兼容MIUI5和MIUI6的,开启悬浮窗设置界面 * @annotation ADRIAN.2015.8.4.18.37 */ public boolean goStartSetting(Context ctx){ if(IS_MIUI){ if("V6".equalsIgnoreCase(miuiVersion) || "V7".equalsIgnoreCase(miuiVersion)){ Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR"); intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity"); intent.putExtra("extra_pkgname", FS.getInstance().getPackageName()); ctx.startActivity(intent); startGuideView(ctx, SetGuideActivity.TYPE_GO_START_SETTING_V6); // Intent intent = new Intent( // Settings.ACTION_APPLICATION_DETAILS_SETTINGS); // Uri uri = Uri.fromParts("package", FS.getInstance().getPackageName(), null); // intent.setData(uri); }else{ String pkgName = StartDetectionUtils.getPkgName(ctx); Uri packageURI = Uri.parse("package:" + pkgName); Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packageURI); ctx.startActivity(intent); startGuideView(ctx, SetGuideActivity.TYPE_GO_START_SETTING_V5); } return true; } else { return false; } }
华为手机
public void ddd(Context ctx){ try { // 华为大坑,不能直接用Intent来启动,会启不起来 String cmd = "am start -n com.huawei.systemmanager/.optimize.process.ProtectActivity"; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { cmd += " --user " + getUserSerial(ctx); } Runtime.getRuntime().exec(cmd); } catch (IOException ex) { } // Intent intent = new Intent(ctx, ProtectedActivity.class); // intent.putExtra(ErtaoConstants.EXTRA_FRAGMENT_CLASS, ProtectedFragment.class.getName()); // intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // context.startActivity(intent); // 先获取上下文,避免跳转到其它界面后Fragment与Activity解绑,getActivity()空指针 // final Context context = getActivity(); // mHandler.postDelayed(new Runnable() { // @Override // public void run() { // Intent intent = new Intent(context, ProtectedActivity.class); // intent.putExtra(ErtaoConstants.EXTRA_FRAGMENT_CLASS, ProtectedFragment.class.getName()); // intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // context.startActivity(intent); // } // }, 1000); } public String getUserSerial(Context ctx) { //noinspection ResourceType Object userManager = ctx.getSystemService("user"); if (userManager == null) return ""; try { Method myUserHandleMethod = android.os.Process.class.getMethod("myUserHandle", (Class<?>[]) null); Object myUserHandle = myUserHandleMethod.invoke(android.os.Process.class, (Object[]) null); Method getSerialNumberForUser = userManager.getClass().getMethod("getSerialNumberForUser", myUserHandle.getClass()); long userSerial = (Long) getSerialNumberForUser.invoke(userManager, myUserHandle); return String.valueOf(userSerial); } catch (NoSuchMethodException ex) { } catch (IllegalArgumentException ex) { } catch (IllegalAccessException ex) { } catch (InvocationTargetException ex) { } return ""; }
相关文章推荐
- Android 应用权限管理默认开关的修改方法
- 市面上省电管理简要设计说明和规则
- 乐pro3(lex720)评测
- 乐视手机疯长之谜:冯幸和他的那些铁哥们
- 第12周项目5-迷宫问题之图深度优先遍历解法
- CharSequence的getText()与String的getString()区别和为什么加""
- poj 2478 欧拉函数
- 找出互联网类似以下图的实例
- iOS - CocoaPods使用傻瓜简版
- android触控之MotionEvent
- R基础练习题
- hdu1358
- pentaho cde popup弹出框口
- 金立S6:因“耀”开启金属手机2.0时代
- safari浏览器 session tomcat服务器
- 验证码识别
- android windows的一些item属性
- 【转】AdaBoost--从原理到实现
- find_task_by_vpid undefined 问题
- jQuery和D3两种版本输入框长度控制