增加开发者模式

This commit is contained in:
2022-06-28 10:41:15 +08:00
parent b410754600
commit 964a1a8274
20 changed files with 1316 additions and 80 deletions

View File

@@ -101,6 +101,15 @@ android {
//签名
signingConfigs {
tuixin {
storeFile file("src/keystore/tuixin.jks")
storePassword "123456"
keyAlias "universal"
keyPassword "123456"
v1SigningEnabled true
v2SigningEnabled true
}
xueshibao {
storeFile file("src/keystore/xueshibaoos.jks")
storePassword "123456"
@@ -128,30 +137,23 @@ android {
v2SigningEnabled true
}
debug {
own {
storeFile file("src/keystore/tt.jks")
storePassword "fht19961207"
keyAlias "key0"
keyPassword "981964879aa"
v1SigningEnabled true
v2SigningEnabled false
}
release {
storeFile file("src/keystore/tt.jks")
storePassword "fht19961207"
keyAlias "key0"
keyPassword "981964879aa"
v1SigningEnabled true
v2SigningEnabled false
v2SigningEnabled true
}
}
buildTypes {
zhanRuiRelease.initWith(release)
zhanRuiRelease {
tuiXinDebug.initWith(debug)
tuiXinDebug {
versionNameSuffix "-debug"
buildConfigField "String", "platform", '"ZhanRui"'
signingConfig signingConfigs.zhanRui
debuggable true
signingConfig signingConfigs.tuixin
}
zhanRuiDebug.initWith(debug)
@@ -162,6 +164,12 @@ android {
signingConfig signingConfigs.zhanRui
}
zhanRuiRelease.initWith(release)
zhanRuiRelease {
buildConfigField "String", "platform", '"ZhanRui"'
signingConfig signingConfigs.zhanRui
}
//userdebug rom使用这个版本
zhanRuiUserdebug.initWith(zhanRuiDebug)
zhanRuiUserdebug {
@@ -202,7 +210,7 @@ android {
//Zipalign优化
zipAlignEnabled true
//签名
signingConfig signingConfigs.release
signingConfig signingConfigs.xueshibao
//将release版本的包名重命名加上版本及日期
applicationVariants.all { variant ->
variant.outputs.each { output ->
@@ -316,8 +324,8 @@ dependencies {
implementation 'com.github.bingoogolapple:BGASwipeBackLayout-Android:2.0.2'
//圆角
implementation 'de.hdodenhof:circleimageview:2.2.0'
//圆角ImageView
implementation 'com.github.zane618:NiceImageView:1.0.0'
// 圆角ImageView
// implementation 'com.github.zane618:NiceImageView:1.0.0'
// 权限请求框架https://github.com/getActivity/XXPermissions
implementation 'com.github.getActivity:XXPermissions:12.3'
//动态权限框架

View File

@@ -10,24 +10,31 @@
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- 【必须】 移动推送 TPNS SDK 5.0版本所需权限 -->
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<!-- 【必须】 移动推送 TPNS SDK 5.0版本所需权限 -->
<permission
android:name="com.tt.ttutils.permission.XGPUSH_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="com.tt.ttutils.permission.XGPUSH_RECEIVE" /> <!-- 【必须】 移动推送 TPNS SDK所需权限 -->
<uses-permission android:name="com.tt.ttutils.permission.XGPUSH_RECEIVE" />
<!-- 【必须】 移动推送 TPNS SDK所需权限 -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- 【常用】 移动推送 TPNS SDK所需权限 -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- 【常用】 移动推送 TPNS SDK所需权限 -->
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- Required -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Required -->
<permission
android:name="${applicationId}.permission.JPUSH_MESSAGE"
android:protectionLevel="signature" /> <!-- Required 一些系统要求的权限,如访问网络等 -->
android:protectionLevel="signature" />
<!-- Required 一些系统要求的权限,如访问网络等 -->
<uses-permission android:name="${applicationId}.permission.JPUSH_MESSAGE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.INTERNET" />
@@ -36,13 +43,17 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- Optional for location -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- Optional for location -->
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- 用于开启 debug 版本的应用在6.0 系统上 层叠窗口权限 -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- 用于开启 debug 版本的应用在6.0 系统上 层叠窗口权限 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <!-- Android Q后台定位权限 -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<!-- Android Q后台定位权限 -->
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
@@ -56,29 +67,33 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/ImmerseTheme">
<activity android:name=".activity.retrofit.RetrofitActivity"></activity>
<activity android:name=".activity.PackageActivity" />
<activity android:name=".activity.main.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity.KotlinMainActivity">
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
</activity>
<activity android:name=".activity.test.TestActivity">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity android:name=".activity.retrofit.RetrofitActivity" />
<activity android:name=".activity.PackageActivity" />
<service
android:name=".server.main.MainService"
android:enabled="true"
android:exported="true"></service>
android:exported="true" />
<receiver
android:name=".receiver.PackageReceiver"
@@ -122,11 +137,15 @@
<!-- 自定义广播 -->
<action android:name="com.jiaoguanyi.appstore.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver> <!-- -->
</receiver>
<!-- -->
<!-- 应用的其它配置 -->
<uses-library
android:name="org.apache.http.legacy"
android:required="false" /> <!-- 【必须】 移动推送 TPNS 默认通知 -->
android:required="false" />
<!-- 【必须】 移动推送 TPNS 默认通知 -->
<activity
android:name="com.tencent.android.tpush.TpnsActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
@@ -140,7 +159,8 @@
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity> <!-- 【必须】 移动推送 TPNS receiver广播接收 -->
</activity>
<!-- 【必须】 移动推送 TPNS receiver广播接收 -->
<receiver
android:name="com.tencent.android.tpush.XGPushReceiver"
android:process=":xg_vip_service">
@@ -159,11 +179,13 @@
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</receiver> <!-- 【必须】移动推送 TPNS service -->
</receiver>
<!-- 【必须】移动推送 TPNS service -->
<service
android:name="com.tencent.android.tpush.service.XGVipPushService"
android:persistent="true"
android:process=":xg_vip_service" /> <!-- 【必须】通知 service android:name 部分改为包名.XGVIP_PUSH_ACTION -->
android:process=":xg_vip_service" />
<!-- 【必须】通知 service android:name 部分改为包名.XGVIP_PUSH_ACTION -->
<service
android:name="com.tencent.android.tpush.rpc.XGRemoteService"
android:exported="false">
@@ -172,17 +194,21 @@
<!-- 【必须】请修改为当前APP名包.XGVIP_PUSH_ACTION -->
<action android:name="com.tt.ttutils.XGVIP_PUSH_ACTION" />
</intent-filter>
</service> <!-- 【必须】【注意】authorities 修改为包名.XGVIP_PUSH_AUTH -->
</service>
<!-- 【必须】【注意】authorities 修改为包名.XGVIP_PUSH_AUTH -->
<provider
android:name="com.tencent.android.tpush.XGPushProvider"
android:authorities="com.tt.ttutils.XGVIP_PUSH_AUTH" /> <!-- 【必须】【注意】authorities 修改为包名.TPUSH_PROVIDER -->
android:authorities="com.tt.ttutils.XGVIP_PUSH_AUTH" />
<!-- 【必须】【注意】authorities 修改为包名.TPUSH_PROVIDER -->
<provider
android:name="com.tencent.android.tpush.SettingsContentProvider"
android:authorities="com.tt.ttutils.TPUSH_PROVIDER" /> <!-- 【可选】用于增强保活能力 -->
android:authorities="com.tt.ttutils.TPUSH_PROVIDER" />
<!-- 【可选】用于增强保活能力 -->
<provider
android:name="com.tencent.android.tpush.XGVipPushKAProvider"
android:authorities="com.tt.ttutils.AUTH_XGPUSH_KEEPALIVE"
android:exported="true" /> <!-- 【可选】APP实现的Receiver用于接收消息透传和操作结果的回调请根据需要添加 -->
android:exported="true" />
<!-- 【可选】APP实现的Receiver用于接收消息透传和操作结果的回调请根据需要添加 -->
<!-- YOUR_PACKAGE_PATH.CustomPushReceiver需要改为自己的Receiver -->
<receiver android:name=".tpush.MessageReceiver">
<intent-filter>
@@ -192,7 +218,8 @@
<!-- 监听注册、反注册、设置/删除标签、通知被点击等处理结果 -->
<action android:name="com.tencent.android.xg.vip.action.FEEDBACK" />
</intent-filter>
</receiver> <!-- MQTT START -->
</receiver>
<!-- MQTT START -->
<service
android:name="com.tencent.tpns.mqttchannel.services.MqttService"
android:exported="false"
@@ -201,19 +228,25 @@
<provider
android:name="com.tencent.tpns.baseapi.base.SettingsContentProvider"
android:authorities="com.tt.ttutils.XG_SETTINGS_PROVIDER"
android:exported="false" /> <!-- MQTT END -->
android:exported="false" />
<!-- MQTT END -->
<!-- 【必须】 请修改为 APP 的 AccessId“15”开头的10位数字中间没空格 -->
<meta-data
android:name="XG_V2_ACCESS_ID"
android:value="1500026407" /> <!-- 【必须】 请修改为APP的AccessKey“A”开头的12位字符串中间没空格 -->
android:value="1500026407" />
<!-- 【必须】 请修改为APP的AccessKey“A”开头的12位字符串中间没空格 -->
<meta-data
android:name="XG_V2_ACCESS_KEY"
android:value="AQ6C6W1O19LT" /> <!-- Rich push 核心功能 since 2.0.6 -->
android:value="AQ6C6W1O19LT" />
<!-- Rich push 核心功能 since 2.0.6 -->
<activity
android:name="cn.jpush.android.ui.PopWinActivity"
android:exported="false"
android:theme="@style/MyDialogStyle"
tools:replace="android:exported" /> <!-- Required SDK核心功能 -->
tools:replace="android:exported" />
<!-- Required SDK核心功能 -->
<activity
android:name="cn.jpush.android.ui.PushActivity"
android:configChanges="orientation|keyboardHidden"
@@ -226,7 +259,8 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="${applicationId}" />
</intent-filter>
</activity> <!-- Required SDK 核心功能 -->
</activity>
<!-- Required SDK 核心功能 -->
<!-- 可配置android:process参数将PushService放在其他进程中 -->
<service
android:name="cn.jpush.android.service.PushService"
@@ -237,12 +271,14 @@
<action android:name="cn.jpush.android.intent.PushService" />
<action android:name="cn.jpush.android.intent.PUSH_TIME" />
</intent-filter>
</service> <!-- since 3.0.9 Required SDK 核心功能 -->
</service>
<!-- since 3.0.9 Required SDK 核心功能 -->
<provider
android:name="cn.jpush.android.service.DataProvider"
android:authorities="${applicationId}.DataProvider"
android:exported="false"
android:process=":pushcore" /> <!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
android:process=":pushcore" />
<!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
<!-- 若不启用该功能可删除该组件,或把 enabled 设置成 false App 不会被其他 App 拉起,但会拉起其他的 App。 -->
<service
android:name="cn.jpush.android.service.DaemonService"
@@ -253,7 +289,8 @@
<category android:name="${applicationId}" />
</intent-filter>
</service> <!-- 可选如果使用静态Activity方式拉起该组件必须声明 -->
</service>
<!-- 可选如果使用静态Activity方式拉起该组件必须声明 -->
<activity
android:name="cn.jpush.android.service.DActivity"
android:enabled="true"
@@ -265,11 +302,13 @@
<category android:name="${applicationId}" />
</intent-filter>
</activity> <!-- since 3.1.0 Required SDK 核心功能 -->
</activity>
<!-- since 3.1.0 Required SDK 核心功能 -->
<provider
android:name="cn.jpush.android.service.DownloadProvider"
android:authorities="${applicationId}.DownloadProvider"
android:exported="true" /> <!-- Required SDK核心功能 -->
android:exported="true" />
<!-- Required SDK核心功能 -->
<receiver
android:name="cn.jpush.android.service.PushReceiver"
android:enabled="true">
@@ -289,14 +328,18 @@
<data android:scheme="package" />
</intent-filter>
</receiver> <!-- Required SDK核心功能 -->
</receiver>
<!-- Required SDK核心功能 -->
<receiver
android:name="cn.jpush.android.service.AlarmReceiver"
android:exported="false" /> <!-- 3.5.0新增,用于定时展示功能 -->
android:exported="false" />
<!-- 3.5.0新增,用于定时展示功能 -->
<receiver
android:name="cn.jpush.android.service.SchedulerReceiver"
android:exported="false" /> <!-- 3.6.7 新增,用于负反馈组件 -->
<service android:name="cn.jpush.android.service.MessagingIntentService" /> <!-- User defined. For test only 用户自定义的广播接收器 -->
android:exported="false" />
<!-- 3.6.7 新增,用于负反馈组件 -->
<service android:name="cn.jpush.android.service.MessagingIntentService" />
<!-- User defined. For test only 用户自定义的广播接收器 -->
<receiver
android:name=".sdk.jpush.jpushdemo.MyReceiver"
android:enabled="true">
@@ -313,7 +356,8 @@
<!-- 接收网络变化 连接/断开 since 1.6.3 -->
<category android:name="${applicationId}" />
</intent-filter>
</receiver> <!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调 -->
</receiver>
<!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调 -->
<!-- since 3.3.0 接收JPush相关事件 -->
<receiver android:name=".sdk.jpush.jpushdemo.PushMessageReceiver">
<intent-filter>
@@ -321,7 +365,8 @@
<category android:name="${applicationId}" />
</intent-filter>
</receiver> <!-- since 3.3.0 Required SDK核心功能 -->
</receiver>
<!-- since 3.3.0 Required SDK核心功能 -->
<activity
android:name="cn.jpush.android.service.JNotifyActivity"
android:exported="false"
@@ -333,7 +378,8 @@
<category android:name="${applicationId}" />
</intent-filter>
</activity> <!-- since 3.3.0 Required SDK 核心功能 -->
</activity>
<!-- since 3.3.0 Required SDK 核心功能 -->
<!-- 可配置android:process参数将PushService放在其他进程中 -->
<!-- User defined. For test only 继承自cn.jpush.android.service.JCommonService -->
<service
@@ -343,7 +389,8 @@
<action android:name="cn.jiguang.user.service.action" />
</intent-filter>
</service> <!-- since 3.5.6 新增华硕通道 -->
<receiver android:name="cn.jpush.android.asus.AsusPushMessageReceiver" /> <!-- Required . Enable it you can get statistics data with channel -->
<receiver android:name="cn.jpush.android.asus.AsusPushMessageReceiver" />
<!-- Required . Enable it you can get statistics data with channel -->
<!-- 值来自开发者平台取得的AppKey -->
<meta-data
android:name="JPUSH_CHANNEL"
@@ -351,6 +398,8 @@
<meta-data
android:name="JPUSH_APPKEY"
android:value="${JPUSH_APPKEY}" />
<meta-data
android:name="design_width_in_dp"
android:value="640" />

View File

@@ -63,9 +63,10 @@ class KotlinMainActivity : AppCompatActivity(), CancelAdapt {
val test = noteAidlInterface.note
Log.e("test", test)
}
}
}

View File

@@ -10,6 +10,7 @@ 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;
@@ -30,6 +31,7 @@ import com.tt.ttutils.server.main.MainService;
import com.tt.ttutils.R;
import com.tt.ttutils.utils.java.CmdUtil;
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;
@@ -40,6 +42,12 @@ import butterknife.BindView;
import butterknife.ButterKnife;
public class MainActivity extends ImmerseBaseActivity {
@BindView(R.id.tv_qch_Developeroptions)
TextView tv_qch_Developeroptions;
@BindView(R.id.tv_development_settings_enabled)
TextView tv_development_settings_enabled;
@BindView(R.id.tv_adb_enabled)
TextView tv_adb_enabled;
@BindView(R.id.textView)
TextView textView;
@BindView(R.id.button)
@@ -78,6 +86,16 @@ public class MainActivity extends ImmerseBaseActivity {
@BindView(R.id.bt_start_jgy)
Button bt_start_jgy;
@BindView(R.id.tv_statu)
TextView tv_statu;
@BindView(R.id.bt_camera_close)
Button bt_camera_close;
@BindView(R.id.bt_camera_open)
Button bt_camera_open;
@BindView(R.id.bt_camera_refresh)
Button bt_camera_refresh;
private ServiceConnection mServiceConnection;
private INoteAidlInterface noteAidlInterface;
private ServiceConnection mLicenseServiceConnection;
@@ -105,10 +123,21 @@ public class MainActivity extends ImmerseBaseActivity {
// int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION //导航栏
// | View.SYSTEM_UI_FLAG_FULLSCREEN;//全屏
// decorView.setSystemUiVisibility(uiOptions);
Intent intent = getIntent();
if (intent != null) {
TTUtils.getExtrax(intent);
}
mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent != null) {
TTUtils.getExtrax(intent);
}
}
@Override
public void setListener() {
// mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_NONE, true);
@@ -309,6 +338,41 @@ public class MainActivity extends ImmerseBaseActivity {
// }
}
});
bt_camera_refresh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int code = Settings.System.getInt(getContentResolver(), "qch_app_camera", 0);
tv_statu.setText("状态:" + code);
}
});
bt_camera_close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Settings.System.putInt(getContentResolver(), "qch_app_camera", 1);
Intent cameraIntent = new Intent("qch_camera_forbid").setPackage("com.android.settings");
sendBroadcast(cameraIntent);
}
});
bt_camera_open.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Settings.System.putInt(getContentResolver(), "qch_app_camera", 0);
Intent cameraIntent = new Intent("qch_camera_open").setPackage("com.android.settings");
sendBroadcast(cameraIntent);
}
});
}
@Override
protected void onResume() {
super.onResume();
Log.e(TAG, "onResume: " + Settings.System.getInt(getContentResolver(), "qch_Developeroptions", 0));
tv_qch_Developeroptions.setText("qch_Developeroptions: " + Settings.System.getInt(getContentResolver(), "qch_Developeroptions", 0));
Log.e(TAG, "onResume: " + Settings.Global.getInt(getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0));
tv_development_settings_enabled.setText("development_settings_enabled: " + Settings.Global.getInt(getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0));
Log.e(TAG, "onResume: " + Settings.Global.getInt(getContentResolver(), Settings.Global.ADB_ENABLED, 0));
tv_adb_enabled.setText("development_settings_enabled: " + Settings.Global.getInt(getContentResolver(), Settings.Global.ADB_ENABLED, 0));
}
private HideAppReceiver hideAppReceiver;

