为什么允许安装未知来源 sim卡应用还要sim卡?

OPPO R9s如何允许安装未知来源应用_手机实用技巧_动态网站制作指南
OPPO R9s如何允许安装未知来源应用
来源:人气:1826
&  1)打开手机【设置】,进入设置菜单后点击【其他设置】。(如下图)
  2)在其他设置里面点击【安全与隐私】选项,打开后把【允许安装未知来源应用】的开关打开,就可以解除安装限制了。(如下图)
优质网站模板每天进步一点点
Android系统设置settings应用学习(一)--允许未知来源应用安装
settings,是Android系统应用--设置的源代码,包名称为:com.android.settings
安全设置代码:SecuritySettings.java
* Copyright (C) 2007 The Android Open Source Project
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
package com.android.
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import android.app.A
import android.app.AlertD
import android.app.admin.DevicePolicyM
import android.content.C
import android.content.DialogI
import android.content.I
import android.os.B
import android.os.V
import android.preference.CheckBoxP
import android.preference.ListP
import android.preference.P
import android.preference.Preference.OnPreferenceChangeL
import android.preference.PreferenceG
import android.preference.PreferenceS
import android.provider.S
import android.provider.Telephony.SIMI
import android.security.KeyS
import android.telephony.TelephonyM
import android.util.L
import com.android.internal.telephony.P
import com.android.internal.widget.LockPatternU
import com.android.settings.gemini.SimListE
import com.mediatek.xlog.X
import java.util.ArrayL
import java.util.L
import com.mediatek.featureoption.FeatureO
* Gesture lock pattern settings.
public class SecuritySettings extends SettingsPreferenceFragment
implements OnPreferenceChangeListener, DialogInterface.OnClickListener {
private static final String TAG = "SecuritySettings";
// Lock Settings
private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change";
private static final String KEY_BIOMETRIC_WEAK_IMPROVE_MATCHING =
"biometric_weak_improve_matching";
private static final String KEY_LOCK_ENABLED = "lockenabled";
private static final String KEY_VISIBLE_PATTERN = "visiblepattern";
private static final String KEY_TACTILE_FEEDBACK_ENABLED = "unlock_tactile_feedback";
private static final String KEY_SECURITY_CATEGORY = "security_category";
private static final String KEY_LOCK_AFTER_TIMEOUT = "lock_after_timeout";
private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
private static final int CONFIRM_EXISTING_FOR_BIOMETRIC_IMPROVE_REQUEST = 124;
// Misc Settings
private static final String KEY_SIM_LOCK = "sim_lock";
private static final String KEY_SIM_LOCK_PREF = "sim_lock_pref";
private static final String KEY_SHOW_PASSWORD = "show_password";
private static final String KEY_RESET_CREDENTIALS = "reset_credentials";
private static final String KEY_TOGGLE_INSTALL_APPLICATIONS = "toggle_install_applications";
DevicePolicyManager mDPM;
private ChooseLockSettingsHelper mChooseLockSettingsH
private LockPatternUtils mLockPatternU
private ListPreference mLockA
private CheckBoxPreference mVisibleP
private CheckBoxPreference mTactileF
private CheckBoxPreference mShowP
private Preference mResetC
private CheckBoxPreference mToggleAppI
private DialogInterface mWarnInstallA
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLockPatternUtils = new LockPatternUtils(getActivity());
mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(getActivity());
private PreferenceScreen createPreferenceHierarchy() {
PreferenceScreen root = getPreferenceScreen();
if (root != null) {
root.removeAll();
addPreferencesFromResource(R.xml.security_settings);
root = getPreferenceScreen();
// Add options for lock/unlock screen
int resid = 0;
if (!mLockPatternUtils.isSecure()) {
if (mLockPatternUtils.isLockScreenDisabled()) {
resid = R.xml.security_settings_
resid = R.xml.security_settings_
} else if (mLockPatternUtils.usingBiometricWeak() &&
mLockPatternUtils.isBiometricWeakInstalled()) {
resid = R.xml.security_settings_biometric_
switch (mLockPatternUtils.getKeyguardStoredPasswordQuality()) {
case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
resid = R.xml.security_settings_
case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
resid = R.xml.security_settings_
case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
resid = R.xml.security_settings_
addPreferencesFromResource(resid);
// Add options for device encryption
Xlog.d(TAG,"FeatureOption.MTK_EMMC_SUPPORT="+FeatureOption.MTK_EMMC_SUPPORT);
if(FeatureOption.MTK_EMMC_SUPPORT) {
// Add options for device encryption
DevicePolicyManager dpm =
(DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
switch (dpm.getStorageEncryptionStatus()) {
case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE:
// The device is currently encrypted.
addPreferencesFromResource(R.xml.security_settings_encrypted);
case DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE:
// This device supports encryption but isn't encrypted.
addPreferencesFromResource(R.xml.security_settings_unencrypted);
// lock after preference
mLockAfter = (ListPreference) root.findPreference(KEY_LOCK_AFTER_TIMEOUT);
if (mLockAfter != null) {
setupLockAfterPreference();
updateLockAfterPreferenceSummary();
// visible pattern
mVisiblePattern = (CheckBoxPreference) root.findPreference(KEY_VISIBLE_PATTERN);
// don't display visible pattern if biometric and backup is not pattern
if (resid == R.xml.security_settings_biometric_weak &&
mLockPatternUtils.getKeyguardStoredPasswordQuality() !=
DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
PreferenceGroup securityCategory = (PreferenceGroup)
root.findPreference(KEY_SECURITY_CATEGORY);
if (securityCategory != null && mVisiblePattern != null) {
securityCategory.removePreference(root.findPreference(KEY_VISIBLE_PATTERN));
// tactile feedback. Should be common to all unlock preference screens.
mTactileFeedback = (CheckBoxPreference) root.findPreference(KEY_TACTILE_FEEDBACK_ENABLED);
if (!((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).hasVibrator()) {
PreferenceGroup securityCategory = (PreferenceGroup)
root.findPreference(KEY_SECURITY_CATEGORY);
if (securityCategory != null && mTactileFeedback != null) {
securityCategory.removePreference(mTactileFeedback);
// Append the rest of the settings
addPreferencesFromResource(R.xml.security_settings_misc);
// Do not display SIM lock for CDMA phone
TelephonyManager tm = TelephonyManager.getDefault();
if ((TelephonyManager.PHONE_TYPE_CDMA == tm.getCurrentPhoneType()) &&
(tm.getLteOnCdmaMode() != Phone.LTE_ON_CDMA_TRUE)) {
root.removePreference(root.findPreference(KEY_SIM_LOCK));
//Preference simLockPreferences = root.findPreference(KEY_SIM_LOCK);
Preference simLockPref = root.findPreference(KEY_SIM_LOCK_PREF);
List&SIMInfo& simList = SIMInfo.getInsertedSIMList(getActivity());
int nSimNum = simList.size();
if (nSimNum == 0) {
Xlog.d(TAG,"No sim found");
simLockPref.setEnabled(false);
}else if (nSimNum == 1) {
SIMInfo simInfo = simList.get(0);
Xlog.d(TAG,"Only one Sim inserted");
if (simInfo != null) {
Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.IccLockSettings");
int slot = SIMInfo.getSlotById(getActivity(), simInfo.mSimId);
intent.putExtra("slotid", simInfo.mSlot);
simLockPref.setIntent(intent);
} else if (nSimNum&1) {
Xlog.d(TAG,"two Sims inserted");
simLockPref.getExtras().putInt("type", SimListEntrance.PIN_SETTING_INDEX);
simLockPref.setFragment(SimListEntrance.class.getName());
// Show password
mShowPassword = (CheckBoxPreference) root.findPreference(KEY_SHOW_PASSWORD);
// Credential storage
mResetCredentials = root.findPreference(KEY_RESET_CREDENTIALS);
mToggleAppInstallation = (CheckBoxPreference) findPreference(
KEY_TOGGLE_INSTALL_APPLICATIONS);
mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
private boolean isNonMarketAppsAllowed() {
return Settings.Secure.getInt(getContentResolver(),
Settings.Secure.INSTALL_NON_MARKET_APPS, 0) & 0;
private void setNonMarketAppsAllowed(boolean enabled) {
// Change the system setting
Settings.Secure.putInt(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS,
enabled ? 1 : 0);
private void warnAppInstallation() {
// TODO: DialogFragment?
mWarnInstallApps = new AlertDialog.Builder(getActivity()).setTitle(
getResources().getString(R.string.error_title))
.setIcon(com.android.internal.R.drawable.ic_dialog_alert)
.setMessage(getResources().getString(R.string.install_all_warning))
.setPositiveButton(android.R.string.yes, this)
.setNegativeButton(android.R.string.no, null)
public void onClick(DialogInterface dialog, int which) {
if (dialog == mWarnInstallApps && which == DialogInterface.BUTTON_POSITIVE) {
setNonMarketAppsAllowed(true);
mToggleAppInstallation.setChecked(true);
public void onDestroy() {
super.onDestroy();
if (mWarnInstallApps != null) {
mWarnInstallApps.dismiss();
private void setupLockAfterPreference() {
// Compatible with pre-Froyo
long currentTimeout = Settings.Secure.getLong(getContentResolver(),
Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, 5000);
mLockAfter.setValue(String.valueOf(currentTimeout));
mLockAfter.setOnPreferenceChangeListener(this);
final long adminTimeout = (mDPM != null ? mDPM.getMaximumTimeToLock(null) : 0);
final long displayTimeout = Math.max(0,
Settings.System.getInt(getContentResolver(), SCREEN_OFF_TIMEOUT, 0));
if (adminTimeout & 0) {
// This setting is a slave to display timeout when a device policy is enforced.
// As such, maxLockTimeout = adminTimeout - displayTimeout.
// If there isn't enough time, shows "immediately" setting.
disableUnusableTimeouts(Math.max(0, adminTimeout - displayTimeout));
private void updateLockAfterPreferenceSummary() {
// Update summary message with current value
long currentTimeout = Settings.Secure.getLong(getContentResolver(),
Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, 5000);
final CharSequence[] entries = mLockAfter.getEntries();
final CharSequence[] values = mLockAfter.getEntryValues();
int best = 0;
for (int i = 0; i & values. i++) {
long timeout = Long.valueOf(values[i].toString());
if (currentTimeout &= timeout) {
mLockAfter.setSummary(getString(R.string.lock_after_timeout_summary, entries[best]));
private void disableUnusableTimeouts(long maxTimeout) {
final CharSequence[] entries = mLockAfter.getEntries();
final CharSequence[] values = mLockAfter.getEntryValues();
ArrayList&CharSequence& revisedEntries = new ArrayList&CharSequence&();
ArrayList&CharSequence& revisedValues = new ArrayList&CharSequence&();
for (int i = 0; i & values. i++) {
long timeout = Long.valueOf(values[i].toString());
if (timeout &= maxTimeout) {
revisedEntries.add(entries[i]);
revisedValues.add(values[i]);
if (revisedEntries.size() != entries.length || revisedValues.size() != values.length) {
mLockAfter.setEntries(
revisedEntries.toArray(new CharSequence[revisedEntries.size()]));
mLockAfter.setEntryValues(
revisedValues.toArray(new CharSequence[revisedValues.size()]));
final int userPreference = Integer.valueOf(mLockAfter.getValue());
if (userPreference &= maxTimeout) {
mLockAfter.setValue(String.valueOf(userPreference));
// There will be no highlighted selection since nothing in the list matches
// maxTimeout. The user can still select anything less than maxTimeout.
// TODO: maybe append maxTimeout to the list and mark selected.
mLockAfter.setEnabled(revisedEntries.size() & 0);
public void onResume() {
super.onResume();
// Make sure we reload the preference hierarchy since some of these settings
// depend on others...
createPreferenceHierarchy();
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
if (mVisiblePattern != null) {
mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled());
if (mTactileFeedback != null) {
mTactileFeedback.setChecked(lockPatternUtils.isTactileFeedbackEnabled());
mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),
Settings.System.TEXT_SHOW_PASSWORD, 1) != 0);
KeyStore.State state = KeyStore.getInstance().state();
mResetCredentials.setEnabled(state != KeyStore.State.UNINITIALIZED);
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
final String key = preference.getKey();
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
if (KEY_UNLOCK_SET_OR_CHANGE.equals(key)) {
startFragment(this, "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment",
SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
} else if (KEY_BIOMETRIC_WEAK_IMPROVE_MATCHING.equals(key)) {
ChooseLockSettingsHelper helper =
new ChooseLockSettingsHelper(this.getActivity(), this);
if (!helper.launchConfirmationActivity(
CONFIRM_EXISTING_FOR_BIOMETRIC_IMPROVE_REQUEST, null, null)) {
startBiometricWeakImprove(); // no password set, so no need to confirm
} else if (KEY_LOCK_ENABLED.equals(key)) {
lockPatternUtils.setLockPatternEnabled(isToggled(preference));
} else if (KEY_VISIBLE_PATTERN.equals(key)) {
lockPatternUtils.setVisiblePatternEnabled(isToggled(preference));
} else if (KEY_TACTILE_FEEDBACK_ENABLED.equals(key)) {
lockPatternUtils.setTactileFeedbackEnabled(isToggled(preference));
} else if (preference == mShowPassword) {
Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD,
mShowPassword.isChecked() ? 1 : 0);
} else if (preference == mToggleAppInstallation) {
if (mToggleAppInstallation.isChecked()) {
mToggleAppInstallation.setChecked(false);
warnAppInstallation();
setNonMarketAppsAllowed(false);
// If we didn't handle it, let preferences handle it.
return super.onPreferenceTreeClick(preferenceScreen, preference);
private boolean isToggled(Preference pref) {
return ((CheckBoxPreference) pref).isChecked();
* see confirmPatternThenDisableAndClear
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CONFIRM_EXISTING_FOR_BIOMETRIC_IMPROVE_REQUEST &&
resultCode == Activity.RESULT_OK) {
startBiometricWeakImprove();
createPreferenceHierarchy();
public boolean onPreferenceChange(Preference preference, Object value) {
if (preference == mLockAfter) {
int timeout = Integer.parseInt((String) value);
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, timeout);
} catch (NumberFormatException e) {
Log.e("SecuritySettings", "could not persist lockAfter timeout setting", e);
updateLockAfterPreferenceSummary();
public void startBiometricWeakImprove(){
Intent intent = new Intent();
intent.setClassName("com.android.facelock", "com.android.facelock.AddToSetup");
startActivity(intent);
其中有关未知来源应用安装的有:
mToggleAppInstallation = (CheckBoxPreference) findPreference(
KEY_TOGGLE_INSTALL_APPLICATIONS);
mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
private boolean isNonMarketAppsAllowed() {
return Settings.Secure.getInt(getContentResolver(),
Settings.Secure.INSTALL_NON_MARKET_APPS, 0) & 0;
private void setNonMarketAppsAllowed(boolean enabled) {
// Change the system setting
Settings.Secure.putInt(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS,
enabled ? 1 : 0);
} public void onClick(DialogInterface dialog, int which) {
if (dialog == mWarnInstallApps && which == DialogInterface.BUTTON_POSITIVE) {
setNonMarketAppsAllowed(true);
mToggleAppInstallation.setChecked(true);
源代码Settings$Secure.class中有关允许未知来源应用安装
* Whether the package installer should allow installation of apps downloaded from
* sources other than the Android Market (vending machine).
* 1 = allow installing from other sources
* 0 = only allow installing from the Android Market
public static final String INSTALL_NON_MARKET_APPS = "install_non_market_apps";
没有更多推荐了,后使用快捷导航没有帐号?
其他登录方式
—— 新手入门 ——
—— 智友精华 ——
查看: 3219|回复: 6
在线时间2170 小时最后登录阅读权限45UID2829871注册时间积分4165精华0
, 积分 4165, 距离下一级还需 835 积分
主题帖子 金币4516 元 智豆162 点
本帖最后由 帅哥哥哥哥哥 于
15:44 编辑
我们用电脑手机软件同步手机的时候老是提示要打开允许安装未知来源的应用的设置才能继续安装程序,
下面我就教大家安卓手机设置允许安装未知来源的应用的方法。
& && && && && && && && && && && && && && && && && && && && && && && && && && && && && && && && && && &
& && && && && && && && && && && && && && & 首先进入安卓系统设置界面
& && && && && && && && && && && && && && && && && && && && && && && && && && && && && && && && && &
& && && && && && && && && && && && &&&设置界面选择安全
& && && && && && && && && && && && && && && && && && && && && && && && && && && && && && && && &&&
& && && && && && && && && && && && &&&
& && && && & & && && && && && && &然后勾中未知来源(允许安装未知来源的应用)后面的小框
附件: 你需要才可以下载或查看附件。没有帐号?
楼主很赞!赏波666
打赏排行榜
楼主共收获打赏:
帅哥哥哥哥哥打赏
虚位以待打赏
虚位以待打赏
查看更多打赏排行榜
您的贴子很精彩!希望再分享您的下一贴!
总评分:&金币 + 5&
在线时间15 小时最后登录阅读权限15UID注册时间积分60精华0
, 积分 60, 距离下一级还需 40 积分
主题帖子 金币164 元 智豆0 点
谢谢楼主!!这个是必须的!!!!!
在线时间2170 小时最后登录阅读权限45UID2829871注册时间积分4165精华0
, 积分 4165, 距离下一级还需 835 积分
主题帖子 金币4516 元 智豆162 点
wlxghost 发表于
谢谢楼主!!这个是必须的!!!!!
欢迎介绍更多的机友来我们论坛做客,谢谢
在线时间23589 小时最后登录阅读权限90UID3122308注册时间积分62560精华10
主题帖子 金币-2029 元 智豆2020 点
感谢分享!
在线时间49 小时最后登录阅读权限20UID注册时间积分105精华0
, 积分 105, 距离下一级还需 95 积分
主题帖子 金币207 元 智豆1 点
版主很好,很认真,版主,你的高尚情C太让人感动了。在现在这样一个物欲横流的金钱社会里,竟然还能见到楼主这样的性情中人,无疑是我这辈子最大的幸运。让我深深感受到了人性的伟大。楼主的发言,就好比黑暗中刺裂夜空的闪电,又好比撕开乌云的阳光,一瞬间就让我如饮甘露,让我明白了永恒的真理在这个世界上是真实存在着的。只有楼主这样具备广阔胸怀和完整知识体系的人,才能作为这真理的惟一引言者。看了楼主的发言,我陷入了严肃的思考中。我认为,如果不把楼主的发言顶上去,就是对真理的背叛,就是道德的沦丧!就是人性的泯灭!因此,我决定义无返顾地顶了!{:243:}
在线时间2170 小时最后登录阅读权限45UID2829871注册时间积分4165精华0
, 积分 4165, 距离下一级还需 835 积分
主题帖子 金币4516 元 智豆162 点
版主很好,很认真,版主,你的高尚情C太让人感动了。在现在这样一个物欲横流的金钱社会里,竟然还能见到楼主 ...
你的回复太有才了
大诗人勋章
客户端【我的任务】—完成【大诗人】任务
手机 笔记本 血糖仪 USB声卡 耳机小米6手机,设置允许安装未知来源的应用,开关设置一直失败,所有应用都是不允许安装未知来源,也修改不了_小米吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:5,471,718贴子:
小米6手机,设置允许安装未知来源的应用,开关设置一直失败,所收藏
小米6手机,设置允许安装未知来源的应用,开关设置一直失败,所有应用都是不允许安装未知来源,也修改不了
设置里搜索“未知来源”就可以了
你也是升级完才没有的嘛
贴吧拳王争霸赛中累计获取300场胜利,
点亮12星座印记,
用wifi,也有可能是你没有激活sim卡
12楼正解, 开wifi就好了
**鸡我也是弄半天才搞定!
我的也是一样的问题,解决了没有?
我也遇到一样的问题求解,开wifi没用。。。
求解决方案
我今天更新应用也遇到了,试了各种方法,最后开了vpn才打开那个选项
我也这个问题,这设置有病吧,强j用户啊
突然就好了
重启到recover就可以了
我米6也这样,选项无法勾选,
给安全中心联网就好使了
更新完9.5.7.0系统后的毛病,给安全中心允许联网就可以正常打开了
登录百度帐号}

我要回帖

更多关于 没有sim卡小米允许安装未知来源 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信