增加moshi

This commit is contained in:
2022-08-30 10:08:51 +08:00
parent 84a19370e4
commit 5ffdeef91b
4 changed files with 98 additions and 21 deletions

View File

@@ -279,6 +279,7 @@ dependencies {
implementation 'com.trello.rxlifecycle4:rxlifecycle-android-lifecycle:4.0.2'
//okhttp
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
implementation 'com.squareup.moshi:moshi:1.9.3'
//4.9.3最后一个4.x版本
//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'

View File

@@ -57,16 +57,16 @@
android:supportsRtl="true"
android:theme="@style/ImmerseTheme">
<activity android:name=".activity.AoleyunTestActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity android:name=".activity.main.MainActivity">
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity.KotlinMainActivity">
<!-- <intent-filter> -->

View File

@@ -0,0 +1,20 @@
// IGetInfoInterface.aidl
package com.uiui.sn;
// Declare any non-default types here with import statements
interface IGetInfoInterface {
/**
* Demonstrates some basic types that you can use as parameters
* and return values in AIDL.
*/
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
double aDouble, String aString);
//获取系统开关
boolean isControl();
//获取app是否在管控时间
boolean inControl(String pkg);
//获取app禁用提示
String getDisableContent(String pkg);
}

View File

@@ -10,7 +10,6 @@ import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.hardware.usb.UsbManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
import android.os.RemoteException;
@@ -23,7 +22,6 @@ import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.info.sn.IGetInfoInterface;
import com.jiaoguanyi.appstore.IGetLicenseInterface;
import com.notepad.uiui.INoteAidlInterface;
import com.tt.ttutils.base.ImmerseBaseActivity;
@@ -34,9 +32,9 @@ import com.tt.ttutils.utils.java.JGYUtils;
import com.tt.ttutils.utils.java.TTUtils;
import com.tt.ttutils.utils.java.ToastUtil;
import com.tt.ttutils.utils.jni.NDKTools;
import com.uiui.sn.IGetInfoInterface;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -225,6 +223,8 @@ public class MainActivity extends ImmerseBaseActivity {
registHideAppReceiver();
registForbidAppReceiver();
registerUserInfoReceiver();
registerAppTimeControlReceiver();
registerSnTimeControlReceiver();
String ndks = NDKTools.getStringFromNDK();
mServiceConnection = new ServiceConnection() {
@Override
@@ -312,13 +312,22 @@ public class MainActivity extends ImmerseBaseActivity {
// ApkUtils.openApp(JMainActivity.this, "com.info.sn");
if (getInfoInterface != null) {
try {
String userInfo = getInfoInterface.getUserInfo();
Log.e("mIGetInfoConnection", "getUserInfo: " + userInfo);
List<String> hideAPP = getInfoInterface.getHideAPP();
Log.e("mIGetInfoConnection", "getHideAPP: " + hideAPP);
List<String> forbidAPP = getInfoInterface.getForbidAPP();
Log.e("mIGetInfoConnection", "getForbidAPP: " + forbidAPP);
textView.setText(userInfo);
// String sn = getInfoInterface.getSerial();
// Log.e("mIGetInfoConnection", "getSerial: " + sn);
// String userInfo = getInfoInterface.getUserInfo();
// Log.e("mIGetInfoConnection", "getUserInfo: " + userInfo);
// List<String> hideAPP = getInfoInterface.getHideAPP();
// Log.e("mIGetInfoConnection", "getHideAPP: " + hideAPP);
// List<String> forbidAPP = getInfoInterface.getForbidAPP();
// Log.e("mIGetInfoConnection", "getForbidAPP: " + forbidAPP);
boolean isControl = getInfoInterface.isControl();
Log.e("mIGetInfoConnection", "isControl: " + isControl);
boolean isAvailable = getInfoInterface.inControl("com.zhiduoke.fxy");
Log.e("mIGetInfoConnection", "inControl: " + isAvailable);
String content = getInfoInterface.getDisableContent("com.zhiduoke.fxy");
Log.e("mIGetInfoConnection", "getDisableContent: " + content);
// textView.setText(userInfo);
} catch (RemoteException e) {
e.printStackTrace();
Log.e("mIGetInfoConnection", "getUserInfo: " + e.getMessage());
@@ -444,6 +453,53 @@ public class MainActivity extends ImmerseBaseActivity {
}
}
public static final String APP_TIME_CONTROL_UPDATE = "APP_TIME_CONTROL_UPDATE";
public static final String SN_TIME_CONTROL_UPDATE = "SN_TIME_CONTROL_UPDATE";
private AppTimeControlReceiver mAppTimeControlReceiver;
private void registerAppTimeControlReceiver() {
if (mAppTimeControlReceiver == null) {
mAppTimeControlReceiver = new AppTimeControlReceiver();
}
IntentFilter filter = new IntentFilter();
filter.addAction(APP_TIME_CONTROL_UPDATE);
registerReceiver(mAppTimeControlReceiver, filter);
}
private class AppTimeControlReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(APP_TIME_CONTROL_UPDATE)) {
String jsonString = intent.getStringExtra("jsonString");
Log.e("AppTimeControlReceiver", "onReceive: " + jsonString);
}
}
}
private SnTimeControlReceiver mSnTimeControlReceiver;
private void registerSnTimeControlReceiver() {
if (mSnTimeControlReceiver == null) {
mSnTimeControlReceiver = new SnTimeControlReceiver();
}
IntentFilter filter = new IntentFilter();
filter.addAction(SN_TIME_CONTROL_UPDATE);
registerReceiver(mSnTimeControlReceiver, filter);
}
private class SnTimeControlReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(SN_TIME_CONTROL_UPDATE)) {
String jsonString = intent.getStringExtra("jsonString");
Log.e("SnTimeControlReceiver", "onReceive: " + jsonString);
}
}
}
private void bindService() {
if (noteAidlInterface == null) {
@@ -471,9 +527,9 @@ public class MainActivity extends ImmerseBaseActivity {
if (getInfoInterface == null) {
//这是连接aidl服务的代码
Intent intent = new Intent();
intent.setAction("com.info.sn.IGetInfoInterface");
intent.setPackage("com.info.sn");
intent.setComponent(new ComponentName("com.info.sn", "com.info.sn.service.RemoteService"));
intent.setAction("com.uiui.sn.IGetInfoInterface");
intent.setPackage("com.uiui.sn");
intent.setComponent(new ComponentName("com.uiui.sn", "com.uiui.sn.service.RemoteService"));
bindService(intent, mIGetInfoConnection, Context.BIND_AUTO_CREATE);
}
}