View File

@@ -0,0 +1,102 @@
package com.tt.ttutils.activity.test;
import androidx.appcompat.app.AppCompatActivity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import com.tt.ttutils.R;
import com.tt.ttutils.utils.java.TTUtils;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
public class TestActivity extends AppCompatActivity {
private String TAG = TestActivity.class.getSimpleName();
@BindView(R.id.bt1)
Button bt1;
@BindView(R.id.bt2)
Button bt2;
@BindView(R.id.bt3)
Button bt3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
ButterKnife.bind(this);
Intent intent = getIntent();
if (intent != null) {
TTUtils.getExtrax(intent);
}
bt1.setOnClickListener(view -> setDefault("com.aoleyunos.dop1"));
bt2.setOnClickListener(view -> setDefault("com.aoleyunos.dop2"));
bt3.setOnClickListener(view -> setDefault("com.aoleyun.os"));
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent != null) {
TTUtils.getExtrax(intent);
}
}
private void setDefault(String pkg) {
String className = getStartClassName(pkg);
Intent intent = new Intent("setDefaultLauncher");
intent.putExtra("package", pkg);
intent.putExtra("className", className);
//爱华定制
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.AoleReceiver"));
intent.setPackage("com.android.settings");
sendBroadcast(intent);
}
public String getStartClassName(String pkg) {
PackageInfo packageInfo = null;
try {
packageInfo = getPackageManager().getPackageInfo(pkg, 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (packageInfo == null) {
return "";
} else {
// 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
resolveIntent.setPackage(packageInfo.packageName);
// 通过getPackageManager()的queryIntentActivities方法遍历
List<ResolveInfo> resolveinfoList = getPackageManager()
.queryIntentActivities(resolveIntent, 0);
if (resolveinfoList == null || resolveinfoList.size() == 0) {
return "";
}
ResolveInfo resolveinfo = resolveinfoList.iterator().next();
if (resolveinfo != null) {
// packagename = 参数packname
String packageName = resolveinfo.activityInfo.packageName;
// 这个就是我们要找的该APP的LAUNCHER的Activity[组织形式packagename.mainActivityname]
String className = resolveinfo.activityInfo.name;
return className;
} else {
return "";
}
}
}
}

View File

@@ -0,0 +1,45 @@
package com.tt.ttutils.gson;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
public class NullStringToEmptyAdapterFactory<T> implements TypeAdapterFactory {
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
Class<T> rawType = (Class<T>) type.getRawType();
if (rawType != String.class) {
return null;
}
return (TypeAdapter<T>) new StringAdapter();
}
public static class StringAdapter extends TypeAdapter<String> {
@Override
public String read(JsonReader reader) throws IOException {
if (reader.peek() == JsonToken.NULL) {
reader.nextNull();
return "";
}
return reader.nextString();
}
@Override
public void write(JsonWriter writer, String value) throws IOException {
if (value == null) {
writer.nullValue();
return;
}
writer.value(value);
}
}
}

