233 lines
9.8 KiB
Java
233 lines
9.8 KiB
Java
package com.aoleyun.sn.activity;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.app.StatusBarManager;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.pm.PackageManager;
|
|
import android.graphics.Bitmap;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.os.Environment;
|
|
import android.os.Handler;
|
|
import android.os.PowerManager;
|
|
import android.provider.Settings;
|
|
import android.util.Log;
|
|
import android.view.View;
|
|
import android.webkit.WebView;
|
|
import android.webkit.WebViewClient;
|
|
import android.widget.Button;
|
|
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
import androidx.core.content.ContextCompat;
|
|
|
|
import com.aoleyun.sn.BuildConfig;
|
|
import com.aoleyun.sn.R;
|
|
import com.aoleyun.sn.action.JGYActions;
|
|
import com.aoleyun.sn.base.BaseApplication;
|
|
import com.aoleyun.sn.comm.PackageNames;
|
|
import com.aoleyun.sn.service.LogcatService;
|
|
import com.aoleyun.sn.utils.JGYUtils;
|
|
import com.aoleyun.sn.utils.SPUtils;
|
|
import com.aoleyun.sn.utils.ServiceAliveUtils;
|
|
import com.aoleyun.sn.utils.Utils;
|
|
import com.blankj.utilcode.util.PathUtils;
|
|
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
|
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.nio.file.Paths;
|
|
|
|
import cn.jpush.android.api.JPushInterface;
|
|
|
|
|
|
public class SplashActivity extends AppCompatActivity {
|
|
private static String TAG = SplashActivity.class.getSimpleName();
|
|
private Button bt_log;
|
|
private Button bt_stop;
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
setBar();
|
|
setContentView(R.layout.activity_home);
|
|
initView();
|
|
debugTest();
|
|
new Handler().postDelayed(() -> {
|
|
startActivity(new Intent(SplashActivity.this, MainActivity.class));
|
|
// startActivity(new Intent(HomeActivity.this, CheckNetActivity.class));
|
|
finish();
|
|
}, 2000);
|
|
}
|
|
|
|
private void setBar() {
|
|
UltimateBarX.statusBar(this)
|
|
.transparent()
|
|
.colorRes(R.color.colorPrimaryDark)
|
|
.light(true)
|
|
.apply();
|
|
UltimateBarX.navigationBar(this)
|
|
.transparent()
|
|
.colorRes(R.color.colorPrimaryDark)
|
|
.light(true)
|
|
.apply();
|
|
}
|
|
|
|
private void initView() {
|
|
if (BuildConfig.DEBUG) {
|
|
bt_log = findViewById(R.id.bt_log);
|
|
bt_log.setVisibility(View.VISIBLE);
|
|
bt_log.setOnClickListener(view -> {
|
|
if (!ServiceAliveUtils.isServiceAlive(SplashActivity.this, LogcatService.class.getName())) {
|
|
startService(new Intent(SplashActivity.this, LogcatService.class));
|
|
}
|
|
Intent intent = new Intent(LogcatService.LOGCAT_START_ACTION);
|
|
sendBroadcast(intent);
|
|
});
|
|
bt_stop = findViewById(R.id.bt_stop);
|
|
bt_stop.setVisibility(View.VISIBLE);
|
|
bt_stop.setOnClickListener(view -> {
|
|
if (!ServiceAliveUtils.isServiceAlive(SplashActivity.this, LogcatService.class.getName())) {
|
|
startService(new Intent(SplashActivity.this, LogcatService.class));
|
|
}
|
|
Intent intent = new Intent(LogcatService.LOGCAT_STOP_ACTION);
|
|
sendBroadcast(intent);
|
|
});
|
|
}
|
|
}
|
|
|
|
private void debugTest() {
|
|
// if (!BuildConfig.DEBUG) return;
|
|
// File file = new File("/system/media/bootanimation2.zip");
|
|
// if (file.exists()){
|
|
// Log.e(TAG, "debugTest: "+"file.exists" );
|
|
// }else {
|
|
// Log.e(TAG, "debugTest: "+"file not exists" );
|
|
// }
|
|
// if (file.delete()){
|
|
// Log.e(TAG, "debugTest: "+"file.delete" );
|
|
// }else {
|
|
// Log.e(TAG, "debugTest: "+"file delete failed" );
|
|
// }
|
|
|
|
// Utils.getHardware(this);
|
|
// setWebView();
|
|
// hideStatusBar();
|
|
// boolean qch_force_app = Settings.System.putString(getContentResolver(), "qch_launcher_icon_app", "");
|
|
Log.i(TAG, "DebugTest: qch_launcher_icon_app:" + Settings.System.getString(getContentResolver(), "qch_launcher_icon_app"));
|
|
Log.i(TAG, "DebugTest: qch_hide_NavigationBar: " + Settings.System.getString(getContentResolver(), "qch_hide_NavigationBar"));
|
|
String only_jgy_shortcut_list = Settings.System.getString(getContentResolver(), JGYActions.ACTION_JGY_SHORTCUTLIST);
|
|
Log.i(TAG, "debugTest: only_jgy_shortcut_list:" + only_jgy_shortcut_list);
|
|
String qch_app_forbid = Settings.System.getString(getContentResolver(), "qch_app_forbid");
|
|
Settings.System.putString(getContentResolver(), "qch_app_forbid", qch_app_forbid + ",com.aoleyun.browser");
|
|
Log.e(TAG, "debugTest: qch_app_forbid:" + qch_app_forbid);
|
|
Log.i(TAG, "debugTest: ip = " + JGYUtils.getInstance().getIPAddress());
|
|
Log.i(TAG, "debugTest: getPackage = " + Utils.getPackage());
|
|
Log.i(TAG, "debugTest: getMacAddress = " + Utils.getAndroid10MAC(this));
|
|
// Log.i(TAG, "debugTest: iptables = " + CmdUtil.execute("iptables -L -n" ).toString());
|
|
|
|
Log.i(TAG, "debugTest: " + Utils.getAndroid10MAC(this));
|
|
Log.i(TAG, "debugTest: " + JPushInterface.getRegistrationID(this));
|
|
Log.i(TAG, "debugTest: " + Utils.getCustomVersion());
|
|
Log.i(TAG, "debugTest: " + BuildConfig.VERSION_NAME);
|
|
Log.i(TAG, "debugTest: " + Utils.getAPPVersionName(PackageNames.APPSTORE, this));
|
|
Log.i(TAG, "debugTest: " + Utils.getAndroid7MAC());
|
|
Log.i(TAG, "debugTest: launcher3 " + JGYUtils.getInstance().getStartClassName("com.android.launcher3"));
|
|
// try {
|
|
// new CacheUtils().cleanApplicationUserData(HomeActivity.this, "com.android.launcher3");
|
|
// } catch (Exception e) {
|
|
// e.printStackTrace();
|
|
// Log.e(TAG, "DebugTest: " + e.getMessage());
|
|
// }
|
|
// ActivityManager mAm = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
|
// mAm.killBackgroundProcesses("com.android.documentsui");
|
|
BaseApplication.cleanJpushAlias();
|
|
BaseApplication.cleanJpushTag();
|
|
Log.e(TAG, "debugTest: SPUtils all " + SPUtils.getAll(this));
|
|
try {
|
|
PackageManager packageManager = getPackageManager();
|
|
packageManager.setApplicationEnabledSetting(PackageNames.OLD_DEVICE_INFO, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
|
packageManager.setApplicationEnabledSetting(PackageNames.OLD_APPSTORE, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
|
} catch (Exception e) {
|
|
Log.e(TAG, "debugTest: " + e.getMessage());
|
|
}
|
|
|
|
Utils.getPublicIP(this);
|
|
Utils.obtainWifiInfo(this);
|
|
Log.e("getLocalIP", "set: " + Utils.getIPAddress(this));
|
|
// WiFiUtils.getInstance().connectWifiPws("七彩宏云","colorfulyun.com");
|
|
// WiFiUtils.getInstance().connectWifiPws("fht","colorfulyun.com");
|
|
// WiFiUtils.getInstance().connectWifiPws("tt","colorfulyun.com");
|
|
// JGYUtils.getInstance().shutdown();
|
|
Log.e(TAG, "debugTest: " + PathUtils.getExternalDownloadsPath());
|
|
Log.e(TAG, "debugTest: " + ContextCompat.getExternalFilesDirs(this, Environment.DIRECTORY_DOWNLOADS)[0]);
|
|
}
|
|
|
|
@SuppressLint("NewApi")
|
|
private void hideStatusBar() {
|
|
StatusBarManager mStatusBarManager = (StatusBarManager) getApplicationContext().getSystemService(Context.STATUS_BAR_SERVICE);
|
|
mStatusBarManager.disable(StatusBarManager.DISABLE_HOME);//隐藏home键
|
|
mStatusBarManager.disable(StatusBarManager.DISABLE_BACK);//隐藏返回键
|
|
mStatusBarManager.disable(StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME);
|
|
mStatusBarManager.disable(StatusBarManager.DISABLE_BACK | StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME);
|
|
mStatusBarManager.disable(StatusBarManager.DISABLE_RECENT);//隐藏recent键
|
|
mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);//显示隐藏的虚拟按键
|
|
}
|
|
|
|
|
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
|
private void bootanimotion() {
|
|
File file = new File(Environment.getExternalStorageDirectory() + File.separator + "bootanimation.zip");
|
|
String path0 = "/data/local/qchmedia/bootanimation.zip";
|
|
if (file.exists()) {
|
|
File file1 = new File(path0);
|
|
if (!file1.exists()) {
|
|
file.mkdirs();
|
|
try {
|
|
file.createNewFile();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
Log.e("bootanimation", e.getMessage());
|
|
}
|
|
}
|
|
Log.e("bootanimation", "SD卡路径存在");
|
|
try {
|
|
Path path = Paths.get(file.getAbsolutePath());
|
|
Files.copy(path, new FileOutputStream(path0));
|
|
} catch (Exception e) {
|
|
Log.e("bootanimation", e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
|
|
static final String url = "www.baidu.com";
|
|
|
|
private void setWebView() {
|
|
WebView webView = new WebView(this);
|
|
webView.loadUrl(url);
|
|
webView.getSettings().setJavaScriptEnabled(true);
|
|
webView.setWebViewClient(new WebViewClient() {
|
|
//页面加载开始
|
|
@Override
|
|
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
super.onPageStarted(view, url, favicon);
|
|
}
|
|
|
|
//页面加载完成
|
|
@Override
|
|
public void onPageFinished(WebView view, String url) {
|
|
super.onPageFinished(view, url);
|
|
String realUrl = url;
|
|
//这个realUrl即为重定向之后的地址
|
|
Log.e(TAG, "onPageFinished: " + realUrl);
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
}
|