增加一些台电的管控测试

This commit is contained in:
2022-07-01 09:25:01 +08:00
parent 53738c7b15
commit 430b01abcc
2 changed files with 228 additions and 6 deletions

View File

@@ -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;
}
}

View File

@@ -19,7 +19,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
android:visibility="visible">
<Button
android:id="@+id/bt_usb"
@@ -74,7 +74,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="状态:" />
android:text="打开" />
<Button
android:id="@+id/bt_desktop_launcher"
@@ -105,6 +105,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:orientation="horizontal">
<Button
@@ -141,6 +142,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:orientation="horizontal">
<Button
@@ -178,7 +180,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
android:visibility="visible">
<Button
android:id="@+id/bt_navigation"
@@ -215,7 +217,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
android:visibility="visible">
<Button
android:id="@+id/bt_status"
@@ -356,6 +358,121 @@
android:text="音频off" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/bt_reset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:singleLine="true"
android:text="恢复出厂" />
<Button
android:id="@+id/bt_reset_statu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="状态:" />
<Button
android:id="@+id/bt_reset_on"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:singleLine="true"
android:text="on" />
<Button
android:id="@+id/bt_reset_off"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="off" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/bt_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:singleLine="true"
android:text="输入法" />
<EditText
android:id="@+id/bt_input_statu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="测试" />
<Button
android:id="@+id/bt_input_on"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:singleLine="true"
android:text="on" />
<Button
android:id="@+id/bt_input_off"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="off" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/bt_browser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:singleLine="true"
android:text="浏览器" />
<Button
android:id="@+id/bt_browser_statu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="打开" />
<Button
android:id="@+id/bt_browser_on"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:singleLine="true"
android:text="on" />
<Button
android:id="@+id/bt_browser_off"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="off" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>