View File

@@ -0,0 +1,75 @@
package com.tt.ttutils.network.interceptor;
import android.util.Log;
import com.tt.ttutils.utils.java.MD5Util;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
import okhttp3.Interceptor;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.Response;
import okio.Buffer;
public class RepeatRequestInterceptor implements Interceptor {
private static final String TAG = RepeatRequestInterceptor.class.getSimpleName();
private final ConcurrentHashMap<String, Long> requestIdsMap = new ConcurrentHashMap<>();
public static final String REPEAT_REQUEST_PROTOCOL = "OKHTTP_REPEAT_REQUEST_PROTOCOL";
@NotNull
@Override
public Response intercept(@NotNull Chain chain) throws IOException {
Request request = chain.request();
Response response = chain.proceed(chain.request());
String content = response.body().string();
// Log.e(TAG, "请求体返回:| Response:" + content);
//相同的请求
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString() + request.body());
long time = System.currentTimeMillis();//请求时间
try {
if (requestIdsMap.size() > 0 && requestIdsMap.containsKey(requestKey)) {
// Log.e("REPEAT-REQUEST", "重复请求:" + requestKey + " Method @" + request.method() + " --- " + " URL = " + request.url() + "\t" + bodyToString(request));
Log.e("REPEAT-REQUEST", "重复请求:" + requestKey + " Method @" + request.method() + " --- " + " URL = " + request.url());
//下面这行写了不会抛出onerror
// chain.call().cancel();
return new Response.Builder()
.protocol(Protocol.get(REPEAT_REQUEST_PROTOCOL))
.request(request) //multi thread
.build();
}
requestIdsMap.put(requestKey, time);
// Log.e("REPEAT-REQUEST", "注册请求:" + requestKey + " Method @" + request.method() + " --- " + " URL = " + request.url() + "\t" + bodyToString(request));
Log.e("REPEAT-REQUEST", "注册请求:" + requestKey + " Method @" + request.method() + " --- " + " URL = " + request.url());
// RepeatRequestInterceptor.Builder builder = request.newBuilder();
// builder.addHeader("header", jsonObject.toString());
return chain.proceed(request);
} catch (IOException e) {
Log.e(TAG, "intercept: " + e.getMessage());
throw e;
} finally {
if (requestIdsMap.containsKey(requestKey) && requestIdsMap.containsValue(time)) {//请求任务完成删除map中的数据
requestIdsMap.remove(requestKey);
Log.e("REPEAT-REQUEST", "移除请求:" + requestKey + " Method @" + request.method() + " --- " + " URL = " + request.url() + "\t" + bodyToString(request));
// Log.e("REPEAT-REQUEST", "移除请求:" + requestKey + " Method @" + request.method() + " --- " + " URL = " + request.url());
}
}
}
private static String bodyToString(final Request request) {
try {
final Request copy = request.newBuilder().build();
final Buffer buffer = new Buffer();
copy.body().writeTo(buffer);
return buffer.readUtf8();
} catch (Exception e) {
return "-";
}
}
}

