295 lines
11 KiB
Java
295 lines
11 KiB
Java
package com.tt.ttutils.activity;
|
||
|
||
import android.content.Intent;
|
||
import android.net.Uri;
|
||
import android.os.Bundle;
|
||
import android.provider.Settings;
|
||
import android.util.Log;
|
||
import android.view.View;
|
||
import android.view.inputmethod.InputMethodInfo;
|
||
import android.view.inputmethod.InputMethodManager;
|
||
import android.widget.Button;
|
||
import android.widget.EditText;
|
||
|
||
import androidx.appcompat.app.AppCompatActivity;
|
||
|
||
import com.tt.ttutils.R;
|
||
|
||
import java.util.HashMap;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
|
||
import butterknife.BindView;
|
||
import butterknife.ButterKnife;
|
||
|
||
public class AoleyunTestActivity extends AppCompatActivity {
|
||
private static final String TAG = AoleyunTestActivity.class.getSimpleName();
|
||
|
||
@BindView(R.id.bt_usb)
|
||
Button bt_usb;
|
||
@BindView(R.id.bt_usb_statu)
|
||
Button bt_usb_statu;
|
||
@BindView(R.id.bt_usb_charge)
|
||
Button bt_usb_charge;
|
||
@BindView(R.id.bt_usb_mtp)
|
||
Button bt_usb_mtp;
|
||
@BindView(R.id.bt_usb_midi)
|
||
Button bt_usb_midi;
|
||
|
||
@BindView(R.id.bt_desktop)
|
||
Button bt_desktop;
|
||
@BindView(R.id.bt_desktop_statu)
|
||
Button bt_desktop_statu;
|
||
@BindView(R.id.bt_desktop_launcher)
|
||
Button bt_desktop_launcher;
|
||
@BindView(R.id.bt_desktop_dop2)
|
||
Button bt_desktop_dop2;
|
||
@BindView(R.id.bt_desktop_aoleyun)
|
||
Button bt_desktop_aoleyun;
|
||
|
||
@BindView(R.id.bt_sd)
|
||
Button bt_sd;
|
||
@BindView(R.id.bt_sd_statu)
|
||
Button bt_sd_statu;
|
||
@BindView(R.id.bt_sd_on)
|
||
Button bt_sd_on;
|
||
@BindView(R.id.bt_sd_off)
|
||
Button bt_sd_off;
|
||
|
||
@BindView(R.id.bt_developer)
|
||
Button bt_developer;
|
||
@BindView(R.id.bt_developer_statu)
|
||
Button bt_developer_statu;
|
||
@BindView(R.id.bt_developer_on)
|
||
Button bt_developer_on;
|
||
@BindView(R.id.bt_developer_off)
|
||
Button bt_developer_off;
|
||
|
||
@BindView(R.id.bt_navigation)
|
||
Button bt_navigation;
|
||
@BindView(R.id.bt_navigation_statu)
|
||
Button bt_navigation_statu;
|
||
@BindView(R.id.bt_navigation_on)
|
||
Button bt_navigation_on;
|
||
@BindView(R.id.bt_navigation_off)
|
||
Button bt_navigation_off;
|
||
|
||
@BindView(R.id.bt_status)
|
||
Button bt_status;
|
||
@BindView(R.id.bt_status_statu)
|
||
Button bt_status_statu;
|
||
@BindView(R.id.bt_status_on)
|
||
Button bt_status_on;
|
||
@BindView(R.id.bt_status_off)
|
||
Button bt_status_off;
|
||
|
||
@BindView(R.id.bt_hotspot)
|
||
Button bt_hotspot;
|
||
@BindView(R.id.bt_hotspot_statu)
|
||
Button bt_hotspot_statu;
|
||
@BindView(R.id.bt_hotspot_on)
|
||
Button bt_hotspot_on;
|
||
@BindView(R.id.bt_hotspot_off)
|
||
Button bt_hotspot_off;
|
||
|
||
@BindView(R.id.bt_bht)
|
||
Button bt_bht;
|
||
@BindView(R.id.bt_bht_statu)
|
||
Button bt_bht_statu;
|
||
@BindView(R.id.bt_bht_on)
|
||
Button bt_bht_on;
|
||
@BindView(R.id.bt_bht_off)
|
||
Button bt_bht_off;
|
||
|
||
@BindView(R.id.bt_bt_on)
|
||
Button bt_bt_on;
|
||
@BindView(R.id.bt_bt_off)
|
||
Button bt_bt_off;
|
||
@BindView(R.id.bt_bhtvideo_on)
|
||
Button bt_bhtvideo_on;
|
||
@BindView(R.id.bt_bhtvideo_off)
|
||
Button bt_bhtvideo_off;
|
||
|
||
@BindView(R.id.bt_reset)
|
||
Button bt_reset;
|
||
@BindView(R.id.bt_reset_statu)
|
||
Button bt_reset_statu;
|
||
@BindView(R.id.bt_reset_on)
|
||
Button bt_reset_on;
|
||
@BindView(R.id.bt_reset_off)
|
||
Button bt_reset_off;
|
||
|
||
@BindView(R.id.bt_input)
|
||
Button bt_input;
|
||
@BindView(R.id.bt_input_statu)
|
||
EditText bt_input_statu;
|
||
@BindView(R.id.bt_input_on)
|
||
Button bt_input_on;
|
||
@BindView(R.id.bt_input_off)
|
||
Button bt_input_off;
|
||
|
||
@BindView(R.id.bt_browser)
|
||
Button bt_browser;
|
||
@BindView(R.id.bt_browser_statu)
|
||
Button bt_browser_statu;
|
||
@BindView(R.id.bt_browser_on)
|
||
Button bt_browser_on;
|
||
@BindView(R.id.bt_browser_off)
|
||
Button bt_browser_off;
|
||
|
||
|
||
@Override
|
||
protected void onCreate(Bundle savedInstanceState) {
|
||
super.onCreate(savedInstanceState);
|
||
setContentView(R.layout.activity_aoleyun_test);
|
||
ButterKnife.bind(this);
|
||
init();
|
||
}
|
||
|
||
private void init() {
|
||
bt_usb_charge.setOnClickListener(view -> {
|
||
Intent usbIntent = new Intent("aole_action_usb_usb_charge").setPackage("com.android.settings");
|
||
sendBroadcast(usbIntent);
|
||
});
|
||
bt_usb_mtp.setOnClickListener(view -> {
|
||
Intent usbIntent = new Intent("aole_action_usb_usb_mtp").setPackage("com.android.settings");
|
||
sendBroadcast(usbIntent);
|
||
});
|
||
bt_usb_midi.setOnClickListener(view -> {
|
||
Intent usbIntent = new Intent("aole_action_usb_usb_midi").setPackage("com.android.settings");
|
||
sendBroadcast(usbIntent);
|
||
});
|
||
|
||
bt_desktop_statu.setOnClickListener(view -> gotoLauncher());
|
||
bt_desktop_launcher.setOnClickListener(view -> {
|
||
Intent intent = new Intent("setDefaultLauncher");
|
||
intent.putExtra("package", "com.android.launcher3");
|
||
intent.putExtra("className", "com.android.launcher3.Launcher");
|
||
intent.setPackage("com.android.settings");
|
||
sendBroadcast(intent);
|
||
});
|
||
bt_desktop_dop2.setOnClickListener(view -> {
|
||
Intent intent = new Intent("setDefaultLauncher");
|
||
intent.putExtra("package", "com.aoleyunos.dop2");
|
||
intent.putExtra("className", "com.aoleyunos.dop2.activity.main.MainActivity");
|
||
intent.setPackage("com.android.settings");
|
||
sendBroadcast(intent);
|
||
});
|
||
bt_desktop_aoleyun.setOnClickListener(view -> {
|
||
Intent intent = new Intent("setDefaultLauncher");
|
||
intent.putExtra("package", "com.uiui.os");
|
||
intent.putExtra("className", "com.uiui.os.Launcher");
|
||
intent.setPackage("com.android.settings");
|
||
sendBroadcast(intent);
|
||
});
|
||
|
||
bt_sd_on.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_sdcard_forbid_on", 0));
|
||
bt_sd_off.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_sdcard_forbid_on", 1));
|
||
|
||
bt_developer_on.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_Developeroptions", 0));
|
||
bt_developer_off.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_Developeroptions", 1));
|
||
|
||
bt_navigation_on.setOnClickListener(view -> {
|
||
Intent navIntent = new Intent("aole_show_NavigationBar").setPackage("com.android.systemui");
|
||
sendBroadcast(navIntent);
|
||
});
|
||
bt_navigation_off.setOnClickListener(view -> {
|
||
Intent navIntent = new Intent("aole_hide_NavigationBar").setPackage("com.android.systemui");
|
||
sendBroadcast(navIntent);
|
||
});
|
||
|
||
bt_status_on.setOnClickListener(view -> {
|
||
Intent navIntent = new Intent("aole_show_statusBar").setPackage("com.android.systemui");
|
||
sendBroadcast(navIntent);
|
||
});
|
||
bt_status_off.setOnClickListener(view -> {
|
||
Intent navIntent = new Intent("aole_hide_statusBar").setPackage("com.android.systemui");
|
||
sendBroadcast(navIntent);
|
||
});
|
||
|
||
bt_hotspot_on.setOnClickListener(view -> {
|
||
Settings.System.putInt(getContentResolver(), "aole_hotspot_forbid_on", 0);
|
||
});
|
||
bt_hotspot_off.setOnClickListener(view -> {
|
||
Settings.System.putInt(getContentResolver(), "aole_hotspot_forbid_on", 1);
|
||
Intent intent = new Intent("aole_hotspot_close");
|
||
intent.setPackage("com.android.settings");
|
||
sendStickyBroadcast(intent);
|
||
});
|
||
|
||
bt_bht_on.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_bht_forbid_on", 0));
|
||
bt_bht_off.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_bht_forbid_on", 1));
|
||
bt_bt_on.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_bt_forbid_on", 0));
|
||
bt_bt_off.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_bt_forbid_on", 1));
|
||
bt_bhtvideo_on.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_bhtvideo_forbid_on", 0));
|
||
bt_bhtvideo_off.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_bhtvideo_forbid_on", 1));
|
||
|
||
bt_reset_on.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_restore_forbid_on", 0));
|
||
bt_reset_off.setOnClickListener(view -> Settings.System.putInt(getContentResolver(), "aole_restore_forbid_on", 1));
|
||
|
||
bt_input.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View view) {
|
||
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
|
||
List<InputMethodInfo> InputMethods = imeManager.getEnabledInputMethodList();
|
||
Log.e(TAG, "onClick: " + InputMethods);
|
||
}
|
||
});
|
||
bt_input_on.setOnClickListener(view -> {
|
||
Intent intent = new Intent("setDefaultInputMethod");
|
||
intent.putExtra("package", getInputMethodId("com.baidu.input"));
|
||
intent.setPackage("com.android.settings");
|
||
sendBroadcast(intent);
|
||
});
|
||
bt_input_off.setOnClickListener(view -> {
|
||
Intent intent = new Intent("setDefaultInputMethod");
|
||
intent.putExtra("package", getInputMethodId("com.sohu.inputmethod.sogou"));
|
||
intent.setPackage("com.android.settings");
|
||
sendBroadcast(intent);
|
||
});
|
||
|
||
|
||
bt_browser_statu.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View view) {
|
||
Intent intent= new Intent(); intent.setAction("android.intent.action.VIEW");
|
||
Uri content_url = Uri.parse("https://www.baidu.com/");
|
||
intent.setData(content_url);
|
||
startActivity(intent);
|
||
}
|
||
});
|
||
bt_browser_on.setOnClickListener(view -> {
|
||
|
||
Intent intent = new Intent("setDefaultBrowser");
|
||
intent.putExtra("package", ("com.quark.browser"));
|
||
intent.setPackage("com.android.settings");
|
||
sendBroadcast(intent);
|
||
});
|
||
bt_browser_off.setOnClickListener(view -> {
|
||
Intent intent = new Intent("setDefaultBrowser");
|
||
intent.putExtra("package", ("com.android.chrome"));
|
||
intent.setPackage("com.android.settings");
|
||
sendBroadcast(intent);
|
||
});
|
||
}
|
||
|
||
private void gotoLauncher() {
|
||
Intent i = new Intent(Intent.ACTION_MAIN);
|
||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //android123提示如果是服务里调用,必须加入new task标识
|
||
i.addCategory(Intent.CATEGORY_HOME);
|
||
startActivity(i);
|
||
}
|
||
|
||
private String getInputMethodId(String pkg) {
|
||
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
|
||
List<InputMethodInfo> InputMethods = imeManager.getInputMethodList();
|
||
Map<String, String> inputMap = new HashMap<>();
|
||
for (InputMethodInfo inputMethodInfo : InputMethods) {
|
||
inputMap.put(inputMethodInfo.getPackageName(), inputMethodInfo.getId());
|
||
}
|
||
String id = inputMap.get(pkg);
|
||
Log.e(TAG, "getInputMethodId: " + id);
|
||
return id;
|
||
}
|
||
}
|