date:2021-09-30 18:26:58

This commit is contained in:
2021-09-30 18:27:13 +08:00
parent 81147b61f8
commit 2884e4924e
10 changed files with 449 additions and 39 deletions

View File

@@ -72,14 +72,12 @@ android {
flavorDimensions "default" flavorDimensions "default"
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
signingConfig signingConfigs.debug
} }
beta { beta {
flavorDimensions "default" flavorDimensions "default"
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
signingConfig signingConfigs.debug
buildConfigField "String", "test", '"测试文本"' buildConfigField "String", "test", '"测试文本"'
} }
} }
@@ -87,9 +85,45 @@ android {
sourceSets { sourceSets {
beta.res.srcDirs = ['src/beta/res'] beta.res.srcDirs = ['src/beta/res']
} }
// externalNativeBuild {
// ndkBuild {
// path 'src/main/jni/Android.mk'
// }
// }
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDirs = ['src/main/jniLibs']
}
//签名 //签名
signingConfigs { signingConfigs {
xueshibao{
storeFile file("src/keystore/xueshibaoos.jks")
storePassword "123456"
keyAlias "xueshibaoos"
keyPassword "123456"
v1SigningEnabled true
v2SigningEnabled true
}
zhanRui {
storeFile file("src/keystore/zhanxun.keystore")
storePassword "123456"
keyAlias "zhanxun"
keyPassword "123456"
v1SigningEnabled true
v2SigningEnabled true
}
zhanRuiUserdebug {
storeFile file("src/keystore/zhanxunUserdebug.keystore")
storePassword "123456"
keyAlias "zhanxunUserdebug"
keyPassword "123456"
v1SigningEnabled true
v2SigningEnabled true
}
debug { debug {
storeFile file("src/keystore/tt.jks") storeFile file("src/keystore/tt.jks")
storePassword "fht19961207" storePassword "fht19961207"
@@ -110,23 +144,40 @@ android {
} }
buildTypes { buildTypes {
// externalNativeBuild { zhanRuiRelease.initWith(release)
// ndkBuild { zhanRuiRelease {
// path 'src/main/jni/Android.mk' buildConfigField "String", "platform", '"ZhanRui"'
// } signingConfig signingConfigs.zhanRui
// }
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDirs = ['src/main/jniLibs']
} }
zhanRuiDebug.initWith(debug)
zhanRuiDebug {
versionNameSuffix "-debug"
buildConfigField "String", "platform", '"ZhanRui"'
debuggable true
signingConfig signingConfigs.zhanRui
}
//userdebug rom使用这个版本
zhanRuiUserdebug.initWith(zhanRuiDebug)
zhanRuiUserdebug {
versionNameSuffix "-debug"
buildConfigField "String", "platform", '"ZhanRui"'
debuggable true
signingConfig signingConfigs.zhanRuiUserdebug
}
debug { debug {
// 显示Log buildConfigField "String", "platform", '"MTK"'
buildConfigField "boolean", "LOG_DEBUG", "true" // 不显示Log
//buildConfigField "boolean", "LOG_DEBUG", "false"
//
versionNameSuffix "-debug" versionNameSuffix "-debug"
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//Zipalign优化 //Zipalign优化
zipAlignEnabled true zipAlignEnabled true
signingConfig signingConfigs.debug signingConfig signingConfigs.xueshibao
applicationVariants.all { variant -> applicationVariants.all { variant ->
variant.outputs.each { output -> variant.outputs.each { output ->
def outputFile = output.outputFile def outputFile = output.outputFile
@@ -137,18 +188,18 @@ android {
} }
} }
} }
release { release {
// 不显示Log buildConfigField "String", "platform", '"MTK"'
buildConfigField "boolean", "LOG_DEBUG", "false"
//混淆 //混淆
minifyEnabled false minifyEnabled false
//Zipalign优化
zipAlignEnabled true
//前一部分代表系统默认的android程序的混淆文件该文件已经包含了基本的混淆声明后一个文件是自己的定义混淆文件 //前一部分代表系统默认的android程序的混淆文件该文件已经包含了基本的混淆声明后一个文件是自己的定义混淆文件
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//Zipalign优化
zipAlignEnabled true
//签名 //签名
signingConfig signingConfigs.release signingConfig signingConfigs.release
// 将release版本的包名重命名加上版本及日期 //将release版本的包名重命名加上版本及日期
applicationVariants.all { variant -> applicationVariants.all { variant ->
variant.outputs.each { output -> variant.outputs.each { output ->
def outputFile = "" def outputFile = ""
@@ -160,6 +211,7 @@ android {
} }
} }
} }
} }
@@ -175,8 +227,8 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
////三方 ////三方
//极光推送 //极光推送
implementation 'cn.jiguang.sdk:jpush:3.7.0' // 此处以JPush 3.7.0 版本为例。 implementation 'cn.jiguang.sdk:jpush:3.8.6' // 此处以JPush 3.7.0 版本为例。
implementation 'cn.jiguang.sdk:jcore:2.4.2' // 此处以JCore 2.4.2 版本为例。 implementation 'cn.jiguang.sdk:jcore:2.6.0' // 此处以JCore 2.4.2 版本为例。
//okhttp //okhttp
implementation 'com.squareup.okhttp3:okhttp:4.6.0' implementation 'com.squareup.okhttp3:okhttp:4.6.0'
//RxJava和Retrofit //RxJava和Retrofit

Binary file not shown.

View File

@@ -46,20 +46,21 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name="com.tt.activity.PackageActivity"></activity> <activity android:name="com.tt.activity.PackageActivity"></activity>
<activity android:name="com.tt.activity.JMainActivity" > <activity android:name="com.tt.activity.JMainActivity">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity android:name="com.tt.activity.MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="com.tt.activity.MainActivity">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<receiver <receiver
android:name="com.tt.receiver.PackageReceiver" android:name="com.tt.receiver.PackageReceiver"
android:enabled="true" android:enabled="true"

View File

@@ -0,0 +1,19 @@
// IGetInfoInterface.aidl
package com.info.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);
String getUserInfo();
List<String> getHideAPP();
List<String> getForbidAPP();
}

View File

@@ -0,0 +1,14 @@
// IGetLicenseInterface.aidl
package com.jiaoguanyi.appstore;
// Declare any non-default types here with import statements
interface IGetLicenseInterface {
/**
* 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);
String getLicense();
}

View File

@@ -0,0 +1,15 @@
// INoteAidlInterface.aidl
package com.notepad.uiui;
// Declare any non-default types here with import statements
interface INoteAidlInterface {
/**
* 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);
String getNote();
}

View File

@@ -1,22 +1,36 @@
package com.tt.activity; package com.tt.activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.net.Uri; import android.net.Uri;
import android.os.Environment; import android.os.Environment;
import android.os.IBinder;
import android.os.RemoteException;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.info.sn.IGetInfoInterface;
import com.jiaoguanyi.appstore.IGetLicenseInterface;
import com.notepad.uiui.INoteAidlInterface;
import com.tt.base.BaseActivity; import com.tt.base.BaseActivity;
import com.tt.ttutils.R; import com.tt.ttutils.R;
import com.tt.ttutils.java.ApkUtils;
import com.tt.ttutils.java.ToastUtil; import com.tt.ttutils.java.ToastUtil;
import com.tt.ttutils.jni.NDKTools; import com.tt.ttutils.jni.NDKTools;
import java.lang.annotation.Native; import java.util.ArrayList;
import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
@@ -24,6 +38,16 @@ import butterknife.ButterKnife;
public class JMainActivity extends BaseActivity { public class JMainActivity extends BaseActivity {
@BindView(R.id.textView) @BindView(R.id.textView)
TextView textView; TextView textView;
@BindView(R.id.button)
Button button;
private ServiceConnection mServiceConnection;
private INoteAidlInterface noteAidlInterface;
private ServiceConnection mLicenseServiceConnection;
private IGetLicenseInterface getLicenseInterface;
private ServiceConnection mIGetInfoConnection;
private IGetInfoInterface getInfoInterface;
private String TAG = JMainActivity.class.getSimpleName();
@Override @Override
protected int setLayoutResourceID() { protected int setLayoutResourceID() {
@@ -46,18 +70,230 @@ public class JMainActivity extends BaseActivity {
@Override @Override
protected void initData() { protected void initData() {
registHideAppReceiver();
registForbidAppReceiver();
registerUserInfoReceiver();
String ndks = NDKTools.getStringFromNDK(); String ndks = NDKTools.getStringFromNDK();
mServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
noteAidlInterface = INoteAidlInterface.Stub.asInterface(iBinder);
Log.e(TAG, "onServiceConnected: ");
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
Log.e(TAG, "onServiceDisconnected: ");
noteAidlInterface = null;
// Intent intent = new Intent();
// intent.setComponent(new ComponentName("com.notepad.uiui", "com.notepad.uiui.service.NoteService"));
// startService(intent);
}
};
mLicenseServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
getLicenseInterface = IGetLicenseInterface.Stub.asInterface(service);
}
@Override
public void onServiceDisconnected(ComponentName name) {
getLicenseInterface = null;
}
};
mIGetInfoConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
Log.e(TAG, "onServiceConnected: mIGetInfoConnection");
getInfoInterface = IGetInfoInterface.Stub.asInterface(service);
}
@Override
public void onServiceDisconnected(ComponentName name) {
Log.e(TAG, "onServiceDisconnected: mIGetInfoConnection");
getInfoInterface = null;
bindinfoService();
}
};
bindService();
bindLicenseService();
bindinfoService();
// Intent intent2 = new Intent();
// intent2.setComponent(new ComponentName("com.info.sn", "com.notepad.uiui.service.NoteService"));
// startService(intent2);
// Intent intent = new Intent();
// intent.setComponent(new ComponentName("com.notepad.uiui", "com.notepad.uiui.service.NoteService"));
// startService(intent);
textView.setText(ndks); textView.setText(ndks);
textView.setOnClickListener(new View.OnClickListener() { textView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
open(); // open();
bindService();
try {
if (noteAidlInterface == null) {
bindService();
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.notepad.uiui", "com.notepad.uiui.service.NoteService"));
startService(intent);
return;
}
Log.e(TAG, "onClick: " + noteAidlInterface);
String test = noteAidlInterface.getNote();
Log.e(TAG, "onClick: " + test);
} catch (RemoteException e) {
// e.printStackTrace();
Log.e(TAG, "onClick: " + e.getMessage());
}
}
});
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 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);
} catch (RemoteException e) {
e.printStackTrace();
Log.e("mIGetInfoConnection", "getUserInfo: " + e.getMessage());
}
}else {
bindinfoService();
}
// if (getLicenseInterface != null) {
// try {
// String license = getLicenseInterface.getLicense();
// Log.e(TAG, "onClick: " + license);
// textView.setText(license);
// } catch (RemoteException e) {
// e.printStackTrace();
// Log.e(TAG, "onClick: " + e.getMessage());
// }
// }
} }
}); });
} }
private HideAppReceiver hideAppReceiver;
private void registHideAppReceiver() {
if (hideAppReceiver == null) {
hideAppReceiver = new HideAppReceiver();
}
IntentFilter filter = new IntentFilter();
filter.addAction("UPDATE_HIDE_APP");
registerReceiver(hideAppReceiver, filter);
}
private class HideAppReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.e(TAG, "onReceive: " + intent.getAction());
ArrayList<String> appList = intent.getStringArrayListExtra("hide_app_list");
if (appList != null) {
Log.e(TAG, "onReceive: " + appList);
}
}
}
private ForbidAppReceiver forbidAppReceiver;
private void registForbidAppReceiver() {
if (forbidAppReceiver == null) {
forbidAppReceiver = new ForbidAppReceiver();
}
IntentFilter filter = new IntentFilter();
filter.addAction("UPDATE_FORBID_APP");
registerReceiver(forbidAppReceiver, filter);
}
private class ForbidAppReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.e(TAG, "onReceive: " + intent.getAction());
ArrayList<String> appList = intent.getStringArrayListExtra("forbid_app_list");
if (appList != null) {
Log.e(TAG, "onReceive: " + appList);
}
}
}
private static final String UPDATE_USER_INFO = "UPDATE_USER_INFO";
private UserInfoReceiver userInfoReceiver;
private void registerUserInfoReceiver() {
if (userInfoReceiver == null) {
userInfoReceiver = new UserInfoReceiver();
}
IntentFilter filter = new IntentFilter();
filter.addAction(UPDATE_USER_INFO);
registerReceiver(userInfoReceiver, filter);
}
private class UserInfoReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.e(TAG, "onReceive: " + intent.getAction());
String userInfo = intent.getStringExtra("user_info");
Log.e(TAG, "onReceive: " + userInfo);
}
}
private void bindService() {
if (noteAidlInterface == null) {
//这是连接aidl服务的代码
Intent intent = new Intent();
intent.setAction("com.notepad.uiui.INoteAidlInterface");
intent.setPackage("com.notepad.uiui");
intent.setComponent(new ComponentName("com.notepad.uiui", "com.notepad.uiui.service.NoteService"));
bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);
}
}
private void bindLicenseService() {
if (getLicenseInterface == null) {
//这是连接aidl服务的代码
Intent intent = new Intent();
intent.setAction("com.jiaoguanyi.appstore.IGetLicenseInterface");
intent.setPackage("com.jiaoguanyi.appstore");
intent.setComponent(new ComponentName("com.jiaoguanyi.appstore", "com.mjsheng.myappstore.service.RemoteService"));
bindService(intent, mLicenseServiceConnection, Context.BIND_AUTO_CREATE);
}
}
private void bindinfoService() {
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"));
bindService(intent, mIGetInfoConnection, Context.BIND_AUTO_CREATE);
}
}
// 用来计算返回键的点击间隔时间 // 用来计算返回键的点击间隔时间
private long exitTime = 0; private long exitTime = 0;
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK if (keyCode == KeyEvent.KEYCODE_BACK
@@ -74,7 +310,8 @@ public class JMainActivity extends BaseActivity {
return super.onKeyDown(keyCode, event); return super.onKeyDown(keyCode, event);
} }
private long mPreClickTime=0;
private long mPreClickTime = 0;
private void lazyExit() { private void lazyExit() {
if (System.currentTimeMillis() - mPreClickTime > 1000) { if (System.currentTimeMillis() - mPreClickTime > 1000) {
@@ -101,4 +338,5 @@ public class JMainActivity extends BaseActivity {
startActivityForResult(intent, 1); startActivityForResult(intent, 1);
} }
} }
} }

View File

@@ -1,21 +1,32 @@
package com.tt.activity package com.tt.activity
import android.content.ComponentName
import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.ServiceConnection
import android.os.Bundle import android.os.Bundle
import android.os.Environment import android.os.Environment
import android.os.IBinder
import android.util.Log
import android.widget.Button import android.widget.Button
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.notepad.uiui.INoteAidlInterface
import com.tt.ttutils.R import com.tt.ttutils.R
import com.tt.ttutils.java.DevicesUtils import com.tt.ttutils.java.DevicesUtils
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
import me.jessyan.autosize.internal.CancelAdapt import me.jessyan.autosize.internal.CancelAdapt
import java.io.File import java.io.File
import kotlin.math.log
class MainActivity : AppCompatActivity(), CancelAdapt { class MainActivity : AppCompatActivity(), CancelAdapt {
lateinit var button: Button lateinit var button: Button
private val INSTALLAPK_ACTION = "JGY_INSTALLAPK_ACTION" private val INSTALLAPK_ACTION = "JGY_INSTALLAPK_ACTION"
private val INSTALLAPK_PREMISSIONS = "com.jiaoguanyi.appstore.permissions.INSTALL_APK" private val INSTALLAPK_PREMISSIONS = "com.jiaoguanyi.appstore.permissions.INSTALL_APK"
lateinit var filePath:String lateinit var filePath: String
lateinit var mServiceConnection: ServiceConnection
lateinit var noteAidlInterface: INoteAidlInterface
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
@@ -25,12 +36,35 @@ class MainActivity : AppCompatActivity(), CancelAdapt {
filePath = filePath =
Environment.getExternalStorageDirectory().absolutePath + File.separator + "Android_8.8.0.5420_537068981.apk" Environment.getExternalStorageDirectory().absolutePath + File.separator + "Android_8.8.0.5420_537068981.apk"
button = findViewById(R.id.button) button = findViewById(R.id.button)
button.setOnClickListener { // button.setOnClickListener {
val intent = Intent(INSTALLAPK_ACTION) // //教管壹静默安装代码
intent.putExtra("packageName", "com.tencent.mobileqq") // val intent = Intent(INSTALLAPK_ACTION)
intent.putExtra("filePath", filePath) // intent.putExtra("packageName", "com.tencent.mobileqq")
sendBroadcast(intent, INSTALLAPK_PREMISSIONS) // intent.putExtra("filePath", filePath)
// sendBroadcast(intent, INSTALLAPK_PREMISSIONS)
// }
mServiceConnection = object : ServiceConnection {
override fun onServiceConnected(
componentName: ComponentName,
iBinder: IBinder
) {
noteAidlInterface = INoteAidlInterface.Stub.asInterface(iBinder)
}
override fun onServiceDisconnected(componentName: ComponentName) {
}
} }
val intent = Intent("com.notepad.uiui.INoteAidlInterface")
intent.setPackage("com.notepad.uiui")
bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE)
button.setOnClickListener {
val test = noteAidlInterface.note
Log.e("test", test)
}
} }

View File

@@ -1,5 +1,15 @@
package com.tt.ttutils.java; package com.tt.ttutils.java;
import android.content.Context;
import android.content.Intent;
public class ApkUtils { public class ApkUtils {
public static void openApp(Context context, String packageName) {
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);
if (intent != null) {
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
} }

View File

@@ -14,10 +14,37 @@ android {
consumerProguardFiles 'consumer-rules.pro' consumerProguardFiles 'consumer-rules.pro'
} }
productFlavors {
official {
flavorDimensions "default"
}
beta {
flavorDimensions "default"
}
}
buildTypes { buildTypes {
zhanRuiRelease {
}
zhanRuiDebug {
}
zhanRuiUserdebug {
}
debug {
}
release { release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
} }