View File

@@ -1,15 +1,107 @@
package com.tt.ttutils.utils.java;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.IPackageDataObserver;
import android.content.pm.IPackageStatsObserver;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.text.TextUtils;
import android.content.pm.PackageStats;
import android.os.RemoteException;
import android.util.Log;
import java.util.List;
import java.io.File;
import java.lang.reflect.Method;
public class ApkUtils {
private static final String TAG = ApkUtils.class.getSimpleName();
private final long MAX_WAIT_TIME = 60 * 1000;
private final long WAIT_TIME_INCR = 10 * 1000;
/**
* 通过包名获取大小
*
* @param context
* @param packageName
* @return
*/
public static long getPackageSize(Context context, String packageName) {
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = null;
try {
packageInfo = packageManager.getPackageInfo(packageName, 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (packageInfo == null) {
return 0L;
} else {
return new File(packageInfo.applicationInfo.publicSourceDir).length();
}
}
public long getApplicationCache(Context context, String packageName) throws Exception {
try {
PackageStatsObserver observer = new PackageStatsObserver();
// wait on observer
synchronized (observer) {
Method method = PackageManager.class.getMethod("getPackageSizeInfo", String.class, IPackageStatsObserver.class);
method.invoke(context.getPackageManager(), packageName, observer);
// getPm().getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
long waitTime = 0;
while ((!observer.isDone()) || (waitTime > MAX_WAIT_TIME)) {
observer.wait(WAIT_TIME_INCR);
waitTime += WAIT_TIME_INCR;
}
if (!observer.isDone()) {
throw new Exception("Timed out waiting for PackageStatsObserver.onGetStatsCompleted");
}
}
Log.d(TAG, "toString " + observer.stats.toString());
return observer.stats.dataSize + observer.stats.cacheSize;
} catch (RemoteException e) {
Log.w(TAG, "Failed to get handle for PackageManger Exception: " + e);
return -1;
} catch (InterruptedException e) {
Log.w(TAG, "InterruptedException :" + e);
return -1;
}
}
static class PackageDataObserver extends IPackageDataObserver.Stub {
public boolean retValue = false;
private boolean doneFlag = false;
public void onRemoveCompleted(String packageName, boolean succeeded) throws RemoteException {
synchronized (this) {
retValue = succeeded;
doneFlag = true;
notifyAll();
}
}
public boolean isDone() {
return doneFlag;
}
}
static class PackageStatsObserver extends IPackageStatsObserver.Stub {
boolean retValue = false;
PackageStats stats;
private boolean doneFlag = false;
public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException {
synchronized (this) {
retValue = succeeded;
stats = pStats;
doneFlag = true;
notifyAll();
}
}
public boolean isDone() {
return doneFlag;
}
}
}

View File

@@ -23,6 +23,7 @@ public class AppUtils {
}
//https://www.jianshu.com/p/9dac8c2aeb4d
//https://www.jianshu.com/p/33695ee91d18
public static boolean openPackage(Context context, String packageName) {
Context pkgContext = getPackageContext(context, packageName);

View File

@@ -131,5 +131,4 @@ public class DevicesUtils {
}
return jsonObject.toString();
}
}

View File

@@ -5,8 +5,11 @@ import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.util.Log;
import com.tt.ttutils.BuildConfig;
import com.tt.ttutils.disklrucache.CacheHelper;
import com.tt.ttutils.receiver.BootReceiver;
@@ -20,6 +23,19 @@ public class JGYUtils {
private CacheHelper cacheHelper;
public static int UnknowPlatform = 0;
public static int MTKPlatform = 1;
// TODO: 2022/4/23 标签替换未完成
public static int CubePlatform = 2;
public static int ZhanruiPlatform = 3;
public static String Other = "其他";
public static String MTKTag = "MTK";
// TODO: 2022/4/23 标签替换未完成
public static String CubeTag = "展锐cube";
public static String ZhanruiTag = "展锐";
private JGYUtils(Context context) {
if (context == null) {
throw new RuntimeException("Context is NULL");
@@ -43,6 +59,117 @@ public class JGYUtils {
return sInstance;
}
public int checkSNPlatform(String sn) {
String secondChars = sn.substring(1, 2);
if ("N".equalsIgnoreCase(secondChars)) {//MTK平台
return MTKPlatform;
} else if ("R".equalsIgnoreCase(secondChars)) {//展锐平台
return ZhanruiPlatform;
} else {
Log.e(TAG, "checkSNPlatform: " + "sn: " + sn + "没有对应平台");
return UnknowPlatform;
}
}
public int checkAppPlatform() {
String platform = BuildConfig.platform;
if ("MTK".equalsIgnoreCase(platform)) {
Log.i(TAG, "checkAppPlatform: " + "MTK平台");
return MTKPlatform;
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
Log.i(TAG, "checkAppPlatform: " + "展锐平台");
return ZhanruiPlatform;
} else if ("ZhanRuiCube".equalsIgnoreCase(platform)) {
Log.i(TAG, "checkAppPlatform: " + "酷比平台");
return CubePlatform;
} else {
Log.i(TAG, "checkAppPlatform: " + "没有数据");
return UnknowPlatform;
}
}
public boolean isSamePlatform(String platform) {
String AppPlatform = BuildConfig.platform;
if ("ZhanRui".equals(AppPlatform)) {
return ZhanruiTag.equals(platform);
} else {
return AppPlatform.equals(platform);
}
}
public interface GetAppPlatformCallback {
void AppPlatform(int platform);
}
public void getAppPlatform(GetAppPlatformCallback getAppPlatformCallback) {
String platform = BuildConfig.platform;
if ("MTK".equalsIgnoreCase(platform)) {
getAppPlatformCallback.AppPlatform(MTKPlatform);
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
getAppPlatformCallback.AppPlatform(ZhanruiPlatform);
} else if ("ZhanRuiCube".equalsIgnoreCase(platform)) {
getAppPlatformCallback.AppPlatform(CubePlatform);
} else {
getAppPlatformCallback.AppPlatform(UnknowPlatform);
}
}
public String getAppPlatform() {
String platform = BuildConfig.platform;
if ("MTK".equalsIgnoreCase(platform)) {
return MTKTag;
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
return ZhanruiTag;
} else if ("ZhanRuiCube".equalsIgnoreCase(platform)) {
return CubeTag;
} else {
return Other;
}
}
/**
* 从Manifest中获取meta-data值
* https://blog.csdn.net/yue_233/article/details/91453451
*
* @return
*/
public String getStringMetaData() {
ApplicationInfo appInfo = null;
try {
appInfo = mContext.getPackageManager().getApplicationInfo(mContext.getPackageName(), PackageManager.GET_META_DATA);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
String value = appInfo.metaData.getString("CHANNEL_VALUE");
return value;
}
public static boolean isOfficialVersion() {
String channelValue = JGYUtils.getInstance().getStringMetaData();
return "official".equals(channelValue);
}
public static boolean isOfficialVersion(Context context) {
Log.e(TAG, "isOfficialVersion: " + ProcessUtil.getCurrentProcessName(context));
String channelValue = JGYUtils.getInstance().getStringMetaData();
return "official".equals(channelValue);
}
public static boolean isNewlyVersion() {
String channelValue = JGYUtils.getInstance().getStringMetaData();
return "beta".equals(channelValue);
}
public static boolean isBetaVersion() {
String channelValue = JGYUtils.getInstance().getStringMetaData();
return "beta".equals(channelValue);
}
public static String getCHANNEL_VALUE() {
return JGYUtils.getInstance().getStringMetaData();
}
public static final String PACKAGE_DEVICEINFO = "com.aoleyun.sn";
public static final String CLASS_DEVICEINFO = "com.aoleyun.sn.receiver.BootReceiver";

View File

@@ -0,0 +1,175 @@
package com.tt.ttutils.utils.java;
import android.app.Activity;
import android.app.WallpaperManager;
import android.app.role.RoleManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Process;
import android.os.UserHandle;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.WindowManager;
import com.tt.ttutils.R;
import java.io.IOException;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
public class LauncherUtils {
public static void setRoleHolderAsUser(Context context, String packageName) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
String roleName = "android.app.role.HOME";
boolean add = true;
int flags = 0;
UserHandle user = Process.myUserHandle();
Log.i("settingssssssstemf", (add ? "Adding" : "Removing") + " package as role holder, role: "
+ roleName + ", package: " + packageName);
if (JGYUtils.getInstance().checkAppPlatform() != JGYUtils.MTKPlatform) {
RoleManager roleManager = context.getSystemService(RoleManager.class);
Executor executor = context.getMainExecutor();
Consumer<Boolean> callback = successful -> {
if (successful) {
Log.d("settingssssssstemf", "Package " + (add ? "added" : "removed")
+ " as role holder, role: " + roleName + ", package: " + packageName);
} else {
Log.d("settingssssssstemf", "Failed to " + (add ? "add" : "remove")
+ " package as role holder, role: " + roleName + ", package: "
+ packageName);
}
};
roleManager.addRoleHolderAsUser(roleName, packageName, flags, user, executor, callback);
Log.i("settingssssssstemf", "addRoleHolderAsUser done");
}
} else {
}
}
// private void setDefault() {
// String mRoleName ="android.app.role.HOME";
// final Intent intent = new Intent(Intent.ACTION_MANAGE_DEFAULT_APP)
// .putExtra(Intent.EXTRA_ROLE_NAME, mRoleName);
// startActivity(intent);
// }
public static boolean isDefaultHome(Context context) {
Intent intent = new Intent(Intent.ACTION_MAIN);//Intent.ACTION_VIEW
intent.addCategory("android.intent.category.HOME");
intent.addCategory("android.intent.category.DEFAULT");
PackageManager pm = context.getPackageManager();
ResolveInfo info = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
boolean isDefault = context.getPackageName().equals(info.activityInfo.packageName);
return isDefault;
}
private String getHomeLauncher(Context context) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, 0);
String currentHomePackage = resolveInfo.activityInfo.packageName;
return currentHomePackage;
}
private void setDefaultL(Context context) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory("android.intent.category.HOME");
try {
intent.setComponent(new ComponentName("android", "com.android.internal.app.ResolverActivity"));
context.startActivity(intent);
} catch (Exception e) {
try {
intent.setComponent(new ComponentName("com.huawei.android.internal.app", "com.huawei.android.internal.app.HwResolverActivity"));//这个类有些华为手机找不到
context.startActivity(intent);
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
public Bitmap blur(Context context, Bitmap image) {
int width = Math.round(image.getWidth() * 0.4f);
int height = Math.round(image.getHeight() * 0.4f);
Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);
RenderScript rs = RenderScript.create(context);
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
blurScript.setRadius(25f);
blurScript.setInput(tmpIn);
blurScript.forEach(tmpOut);
tmpOut.copyTo(outputBitmap);
return outputBitmap;
}
public Bitmap getWallpaperBg(Context context) {
WallpaperManager wallpaperManager = WallpaperManager.getInstance(context);
Drawable wallpaperDrawable = wallpaperManager.getDrawable();
Bitmap bm = ((BitmapDrawable) wallpaperDrawable).getBitmap();
Bitmap bitmap = cropImage(context, bm);
return bitmap;
}
private void SetWallPaper(Activity activity) {
//利用WallpaparManager,添加权限set_wallpaper
WallpaperManager wallpaperManager = WallpaperManager.getInstance(activity);
try {
wallpaperManager.setBitmap(BitmapFactory.decodeResource(activity.getResources(), R.drawable.wallpapers));
} catch (IOException e) {
e.printStackTrace();
Log.e("TT", e.getMessage());
}
SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putInt("SetWallPaper", 1);
editor.apply();
//getSystemService(WALLPAPER_SERVICE)获取wallpaperManager会出问题
/* @SuppressLint("ServiceCast")
WallpaperManager manager =(WallpaperManager)getSystemService(WALLPAPER_SERVICE);
try {
manager.setBitmap(BitmapFactory.decodeResource(getResources(),R.drawable.pic1));
} catch (IOException e) {
e.printStackTrace();
}*/
}
private Bitmap cropImage(Context context, Bitmap oldBitmap) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();
wm.getDefaultDisplay().getRealMetrics(dm);
int width = dm.widthPixels; // 屏幕宽度像素1200
int height = dm.heightPixels; // 屏幕高度像素1920
int picWidth = oldBitmap.getWidth();
int picHeight = oldBitmap.getHeight();
float wScala = (float) height / width;
float bScala = (float) picHeight / picWidth;
int newPicWidth;
int newpicHeight;
Bitmap bitmap = null;
if (wScala > bScala) {
newPicWidth = (int) (picWidth / wScala);
newpicHeight = picHeight;
bitmap = Bitmap.createBitmap(oldBitmap, (newPicWidth - width) / 2, 0, newPicWidth, newpicHeight);
} else {
newPicWidth = picWidth;
newpicHeight = (int) (picHeight * wScala);
bitmap = Bitmap.createBitmap(oldBitmap, 0, (picHeight - newpicHeight) / 2, newPicWidth, newpicHeight);
}
return bitmap;
}
}

View File

@@ -0,0 +1,96 @@
package com.tt.ttutils.utils.java;
import android.app.ActivityManager;
import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.reflect.Method;
import java.util.List;
public class ProcessUtil {
private static String currentProcessName;
/**
* @return 当前进程名
*/
@Nullable
public static String getCurrentProcessName(@NonNull Context context) {
if (!TextUtils.isEmpty(currentProcessName)) {
return currentProcessName;
}
//1)通过Application的API获取当前进程名
currentProcessName = getCurrentProcessNameByApplication();
if (!TextUtils.isEmpty(currentProcessName)) {
return currentProcessName;
}
//2)通过反射ActivityThread获取当前进程名
currentProcessName = getCurrentProcessNameByActivityThread();
if (!TextUtils.isEmpty(currentProcessName)) {
return currentProcessName;
}
//3)通过ActivityManager获取当前进程名
currentProcessName = getCurrentProcessNameByActivityManager(context);
return currentProcessName;
}
/**
* 通过Application新的API获取进程名无需反射无需IPC效率最高。
*/
public static String getCurrentProcessNameByApplication() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
return Application.getProcessName();
}
return null;
}
/**
* 通过反射ActivityThread获取进程名避免了ipc
*/
public static String getCurrentProcessNameByActivityThread() {
String processName = null;
try {
final Method declaredMethod = Class.forName("android.app.ActivityThread", false, Application.class.getClassLoader())
.getDeclaredMethod("currentProcessName", (Class<?>[]) new Class[0]);
declaredMethod.setAccessible(true);
final Object invoke = declaredMethod.invoke(null, new Object[0]);
if (invoke instanceof String) {
processName = (String) invoke;
}
} catch (Throwable e) {
e.printStackTrace();
}
return processName;
}
/**
* 通过ActivityManager 获取进程名需要IPC通信
*/
public static String getCurrentProcessNameByActivityManager(@NonNull Context context) {
if (context == null) {
return null;
}
int pid = android.os.Process.myPid();
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
if (am != null) {
List<ActivityManager.RunningAppProcessInfo> runningAppList = am.getRunningAppProcesses();
if (runningAppList != null) {
for (ActivityManager.RunningAppProcessInfo processInfo : runningAppList) {
if (processInfo.pid == pid) {
return processInfo.processName;
}
}
}
}
return null;
}
}

