keepLive2
This commit is contained in:
parent
4f7f5d6a73
commit
637296d769
@ -4,6 +4,7 @@
|
||||
package="com.arpa.hndahesudintocctmsdriver">
|
||||
<!-- 白名单 -->
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||
<uses-permission android:name="com.huawei.permission.external_app_settings.USE_COMPONENT"/>
|
||||
<!-- 基础权限 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
@ -65,19 +66,42 @@
|
||||
android:name="com/alct/mdp"
|
||||
android:required="false" />
|
||||
|
||||
<service
|
||||
android:name=".ui.text.TestNotificationListenerService"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"><!--必要的绑定权限-->
|
||||
<intent-filter>
|
||||
<action android:name="android.service.notification.NotificationListenerService" /><!--必要的action-->
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".ui.text.TestService"
|
||||
android:directBootAware="true"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:foregroundServiceType="phoneCall|mediaPlayback|dataSync|mediaProjection|connectedDevice|location" />
|
||||
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.MainActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="portrait" ></activity>
|
||||
android:screenOrientation="portrait"></activity>
|
||||
|
||||
<activity
|
||||
android:name=".ui.text.TextActivity"
|
||||
android:exported="true">
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.wallet.WithdrawalActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.wallet.UpBankActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.home.OrderAllActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -92,10 +116,17 @@
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.auth.PhotoCarActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.auth.VehicleAuthActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.home.shangchuan.ShangChuangImgActivity"
|
||||
android:screenOrientation="portrait">
|
||||
@ -111,13 +142,13 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.home.shangchuan.GetShangChuanActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.auth.AuthQualificationActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.home.OrderListActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.home.HuoYunDelActivity"
|
||||
android:screenOrientation="portrait">
|
||||
@ -130,13 +161,13 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.auth.CertificatesActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.auth.AddCarSuccActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.login.LoginActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.login.WelcomeActivity"
|
||||
android:screenOrientation="portrait">
|
||||
@ -159,10 +190,10 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.home.drivercircle.VideoReleaseActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.home.shangchuan.WebPDFActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.home.StartYunDanActivity"
|
||||
android:screenOrientation="portrait">
|
||||
@ -170,13 +201,13 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.home.drivercircle.HomePageActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.alert.VehicleChoiceActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.home.shangchuan.OrderComplaintActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.ui.web.WebActivity"
|
||||
android:screenOrientation="portrait"
|
||||
@ -190,7 +221,7 @@
|
||||
<activity
|
||||
android:name=".ui.news.NewActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||
|
||||
<service
|
||||
android:name="com.arpa.hndahesudintocctmsdriver.service.TrackService"
|
||||
@ -233,7 +264,7 @@
|
||||
<meta-data
|
||||
android:name="com.amap.api.v2.apikey"
|
||||
android:value="78019612271411eca3af34db91930620" />
|
||||
<!-- android:value="702eaa84675618b8eb69298d9fd42ca3" />-->
|
||||
<!-- android:value="702eaa84675618b8eb69298d9fd42ca3" />-->
|
||||
|
||||
<service android:name="com.amap.api.location.APSService"></service>
|
||||
|
||||
|
@ -3,14 +3,17 @@ package com.arpa.hndahesudintocctmsdriver;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alct.mdp.MDPLocationCollectionManager;
|
||||
import com.arpa.hndahesudintocctmsdriver.report.JTTProcess;
|
||||
import com.arpa.hndahesudintocctmsdriver.request.net.Api;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.text.TestNotificationListenerService;
|
||||
import com.dahe.mylibrary.CommonBaseLibrary;
|
||||
import com.esign.esignsdk.EsignSdk;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.sp.SPUtil;
|
||||
@ -29,10 +32,24 @@ public class App extends Application {
|
||||
public static int APP_STATUS = APP_STATUS_KILLED; // 记录App的启动状态
|
||||
private Context con;
|
||||
public static App mApplication = null;
|
||||
/**
|
||||
* 启动服务
|
||||
*/
|
||||
private void startService() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
/****************第三点*******************/
|
||||
//安卓8.0以上开启为前台服务
|
||||
startForegroundService(new Intent(this, App.class));
|
||||
} else {
|
||||
startService(new Intent(this, App.class));
|
||||
}
|
||||
startService(new Intent(this, TestNotificationListenerService.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
startService();
|
||||
mApplication = this;
|
||||
con = getBaseContext();
|
||||
CommonBaseLibrary.getInstance().init(this, Api.BASE_URL);
|
||||
|
@ -1,10 +1,13 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.ui.my;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -16,6 +19,7 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.event.PersonEvent;
|
||||
import com.arpa.hndahesudintocctmsdriver.event.VehicleEvent;
|
||||
@ -23,6 +27,7 @@ import com.arpa.hndahesudintocctmsdriver.parts.ConfigParts;
|
||||
import com.arpa.hndahesudintocctmsdriver.parts.StartOrderParts;
|
||||
import com.arpa.hndahesudintocctmsdriver.parts.UserParts;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.business.BusinessActivity;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.text.TextActivity;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.PicturlUtil;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.google.gson.Gson;
|
||||
@ -50,6 +55,7 @@ import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author hlh
|
||||
@ -232,24 +238,27 @@ public class MyFragment extends BaseFragment {
|
||||
});
|
||||
//联系我们
|
||||
onContact.setOnClickListener(v -> {
|
||||
String serviceMobile="";
|
||||
if(ConfigParts.getConfigParts(con)!=null){
|
||||
serviceMobile=ConfigParts.getConfigParts(con).getData().getServiceMobile();
|
||||
serviceMobile=StringUtil.isNull(serviceMobile,"");
|
||||
}
|
||||
String[] title={"平台客服:"+serviceMobile};
|
||||
String[] value={serviceMobile};
|
||||
new XPopup.Builder(con)
|
||||
.isDarkTheme(false)
|
||||
.isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
|
||||
.asCenterList("请选择",title,
|
||||
(position1, text) -> {
|
||||
Intent intent = new Intent(Intent.ACTION_DIAL);
|
||||
Uri data = Uri.parse("tel:" + value[position1]);
|
||||
intent.setData(data);
|
||||
startActivity(intent);
|
||||
})
|
||||
.show();
|
||||
getActivity().startActivity(new Intent(getActivity(), TextActivity.class));
|
||||
// isNotificationListenerEnabled(getActivity());
|
||||
// goHuaWeiMainager();
|
||||
// String serviceMobile="";
|
||||
// if(ConfigParts.getConfigParts(con)!=null){
|
||||
// serviceMobile=ConfigParts.getConfigParts(con).getData().getServiceMobile();
|
||||
// serviceMobile=StringUtil.isNull(serviceMobile,"");
|
||||
// }
|
||||
// String[] title={"平台客服:"+serviceMobile};
|
||||
// String[] value={serviceMobile};
|
||||
// new XPopup.Builder(con)
|
||||
// .isDarkTheme(false)
|
||||
// .isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
|
||||
// .asCenterList("请选择",title,
|
||||
// (position1, text) -> {
|
||||
// Intent intent = new Intent(Intent.ACTION_DIAL);
|
||||
// Uri data = Uri.parse("tel:" + value[position1]);
|
||||
// intent.setData(data);
|
||||
// startActivity(intent);
|
||||
// })
|
||||
// .show();
|
||||
});
|
||||
//咨询建议
|
||||
onOpinion.setOnClickListener(v -> {
|
||||
@ -264,6 +273,47 @@ public class MyFragment extends BaseFragment {
|
||||
onSetUp.setOnClickListener(v -> startActivity(new Intent(con, SetupActivity.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否开启通知使用权限
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public void isNotificationListenerEnabled(Context context) {
|
||||
Set<String> packageNames = NotificationManagerCompat.getEnabledListenerPackages(context);
|
||||
if (!packageNames.contains(context.getPackageName())) {//没有开启使用权限,去开启
|
||||
Intent intent = new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void goHuaWeiMainager() {
|
||||
try {
|
||||
Intent intent = new Intent(getActivity().getPackageName());
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// ComponentName comp = new ComponentName("com.huawei.systemmanager", "com.huawei.permissionmanager.ui.MainActivity");
|
||||
ComponentName comp = new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity");
|
||||
intent.setComponent(comp);
|
||||
getActivity().startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(getActivity(), "跳转失败", Toast.LENGTH_LONG).show();
|
||||
e.printStackTrace();
|
||||
goIntentSetting();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void goIntentSetting() {
|
||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
Uri uri = Uri.fromParts("package", getActivity().getPackageName(), null);
|
||||
intent.setData(uri);
|
||||
try {
|
||||
getActivity().startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void initAuth(){
|
||||
if(userBean.getData()!=null){
|
||||
name.setText(StringUtil.isNull(userBean.getData().getUname(),"未实名"));
|
||||
|
@ -0,0 +1,36 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.ui.text;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
|
||||
/**
|
||||
* @ClassName AutoStartAppUtil
|
||||
* @Author 用户
|
||||
* @Date 2022/10/9 9:56
|
||||
* @Description TODO
|
||||
*/
|
||||
public class AutoStartAppUtil {
|
||||
public static final Intent[] POWERMANAGER_INTENTS = {
|
||||
new Intent().setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity")),
|
||||
//new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.privacypermissionsentry.PermissionTopActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.startupapp.StartupAppListActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.oppo.safe", "com.oppo.safe.permission.startup.StartupAppListActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager")),
|
||||
new Intent().setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.samsung.android.lool", "com.samsung.android.sm.battery.ui.BatteryActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.samsung.android.lool", "com.samsung.android.sm.ui.battery.BatteryActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.htc.pitroad", "com.htc.pitroad.landingpage.activity.LandingPageActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.asus.mobilemanager", "com.asus.mobilemanager.MainActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.transsion.phonemanager", "com.itel.autobootmanager.activity.AutoBootMgrActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.meizu.safe", "com.meizu.safe.permission.SmartBGActivity")),
|
||||
new Intent().setComponent(new ComponentName("cn.nubia.security2", "cn.nubia.security.appmanage.selfstart.ui.SelfStartActivity")),
|
||||
new Intent().setComponent(new ComponentName("com.transsion.phonemaster", "com.cyin.himgr.applicationmanager.view.activities.AutoStartActivity")),
|
||||
};
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.ui.text;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
|
||||
/**
|
||||
* @ClassName TestNotificationListenerService
|
||||
* @Author 用户
|
||||
* @Date 2022/10/9 9:53
|
||||
* @Description TODO
|
||||
*/
|
||||
public class TestNotificationListenerService extends NotificationListenerService {
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotificationPosted(StatusBarNotification sbn) {
|
||||
super.onNotificationPosted(sbn);
|
||||
//Notification notification = sbn.getNotification();
|
||||
// Log.d(LiveTaskApplication.TAG, "sbn.getPackageName: " + sbn.getPackageName());
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.ui.text;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.R;
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.MainActivity;
|
||||
|
||||
/**
|
||||
* @ClassName TestService
|
||||
* @Author 用户
|
||||
* @Date 2022/10/9 9:51
|
||||
* @Description TODO
|
||||
*/
|
||||
public class TestService extends Service {
|
||||
|
||||
private static final int VISIBILITY_PUBLIC = 1000;
|
||||
private static final int PRIORITY_HIGH = 1000;
|
||||
private final String CHANNEL_ONE_ID = "100";
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onUnbind(Intent intent) {
|
||||
return super.onUnbind(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
/****************第一点*******************/
|
||||
//创建通知栏常驻通知
|
||||
initNotif("title", "text");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
stopForeground(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
// return super.onStartCommand(intent, flags, startId);
|
||||
/****************第二点*******************/
|
||||
//返回START_STICKY,被系统或手动清理后可重启
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
public void initNotif(String title, String context) {
|
||||
//RemoteViews remoteView = new RemoteViews(getPackageName(), R.layout.RemoteView);
|
||||
Drawable drawable = getResources().getDrawable(R.mipmap.ic_launcher, null);
|
||||
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
|
||||
Bitmap bitmapIcon = getBitmapFromDrawable(drawable);
|
||||
|
||||
Intent nfIntent = new Intent(this, MainActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, nfIntent, 0);
|
||||
@SuppressLint("WrongConstant") NotificationCompat.Builder builder = new NotificationCompat.Builder(this.getApplicationContext(), CHANNEL_ONE_ID)
|
||||
.setContentIntent(pendingIntent) // 设置PendingIntent
|
||||
.setSmallIcon(R.mipmap.ic_launcher) // 设置状态栏内的小图标
|
||||
//.setLargeIcon(bitmapIcon)// 设置大图标
|
||||
.setContentTitle(title)
|
||||
.setContentText(context) // 设置内容
|
||||
.setWhen(System.currentTimeMillis())// 设置该通知发生的时间
|
||||
.setVisibility(VISIBILITY_PUBLIC)// 锁屏显示全部通知
|
||||
//.setDefaults(Notification.DEFAULT_ALL)// //使用默认的声音、振动、闪光
|
||||
.setPriority(PRIORITY_HIGH);// 通知的优先级
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
//修改安卓8.0以上系统报错
|
||||
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ONE_ID, "服务常驻通知", NotificationManager.IMPORTANCE_MIN);
|
||||
notificationChannel.enableLights(false);//如果使用中的设备支持通知灯,则说明此通知通道是否应显示灯
|
||||
notificationChannel.setShowBadge(false);//是否显示角标
|
||||
notificationChannel.enableVibration(false);//是否震动
|
||||
notificationChannel.setLockscreenVisibility(VISIBILITY_PUBLIC);//锁屏显示全部通知
|
||||
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
manager.createNotificationChannel(notificationChannel);
|
||||
builder.setChannelId(CHANNEL_ONE_ID);
|
||||
}
|
||||
Notification notification = builder.build(); // 获取构建好的Notification
|
||||
notification.defaults = Notification.DEFAULT_SOUND; //设置为默认的声音
|
||||
|
||||
startForeground(1, notification);
|
||||
}
|
||||
|
||||
/**
|
||||
* 把资源图片转换成Bitmap
|
||||
*
|
||||
* @param drawable 资源图片
|
||||
* @return 位图
|
||||
*/
|
||||
public static Bitmap getBitmapFromDrawable(Drawable drawable) {
|
||||
int width = drawable.getBounds().width();
|
||||
int height = drawable.getBounds().height();
|
||||
Bitmap bitmap = Bitmap.createBitmap(width, height, drawable
|
||||
.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
|
||||
: Bitmap.Config.RGB_565);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, width, height);
|
||||
drawable.draw(canvas);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,338 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.ui.text;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.R;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @ClassName TextActivity
|
||||
* @Author 用户
|
||||
* @Date 2022/10/9 10:05
|
||||
* @Description TODO
|
||||
*/
|
||||
public class TextActivity extends AppCompatActivity implements View.OnClickListener{
|
||||
|
||||
private TextView mLeft;
|
||||
private TextView mBandName;
|
||||
private TextView mAutoStart;
|
||||
private TextView mTutorials;
|
||||
private TextView mLockApp;
|
||||
private TextView mBatteryOptimization;
|
||||
private WebView mWebView1, mWebView2;
|
||||
|
||||
private boolean isWeb = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main1);
|
||||
//提示: 需要与服务共享数据自行绑定服务
|
||||
initView();
|
||||
/****************第四点*******************/
|
||||
//开启通知使用权限(有的手机需要开启才能重启进程)
|
||||
isNotificationListenerEnabled(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == mLeft) {
|
||||
if (isWeb) {
|
||||
isWeb = false;
|
||||
mWebView1.setVisibility(View.GONE);
|
||||
mWebView2.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
finish();
|
||||
} else if (v == mTutorials) {
|
||||
isWeb = true;
|
||||
mWebView1.setVisibility(View.VISIBLE);
|
||||
String brand = getDeviceBrand();
|
||||
String htmlName = "";
|
||||
if (brand.equalsIgnoreCase("huawei")) {
|
||||
htmlName = "huawei";
|
||||
} else if (brand.equalsIgnoreCase("honor")) {
|
||||
htmlName = "honor";
|
||||
} else if (brand.equalsIgnoreCase("infinix")) {
|
||||
htmlName = "infinix";
|
||||
} else if (brand.equalsIgnoreCase("meizu")) {
|
||||
htmlName = "meizu";
|
||||
} else if (brand.equalsIgnoreCase("xiaomi")) {
|
||||
htmlName = "xiaomi";
|
||||
} else if (brand.equalsIgnoreCase("redmi")) {
|
||||
htmlName = "redmi";
|
||||
} else if (brand.equalsIgnoreCase("oppo")) {
|
||||
htmlName = "oppo";
|
||||
} else if (brand.equalsIgnoreCase("realme")) {
|
||||
htmlName = "realme";
|
||||
} else if (brand.equalsIgnoreCase("onePlus")) {
|
||||
htmlName = "onePlus";
|
||||
} else if (brand.equalsIgnoreCase("vivo")) {
|
||||
htmlName = "vivo";
|
||||
} else if (brand.equalsIgnoreCase("iqoo")) {
|
||||
htmlName = "iqoo";
|
||||
} else if (brand.equalsIgnoreCase("smartisan")) {
|
||||
htmlName = "smartisan";
|
||||
} else if (brand.equalsIgnoreCase("sumsang")) {
|
||||
htmlName = "sumsang";
|
||||
} else if (brand.equalsIgnoreCase("asus")) {
|
||||
htmlName = "asus";
|
||||
} else if (brand.equalsIgnoreCase("lenovo")) {
|
||||
htmlName = "lenovo";
|
||||
} else if (brand.equalsIgnoreCase("nubia")) {
|
||||
htmlName = "nubia";
|
||||
}
|
||||
if (!getSystemLanguage().contains("zh")) {// 非中文
|
||||
htmlName = htmlName + "_e";
|
||||
}
|
||||
mWebView1.loadUrl("http://服务器接口地址/autostart/autostart_" + htmlName + ".html");
|
||||
|
||||
} else if (v == mAutoStart) {
|
||||
Intent intents = null;
|
||||
for (Intent intent : AutoStartAppUtil.POWERMANAGER_INTENTS)
|
||||
if (getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
|
||||
intents = intent;
|
||||
break;
|
||||
}
|
||||
Log.e("gy", "手机品牌 device brand:" + getDeviceBrand());
|
||||
if (intents != null) {
|
||||
if (getDeviceBrand().equalsIgnoreCase("Infinix")) {
|
||||
Toast.makeText(this, "无权打开系统界面, 请点击查看教程手动设置", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (getDeviceBrand().equalsIgnoreCase("OPPO") || getDeviceBrand().equalsIgnoreCase("realme")) {
|
||||
if (ContextCompat.checkSelfPermission(TextActivity.this, "oppo.permission.OPPO_COMPONENT_SAFE") != PackageManager.PERMISSION_GRANTED) {
|
||||
// oppo 为系统权限不对外开放
|
||||
Toast.makeText(this, "无权打开系统界面, 请点击查看教程手动设置", Toast.LENGTH_SHORT).show();
|
||||
// ActivityCompat.requestPermissions(PermissionsDescriptionActivity.this, new
|
||||
// String[]{"oppo.permission.OPPO_COMPONENT_SAFE"}, 1);
|
||||
} else {
|
||||
startActivity(intents);
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
startActivity(intents);
|
||||
}catch (Exception e){
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (getDeviceBrand().equalsIgnoreCase("OnePlus")) {
|
||||
intents = new Intent("com.android.settings.action.BACKGROUND_OPTIMIZE");
|
||||
startActivity(intents);
|
||||
return;
|
||||
}
|
||||
// if (SystemUtil.getDeviceBrand().equalsIgnoreCase("SMARTISAN")) {
|
||||
// intents = new Intent("com.smartisanos.security.action.SWITCHED_PERMISSIONS_NEW");//无效
|
||||
// startActivity(intents);
|
||||
// return;
|
||||
// }
|
||||
Toast.makeText(this, "无权打开系统界面, 请点击查看教程手动设置", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else if (v == mLockApp) {
|
||||
isWeb = true;
|
||||
mWebView2.setVisibility(View.VISIBLE);
|
||||
if (getSystemLanguage().contains("zh")) {// 中文
|
||||
mWebView2.loadUrl("http://服务器接口地址/locktask/lockApp.html");
|
||||
} else {
|
||||
mWebView2.loadUrl("http://服务器接口地址/locktask/lockApp_e.html");
|
||||
}
|
||||
} else if (v == mBatteryOptimization) {
|
||||
// 显示屏幕以控制哪些应用可以忽略电池优化
|
||||
// 您可以PowerManager.isIgnoringBatteryOptimizations()用来确定应用程序是否已经忽略优化。
|
||||
// 您可以 ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS用来要求用户将您放在此列表中。
|
||||
//android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setIcon(R.mipmap.ic_launcher)
|
||||
.setTitle("忽略电池优化")
|
||||
.setMessage("参考说明:\n在手机 设置 --> 电池 --> 耗电管理 中找到" + getString(R.string.app_name) + ", 设置 允许后台运行 或 允许后台启动 等")
|
||||
.setPositiveButton("设置忽略", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
if (!isIgnoringBatteryOptimizations()) {
|
||||
try {
|
||||
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
||||
intent.setData(Uri.parse("package:" + getPackageName()));
|
||||
//跳转之前判断intent是否存在,否则有的机型会报找不到activity
|
||||
if (intent.resolveActivity(getPackageManager()) == null) {
|
||||
intent = new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
|
||||
intent.setData(Uri.parse("package:" + getPackageName()));
|
||||
if (intent.resolveActivity(getPackageManager()) == null) {
|
||||
// showToast("无法启动系统界面,请以参考说明操作");
|
||||
} else {
|
||||
startActivity(intent);
|
||||
}
|
||||
} else {
|
||||
startActivity(intent);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否开启通知使用权限
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public void isNotificationListenerEnabled(Context context) {
|
||||
Set<String> packageNames = NotificationManagerCompat.getEnabledListenerPackages(this);
|
||||
if (!packageNames.contains(context.getPackageName())) {//没有开启使用权限,去开启
|
||||
Intent intent = new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
mBandName = (TextView) findViewById(R.id.bandName);
|
||||
mLeft = (TextView) findViewById(R.id.left);
|
||||
mLeft.setOnClickListener(this);
|
||||
mAutoStart = (TextView) findViewById(R.id.autoStart);
|
||||
mAutoStart.setOnClickListener(this);
|
||||
mTutorials = (TextView) findViewById(R.id.tutorials);
|
||||
mTutorials.setOnClickListener(this);
|
||||
mLockApp = (TextView) findViewById(R.id.lockApp);
|
||||
mLockApp.setOnClickListener(this);
|
||||
mBatteryOptimization = (TextView) findViewById(R.id.battery_optimization);
|
||||
mBatteryOptimization.setOnClickListener(this);
|
||||
mWebView1 = (WebView) findViewById(R.id.webView1);
|
||||
mWebView1.setOnClickListener(this);
|
||||
mWebView2 = (WebView) findViewById(R.id.webView2);
|
||||
mWebView2.setOnClickListener(this);
|
||||
|
||||
mBandName.setText(getDeviceBrand());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 确定应用程序是否已经忽略电池优化
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isIgnoringBatteryOptimizations() {
|
||||
boolean isIgnoring = false;
|
||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
if (powerManager != null) {
|
||||
isIgnoring = powerManager.isIgnoringBatteryOptimizations(getPackageName());
|
||||
}
|
||||
return isIgnoring;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
//super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
switch (requestCode) {
|
||||
case 1:
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
Intent intents = null;
|
||||
for (Intent intent : AutoStartAppUtil.POWERMANAGER_INTENTS)
|
||||
if (getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
|
||||
intents = intent;
|
||||
break;
|
||||
}
|
||||
if (intents != null) {
|
||||
startActivity(intents);
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, "无权打开系统界面, 请点击查看教程手动设置", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 原生Android系统 开启后台运行调用这里
|
||||
*/
|
||||
public void requestIgnoreBatteryOptimizations() {
|
||||
try {
|
||||
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
||||
intent.setData(Uri.parse("package:" + getPackageName()));
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
moveTaskToBack(true);//按返回键,不 finish activity
|
||||
return true;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前手机系统语言。
|
||||
*
|
||||
* @return 返回当前系统语言。例如:当前设置的是“中文-中国”,则返回“zh-CN”
|
||||
*/
|
||||
public static String getSystemLanguage() {
|
||||
return Locale.getDefault().getLanguage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前系统上的语言列表(Locale列表)
|
||||
*
|
||||
* @return 语言列表
|
||||
*/
|
||||
public static Locale[] getSystemLanguageList() {
|
||||
return Locale.getAvailableLocales();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前手机系统版本号
|
||||
*
|
||||
* @return 系统版本号
|
||||
*/
|
||||
public static String getSystemVersion() {
|
||||
return android.os.Build.VERSION.RELEASE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取手机型号
|
||||
*
|
||||
* @return 手机型号
|
||||
*/
|
||||
public static String getSystemModel() {
|
||||
return android.os.Build.MODEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取手机厂商
|
||||
*
|
||||
* @return 手机厂商
|
||||
*/
|
||||
public static String getDeviceBrand() {
|
||||
return android.os.Build.BRAND;
|
||||
}
|
||||
}
|
221
app/src/main/res/layout/activity_main1.xml
Normal file
221
app/src/main/res/layout/activity_main1.xml
Normal file
@ -0,0 +1,221 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/titleBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:clipToPadding="true"
|
||||
tools:context=".activity.BaseActivity">
|
||||
<!--android:fitsSystemWindows="true"-->
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/left"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:gravity="center"
|
||||
android:text="返回"
|
||||
android:textColor="@android:color/black"
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center"
|
||||
android:text="后台运行设置"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/right"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:gravity="center"
|
||||
android:text=""
|
||||
android:textColor="@android:color/black"
|
||||
android:visibility="gone" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/line"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="?android:attr/listDivider"
|
||||
android:visibility="visible" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:padding="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:text="你的手机"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bandName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="HUAWEI"
|
||||
android:textColor="@android:color/holo_orange_dark"
|
||||
android:textSize="18sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:padding="20dp"
|
||||
android:text="为什么要让应用程序在后台运行?"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingEnd="40dp"
|
||||
android:paddingBottom="20dp"
|
||||
android:text="接收通知需要应用在后台持续运行,以避免进程被系统终止。 这可能会错过来电和信息。"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingEnd="40dp"
|
||||
android:text="注意:如果您的手机上安装了第三方安全管理应用,请将IMFitPro添加到它们的例外中, 不受其约束。"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tutorials"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:drawablePadding="20dp"
|
||||
android:gravity="center"
|
||||
android:text="查看自启动教程"
|
||||
android:textColor="@android:color/holo_orange_dark"
|
||||
android:textSize="18sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/autoStart"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:drawablePadding="20dp"
|
||||
android:gravity="center"
|
||||
android:text="设置自启动"
|
||||
android:textColor="@android:color/holo_orange_dark"
|
||||
android:textSize="18sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lockApp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:drawablePadding="20dp"
|
||||
android:gravity="center"
|
||||
android:text="在后台锁定应用程序"
|
||||
android:textColor="@android:color/holo_orange_dark"
|
||||
android:textSize="18sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/battery_optimization"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:drawablePadding="20dp"
|
||||
android:gravity="center"
|
||||
android:text="忽略电池优化"
|
||||
android:textColor="@android:color/holo_orange_dark"
|
||||
android:textSize="18sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<WebView
|
||||
android:id="@+id/webView1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white"
|
||||
android:visibility="gone" />
|
||||
|
||||
<WebView
|
||||
android:id="@+id/webView2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
@ -0,0 +1,163 @@
|
||||
package com.dahe.mylibrary.utils;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.dahe.mylibrary.R;
|
||||
|
||||
/**
|
||||
* @ClassName MobileInfoUtils
|
||||
* @Author 用户
|
||||
* @Date 2022/10/8 10:18
|
||||
* @Description TODO
|
||||
*/
|
||||
public class MobileInfoUtils {
|
||||
|
||||
// private SettingDialogPermision dialog_per;
|
||||
|
||||
//获取手机类型
|
||||
|
||||
private static String getMobileType() {
|
||||
|
||||
return Build.MANUFACTURER;
|
||||
|
||||
}
|
||||
|
||||
//跳转至授权页面
|
||||
|
||||
public void jumpStartInterface(Context context) {
|
||||
|
||||
Intent intent = new Intent();
|
||||
|
||||
try {
|
||||
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
Log.e("HLQ_Struggle", "******************当前手机型号为:" + getMobileType());
|
||||
|
||||
ComponentName componentName = null;
|
||||
|
||||
if (getMobileType().equals("Xiaomi")) { // 红米Note4测试通过
|
||||
|
||||
componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity");
|
||||
|
||||
} else if (getMobileType().equals("Letv")) { // 乐视2测试通过
|
||||
|
||||
intent.setAction("com.letv.android.permissionautoboot");
|
||||
|
||||
} else if (getMobileType().equals("samsung")) { // 三星Note5测试通过
|
||||
|
||||
//componentName = new ComponentName("com.samsung.android.sm_cn", "com.samsung.android.sm.ui.ram.AutoRunActivity");
|
||||
|
||||
//componentName = ComponentName.unflattenFromString("com.samsung.android.sm/.ui.ram.RamActivity");// Permission Denial not exported from uid 1000,不允许被其他程序调用
|
||||
|
||||
componentName = ComponentName.unflattenFromString("com.samsung.android.sm/.app.dashboard.SmartManagerDashBoardActivity");
|
||||
|
||||
} else if (getMobileType().equals("HUAWEI")) { // 华为测试通过
|
||||
|
||||
//componentName = new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity");//锁屏清理
|
||||
|
||||
componentName = ComponentName.unflattenFromString("com.huawei.systemmanager/.startupmgr.ui.StartupNormalAppListActivity");//跳自启动管理
|
||||
|
||||
//SettingOverlayView.show(context);
|
||||
|
||||
} else if (getMobileType().equals("vivo")) { // VIVO测试通过
|
||||
|
||||
componentName = ComponentName.unflattenFromString("com.iqoo.secure/.safeguard.PurviewTabActivity");
|
||||
|
||||
} else if (getMobileType().equals("Meizu")) { //万恶的魅族
|
||||
|
||||
//componentName = ComponentName.unflattenFromString("com.meizu.safe/.permission.PermissionMainActivity");//跳转到手机管家
|
||||
|
||||
componentName = ComponentName.unflattenFromString("com.meizu.safe/.permission.SmartBGActivity");//跳转到后台管理页面
|
||||
|
||||
} else if (getMobileType().equals("OPPO")) { // OPPO R8205测试通过
|
||||
|
||||
componentName = ComponentName.unflattenFromString("com.oppo.safe/.permission.startup.StartupAppListActivity");
|
||||
|
||||
} else if (getMobileType().equals("ulong")) { // 360手机 未测试
|
||||
|
||||
componentName = new ComponentName("com.yulong.android.coolsafe", ".ui.activity.autorun.AutoRunListActivity");
|
||||
|
||||
} else {
|
||||
|
||||
// 将用户引导到系统设置页面
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
|
||||
Log.e("HLQ_Struggle", "APPLICATION_DETAILS_SETTINGS");
|
||||
|
||||
intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
|
||||
|
||||
intent.setData(Uri.fromParts("package", context.getPackageName(), null));
|
||||
|
||||
} else if (Build.VERSION.SDK_INT <= 8) {
|
||||
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
|
||||
intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
|
||||
|
||||
intent.putExtra("com.android.settings.ApplicationPkgName", context.getPackageName());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
intent.setComponent(componentName);
|
||||
|
||||
context.startActivity(intent);
|
||||
|
||||
// if (getMobileType().equals("Xiaomi")) {
|
||||
//
|
||||
// showtip();//显示弹窗(**特别注意**)
|
||||
//
|
||||
// }
|
||||
//
|
||||
// if (getMobileType().equals("samsung")){
|
||||
//
|
||||
// new SettingOverlayView().show(context);//
|
||||
//
|
||||
// }
|
||||
|
||||
} catch (Exception e) {//抛出异常就直接打开设置页面
|
||||
|
||||
Log.e("HLQ_Struggle", e.getLocalizedMessage());
|
||||
|
||||
intent = new Intent(Settings.ACTION_SETTINGS);
|
||||
|
||||
context.startActivity(intent);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//小米手机显示弹窗
|
||||
|
||||
// private void showtip() {
|
||||
//
|
||||
// try {
|
||||
//
|
||||
// dialog_per=new SettingDialogPermision(context, R.style.CustomDialog4);
|
||||
//
|
||||
// dialog_per.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST);//注意这里改成吐司类型
|
||||
//
|
||||
// dialog_per.show();
|
||||
//
|
||||
// Log.e("HLQ_Struggle","显示弹窗");
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// e.printStackTrace();
|
||||
//
|
||||
// Log.e("HLQ_Struggle", "没有显示弹窗"+e.getMessage());
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
Loading…
Reference in New Issue
Block a user