乐视手机调用自启动管理,
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);
}
}
/** * 主要功能: *
设置自启动管理,主要适用小米手机,其它未考虑 *
步骤 *
1. 先判断是不是MIUI *
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;
}
}
/** * 主要功能: *
兼容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 "";
}