View File

@@ -3,12 +3,17 @@ package com.tt.ttutils.utils.java;
import android.annotation.SuppressLint;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.util.Log;
import com.tt.ttutils.disklrucache.CacheHelper;
import java.util.Iterator;
import java.util.Set;
public class TTUtils {
private static final String TAG = TTUtils.class.getSimpleName();
@@ -60,5 +65,18 @@ public class TTUtils {
return false;
}
public static void getExtrax(Intent intent) {
if (intent == null) return;
String action = intent.getAction();
Log.e(TAG, "getExtrax: " + action);
Bundle bundle = intent.getExtras();
if (bundle == null) return;
Set<String> ks = bundle.keySet();
Iterator<String> iterator = ks.iterator();
while (iterator.hasNext()) {
String key = iterator.next();
Log.e("KEY", key);
Log.e("value", intent.getStringExtra(key));
}
}
}

View File

@@ -17,6 +17,56 @@
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_statu"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:id="@+id/bt_camera_close"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="关闭" />
<Button
android:id="@+id/bt_camera_open"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="打开" />
<Button
android:id="@+id/bt_camera_refresh"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="刷新"
app:layout_constraintEnd_toEndOf="parent" />
</LinearLayout>
<TextView
android:id="@+id/tv_qch_Developeroptions"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_development_settings_enabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_adb_enabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/bt_bar_show"
android:layout_width="wrap_content"

