增加一些台电的管控测试
This commit is contained in:
@@ -1,18 +1,30 @@
|
||||
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)
|
||||
@@ -98,6 +110,33 @@ public class AoleyunTestActivity extends AppCompatActivity {
|
||||
@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) {
|
||||
@@ -121,6 +160,7 @@ public class AoleyunTestActivity extends AppCompatActivity {
|
||||
sendBroadcast(usbIntent);
|
||||
});
|
||||
|
||||
bt_desktop_statu.setOnClickListener(view -> gotoLauncher());
|
||||
bt_desktop_launcher.setOnClickListener(view -> {
|
||||
Intent intent = new Intent("setDefaultLauncher");
|
||||
intent.putExtra("package", "com.android.launcher3");
|
||||
@@ -137,8 +177,8 @@ public class AoleyunTestActivity extends AppCompatActivity {
|
||||
});
|
||||
bt_desktop_aoleyun.setOnClickListener(view -> {
|
||||
Intent intent = new Intent("setDefaultLauncher");
|
||||
intent.putExtra("package", "com.aoleyunos.os");
|
||||
intent.putExtra("className", "com.aoleyunos.os.Launcher");
|
||||
intent.putExtra("package", "com.uiui.os");
|
||||
intent.putExtra("className", "com.uiui.os.Launcher");
|
||||
intent.setPackage("com.android.settings");
|
||||
sendBroadcast(intent);
|
||||
});
|
||||
@@ -184,6 +224,71 @@ public class AoleyunTestActivity extends AppCompatActivity {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user