华为手机远程协助父母手机
手机怎样远程控制电脑和手机?有时候,我们可能会有这种需求——需要通过自己的手机远程操作控制电脑或手机,比方说,远程协助指导家里老人操作手机;再比如,疫情严重居家隔离时,需要远程操控公司电脑获取工作资料...
2024.11.20今天我们介绍一下MDM,看了下边的介绍你就知道如何控制自己的设备了,首先介绍一下MDM是什么的缩写,MDM是什么?MDM 是 (Mobile Device Management )的缩写,中文翻译过来就是移动设备管理。随着移动设备计算能力地增强,移动设备携带越来越方便,移动化办公已经成为一种潮流,一种趋势,企业对移动设备管理的需求越来越急切。MDM是企业IT 向移动互联网过渡的平台技术,帮助企业将IT管理能力从传统的 PC 延伸到移动设备甚至 移动应用APP 。随着时间的发展, MDM 厂商逐渐扩展出 MAM (Mobile Application Management)移动设备的应用程序管理,MEM(Mobile Email Management)移动设备的邮件管理和 MCM (Mobile Content Management)移动设备的内容管理等更多功能,但是MDM是这些管理的基础。
一、激活设备管理器
使用MDM功能要先激活设备管理器
代码如下:
/** * 激活设备管理权限 成功执行激活时,DeviceAdminReceiver中的 onEnabled 会响应 */ private void activeManage() { // 启动设备管理(隐式Intent) - 在AndroidManifest.xml中设定相应过滤器 Intent intents = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); // 权限列表 intents.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, componentName); // 描述(additional explanation) intents.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "------ 其他描述 ------"); startActivityForResult(intents, 0); }二、可以远程对设备做哪些操作
要先获得DevicePolicyManager实例才可以进行控制操作
DevicePolicyManager mDPM = (DevicePolicyManager) mContext .getSystemService(Context.DEVICE_POLICY_SERVICE);1、控制锁屏
mDPM.lockNow();2、控制摄像机的使用
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public int setCameraDisabled(boolean disableCamera) { if (isDeviceAdminActive()) { if (API_LEVEL < 14) { return ERROR_UNSUPPORTED; } mDPM.setCameraDisabled(mDeviceAdminSample, disableCamera); return 0; } else { // activateDeviceAdmin(); return ERROR_UNACTIVATED; } } public boolean getCameraDisabled() { if (isDeviceAdminActive()) { if (API_LEVEL < 14) { return false; } return mDPM.getCameraDisabled(mDeviceAdminSample); } else { // activateDeviceAdmin(); return false; } }3、控制密码
public int resetPasswd(String newPasswd) { if (isDeviceAdminActive()) { boolean succeed = mDPM.resetPassword(newPasswd, DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY); if (succeed) { return 0; } else { return ERROR_PASSWD_QUALITY; } } else { // 激活时间与用户的操作有关,所以不等待,直接返回操作失败 activateDeviceAdmin(); return ERROR_UNACTIVATED; } } public int setPasswdQuality(int value) { if (isDeviceAdminActive()) { if (API_LEVEL < 11) { return ERROR_UNSUPPORTED; } mDPM.setPasswordQuality(mDeviceAdminSample, value); return 0; } else { activateDeviceAdmin(); return ERROR_UNACTIVATED; } } public String getPasswordQuality() { if (isDeviceAdminActive()) { int quality = mDPM.getPasswordQuality(mDeviceAdminSample); switch (quality) { case DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK: return "图案"; case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC: return "数字"; case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC: return "字母"; case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC: return "数字和字母"; default: return "其它"; } } else { activateDeviceAdmin(); return "未知"; } } public int setPasswordMinimumLength(int value) { if (isDeviceAdminActive()) { mDPM.setPasswordMinimumLength(mDeviceAdminSample, value); return 0; } else { activateDeviceAdmin(); return ERROR_UNACTIVATED; } } /* * -1无法获取 */ public int getPasswordMinimumLength() { if (isDeviceAdminActive()) { return mDPM.getPasswordMinimumLength(mDeviceAdminSample); } else { activateDeviceAdmin(); return -1; } } // TODO: 2017-2-7 策略信息中并没有该项 @TargetApi(Build.VERSION_CODES.HONEYCOMB) public int setPasswordMinimumLetters(int value) { if (isDeviceAdminActive()) { if (API_LEVEL < 11) { return ERROR_UNSUPPORTED; } mDPM.setPasswordMinimumLetters(mDeviceAdminSample, value); return 0; } else { activateDeviceAdmin(); return ERROR_UNACTIVATED; } } @TargetApi(Build.VERSION_CODES.HONEYCOMB) public int setPasswordMinimumNumeric(int value) { if (isDeviceAdminActive()) { if (API_LEVEL < 11) { return ERROR_UNSUPPORTED; } mDPM.setPasswordMinimumNumeric(mDeviceAdminSample, value); return 0; } else { activateDeviceAdmin(); return ERROR_UNACTIVATED; } } @TargetApi(Build.VERSION_CODES.HONEYCOMB) public int setPasswordMinimumLowerCase(int value) { if (isDeviceAdminActive()) { if (API_LEVEL < 11) { return ERROR_UNSUPPORTED; } mDPM.setPasswordMinimumLowerCase(mDeviceAdminSample, value); return 0; } else { activateDeviceAdmin(); return ERROR_UNACTIVATED; } } @TargetApi(Build.VERSION_CODES.HONEYCOMB) public int setPasswordMinimumUpperCase(int value) { if (isDeviceAdminActive()) { if (API_LEVEL < 11) { return ERROR_UNSUPPORTED; } mDPM.setPasswordMinimumUpperCase(mDeviceAdminSample, value); return 0; } else { activateDeviceAdmin(); return ERROR_UNACTIVATED; } } @TargetApi(Build.VERSION_CODES.HONEYCOMB) public int setPasswordMinimumSymbols(int value) { if (isDeviceAdminActive()) { if (API_LEVEL < 11) { return ERROR_UNSUPPORTED; } mDPM.setPasswordMinimumSymbols(mDeviceAdminSample, value); return 0; } else { activateDeviceAdmin(); return ERROR_UNACTIVATED; } } /* * -1无法获取 */ public int getPasswordMinimumSymbols() { if (isDeviceAdminActive()) { return mDPM.getPasswordMinimumSymbols(mDeviceAdminSample); } else { activateDeviceAdmin(); return -1; } } @TargetApi(Build.VERSION_CODES.HONEYCOMB) public int setPasswordMinimumNonLetter(int value) { if (isDeviceAdminActive()) { if (API_LEVEL < 11) { return ERROR_UNSUPPORTED; } mDPM.setPasswordMinimumNonLetter(mDeviceAdminSample, value); return 0; } else { activateDeviceAdmin(); return ERROR_UNACTIVATED; } } @TargetApi(Build.VERSION_CODES.HONEYCOMB) public int setPasswordHistoryLength(int value) { if (isDeviceAdminActive()) { if (API_LEVEL < 11) { return ERROR_UNSUPPORTED; } mDPM.setPasswordHistoryLength(mDeviceAdminSample, value); return 0; } else { activateDeviceAdmin(); return ERROR_UNACTIVATED; } } /* * -1无法获取 */ public int getPasswordHistoryLength() { if (isDeviceAdminActive()) { return mDPM.getPasswordHistoryLength(mDeviceAdminSample); } else { activateDeviceAdmin(); return -1; } } @TargetApi(Build.VERSION_CODES.HONEYCOMB) public int setPasswordExpirationTimeout(int value) { if (isDeviceAdminActive()) { if (API_LEVEL < 11) { return ERROR_UNSUPPORTED; } mDPM.setPasswordExpirationTimeout(mDeviceAdminSample, value * MS_PER_DAY); return 0; } else { activateDeviceAdmin(); return ERROR_UNACTIVATED; } } /* * -1无法获取 */ public long getPasswordExpirationTimeout() { if (isDeviceAdminActive()) { long ret = mDPM.getPasswordExpirationTimeout(mDeviceAdminSample); return ret / MS_PER_DAY; } else { activateDeviceAdmin(); return -1; } }4、控制蓝牙
// 打开、关闭蓝牙 public int setBluetoothState(boolean enable) { BluetoothAdapter bluetoothAdapter = BluetoothAdapter .getDefaultAdapter(); if (bluetoothAdapter == null) { return ERROR_UNSUPPORTED; } if (enable) { bluetoothAdapter.enable(); } else { bluetoothAdapter.disable(); } return 0; }5、WIFI控制相关
public int getWifiState() { android.net.wifi.WifiManager wifiManager = (android.net.wifi.WifiManager) mContext .getSystemService(Context.WIFI_SERVICE); return wifiManager.getWifiState(); } // 打开、关闭wifi public void setWifiState(boolean enable) { android.net.wifi.WifiManager wifiManager = (android.net.wifi.WifiManager) mContext .getSystemService(Context.WIFI_SERVICE); wifiManager.setWifiEnabled(enable); } // 打开、关闭wifi public void disconnectWifi() { android.net.wifi.WifiManager wifiManager = (android.net.wifi.WifiManager) mContext .getSystemService(Context.WIFI_SERVICE); wifiManager.getConnectionInfo().getNetworkId(); WifiAdmin wifiAdmin = new WifiAdmin(mContext); wifiAdmin.disconnectWifi(wifiManager.getConnectionInfo().getNetworkId()); //wifiManager.disconnect(); }6、设置静音
// 设置静音 public int setMute(boolean setMute) { if (setMute) { AudioManager audioManager = (AudioManager) mContext .getSystemService(Context.AUDIO_SERVICE); audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0); // mute // music // stream audioManager.setStreamVolume(AudioManager.STREAM_RING, 0, 0); // mute // ring // stream if (Build.VERSION.SDK_INT >= 8) { audioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); audioManager.requestAudioFocus(null, AudioManager.STREAM_RING, AudioManager.AUDIOFOCUS_GAIN); } } else { AudioManager audioManager = (AudioManager) mContext .getSystemService(Context.AUDIO_SERVICE); int maxMusic = audioManager .getStreamMaxVolume(AudioManager.STREAM_MUSIC); audioManager .setStreamVolume(AudioManager.STREAM_MUSIC, maxMusic, 0); // mute // music // stream int maxRing = audioManager .getStreamMaxVolume(AudioManager.STREAM_RING); audioManager.setStreamVolume(AudioManager.STREAM_RING, maxRing, 0); // mute // ring // stream if (Build.VERSION.SDK_INT >= 8) { audioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); audioManager.requestAudioFocus(null, AudioManager.STREAM_RING, AudioManager.AUDIOFOCUS_GAIN); } } return 0; }7、恢复出厂设置
@TargetApi(Build.VERSION_CODES.GINGERBREAD) public int wipeData(boolean withExternalStorage) { if (isDeviceAdminActive()) { if (API_LEVEL >= 9) {// mDPM.wipeData(withExternalStorage ? DevicePolicyManager.WIPE_EXTERNAL_STORAGE// : 0); mDPM.wipeData(DevicePolicyManager.WIPE_EXTERNAL_STORAGE); } else { // WIPE_EXTERNAL_STORAGE is not supported under API level 9 mDPM.wipeData(0); } return 0; } else { activateDeviceAdmin(); return ERROR_UNACTIVATED; } }要想实现更多的管理服务得去不同厂家申请了,比如申请加入APP白名单的接口,wifi黑白名单的各种黑操作之类的。
有问题欢迎留言讨论
喜欢 就关注吧,欢迎投稿!
手机怎样远程控制电脑和手机?有时候,我们可能会有这种需求——需要通过自己的手机远程操作控制电脑或手机,比方说,远程协助指导家里老人操作手机;再比如,疫情严重居家隔离时,需要远程操控公司电脑获取工作资料...
2024.11.20以前,我们总能看到这样的说话或者传言,ios系统流畅、安全系数高,因为它是一个封闭性的移动操作系统,而安卓手机由于是开发性的移动操作系统,在安全上不如iPhone手机。那么,真的是这样吗? 其实,如...
2024.11.22iPhone手机和安卓手机到底应该怎么选择,咱们来聊一聊,有任何想法可以评论区交流。咱们先说苹果手机,苹果手机有一大优点,两大缺点。一大优点,就是咱们不得不否认,苹果的IOS系统相对于安卓来说确实流畅...
2024.11.19现在的智能手机已经普及大众,大部分人都有很多年使用手机的经验,在这期间也换过不少手机,而在智能手机中,大致分为两大阵营,一个是以安卓为操作系统的智能手机,通常国产手机都是安卓阵营,另一个是以iOS为操...
2024.11.19好多人都说有条件一定要买苹果,因为苹果的系统比安卓的好用。 说说我自己的感受吧!用苹果也有一段时间了,最大的弊端就是他的信号跟电池。动不动能让我崩溃,每天出门一定要检查我的苹果机有没有电。每次回老家...
2024.11.22