View File

@@ -17,6 +17,56 @@
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_statu"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:id="@+id/bt_camera_close"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="关闭" />
<Button
android:id="@+id/bt_camera_open"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="打开" />
<Button
android:id="@+id/bt_camera_refresh"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="刷新"
app:layout_constraintEnd_toEndOf="parent" />
</LinearLayout>
<TextView
android:id="@+id/tv_qch_Developeroptions"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_development_settings_enabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_adb_enabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/bt_bar_show"
android:layout_width="wrap_content"
@@ -164,12 +214,12 @@
app:layout_constraintTop_toTopOf="@+id/accessory" />
<Button
android:id="@+id/bt_bc_boot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="broadcast"
app:layout_constraintStart_toEndOf="@+id/icon_on"
app:layout_constraintTop_toTopOf="@+id/accessory" />
android:id="@+id/bt_bc_boot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="broadcast"
app:layout_constraintStart_toEndOf="@+id/icon_on"
app:layout_constraintTop_toTopOf="@+id/accessory" />
<Button
android:id="@+id/bt_start_jgy"

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.test.TestActivity">
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="com.aoleyunos.dop1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/bt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="com.aoleyunos.dop2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/bt1" />
<Button
android:id="@+id/bt3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="com.aoleyun.os"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/bt2" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -6,4 +6,245 @@
<!-- <color name="colorPrimary">#6200EE</color>-->
<!-- <color name="colorPrimaryDark">#3700B3</color>-->
<!-- <color name="colorAccent">#03DAC5</color>-->
<!--https://www.jianshu.com/p/8dc258dfd189-->
<color name="transparent">#00000000</color><!--透明色-->
<color name="colorYang">#FFE2C59B</color><!--羊皮纸色-->
<color name="ivory">#FFFFFFF0</color><!--象牙色-->
<color name="lightYellow">#FFFFFFE0</color><!--亮黄色-->
<color name="yellow">#FFFFFF00</color><!--黄色-->
<color name="snow">#FFFFFAFA</color><!--雪白色-->
<color name="floralWhite">#FFFFFAF0</color><!--花白色-->
<color name="lemonChiffon">#FFFFFACD</color><!--柠檬绸色-->
<color name="cornSilk">#FFFFF8DC</color><!--米绸色-->
<color name="seashell">#FFFFF5EE</color><!--海贝色-->
<color name="lavenderBlush">#FFFFF0F5</color><!--淡紫红色-->
<color name="papayaWhip">#FFFFEFD5</color><!--番木色-->
<color name="blanchedAlmond">#FFFFEBCD</color><!--白杏色-->
<color name="mistyRose">#FFFFE4E1</color><!--浅玫瑰色-->
<color name="bisque">#FFFFE4C4</color><!--桔黄色-->
<color name="moccasin">#FFFFE4B5</color><!--鹿皮色-->
<color name="navajoWhite">#FFFFDEAD</color><!--纳瓦白-->
<color name="peachPuff">#FFFFDAB9</color><!--桃色-->
<color name="gold">#FFFFD700</color><!--金色-->
<color name="pink">#FFFFC0CB</color><!--粉红色-->
<color name="lightPink">#FFFFB6C1</color><!--亮粉红色-->
<color name="orange">#FFFFA500</color><!--橙色-->
<color name="lightSalmon">#FFFFA07A</color><!--亮肉色-->
<color name="darkOrange">#FFFF8C00</color><!--暗桔黄色-->
<color name="coral">#FFFF7F50</color><!--珊瑚色-->
<color name="hotPink">#FFFF69B4</color><!--热粉红色-->
<color name="tomato">#FFFF6347</color><!--西红柿色-->
<color name="orangeRed">#FFFF4500</color><!--红橙色-->
<color name="deepPink">#FFFF1493</color><!--深粉红色-->
<color name="fuchsia">#FFFF00FF</color><!--紫红色-->
<color name="red">#FFFF0000</color><!--红色-->
<color name="oldLace">#FFFDF5E6</color><!--老花色-->
<color name="lightGoldenrodYellow">#FFFAFAD2</color><!--亮金黄色-->
<color name="linen">#FFFAF0E6</color><!--亚麻色-->
<color name="antiqueWhite">#FFFAEBD7</color><!--古董白色-->
<color name="salmon">#FFFA8072</color><!--鲜肉色-->
<color name="ghostWhite">#FFF8F8FF</color><!--幽灵白-->
<color name="mintCream">#FFF5FFFA</color><!--薄荷色-->
<color name="whiteSmoke">#FFF5F5F5</color><!--烟白色-->
<color name="beige">#FFF5F5DC</color><!--米色-->
<color name="wheat">#FFF5DEB3</color><!--浅黄色-->
<color name="sandyBrown">#FFF4A460</color><!--沙褐色-->
<color name="azure">#FFF0FFFF</color><!--天蓝色-->
<color name="aliceBlue">#FFF0F8FF</color><!--艾利斯兰色-->
<color name="khaki">#FFF0E68C</color><!--黄褐色-->
<color name="lightCoral">#FFF08080</color><!--亮珊瑚色-->
<color name="paleGoldenrod">#FFEEE8AA</color><!--苍麒麟色-->
<color name="violet">#FFEE82EE</color><!--紫罗兰色-->
<color name="darkSalmon">#FFE9967A</color><!--暗肉色-->
<color name="lavender">#FFE6E6FA</color><!--淡紫色-->
<color name="lightCyan">#FFE0FFFF</color><!--亮青色-->
<color name="burlyWood">#FFDEB887</color><!--实木色-->
<color name="plum">#FFDDA0DD</color><!--洋李色-->
<color name="lightGrey">#FFDCDCDC</color><!--淡灰色-->
<color name="crimson">#FFDC143C</color><!--暗深红色-->
<color name="paleVioletRed">#FFDB7093</color><!--苍紫罗兰色-->
<color name="goldenrod">#FFDAA520</color><!--金麒麟色-->
<color name="orchid">#FFDA70D6</color><!--淡紫色-->
<color name="thistle">#FFD8BFD8</color><!--蓟色-->
<color name="lightGray">#FFD3D3D3</color><!--亮灰色-->
<color name="tan">#FFD2B48C</color><!--茶色-->
<color name="chocolate">#FFD2691E</color><!--巧可力色-->
<color name="peru">#FFCD853F</color><!--秘鲁色-->
<color name="indianRed">#FFCD5C5C</color><!--印第安红色-->
<color name="mediumVioletRed">#FFC71585</color><!--中紫罗兰色-->
<color name="silver">#FFC0C0C0</color><!--银色-->
<color name="darkKhaki">#FFBDB76B</color><!--暗黄褐色-->
<color name="rosyBrown">#FFBC8F8F</color><!--褐玫瑰红色-->
<color name="mediumOrchid">#FFBA55D3</color><!--中粉紫色-->
<color name="darkGoldenrod">#FFB8860B</color><!--暗金黄色-->
<color name="firebrick">#FFB22222</color><!--火砖色-->
<color name="powderBlue">#FFB0E0E6</color><!--粉蓝色-->
<color name="lightSteelBlue">#FFB0C4DE</color><!--亮钢兰色-->
<color name="paleTurquoise">#FFAFEEEE</color><!--苍宝石绿色-->
<color name="greenYellow">#FFADFF2F</color><!--黄绿色-->
<color name="lightBlue">#FFADD8E6</color><!--亮蓝色-->
<color name="darkGray">#FFA9A9A9</color><!--暗灰色-->
<color name="brown">#FFA52A2A</color><!--褐色-->
<color name="sienna">#FFA0522D</color><!--赭色-->
<color name="darkOrchid">#FF9932CC</color><!--暗紫色-->
<color name="paleGreen">#FF98FB98</color><!--苍绿色-->
<color name="darkViolet">#FF9400D3</color><!--暗紫罗兰色-->
<color name="mediumPurple">#FF9370DB</color><!--中紫色-->
<color name="lightGreen">#FF90EE90</color><!--亮绿色-->
<color name="darkSeaGreen">#FF8FBC8F</color><!--暗海兰色-->
<color name="saddleBrown">#FF8B4513</color><!--重褐色-->
<color name="darkMagenta">#FF8B008B</color><!--暗洋红色-->
<color name="darkRed">#FF8B0000</color><!--暗红色-->
<color name="blueViolet">#FF8A2BE2</color><!--紫罗兰蓝色-->
<color name="lightSkyBlue">#FF87CEFA</color><!--亮天蓝色-->
<color name="skyBlue">#FF87CEEB</color><!--天蓝色-->
<color name="gray">#FF808080</color><!--灰色-->
<color name="olive">#FF808000</color><!--橄榄色-->
<color name="purple">#FF800080</color><!--紫色-->
<color name="maroon">#FF800000</color><!--粟色-->
<color name="aquamarine">#FF7FFFD4</color><!--碧绿色-->
<color name="chartreuse">#FF7FFF00</color><!--黄绿色-->
<color name="lawnGreen">#FF7CFC00</color><!--草绿色-->
<color name="mediumSlateBlue">#FF7B68EE</color><!--中暗蓝色-->
<color name="lightSlateGray">#FF778899</color><!--亮蓝灰色-->
<color name="slateGray">#FF708090</color><!--灰石色-->
<color name="oliveDrab">#FF6B8E23</color><!--深绿褐色-->
<color name="slateBlue">#FF6A5ACD</color><!--石蓝色-->
<color name="dimGray">#FF696969</color><!--暗灰色-->
<color name="mediumAquamarine">#FF66CDAA</color><!--中绿色-->
<color name="cornFlowerBlue">#FF6495ED</color><!--菊兰色-->
<color name="cadetBlue">#FF5F9EA0</color><!--军兰色-->
<color name="darkOliveGreen">#FF556B2F</color><!--暗橄榄绿色-->
<color name="indigo">#FF4B0082</color><!--靛青色-->
<color name="mediumTurquoise">#FF48D1CC</color><!--中绿宝石色-->
<color name="darkSlateBlue">#FF483D8B</color><!--暗灰蓝色-->
<color name="steelBlue">#FF4682B4</color><!--钢兰色-->
<color name="royalBlue">#FF4169E1</color><!--皇家蓝色-->
<color name="turquoise">#FF40E0D0</color><!--青绿色-->
<color name="mediumSeaGreen">#FF3CB371</color><!--中海蓝色-->
<color name="limeGreen">#FF32CD32</color><!--橙绿色-->
<color name="darkSlateGray">#FF2F4F4F</color><!--暗瓦灰色-->
<color name="seaGreen">#FF2E8B57</color><!--海绿色-->
<color name="forestGreen">#FF228B22</color><!--森林绿色-->
<color name="lightSeaGreen">#FF20B2AA</color><!--亮海蓝色-->
<color name="dodgerBlue">#FF1E90FF</color><!--闪兰色-->
<color name="midnightBlue">#FF191970</color><!--中灰兰色-->
<color name="aqua">#FF00FFFF</color><!--浅绿色-->
<color name="springGreen">#FF00FF7F</color><!--春绿色-->
<color name="lime">#FF00FF00</color><!--酸橙色-->
<color name="mediumSpringGreen">#FF00FA9A</color><!--中春绿色-->
<color name="darkTurquoise">#FF00CED1</color><!--暗宝石绿色-->
<color name="deepSkyBlue">#FF00BFFF</color><!--深天蓝色-->
<color name="darkCyan">#FF008B8B</color><!--暗青色-->
<color name="teal">#FF008080</color><!--水鸭色-->
<color name="green">#FF008000</color><!--绿色-->
<color name="darkGreen">#FF006400</color><!--暗绿色-->
<color name="blue">#FF0000FF</color><!--蓝色-->
<color name="mediumBlue">#FF0000CD</color><!--中兰色-->
<color name="darkBlue">#FF00008B</color><!--暗蓝色-->
<color name="navy">#FF000080</color><!--海军色-->
<color name="unBlack">#FF2B2B2B</color><!--不知名黑色-->
<!--https://www.cnblogs.com/elleniou/archive/2012/04/25/2469676.html-->
<color name="white">#ffffff</color><!--白色 -->
<color name="lightyellow">#ffffe0</color><!--亮黄色 -->
<color name="floralwhite">#fffaf0</color><!--花白色 -->
<color name="lemonchiffon">#fffacd</color><!--柠檬绸色 -->
<color name="cornsilk">#fff8dc</color><!--米绸色 -->
<color name="seaShell">#fff5ee</color><!--海贝色 -->
<color name="lavenderblush">#fff0f5</color><!--淡紫红 -->
<color name="papayawhip">#ffefd5</color><!--番木色 -->
<color name="blanchedalmond">#ffebcd</color><!--白杏色 -->
<color name="mistyrose">#ffe4e1</color><!--浅玫瑰色 -->
<color name="navajowhite">#ffdead</color><!--纳瓦白 -->
<color name="peachpuff">#ffdab9</color><!--桃色 -->
<color name="lightpink">#ffb6c1</color><!--亮粉红色 -->
<color name="lightsalmon">#ffa07a</color><!--亮肉色 -->
<color name="darkorange">#ff8c00</color><!--暗桔黄色 -->
<color name="hotpink">#ff69b4</color><!--热粉红色 -->
<color name="orangered">#ff4500</color><!--红橙色 -->
<color name="deeppink">#ff1493</color><!--深粉红色 -->
<color name="magenta">#ff00ff</color><!--红紫色 -->
<color name="oldlace">#fdf5e6</color><!--老花色 -->
<color name="lightgoldenrodyellow">#fafad2</color><!--亮金黄色 -->
<color name="antiquewhite">#faebd7</color><!--古董白 -->
<color name="ghostwhite">#f8f8ff</color><!--幽灵白 -->
<color name="mintcream">#f5fffa</color><!--薄荷色 -->
<color name="whitesmoke">#f5f5f5</color><!--烟白色 -->
<color name="sandybrown">#f4a460</color><!--沙褐色 -->
<color name="honeydew">#f0fff0</color><!--蜜色 -->
<color name="aliceblue">#f0f8ff</color><!--艾利斯兰 -->
<color name="lightcoral">#f08080</color><!--亮珊瑚色 -->
<color name="palegoldenrod">#eee8aa</color><!--苍麒麟色 -->
<color name="darksalmon">#e9967a</color><!--暗肉色 -->
<color name="lightcyan">#e0ffff</color><!--亮青色 -->
<color name="burlywood">#deb887</color><!--实木色 -->
<color name="gainsboro">#dcdcdc</color><!--淡灰色 -->
<color name="palevioletred">#db7093</color><!--苍紫罗兰色 -->
<color name="lightgray">#d3d3d3</color><!--亮灰色 -->
<color name="lightgrey">#d3d3d3</color><!--亮灰色 -->
<color name="indianred">#cd5c5c</color><!--印第安红 -->
<color name="mediumvioletred">#c71585</color><!--中紫罗兰色 -->
<color name="darkkhaki">#bdb76b</color><!--暗黄褐色 -->
<color name="rosybrown">#bc8f8f</color><!--褐玫瑰红 -->
<color name="mediumorchid">#ba55d3</color><!--中粉紫色 -->
<color name="darkgoldenrod">#b8860b</color><!--暗金黄色 -->
<color name="powderblue">#b0e0e6</color><!--粉蓝色 -->
<color name="lightsteelblue">#b0c4de</color><!--亮钢兰色 -->
<color name="paleturquoise">#afeeee</color><!--苍宝石绿 -->
<color name="greenyellow">#adff2f</color><!--黄绿色 -->
<color name="lightblue">#add8e6</color><!--亮蓝色 -->
<color name="darkgray">#a9a9a9</color><!--暗灰色 -->
<color name="darkgrey">#a9a9a9</color><!--暗灰色 -->
<color name="darkorchid">#9932cc</color><!--暗紫色 -->
<color name="palegreen">#98fb98</color><!--苍绿色 -->
<color name="darkviolet">#9400d3</color><!--暗紫罗兰色 -->
<color name="mediumpurple">#9370db</color><!--中紫色 -->
<color name="lightgreen">#90ee90</color><!--亮绿色 -->
<color name="darkseagreen">#8fbc8f</color><!--暗海兰色 -->
<color name="saddlebrown">#8b4513</color><!--重褐色 -->
<color name="darkmagenta">#8b008b</color><!--暗洋红 -->
<color name="darkred">#8b0000</color><!--暗红色 -->
<color name="blueviolet">#8a2be2</color><!--紫罗兰蓝色 -->
<color name="lightskyblue">#87cefa</color><!--亮天蓝色 -->
<color name="skyblue">#87ceeb</color><!--天蓝色 -->
<color name="grey">#808080</color><!--灰色 -->
<color name="lawngreen">#7cfc00</color><!--草绿色 -->
<color name="mediumslateblue">#7b68ee</color><!--中暗蓝色 -->
<color name="lightslategray">#778899</color><!--亮蓝灰 -->
<color name="lightslategrey">#778899</color><!--亮蓝灰 -->
<color name="slategray">#708090</color><!--灰石色 -->
<color name="slategrey">#708090</color><!--灰石色 -->
<color name="olivedrab">#6b8e23</color><!--深绿褐色 -->
<color name="slateblue">#6a5acd</color><!--石蓝色 -->
<color name="dimgray">#696969</color><!--暗灰色 -->
<color name="dimgrey">#696969</color><!--暗灰色 -->
<color name="mediumaquamarine">#66cdaa</color><!--中绿色 -->
<color name="cornflowerblue">#6495ed</color><!--菊兰色 -->
<color name="cadetblue">#5f9ea0</color><!--军兰色 -->
<color name="darkolivegreen">#556b2f</color><!--暗橄榄绿 -->
<color name="mediumturquoise">#48d1cc</color><!--中绿宝石 -->
<color name="darkslateblue">#483d8b</color><!--暗灰蓝色 -->
<color name="steelblue">#4682b4</color><!--钢兰色 -->
<color name="royalblue">#4169e1</color><!--皇家蓝 -->
<color name="mediumseagreen">#3cb371</color><!--中海蓝 -->
<color name="limegreen">#32cd32</color><!--橙绿色 -->
<color name="darkslategray">#2f4f4f</color><!--暗瓦灰色 -->
<color name="darkslategrey">#2f4f4f</color><!--暗瓦灰色 -->
<color name="seagreen">#2e8b57</color><!--海绿色 -->
<color name="forestgreen">#228b22</color><!--森林绿 -->
<color name="lightseagreen">#20b2aa</color><!--亮海蓝色 -->
<color name="dodgerblue">#1e90ff</color><!--闪兰色 -->
<color name="midnightblue">#191970</color><!--中灰兰色 -->
<color name="cyan">#00ffff</color><!--青色 -->
<color name="springgreen">#00ff7f</color><!--春绿色 -->
<color name="mediumspringgreen">#00fa9a</color><!--中春绿色 -->
<color name="darkturquoise">#00ced1</color><!--暗宝石绿 -->
<color name="deepskyblue">#00bfff</color><!--深天蓝色 -->
<color name="darkcyan">#008b8b</color><!--暗青色 -->
<color name="darkgreen">#006400</color><!--暗绿色 -->
<color name="mediumblue">#0000cd</color><!--中兰色 -->
<color name="darkblue">#00008b</color><!--暗蓝色 -->
<color name="black">#000000</color><!--黑色 -->
</resources>

View File

@@ -11,7 +11,7 @@ android {
}
buildTypes {
zhanRuiRelease {
tuiXinDebug {
}
@@ -19,6 +19,10 @@ android {
}
zhanRuiRelease {
}
zhanRuiUserdebug {
}

View File

@@ -27,7 +27,7 @@ android {
buildTypes {
zhanRuiRelease {
tuiXinDebug {
}
@@ -35,6 +35,10 @@ android {
}
zhanRuiRelease {
}
zhanRuiUserdebug {
}