version:1.1.5
update: bugfixes:优化闹钟自动接听
This commit is contained in:
@@ -8,6 +8,7 @@ import android.content.pm.ResolveInfo;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xxpatx.os.activity.main.MainActivity;
|
||||
import com.xxpatx.os.bean.DailyAppBean;
|
||||
import com.xxpatx.os.config.CommonConfig;
|
||||
|
||||
@@ -35,11 +36,16 @@ public class AppStatusManager {
|
||||
this.add("com.android.documentsui");
|
||||
this.add("com.android.calculator2");
|
||||
this.add("com.android.calendar");
|
||||
this.add("com.mediatek.camera");
|
||||
this.add("com.android.dialer");
|
||||
this.add("com.android.settings");
|
||||
}};
|
||||
|
||||
private static final Set<String> mExcludeApp = new HashSet<String>() {{
|
||||
this.add("com.android.contacts");
|
||||
this.add("com.android.dialer");
|
||||
this.add("com.mediatek.camera");
|
||||
}};
|
||||
|
||||
|
||||
private AppStatusManager(Context context) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
@@ -70,13 +76,13 @@ public class AppStatusManager {
|
||||
public void addHidedApp(String pkg) {
|
||||
this.hidedAppSet.add(pkg);
|
||||
mMMKV.encode(APP_STATUS_MANAGER_KEY, hidedAppSet);
|
||||
// mContext.sendBroadcast(new Intent(OldMainActivity.ACTION_PACKAGE_HIDE));
|
||||
mContext.sendBroadcast(new Intent(MainActivity.ACTION_PACKAGE_HIDE));
|
||||
}
|
||||
|
||||
public void removeHidedApp(String pkg) {
|
||||
this.hidedAppSet.remove(pkg);
|
||||
mMMKV.encode(APP_STATUS_MANAGER_KEY, hidedAppSet);
|
||||
// mContext.sendBroadcast(new Intent(OldMainActivity.ACTION_PACKAGE_HIDE));
|
||||
mContext.sendBroadcast(new Intent(MainActivity.ACTION_PACKAGE_HIDE));
|
||||
}
|
||||
|
||||
public List<DailyAppBean> getPackageList() {
|
||||
@@ -89,6 +95,9 @@ public class AppStatusManager {
|
||||
List<ResolveInfo> resolveinfoList = pm.queryIntentActivities(resolveIntent, 0);
|
||||
for (ResolveInfo packageInfo : resolveinfoList) {
|
||||
String pkg = packageInfo.activityInfo.packageName;
|
||||
if (mExcludeApp.contains(pkg)) {
|
||||
continue;
|
||||
}
|
||||
if (hidedAppSet.contains(pkg)) {
|
||||
Log.e(TAG, "getPackageList: " + pkg);
|
||||
DailyAppBean appSelectBean = new DailyAppBean(packageInfo.activityInfo.loadLabel(pm).toString(),
|
||||
|
||||
@@ -1,195 +0,0 @@
|
||||
package com.xxpatx.os.manager;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.bugly.crashreport.CrashReport;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xxpatx.os.config.CommonConfig;
|
||||
import com.xxpatx.sn.IGetInfoInterface;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
public class RemoteManager {
|
||||
private static final String TAG = "RemoteManager";
|
||||
|
||||
private static final String SN_KEY = "sn_serial_key";
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static RemoteManager sInstance;
|
||||
private Context mContext;
|
||||
private static boolean mServiceConnected = false;
|
||||
|
||||
private IGetInfoInterface mIGetInfoInterface;
|
||||
private ServiceConnection mIGetInfoConnection;
|
||||
|
||||
private RemoteManager(Context context) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
}
|
||||
this.mContext = context;
|
||||
mIGetInfoConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
Log.e(TAG, "onServiceConnected: mIGetInfoConnection");
|
||||
mIGetInfoInterface = IGetInfoInterface.Stub.asInterface(service);
|
||||
mServiceConnected = true;
|
||||
for (ConnectedListener listener : mListeners) {
|
||||
if (listener != null) {
|
||||
listener.onRemoteConnected();
|
||||
}
|
||||
}
|
||||
try {
|
||||
String sn = mIGetInfoInterface.getSerial();
|
||||
CrashReport.setDeviceModel(mContext, sn);
|
||||
mMMKV.encode(SN_KEY, sn);
|
||||
Log.e(TAG, "onServiceConnected: sn = " + sn);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
Log.e(TAG, "onServiceDisconnected: mIGetInfoConnection");
|
||||
mIGetInfoInterface = null;
|
||||
mServiceConnected = false;
|
||||
bindInfoService();
|
||||
}
|
||||
};
|
||||
bindInfoService();
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
if (sInstance == null) {
|
||||
Log.e(TAG, "init: ");
|
||||
sInstance = new RemoteManager(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static RemoteManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
throw new IllegalStateException("You must be init RemoteManager first");
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public static boolean isServiceConnected() {
|
||||
return mServiceConnected;
|
||||
}
|
||||
|
||||
public interface ConnectedListener {
|
||||
void onRemoteConnected();
|
||||
}
|
||||
|
||||
private static Set<ConnectedListener> mListeners = new CopyOnWriteArraySet<>();
|
||||
|
||||
public static void setListener(ConnectedListener listener) {
|
||||
mListeners.add(listener);
|
||||
if (mServiceConnected) {
|
||||
listener.onRemoteConnected();
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeListener(ConnectedListener listener) {
|
||||
mListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void bindInfoService() {
|
||||
if (mIGetInfoInterface == null) {
|
||||
//这是连接aidl服务的代码
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("com.xxpatx.sn.IGetInfoInterface");
|
||||
intent.setPackage("com.xxpatx.sn");
|
||||
intent.setComponent(new ComponentName("com.xxpatx.sn", "com.xxpatx.sn.service.RemoteService"));
|
||||
mContext.bindService(intent, mIGetInfoConnection, Context.BIND_AUTO_CREATE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 获取sn
|
||||
*/
|
||||
public String getSerial() {
|
||||
// if (BuildConfig.DEBUG) return "MTK13220282310";
|
||||
if (mIGetInfoInterface != null) {
|
||||
try {
|
||||
return mIGetInfoInterface.getSerial();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "getSerial: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
bindInfoService();
|
||||
}
|
||||
return mMMKV.decodeString(SN_KEY, "");
|
||||
}
|
||||
|
||||
public boolean putSystemInt(String name, int value) {
|
||||
if (mIGetInfoInterface != null) {
|
||||
try {
|
||||
return mIGetInfoInterface.SystemPutInt(name, value);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "putSystemInt: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
bindInfoService();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void killBackgroundProcesses(String pkg) {
|
||||
if (mIGetInfoInterface != null) {
|
||||
try {
|
||||
mIGetInfoInterface.killBackgroundProcesses(pkg);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "killBackgroundProcesses: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
bindInfoService();
|
||||
}
|
||||
}
|
||||
|
||||
public String getConnectWifiSsid() {
|
||||
if (mIGetInfoInterface != null) {
|
||||
try {
|
||||
return mIGetInfoInterface.getWifiSsid();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "killBackgroundProcesses: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
bindInfoService();
|
||||
}
|
||||
return "获取失败";
|
||||
}
|
||||
|
||||
public void openLauncher3() {
|
||||
if (mIGetInfoInterface != null) {
|
||||
try {
|
||||
mIGetInfoInterface.openLauncher3();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "openLauncher3: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
bindInfoService();
|
||||
}
|
||||
}
|
||||
|
||||
public void setDefaultDesktop(String pkgName, String className) {
|
||||
if (mIGetInfoInterface != null) {
|
||||
try {
|
||||
mIGetInfoInterface.setDefaultDesktop(pkgName, className);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setDefaultDesktop: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
bindInfoService();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user