Untitled
unknown
java
2 years ago
3.3 kB
9
Indexable
package com.example.knoxdeprecatedtester; import android.os.Bundle; import android.widget.CompoundButton; import android.widget.Switch; import androidx.appcompat.app.AppCompatActivity; import com.samsung.android.knox.EnterpriseDeviceManager; import com.samsung.android.knox.restriction.RestrictionPolicy; public class MainActivity extends AppCompatActivity { private Switch switchCamera, switchMic, switchVideoRec; EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(this); RestrictionPolicy restrictionPolicy = edm.getRestrictionPolicy(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); switchCamera = findViewById(R.id.switchCamera); switchMic = findViewById(R.id.switchMic); switchVideoRec = findViewById(R.id.switchVideo); switchCamera.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { try { // Disable camera. Other applications that use the camera cannot // use it. boolean result = restrictionPolicy.setCameraState(false); if (true == result) { // Camera is disabled and cannot be enabled by user. System.out.println("Set Camera State Switched:" + isChecked); } } catch (SecurityException e) { System.out.println("Set Camera State: something went wrong..."); } } }); switchMic.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { try { // Disable microphone. Other functionalities like voice recording cannot // be used boolean result = restrictionPolicy.setMicrophoneState(false); if (true == result) { // Microphone is disabled and user cannot use microphone-related // functions. System.out.println("Set Mic State Switched:" + isChecked); } } catch (SecurityException e) { System.out.println("Set Mic State Switched: something went wrong..."); } } }); switchVideoRec.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { try { if (restrictionPolicy.allowVideoRecord(isChecked)) { System.out.println("Set Video Rec Switched:" + isChecked); } else { System.out.println("Set Video Rec Switched: FAILED"); } } catch (SecurityException e) { System.out.println("Set Video Rec Switched: something went wrong..."); } } }); } }
Editor is loading...