package com.aoleyun.sn.activity; import android.annotation.SuppressLint; import android.app.AlarmManager; import android.app.StatusBarManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.media.AudioManager; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.Handler; 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.activity.checknet.CheckNetActivity; import com.aoleyun.sn.activity.main.MainActivity; import com.aoleyun.sn.base.BaseApplication; import com.aoleyun.sn.comm.CommonConfig; import com.aoleyun.sn.comm.JGYActions; import com.aoleyun.sn.comm.PackageNames; import com.aoleyun.sn.network.NetInterfaceManager; import com.aoleyun.sn.service.LogcatService; import com.aoleyun.sn.utils.ApkUtils; import com.aoleyun.sn.utils.CmdUtil; import com.aoleyun.sn.utils.FlowInfo; import com.aoleyun.sn.utils.ForegroundAppUtil; import com.aoleyun.sn.utils.GetFlowUtil; import com.aoleyun.sn.utils.JGYUtils; import com.aoleyun.sn.utils.NetworkUtils; import com.aoleyun.sn.utils.SPUtils; import com.aoleyun.sn.utils.ServiceAliveUtils; import com.aoleyun.sn.utils.TimeUtils; import com.aoleyun.sn.utils.Utils; import com.blankj.utilcode.util.PathUtils; import com.google.gson.Gson; import com.tencent.mmkv.MMKV; import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX; import java.io.File; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; import io.reactivex.rxjava3.annotations.NonNull; import io.reactivex.rxjava3.core.Observable; import io.reactivex.rxjava3.core.ObservableEmitter; import io.reactivex.rxjava3.core.ObservableOnSubscribe; import io.reactivex.rxjava3.core.Observer; import io.reactivex.rxjava3.disposables.Disposable; import io.reactivex.rxjava3.functions.Consumer; import io.reactivex.rxjava3.schedulers.Schedulers; import okhttp3.internal.Util; 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)); finish(); // startActivity(new Intent(SplashActivity.this, CheckNetActivity.class)); }, 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) { JGYUtils.getModel(); Log.e(TAG, "getOperators: " + NetworkUtils.getOperators(this)); Log.e(TAG, "PublicIP: " + MMKV.defaultMMKV().decodeString(NetInterfaceManager.PublicIP, "")); NetInterfaceManager.GetWhois(); Log.e(TAG, "initView: " + NetworkUtils.getPhoneNumber(this)); FlowInfo flowInfo1 = GetFlowUtil.getAppFlowInfo(BuildConfig.APPLICATION_ID, this); Log.e(TAG, "initView: " + GetFlowUtil.byteToMB(flowInfo1.getUpKb())); Log.e(TAG, "initView: " + GetFlowUtil.byteToMB(flowInfo1.getDownKb())); FlowInfo flowInfo2 = GetFlowUtil.getAppFlowInfo("com.aoleyun.appstore", this); Log.e(TAG, "initView: " + GetFlowUtil.byteToMB(flowInfo2.getUpKb())); Log.e(TAG, "initView: " + GetFlowUtil.byteToMB(flowInfo2.getDownKb())); Log.e(TAG, "initView: " + Utils.getCurrentChargingCurrent()); Log.e(TAG, "initView: " + Utils.getCurrentChargingVoltage()); ApkUtils.showAllAPP(this); // JGYUtils.getInstance().cleanBackgroundMemory(); // NetInterfaceManager.getInstance().uploadLogFile(); 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: aole_hide_NavigationBar: " + Settings.System.getString(getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_NAVIGATION_BAR)); 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 aole_app_forbid = Settings.System.getString(getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID); Settings.System.putString(getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, aole_app_forbid + ",com.aoleyun.browser"); Log.e(TAG, "debugTest: aole_app_forbid:" + aole_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.e(TAG, "getCustomVersion: " + Utils.getCustomVersion()); Log.e(TAG, "getRomVersion: " + Utils.getRomVersion()); 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"); Log.e(TAG, "debugTest: SPUtils all " + new Gson().toJson(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]); //静音 AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) { int ringMax = audioManager.getStreamMinVolume(AudioManager.STREAM_RING); int musicMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_MUSIC); int voiceMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_VOICE_CALL); audioManager.setStreamVolume(AudioManager.STREAM_RING, ringMax, 0); audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, voiceMax, 0); audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, musicMax, 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); } }); } }