Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
...@@ -22,6 +22,7 @@ import android.os.AsyncTask; ...@@ -22,6 +22,7 @@ import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.os.CountDownTimer; import android.os.CountDownTimer;
import android.os.SystemClock; import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
import android.os.storage.StorageManager; import android.os.storage.StorageManager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -100,6 +101,8 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity { ...@@ -100,6 +101,8 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
private AppearAnimationUtils mAppearAnimationUtils; private AppearAnimationUtils mAppearAnimationUtils;
private DisappearAnimationUtils mDisappearAnimationUtils; private DisappearAnimationUtils mDisappearAnimationUtils;
private boolean mIsScale = false;
private final float mScale = 0.65f;
// required constructor for fragments // required constructor for fragments
public ConfirmLockPatternFragment() { public ConfirmLockPatternFragment() {
...@@ -122,6 +125,8 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity { ...@@ -122,6 +125,8 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
mLeftSpacerLandscape = view.findViewById(R.id.leftSpacer); mLeftSpacerLandscape = view.findViewById(R.id.leftSpacer);
mRightSpacerLandscape = view.findViewById(R.id.rightSpacer); mRightSpacerLandscape = view.findViewById(R.id.rightSpacer);
resizePattern();
// make it so unhandled touch events within the unlock screen go to the // make it so unhandled touch events within the unlock screen go to the
// lock pattern view. // lock pattern view.
final LinearLayoutWithDefaultTouchRecepient topLayout final LinearLayoutWithDefaultTouchRecepient topLayout
...@@ -140,6 +145,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity { ...@@ -140,6 +145,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
mLockPatternUtils.isTactileFeedbackEnabled()); mLockPatternUtils.isTactileFeedbackEnabled());
mLockPatternView.setInStealthMode(!mLockPatternUtils.isVisiblePatternEnabled( mLockPatternView.setInStealthMode(!mLockPatternUtils.isVisiblePatternEnabled(
mEffectiveUserId)); mEffectiveUserId));
mLockPatternView.setLockPatternSize(mLockPatternUtils.getLockPatternSize(mEffectiveUserId));
mLockPatternView.setOnPatternListener(mConfirmExistingLockPatternListener); mLockPatternView.setOnPatternListener(mConfirmExistingLockPatternListener);
updateStage(Stage.NeedToUnlock); updateStage(Stage.NeedToUnlock);
...@@ -215,6 +221,27 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity { ...@@ -215,6 +221,27 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
mCredentialCheckResultTracker.setListener(this); mCredentialCheckResultTracker.setListener(this);
} }
private void resizePattern() {
if ((getActivity() != null) && getActivity().isInMultiWindowMode()) {
mIsScale = true;
ViewGroup.LayoutParams lp = mLockPatternView.getLayoutParams();
lp.width *= mScale;
lp.height *= mScale;
mLockPatternView.setLayoutParams(lp);
}
}
@Override
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
super.onMultiWindowModeChanged(isInMultiWindowMode);
if (!isInMultiWindowMode && mIsScale) {
ViewGroup.LayoutParams lp = mLockPatternView.getLayoutParams();
lp.width /= mScale;
lp.height /= mScale;
mLockPatternView.setLayoutParams(lp);
}
}
@Override @Override
protected void onShowError() { protected void onShowError() {
} }
...@@ -454,7 +481,9 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity { ...@@ -454,7 +481,9 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
mLockPatternUtils, pattern, challenge, localUserId, mLockPatternUtils, pattern, challenge, localUserId,
onVerifyCallback) onVerifyCallback)
: LockPatternChecker.verifyTiedProfileChallenge( : LockPatternChecker.verifyTiedProfileChallenge(
mLockPatternUtils, LockPatternUtils.patternToString(pattern), mLockPatternUtils,
LockPatternUtils.patternToString(pattern,
mLockPatternUtils.getLockPatternSize(mEffectiveUserId)),
true, challenge, localUserId, onVerifyCallback); true, challenge, localUserId, onVerifyCallback);
} }
...@@ -479,7 +508,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity { ...@@ -479,7 +508,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE, intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
StorageManager.CRYPT_TYPE_PATTERN); StorageManager.CRYPT_TYPE_PATTERN);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
LockPatternUtils.patternToString(pattern)); mLockPatternUtils.patternToString(pattern, localEffectiveUserId));
} }
mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs, mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs,
localEffectiveUserId); localEffectiveUserId);
......
package com.android.settings;
import android.content.Intent;
import android.app.Activity;
import android.net.Uri;
import android.util.Log;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;
import com.android.internal.logging.MetricsProto.MetricsEvent;
public class Contributors extends SettingsPreferenceFragment {
private static final String LOG_TAG = "Contributors";
private static final String URL_E_CONTRIBUTORS = "https://e.foundation/support-us/#halloffame";
private static final String KEY_E_CONTRIBUTORS = "e_contributors";
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.contributors);
}
@Override
protected int getMetricsCategory() {
return MetricsEvent.CONTRIBUTORS;
}
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference.getKey().equals(KEY_E_CONTRIBUTORS)) {
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setData(Uri.parse(URL_E_CONTRIBUTORS));
try {
startActivity(intent);
} catch (Exception e) {
Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
}
}
return super.onPreferenceTreeClick(preference);
}
}
...@@ -48,6 +48,8 @@ import android.util.Log; ...@@ -48,6 +48,8 @@ import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnKeyListener; import android.view.View.OnKeyListener;
import android.view.View.OnTouchListener; import android.view.View.OnTouchListener;
...@@ -67,6 +69,7 @@ import com.android.internal.widget.LockPatternView; ...@@ -67,6 +69,7 @@ import com.android.internal.widget.LockPatternView;
import com.android.internal.widget.LockPatternView.Cell; import com.android.internal.widget.LockPatternView.Cell;
import com.android.internal.widget.LockPatternView.DisplayMode; import com.android.internal.widget.LockPatternView.DisplayMode;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -83,7 +86,7 @@ import java.util.List; ...@@ -83,7 +86,7 @@ import java.util.List;
* </pre> * </pre>
*/ */
public class CryptKeeper extends Activity implements TextView.OnEditorActionListener, public class CryptKeeper extends Activity implements TextView.OnEditorActionListener,
OnKeyListener, OnTouchListener, TextWatcher { OnKeyListener, OnTouchListener, TextWatcher, OnClickListener {
private static final String TAG = "CryptKeeper"; private static final String TAG = "CryptKeeper";
private static final String DECRYPT_STATE = "trigger_restart_framework"; private static final String DECRYPT_STATE = "trigger_restart_framework";
...@@ -116,6 +119,8 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -116,6 +119,8 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
private boolean mEncryptionGoneBad; private boolean mEncryptionGoneBad;
/** If gone bad, should we show encryption failed (false) or corrupt (true)*/ /** If gone bad, should we show encryption failed (false) or corrupt (true)*/
private boolean mCorrupt; private boolean mCorrupt;
/** If gone bad and mdtp is activated we should not allow recovery screen, only wipe the data */
private boolean mMdtpActivated;
/** A flag to indicate when the back event should be ignored */ /** A flag to indicate when the back event should be ignored */
/** When set, blocks unlocking. Set every COOL_DOWN_ATTEMPTS attempts, only cleared /** When set, blocks unlocking. Set every COOL_DOWN_ATTEMPTS attempts, only cleared
by power cycling phone. */ by power cycling phone. */
...@@ -124,6 +129,15 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -124,6 +129,15 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
PowerManager.WakeLock mWakeLock; PowerManager.WakeLock mWakeLock;
private EditText mPasswordEntry; private EditText mPasswordEntry;
private LockPatternView mLockPatternView; private LockPatternView mLockPatternView;
private TextView mStatusText;
private List<Button> mLockPatternButtons = new ArrayList<>();
private static final int[] LOCK_BUTTON_IDS = new int[] {
R.id.lock_pattern_size_3,
R.id.lock_pattern_size_4,
R.id.lock_pattern_size_5,
R.id.lock_pattern_size_6
};
/** Number of calls to {@link #notifyUser()} to ignore before notifying. */ /** Number of calls to {@link #notifyUser()} to ignore before notifying. */
private int mNotificationCountdown = 0; private int mNotificationCountdown = 0;
/** Number of calls to {@link #notifyUser()} before we release the wakelock */ /** Number of calls to {@link #notifyUser()} before we release the wakelock */
...@@ -177,6 +191,9 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -177,6 +191,9 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
super.onPreExecute(); super.onPreExecute();
if (mLockPatternView != null) {
mLockPatternView.removeCallbacks(mFakeUnlockAttemptRunnable);
}
beginAttempt(); beginAttempt();
} }
...@@ -200,23 +217,36 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -200,23 +217,36 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
mLockPatternView.removeCallbacks(mClearPatternRunnable); mLockPatternView.removeCallbacks(mClearPatternRunnable);
mLockPatternView.postDelayed(mClearPatternRunnable, RIGHT_PATTERN_CLEAR_TIMEOUT_MS); mLockPatternView.postDelayed(mClearPatternRunnable, RIGHT_PATTERN_CLEAR_TIMEOUT_MS);
} }
final TextView status = (TextView) findViewById(R.id.status); mStatusText.setText(R.string.starting_android);
status.setText(R.string.starting_android);
hide(R.id.passwordEntry); hide(R.id.passwordEntry);
hide(R.id.switch_ime_button); hide(R.id.switch_ime_button);
hide(R.id.lockPattern); hide(R.id.lockPattern);
hide(R.id.owner_info); hide(R.id.owner_info);
hide(R.id.emergencyCallButton); hide(R.id.emergencyCallButton);
hide(R.id.pattern_sizes);
} else if (failedAttempts == MAX_FAILED_ATTEMPTS) { } else if (failedAttempts == MAX_FAILED_ATTEMPTS) {
// Factory reset the device. // Factory reset the device.
Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR); if(mMdtpActivated){
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); Log.d(TAG,
intent.putExtra(Intent.EXTRA_REASON, "CryptKeeper.MAX_FAILED_ATTEMPTS"); " CryptKeeper.MAX_FAILED_ATTEMPTS, calling encryptStorage with wipe");
sendBroadcast(intent); try {
final IMountService service = getMountService();
service.encryptWipeStorage(StorageManager.CRYPT_TYPE_DEFAULT, "");
} catch (RemoteException e) {
Log.w(TAG, "Unable to call MountService properly");
return;
}
} else {
Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
intent.putExtra(Intent.EXTRA_REASON, "CryptKeeper.MAX_FAILED_ATTEMPTS");
sendBroadcast(intent);
}
} else if (failedAttempts == -1) { } else if (failedAttempts == -1) {
// Right password, but decryption failed. Tell user bad news ... // Right password, but decryption failed. Tell user bad news ...
setContentView(R.layout.crypt_keeper_progress); setContentView(R.layout.crypt_keeper_progress);
showFactoryReset(true); showFactoryReset(true, false);
return; return;
} else { } else {
handleBadAttempt(failedAttempts); handleBadAttempt(failedAttempts);
...@@ -225,8 +255,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -225,8 +255,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
} }
private void beginAttempt() { private void beginAttempt() {
final TextView status = (TextView) findViewById(R.id.status); mStatusText.setText(R.string.checking_decryption);
status.setText(R.string.checking_decryption);
} }
private void handleBadAttempt(Integer failedAttempts) { private void handleBadAttempt(Integer failedAttempts) {
...@@ -242,14 +271,12 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -242,14 +271,12 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
// at this point. // at this point.
cooldown(); cooldown();
} else { } else {
final TextView status = (TextView) findViewById(R.id.status);
int remainingAttempts = MAX_FAILED_ATTEMPTS - failedAttempts; int remainingAttempts = MAX_FAILED_ATTEMPTS - failedAttempts;
if (remainingAttempts < COOL_DOWN_ATTEMPTS) { if (remainingAttempts < COOL_DOWN_ATTEMPTS) {
CharSequence warningTemplate = getText(R.string.crypt_keeper_warn_wipe); CharSequence warningTemplate = getText(R.string.crypt_keeper_warn_wipe);
CharSequence warning = TextUtils.expandTemplate(warningTemplate, CharSequence warning = TextUtils.expandTemplate(warningTemplate,
Integer.toString(remainingAttempts)); Integer.toString(remainingAttempts));
status.setText(warning); mStatusText.setText(warning);
} else { } else {
int passwordType = StorageManager.CRYPT_TYPE_PASSWORD; int passwordType = StorageManager.CRYPT_TYPE_PASSWORD;
try { try {
...@@ -260,17 +287,18 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -260,17 +287,18 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
} }
if (passwordType == StorageManager.CRYPT_TYPE_PIN) { if (passwordType == StorageManager.CRYPT_TYPE_PIN) {
status.setText(R.string.cryptkeeper_wrong_pin); mStatusText.setText(R.string.cryptkeeper_wrong_pin);
} else if (passwordType == StorageManager.CRYPT_TYPE_PATTERN) { } else if (passwordType == StorageManager.CRYPT_TYPE_PATTERN) {
status.setText(R.string.cryptkeeper_wrong_pattern); mStatusText.setText(R.string.cryptkeeper_wrong_pattern);
} else { } else {
status.setText(R.string.cryptkeeper_wrong_password); mStatusText.setText(R.string.cryptkeeper_wrong_password);
} }
} }
if (mLockPatternView != null) { if (mLockPatternView != null) {
mLockPatternView.setDisplayMode(DisplayMode.Wrong); mLockPatternView.setDisplayMode(DisplayMode.Wrong);
mLockPatternView.setEnabled(true); mLockPatternView.setEnabled(true);
setPatternButtonsEnabled(true);
} }
// Reenable the password entry // Reenable the password entry
...@@ -297,10 +325,13 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -297,10 +325,13 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
Log.w(TAG, "Unexpectedly in CryptKeeper even though there is no encryption."); Log.w(TAG, "Unexpectedly in CryptKeeper even though there is no encryption.");
return true; // Unexpected, but fine, I guess... return true; // Unexpected, but fine, I guess...
} }
return state == IMountService.ENCRYPTION_STATE_OK; mMdtpActivated = (state == IMountService.ENCRYPTION_STATE_ERROR_MDTP_ACTIVATED) ||
(state == IMountService.ENCRYPTION_STATE_OK_MDTP_ACTIVATED);
return (state == IMountService.ENCRYPTION_STATE_OK) ||
(state == IMountService.ENCRYPTION_STATE_OK_MDTP_ACTIVATED);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.w(TAG, "Unable to get encryption state properly"); Log.w(TAG, "Unable to get encryption state properly");
return true; return false;
} }
} }
...@@ -400,9 +431,18 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -400,9 +431,18 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
// If we are not encrypted or encrypting, get out quickly. // If we are not encrypted or encrypting, get out quickly.
final String state = SystemProperties.get("vold.decrypt"); final String state = SystemProperties.get("vold.decrypt");
if (!isDebugView() && ("".equals(state) || DECRYPT_STATE.equals(state))) { final boolean isAlarmBoot = SystemProperties.getBoolean("ro.alarm_boot", false);
if ((!isDebugView() && ("".equals(state) || DECRYPT_STATE.equals(state)))
|| isAlarmBoot) {
disableCryptKeeperComponent(this); disableCryptKeeperComponent(this);
// Typically CryptKeeper is launched as the home app. We didn't // Typically CryptKeeper is launched as the home app. We didn't
// want to be running, so need to finish this activity. We can count // want to be running, so need to finish this activity. We can count
...@@ -465,7 +505,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -465,7 +505,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
private void setupUi() { private void setupUi() {
if (mEncryptionGoneBad || isDebugView(FORCE_VIEW_ERROR)) { if (mEncryptionGoneBad || isDebugView(FORCE_VIEW_ERROR)) {
setContentView(R.layout.crypt_keeper_progress); setContentView(R.layout.crypt_keeper_progress);
showFactoryReset(mCorrupt); showFactoryReset(mCorrupt, mMdtpActivated);
return; return;
} }
...@@ -511,8 +551,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -511,8 +551,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
setContentView(R.layout.crypt_keeper_password_entry); setContentView(R.layout.crypt_keeper_password_entry);
mStatusString = R.string.enter_password; mStatusString = R.string.enter_password;
} }
final TextView status = (TextView) findViewById(R.id.status); mStatusText.setText(mStatusString);
status.setText(mStatusString);
final TextView ownerInfo = (TextView) findViewById(R.id.owner_info); final TextView ownerInfo = (TextView) findViewById(R.id.owner_info);
ownerInfo.setText(owner_info); ownerInfo.setText(owner_info);
...@@ -571,6 +610,12 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -571,6 +610,12 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
} }
} }
@Override
public void setContentView(int layoutResID) {
super.setContentView(layoutResID);
mStatusText = (TextView) findViewById(R.id.status);
}
/** /**
* Start encrypting the device. * Start encrypting the device.
*/ */
...@@ -599,8 +644,10 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -599,8 +644,10 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
* there is nothing else we can do * there is nothing else we can do
* @param corrupt true if userdata is corrupt, false if encryption failed * @param corrupt true if userdata is corrupt, false if encryption failed
* partway through * partway through
* @param mdtp_activated true if MDTP is activated according to MountService
* state.
*/ */
private void showFactoryReset(final boolean corrupt) { private void showFactoryReset(final boolean corrupt, final boolean mdtp_activated) {
// Hide the encryption-bot to make room for the "factory reset" button // Hide the encryption-bot to make room for the "factory reset" button
findViewById(R.id.encroid).setVisibility(View.GONE); findViewById(R.id.encroid).setVisibility(View.GONE);
...@@ -610,12 +657,24 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -610,12 +657,24 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
button.setOnClickListener(new OnClickListener() { button.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// Factory reset the device. if(mdtp_activated){
Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR); Log.d(TAG, " Calling encryptStorage with wipe");
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); try {
intent.putExtra(Intent.EXTRA_REASON, final IMountService service = getMountService();
"CryptKeeper.showFactoryReset() corrupt=" + corrupt); service.encryptWipeStorage(StorageManager.CRYPT_TYPE_DEFAULT, "");
sendBroadcast(intent);
} catch (RemoteException e) {
Log.w(TAG, "Unable to call MountService properly");
return;
}
} else {
// Factory reset the device.
Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
intent.putExtra(Intent.EXTRA_REASON,
"CryptKeeper.showFactoryReset() corrupt=" + corrupt);
sendBroadcast(intent);
}
} }
}); });
...@@ -639,7 +698,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -639,7 +698,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
final String state = SystemProperties.get("vold.encrypt_progress"); final String state = SystemProperties.get("vold.encrypt_progress");
if ("error_partially_encrypted".equals(state)) { if ("error_partially_encrypted".equals(state)) {
showFactoryReset(false); showFactoryReset(false, false);
return; return;
} }
...@@ -669,9 +728,8 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -669,9 +728,8 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
// Will happen if no time etc - show percentage // Will happen if no time etc - show percentage
} }
final TextView tv = (TextView) findViewById(R.id.status); if (mStatusText != null) {
if (tv != null) { mStatusText.setText(TextUtils.expandTemplate(status, progress));
tv.setText(TextUtils.expandTemplate(status, progress));
} }
// Check the progress every 1 seconds // Check the progress every 1 seconds
...@@ -687,12 +745,13 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -687,12 +745,13 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
if (mPasswordEntry != null) { if (mPasswordEntry != null) {
mPasswordEntry.setEnabled(false); mPasswordEntry.setEnabled(false);
} }
if (mLockPatternView != null) { if (mLockPatternView != null) {
mLockPatternView.setEnabled(false); mLockPatternView.setEnabled(false);
setPatternButtonsEnabled(false);
} }
final TextView status = (TextView) findViewById(R.id.status); mStatusText.setText(R.string.crypt_keeper_force_power_cycle);
status.setText(R.string.crypt_keeper_force_power_cycle);
} }
/** /**
...@@ -717,18 +776,21 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -717,18 +776,21 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
@Override @Override
public void onPatternStart() { public void onPatternStart() {
setPatternButtonsEnabled(false);
mLockPatternView.removeCallbacks(mClearPatternRunnable); mLockPatternView.removeCallbacks(mClearPatternRunnable);
} }
@Override @Override
public void onPatternCleared() { public void onPatternCleared() {
setPatternButtonsEnabled(true);
} }
@Override @Override
public void onPatternDetected(List<LockPatternView.Cell> pattern) { public void onPatternDetected(List<LockPatternView.Cell> pattern) {
mLockPatternView.setEnabled(false); mLockPatternView.setEnabled(false);
if (pattern.size() >= MIN_LENGTH_BEFORE_REPORT) { if (pattern.size() >= MIN_LENGTH_BEFORE_REPORT) {
new DecryptTask().execute(LockPatternUtils.patternToString(pattern)); new DecryptTask().execute(LockPatternUtils.patternToString(pattern,
mLockPatternView.getLockPatternSize()));
} else { } else {
// Allow user to make as many of these as they want. // Allow user to make as many of these as they want.
fakeUnlockAttempt(mLockPatternView); fakeUnlockAttempt(mLockPatternView);
...@@ -752,10 +814,18 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -752,10 +814,18 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
mPasswordEntry.addTextChangedListener(this); mPasswordEntry.addTextChangedListener(this);
} }
mLockPatternButtons.clear();
// Pattern case // Pattern case
mLockPatternView = (LockPatternView) findViewById(R.id.lockPattern); mLockPatternView = (LockPatternView) findViewById(R.id.lockPattern);
if (mLockPatternView != null) { if (mLockPatternView != null) {
mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener); mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener);
for (int id : LOCK_BUTTON_IDS) {
Button btn = (Button) findViewById(id);
if (btn != null) {
btn.setOnClickListener(this);
mLockPatternButtons.add(btn);
}
}
} }
// Disable the Emergency call button if the device has no voice telephone capability // Disable the Emergency call button if the device has no voice telephone capability
...@@ -1037,4 +1107,39 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList ...@@ -1037,4 +1107,39 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP); PackageManager.DONT_KILL_APP);
} }
@Override
public void onClick(View v) {
if (mLockPatternView == null || !mLockPatternView.isEnabled()) {
return;
}
byte size;
switch (v.getId()) {
default:
case R.id.lock_pattern_size_3:
size = 3;
break;
case R.id.lock_pattern_size_4:
size = 4;
break;
case R.id.lock_pattern_size_5:
size = 5;
break;
case R.id.lock_pattern_size_6:
size = 6;
break;
}
setContentView(R.layout.crypt_keeper_pattern_entry);
passwordEntryInit();
mStatusText.setText(mStatusString = R.string.enter_pattern);
mLockPatternView.setLockPatternSize(size);
mLockPatternView.postInvalidate();
}
private void setPatternButtonsEnabled(boolean enabled) {
for (Button btn : mLockPatternButtons) {
btn.setEnabled(enabled);
}
}
} }
...@@ -155,6 +155,7 @@ public class CryptKeeperConfirm extends InstrumentedFragment { ...@@ -155,6 +155,7 @@ public class CryptKeeperConfirm extends InstrumentedFragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
setHasOptionsMenu(true);
mContentView = inflater.inflate(R.layout.crypt_keeper_confirm, null); mContentView = inflater.inflate(R.layout.crypt_keeper_confirm, null);
establishFinalConfirmationState(); establishFinalConfirmationState();
return mContentView; return mContentView;
......
...@@ -138,6 +138,7 @@ public class CryptKeeperSettings extends InstrumentedFragment { ...@@ -138,6 +138,7 @@ public class CryptKeeperSettings extends InstrumentedFragment {
@Override @Override
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
setHasOptionsMenu(true);
Activity activity = getActivity(); Activity activity = getActivity();
Intent intent = activity.getIntent(); Intent intent = activity.getIntent();
if (DevicePolicyManager.ACTION_START_ENCRYPTION.equals(intent.getAction())) { if (DevicePolicyManager.ACTION_START_ENCRYPTION.equals(intent.getAction())) {
......
...@@ -71,6 +71,10 @@ public class CustomDialogPreference extends DialogPreference { ...@@ -71,6 +71,10 @@ public class CustomDialogPreference extends DialogPreference {
mFragment = fragment; mFragment = fragment;
} }
protected boolean onDismissDialog(final DialogInterface dialog, final int which) {
return true;
}
public static class CustomPreferenceDialogFragment extends PreferenceDialogFragment { public static class CustomPreferenceDialogFragment extends PreferenceDialogFragment {
public static CustomPreferenceDialogFragment newInstance(String key) { public static CustomPreferenceDialogFragment newInstance(String key) {
...@@ -85,6 +89,45 @@ public class CustomDialogPreference extends DialogPreference { ...@@ -85,6 +89,45 @@ public class CustomDialogPreference extends DialogPreference {
return (CustomDialogPreference) getPreference(); return (CustomDialogPreference) getPreference();
} }
private class OnDismissListener implements View.OnClickListener {
private final int mWhich;
private final DialogInterface mDialog;
public OnDismissListener(final DialogInterface dialog, final int which) {
mWhich = which;
mDialog = dialog;
}
@Override
public void onClick(final View view) {
CustomPreferenceDialogFragment.this.onClick(mDialog, mWhich);
if (getCustomizablePreference().onDismissDialog(mDialog, mWhich)) {
mDialog.dismiss();
}
}
}
@Override
public void onStart() {
super.onStart();
if (getDialog() instanceof AlertDialog) {
final AlertDialog dialog = (AlertDialog) getDialog();
if (dialog.getButton(Dialog.BUTTON_NEUTRAL) != null) {
dialog.getButton(Dialog.BUTTON_NEUTRAL).setOnClickListener(
new OnDismissListener(dialog, Dialog.BUTTON_NEUTRAL));
}
if (dialog.getButton(Dialog.BUTTON_POSITIVE) != null) {
dialog.getButton(Dialog.BUTTON_POSITIVE).setOnClickListener(
new OnDismissListener(dialog, Dialog.BUTTON_POSITIVE));
}
if (dialog.getButton(Dialog.BUTTON_NEGATIVE) != null) {
dialog.getButton(Dialog.BUTTON_NEGATIVE).setOnClickListener(
new OnDismissListener(dialog, Dialog.BUTTON_NEGATIVE));
}
}
}
@Override @Override
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
super.onPrepareDialogBuilder(builder); super.onPrepareDialogBuilder(builder);
......
...@@ -165,7 +165,13 @@ public class DateTimeSettings extends SettingsPreferenceFragment ...@@ -165,7 +165,13 @@ public class DateTimeSettings extends SettingsPreferenceFragment
// We use 13:00 so we can demonstrate the 12/24 hour options. // We use 13:00 so we can demonstrate the 12/24 hour options.
mDummyDate.set(now.get(Calendar.YEAR), 11, 31, 13, 0, 0); mDummyDate.set(now.get(Calendar.YEAR), 11, 31, 13, 0, 0);
Date dummyDate = mDummyDate.getTime(); Date dummyDate = mDummyDate.getTime();
mDatePref.setSummary(DateFormat.getLongDateFormat(context).format(now.getTime())); if (getResources().getBoolean(R.bool.config_regional_date_format)) {
String dateFormat = Settings.System.getString(context.getContentResolver(),
Settings.System.DATE_FORMAT);
mDatePref.setSummary(DateFormat.format(dateFormat,now.getTime()));
} else {
mDatePref.setSummary(DateFormat.getLongDateFormat(context).format(now.getTime()));
}
mTimePref.setSummary(DateFormat.getTimeFormat(getActivity()).format(now.getTime())); mTimePref.setSummary(DateFormat.getTimeFormat(getActivity()).format(now.getTime()));
mTimeZone.setSummary(ZoneGetter.getTimeZoneOffsetAndName(now.getTimeZone(), now.getTime())); mTimeZone.setSummary(ZoneGetter.getTimeZoneOffsetAndName(now.getTimeZone(), now.getTime()));
mTime24Pref.setSummary(DateFormat.getTimeFormat(getActivity()).format(dummyDate)); mTime24Pref.setSummary(DateFormat.getTimeFormat(getActivity()).format(dummyDate));
......
/* /*
* Copyright (C) 2008 The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
* Copyright (C) 2013-2014 The CyanogenMod Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -39,6 +40,9 @@ import android.content.pm.PackageManager; ...@@ -39,6 +40,9 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.content.res.Resources; import android.content.res.Resources;
import android.net.NetworkUtils;
import android.net.wifi.IWifiManager;
import android.net.wifi.WifiInfo;
import android.hardware.usb.IUsbManager; import android.hardware.usb.IUsbManager;
import android.hardware.usb.UsbManager; import android.hardware.usb.UsbManager;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
...@@ -62,6 +66,7 @@ import android.support.v14.preference.SwitchPreference; ...@@ -62,6 +66,7 @@ import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceChangeListener; import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen; import android.support.v7.preference.PreferenceScreen;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
...@@ -80,6 +85,7 @@ import android.widget.Toast; ...@@ -80,6 +85,7 @@ import android.widget.Toast;
import com.android.internal.app.LocalePicker; import com.android.internal.app.LocalePicker;
import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.settings.Settings.AppOpsSummaryActivity;
import com.android.settings.applications.BackgroundCheckSummary; import com.android.settings.applications.BackgroundCheckSummary;
import com.android.settings.fuelgauge.InactiveApps; import com.android.settings.fuelgauge.InactiveApps;
import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.BaseSearchIndexProvider;
...@@ -89,6 +95,10 @@ import com.android.settingslib.RestrictedLockUtils; ...@@ -89,6 +95,10 @@ import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedSwitchPreference; import com.android.settingslib.RestrictedSwitchPreference;
import cyanogenmod.providers.CMSettings;
import org.cyanogenmod.internal.util.FileUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
...@@ -99,7 +109,8 @@ import java.util.List; ...@@ -99,7 +109,8 @@ import java.util.List;
*/ */
public class DevelopmentSettings extends RestrictedSettingsFragment public class DevelopmentSettings extends RestrictedSettingsFragment
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener, implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener,
OnPreferenceChangeListener, SwitchBar.OnSwitchChangeListener, Indexable { OnPreferenceChangeListener, SwitchBar.OnSwitchChangeListener, Indexable,
OnPreferenceClickListener {
private static final String TAG = "DevelopmentSettings"; private static final String TAG = "DevelopmentSettings";
/** /**
...@@ -113,6 +124,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -113,6 +124,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
public static final String PREF_SHOW = "show"; public static final String PREF_SHOW = "show";
private static final String ENABLE_ADB = "enable_adb"; private static final String ENABLE_ADB = "enable_adb";
private static final String ADB_TCPIP = "adb_over_network";
private static final String CLEAR_ADB_KEYS = "clear_adb_keys"; private static final String CLEAR_ADB_KEYS = "clear_adb_keys";
private static final String ENABLE_TERMINAL = "enable_terminal"; private static final String ENABLE_TERMINAL = "enable_terminal";
private static final String KEEP_SCREEN_ON = "keep_screen_on"; private static final String KEEP_SCREEN_ON = "keep_screen_on";
...@@ -198,6 +210,13 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -198,6 +210,13 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private static final String INACTIVE_APPS_KEY = "inactive_apps"; private static final String INACTIVE_APPS_KEY = "inactive_apps";
private static final String ROOT_ACCESS_KEY = "root_access";
private static final String ROOT_ACCESS_PROPERTY = "persist.sys.root_access";
private static final String ROOT_APPOPS_KEY = "root_appops";
private static final String UPDATE_RECOVERY_PROPERTY = "persist.sys.recovery_update";
private static final String IMMEDIATELY_DESTROY_ACTIVITIES_KEY private static final String IMMEDIATELY_DESTROY_ACTIVITIES_KEY
= "immediately_destroy_activities"; = "immediately_destroy_activities";
private static final String APP_PROCESS_LIMIT_KEY = "app_process_limit"; private static final String APP_PROCESS_LIMIT_KEY = "app_process_limit";
...@@ -214,6 +233,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -214,6 +233,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private static final String OTA_DISABLE_AUTOMATIC_UPDATE_KEY = "ota_disable_automatic_update"; private static final String OTA_DISABLE_AUTOMATIC_UPDATE_KEY = "ota_disable_automatic_update";
private static final String DEVELOPMENT_TOOLS = "development_tools";
private static final int RESULT_DEBUG_APP = 1000; private static final int RESULT_DEBUG_APP = 1000;
private static final int RESULT_MOCK_LOCATION_APP = 1001; private static final int RESULT_MOCK_LOCATION_APP = 1001;
...@@ -241,6 +262,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -241,6 +262,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private boolean mDontPokeProperties; private boolean mDontPokeProperties;
private SwitchPreference mEnableAdb; private SwitchPreference mEnableAdb;
private SwitchPreference mAdbOverNetwork;
private Preference mClearAdbKeys; private Preference mClearAdbKeys;
private SwitchPreference mEnableTerminal; private SwitchPreference mEnableTerminal;
private Preference mBugreport; private Preference mBugreport;
...@@ -304,10 +326,18 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -304,10 +326,18 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private ColorModePreference mColorModePreference; private ColorModePreference mColorModePreference;
private Preference mRootAppops;
private SwitchPreference mForceResizable; private SwitchPreference mForceResizable;
private SwitchPreference mColorTemperaturePreference; private SwitchPreference mColorTemperaturePreference;
private SwitchPreference mUpdateRecoveryPreference;
private ListPreference mRootAccess;
private Object mSelectedRootValue;
private PreferenceScreen mDevelopmentTools;
private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>(); private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>();
private final ArrayList<SwitchPreference> mResetSwitchPrefs private final ArrayList<SwitchPreference> mResetSwitchPrefs
...@@ -319,8 +349,11 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -319,8 +349,11 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private Dialog mEnableDialog; private Dialog mEnableDialog;
private Dialog mAdbDialog; private Dialog mAdbDialog;
private Dialog mAdbTcpDialog;
private Dialog mAdbKeysDialog; private Dialog mAdbKeysDialog;
private boolean mUnavailable; private boolean mUnavailable;
private Dialog mRootDialog;
private Dialog mUpdateRecoveryDialog;
private boolean mLogpersistCleared; private boolean mLogpersistCleared;
private Dialog mLogpersistClearDialog; private Dialog mLogpersistClearDialog;
...@@ -366,6 +399,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -366,6 +399,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
final PreferenceGroup debugDebuggingCategory = (PreferenceGroup) final PreferenceGroup debugDebuggingCategory = (PreferenceGroup)
findPreference(DEBUG_DEBUGGING_CATEGORY_KEY); findPreference(DEBUG_DEBUGGING_CATEGORY_KEY);
mEnableAdb = findAndInitSwitchPref(ENABLE_ADB); mEnableAdb = findAndInitSwitchPref(ENABLE_ADB);
mAdbOverNetwork = findAndInitSwitchPref(ADB_TCPIP);
mClearAdbKeys = findPreference(CLEAR_ADB_KEYS); mClearAdbKeys = findPreference(CLEAR_ADB_KEYS);
if (!SystemProperties.getBoolean("ro.adb.secure", false)) { if (!SystemProperties.getBoolean("ro.adb.secure", false)) {
if (debugDebuggingCategory != null) { if (debugDebuggingCategory != null) {
...@@ -399,6 +433,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -399,6 +433,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
disableForUser(mClearAdbKeys); disableForUser(mClearAdbKeys);
disableForUser(mEnableTerminal); disableForUser(mEnableTerminal);
disableForUser(mPassword); disableForUser(mPassword);
disableForUser(mUpdateRecoveryPreference);
} }
mDebugAppPref = findPreference(DEBUG_APP_KEY); mDebugAppPref = findPreference(DEBUG_APP_KEY);
...@@ -497,6 +532,10 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -497,6 +532,10 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
} }
mOtaDisableAutomaticUpdate = findAndInitSwitchPref(OTA_DISABLE_AUTOMATIC_UPDATE_KEY); mOtaDisableAutomaticUpdate = findAndInitSwitchPref(OTA_DISABLE_AUTOMATIC_UPDATE_KEY);
if (!SystemProperties.getBoolean("ro.build.ab_update", false)) {
removePreference(mOtaDisableAutomaticUpdate);
mOtaDisableAutomaticUpdate = null;
}
mColorModePreference = (ColorModePreference) findPreference(KEY_COLOR_MODE); mColorModePreference = (ColorModePreference) findPreference(KEY_COLOR_MODE);
mColorModePreference.updateCurrentAndSupported(); mColorModePreference.updateCurrentAndSupported();
...@@ -514,6 +553,37 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -514,6 +553,37 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
removePreference(COLOR_TEMPERATURE_KEY); removePreference(COLOR_TEMPERATURE_KEY);
mColorTemperaturePreference = null; mColorTemperaturePreference = null;
} }
mRootAccess = (ListPreference) findPreference(ROOT_ACCESS_KEY);
mRootAccess.setOnPreferenceChangeListener(this);
mRootAppops = (Preference) findPreference(ROOT_APPOPS_KEY);
mRootAppops.setOnPreferenceClickListener(this);
if (!removeRootOptionsIfRequired()) {
if (FileUtils.fileExists("/system/xbin/su")) {
mRootAccess.setEntries(R.array.root_access_entries);
mRootAccess.setEntryValues(R.array.root_access_values);
} else {
mRootAccess.setEntries(R.array.root_access_entries_adb);
mRootAccess.setEntryValues(R.array.root_access_values_adb);
}
mAllPrefs.add(mRootAccess);
mAllPrefs.add(mRootAppops);
}
mUpdateRecoveryPreference = findAndInitSwitchPref("update_recovery");
if (!getResources().getBoolean(R.bool.config_enableRecoveryUpdater)) {
removePreference(mUpdateRecoveryPreference);
mUpdateRecoveryPreference = null;
if (SystemProperties.getBoolean(UPDATE_RECOVERY_PROPERTY, false)) {
SystemProperties.set(UPDATE_RECOVERY_PROPERTY, "false");
pokeSystemProperties();
}
}
mDevelopmentTools = (PreferenceScreen) findPreference(DEVELOPMENT_TOOLS);
mAllPrefs.add(mDevelopmentTools);
} }
private ListPreference addListPreference(String prefKey) { private ListPreference addListPreference(String prefKey) {
...@@ -540,6 +610,18 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -540,6 +610,18 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
return pref; return pref;
} }
private boolean removeRootOptionsIfRequired() {
// user builds don't get root, and eng always gets root
if (!(Build.IS_DEBUGGABLE || "eng".equals(Build.TYPE))) {
if (mRootAccess != null) {
getPreferenceScreen().removePreference(mRootAccess);
return true;
}
}
return false;
}
@Override @Override
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
...@@ -707,7 +789,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -707,7 +789,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
updateAppProcessLimitOptions(); updateAppProcessLimitOptions();
updateShowAllANRsOptions(); updateShowAllANRsOptions();
updateVerifyAppsOverUsbOptions(); updateVerifyAppsOverUsbOptions();
updateOtaDisableAutomaticUpdateOptions(); if (mOtaDisableAutomaticUpdate != null) {
updateOtaDisableAutomaticUpdateOptions();
}
updateBugreportOptions(); updateBugreportOptions();
updateForceRtlOptions(); updateForceRtlOptions();
updateLogdSizeValues(); updateLogdSizeValues();
...@@ -727,6 +811,37 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -727,6 +811,37 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
updateColorTemperature(); updateColorTemperature();
} }
updateBluetoothDisableAbsVolumeOptions(); updateBluetoothDisableAbsVolumeOptions();
updateRootAccessOptions();
updateAdbOverNetwork();
updateUpdateRecoveryOptions();
}
private void updateAdbOverNetwork() {
int port = CMSettings.Secure.getInt(getActivity().getContentResolver(),
CMSettings.Secure.ADB_PORT, 0);
boolean enabled = port > 0;
updateSwitchPreference(mAdbOverNetwork, enabled);
WifiInfo wifiInfo = null;
if (enabled) {
IWifiManager wifiManager = IWifiManager.Stub.asInterface(
ServiceManager.getService(Context.WIFI_SERVICE));
try {
wifiInfo = wifiManager.getConnectionInfo();
} catch (RemoteException e) {
Log.e(TAG, "wifiManager, getConnectionInfo()", e);
}
}
if (wifiInfo != null) {
String hostAddress = NetworkUtils.intToInetAddress(
wifiInfo.getIpAddress()).getHostAddress();
mAdbOverNetwork.setSummary(hostAddress + ":" + String.valueOf(port));
} else {
mAdbOverNetwork.setSummary(R.string.adb_over_network_summary);
}
} }
private void resetDangerousOptions() { private void resetDangerousOptions() {
...@@ -739,6 +854,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -739,6 +854,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
} }
} }
resetDebuggerOptions(); resetDebuggerOptions();
resetRootAccessOptions();
resetAdbNotifyOptions();
writeLogpersistOption(null, true); writeLogpersistOption(null, true);
writeLogdSizeOption(null); writeLogdSizeOption(null);
writeAnimationScaleOption(0, mWindowAnimationScale, null); writeAnimationScaleOption(0, mWindowAnimationScale, null);
...@@ -808,6 +925,56 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -808,6 +925,56 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
} }
} }
private void updateRootAccessOptions() {
String value = SystemProperties.get(ROOT_ACCESS_PROPERTY, "0");
mRootAccess.setValue(value);
mRootAccess.setSummary(getResources()
.getStringArray(R.array.root_access_entries)[Integer.valueOf(value)]);
if (mRootAppops != null) {
mRootAppops.setEnabled(isRootForAppsEnabled());
}
}
public static boolean isRootForAppsEnabled() {
int value = SystemProperties.getInt(ROOT_ACCESS_PROPERTY, 0);
boolean daemonState =
SystemProperties.get("init.svc.su_daemon", "absent").equals("running");
return daemonState && (value == 1 || value == 3);
}
private void writeRootAccessOptions(Object newValue) {
String oldValue = SystemProperties.get(ROOT_ACCESS_PROPERTY, "0");
SystemProperties.set(ROOT_ACCESS_PROPERTY, newValue.toString());
if (Integer.valueOf(newValue.toString()) < 2 && !oldValue.equals(newValue)
&& "1".equals(SystemProperties.get("cm.service.adb.root", "0"))) {
SystemProperties.set("cm.service.adb.root", "0");
Settings.Secure.putInt(getActivity().getContentResolver(),
Settings.Secure.ADB_ENABLED, 0);
Settings.Secure.putInt(getActivity().getContentResolver(),
Settings.Secure.ADB_ENABLED, 1);
}
updateRootAccessOptions();
}
private void resetAdbNotifyOptions() {
CMSettings.Secure.putInt(getActivity().getContentResolver(),
CMSettings.Secure.ADB_NOTIFY, 1);
}
private void resetRootAccessOptions() {
String oldValue = SystemProperties.get(ROOT_ACCESS_PROPERTY, "0");
SystemProperties.set(ROOT_ACCESS_PROPERTY, "0");
if (!oldValue.equals("0") && "1".equals(SystemProperties.get("cm.service.adb.root", "0"))) {
SystemProperties.set("cm.service.adb.root", "0");
Settings.Secure.putInt(getActivity().getContentResolver(),
Settings.Secure.ADB_ENABLED, 0);
Settings.Secure.putInt(getActivity().getContentResolver(),
Settings.Secure.ADB_ENABLED, 1);
}
updateRootAccessOptions();
}
private void updateHdcpValues() { private void updateHdcpValues() {
ListPreference hdcpChecking = (ListPreference) findPreference(HDCP_CHECKING_KEY); ListPreference hdcpChecking = (ListPreference) findPreference(HDCP_CHECKING_KEY);
if (hdcpChecking != null) { if (hdcpChecking != null) {
...@@ -829,6 +996,10 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -829,6 +996,10 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private void updatePasswordSummary() { private void updatePasswordSummary() {
try { try {
if (mBackupManager == null) {
Log.e(TAG, "Backup Manager is unavailable!");
return;
}
if (mBackupManager.hasBackupPassword()) { if (mBackupManager.hasBackupPassword()) {
mPassword.setSummary(R.string.local_backup_password_summary_change); mPassword.setSummary(R.string.local_backup_password_summary_change);
} else { } else {
...@@ -1022,7 +1193,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -1022,7 +1193,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
} }
private static boolean showEnableOemUnlockPreference() { private static boolean showEnableOemUnlockPreference() {
return !SystemProperties.get(PERSISTENT_DATA_BLOCK_PROP).equals(""); return !SystemProperties.get(PERSISTENT_DATA_BLOCK_PROP).equals("") &&
SystemProperties.getBoolean("ro.oem_unlock_supported", false);
} }
private boolean enableOemUnlockPreference() { private boolean enableOemUnlockPreference() {
...@@ -1859,6 +2031,21 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -1859,6 +2031,21 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
.show(); .show();
} }
private void updateUpdateRecoveryOptions() {
if (mUpdateRecoveryPreference == null) {
return;
}
updateSwitchPreference(mUpdateRecoveryPreference,
SystemProperties.getBoolean(UPDATE_RECOVERY_PROPERTY, false));
}
private void writeUpdateRecoveryOptions() {
SystemProperties.set(UPDATE_RECOVERY_PROPERTY,
mUpdateRecoveryPreference.isChecked() ? "true" : "false");
pokeSystemProperties();
}
@Override @Override
public void onSwitchChanged(Switch switchView, boolean isChecked) { public void onSwitchChanged(Switch switchView, boolean isChecked) {
if (switchView != mSwitchBar.getSwitch()) { if (switchView != mSwitchBar.getSwitch()) {
...@@ -1882,6 +2069,11 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -1882,6 +2069,11 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0); Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
mLastEnabledState = isChecked; mLastEnabledState = isChecked;
setPrefsEnabledState(mLastEnabledState); setPrefsEnabledState(mLastEnabledState);
// Hide development settings from the Settings menu (Android 4.2 behaviour)
getActivity().getSharedPreferences(PREF_FILE, Context.MODE_PRIVATE).edit()
.putBoolean(PREF_SHOW, false)
.apply();
} }
} }
} }
...@@ -1913,6 +2105,19 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -1913,6 +2105,19 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
} }
} }
@Override
public boolean onPreferenceClick(Preference preference) {
if (preference == mRootAppops) {
Activity mActivity = getActivity();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.putExtra("appops_tab", getString(R.string.app_ops_categories_su));
intent.setClass(mActivity, AppOpsSummaryActivity.class);
mActivity.startActivity(intent);
return true;
}
return false;
}
@Override @Override
public boolean onPreferenceTreeClick(Preference preference) { public boolean onPreferenceTreeClick(Preference preference) {
if (Utils.isMonkeyRunning()) { if (Utils.isMonkeyRunning()) {
...@@ -1937,6 +2142,23 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -1937,6 +2142,23 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mVerifyAppsOverUsb.setChecked(false); mVerifyAppsOverUsb.setChecked(false);
updateBugreportOptions(); updateBugreportOptions();
} }
} else if (preference == mAdbOverNetwork) {
if (mAdbOverNetwork.isChecked()) {
if (mAdbTcpDialog != null) {
dismissDialogs();
}
mAdbTcpDialog = new AlertDialog.Builder(getActivity()).setMessage(
getResources().getString(R.string.adb_over_network_warning))
.setTitle(R.string.adb_over_network)
.setPositiveButton(android.R.string.yes, this)
.setNegativeButton(android.R.string.no, this)
.show();
mAdbTcpDialog.setOnDismissListener(this);
} else {
CMSettings.Secure.putInt(getActivity().getContentResolver(),
CMSettings.Secure.ADB_PORT, -1);
updateAdbOverNetwork();
}
} else if (preference == mClearAdbKeys) { } else if (preference == mClearAdbKeys) {
if (mAdbKeysDialog != null) dismissDialogs(); if (mAdbKeysDialog != null) dismissDialogs();
mAdbKeysDialog = new AlertDialog.Builder(getActivity()) mAdbKeysDialog = new AlertDialog.Builder(getActivity())
...@@ -2044,6 +2266,28 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -2044,6 +2266,28 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
writeWebViewMultiprocessOptions(); writeWebViewMultiprocessOptions();
} else if (SHORTCUT_MANAGER_RESET_KEY.equals(preference.getKey())) { } else if (SHORTCUT_MANAGER_RESET_KEY.equals(preference.getKey())) {
resetShortcutManagerThrottling(); resetShortcutManagerThrottling();
} else if (preference == mUpdateRecoveryPreference) {
if (mSwitchBar.isChecked()) {
if (mUpdateRecoveryDialog != null) {
dismissDialogs();
}
if (mUpdateRecoveryPreference.isChecked()) {
mUpdateRecoveryDialog = new AlertDialog.Builder(getActivity()).setMessage(
getResources().getString(R.string.update_recovery_on_warning))
.setTitle(R.string.update_recovery_title)
.setPositiveButton(android.R.string.yes, this)
.setNegativeButton(android.R.string.no, this)
.show();
} else {
mUpdateRecoveryDialog = new AlertDialog.Builder(getActivity()).setMessage(
getResources().getString(R.string.update_recovery_off_warning))
.setTitle(R.string.update_recovery_title)
.setPositiveButton(android.R.string.yes, this)
.setNegativeButton(android.R.string.no, this)
.show();
}
mUpdateRecoveryDialog.setOnDismissListener(this);
}
} else { } else {
return super.onPreferenceTreeClick(preference); return super.onPreferenceTreeClick(preference);
} }
...@@ -2126,6 +2370,24 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -2126,6 +2370,24 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
} else if (preference == mSimulateColorSpace) { } else if (preference == mSimulateColorSpace) {
writeSimulateColorSpace(newValue); writeSimulateColorSpace(newValue);
return true; return true;
} else if (preference == mRootAccess) {
if ("0".equals(SystemProperties.get(ROOT_ACCESS_PROPERTY, "0"))
&& !"0".equals(newValue)) {
mSelectedRootValue = newValue;
mDialogClicked = false;
if (mRootDialog != null) {
dismissDialogs();
}
mRootDialog = new AlertDialog.Builder(getActivity())
.setMessage(getResources().getString(R.string.root_access_warning_message))
.setTitle(R.string.root_access_warning_title)
.setPositiveButton(android.R.string.yes, this)
.setNegativeButton(android.R.string.no, this).show();
mRootDialog.setOnDismissListener(this);
} else {
writeRootAccessOptions(newValue);
}
return true;
} }
return false; return false;
} }
...@@ -2147,6 +2409,18 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -2147,6 +2409,18 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mLogpersistClearDialog.dismiss(); mLogpersistClearDialog.dismiss();
mLogpersistClearDialog = null; mLogpersistClearDialog = null;
} }
if (mRootDialog != null) {
mRootDialog.dismiss();
mRootDialog = null;
}
if (mAdbTcpDialog != null) {
mAdbTcpDialog.dismiss();
mAdbTcpDialog = null;
}
if (mUpdateRecoveryDialog != null) {
mUpdateRecoveryDialog.dismiss();
mUpdateRecoveryDialog = null;
}
} }
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
...@@ -2179,6 +2453,13 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -2179,6 +2453,13 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1); Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
mLastEnabledState = true; mLastEnabledState = true;
setPrefsEnabledState(mLastEnabledState); setPrefsEnabledState(mLastEnabledState);
// Make sure the development settings is visible in the main Settings menu
// This is needed since we may have just turned off dev settings and want to
// turn it on again
getActivity().getSharedPreferences(PREF_FILE, Context.MODE_PRIVATE).edit()
.putBoolean(PREF_SHOW, true)
.apply();
} else { } else {
// Reset the toggle // Reset the toggle
mSwitchBar.setChecked(false); mSwitchBar.setChecked(false);
...@@ -2189,6 +2470,22 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -2189,6 +2470,22 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
} else { } else {
updateLogpersistValues(); updateLogpersistValues();
} }
} else if (dialog == mRootDialog) {
if (which == DialogInterface.BUTTON_POSITIVE) {
writeRootAccessOptions(mSelectedRootValue);
} else {
// Reset the option
writeRootAccessOptions("0");
}
} else if (dialog == mAdbTcpDialog) {
if (which == DialogInterface.BUTTON_POSITIVE) {
CMSettings.Secure.putInt(getActivity().getContentResolver(),
CMSettings.Secure.ADB_PORT, 5555);
}
} else if (dialog == mUpdateRecoveryDialog) {
if (which == DialogInterface.BUTTON_POSITIVE) {
writeUpdateRecoveryOptions();
}
} }
} }
...@@ -2206,6 +2503,15 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ...@@ -2206,6 +2503,15 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mEnableDialog = null; mEnableDialog = null;
} else if (dialog == mLogpersistClearDialog) { } else if (dialog == mLogpersistClearDialog) {
mLogpersistClearDialog = null; mLogpersistClearDialog = null;
} else if (dialog == mRootDialog) {
updateRootAccessOptions();
mRootDialog = null;
} else if (dialog == mAdbTcpDialog) {
updateAdbOverNetwork();
mAdbTcpDialog = null;
} else if (dialog == mUpdateRecoveryDialog) {
updateUpdateRecoveryOptions();
mUpdateRecoveryDialog = null;
} }
} }
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package com.android.settings; package com.android.settings;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManagerNative; import android.app.ActivityManagerNative;
import android.app.AlertDialog; import android.app.AlertDialog;
...@@ -88,7 +90,6 @@ public class DeviceAdminAdd extends Activity { ...@@ -88,7 +90,6 @@ public class DeviceAdminAdd extends Activity {
Handler mHandler; Handler mHandler;
DevicePolicyManager mDPM; DevicePolicyManager mDPM;
AppOpsManager mAppOps;
DeviceAdminInfo mDeviceAdmin; DeviceAdminInfo mDeviceAdmin;
CharSequence mAddMsgText; CharSequence mAddMsgText;
String mProfileOwnerName; String mProfileOwnerName;
...@@ -113,19 +114,17 @@ public class DeviceAdminAdd extends Activity { ...@@ -113,19 +114,17 @@ public class DeviceAdminAdd extends Activity {
boolean mWaitingForRemoveMsg; boolean mWaitingForRemoveMsg;
boolean mAddingProfileOwner; boolean mAddingProfileOwner;
boolean mAdminPoliciesInitialized; boolean mAdminPoliciesInitialized;
int mCurSysAppOpMode;
int mCurToastAppOpMode;
boolean mIsCalledFromSupportDialog = false; boolean mIsCalledFromSupportDialog = false;
@Override @Override
protected void onCreate(Bundle icicle) { protected void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
mHandler = new Handler(getMainLooper()); mHandler = new Handler(getMainLooper());
mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE); mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
mAppOps = (AppOpsManager)getSystemService(Context.APP_OPS_SERVICE);
PackageManager packageManager = getPackageManager(); PackageManager packageManager = getPackageManager();
if ((getIntent().getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) != 0) { if ((getIntent().getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
...@@ -447,24 +446,14 @@ public class DeviceAdminAdd extends Activity { ...@@ -447,24 +446,14 @@ public class DeviceAdminAdd extends Activity {
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
mActionButton.setEnabled(true);
updateInterface(); updateInterface();
// As long as we are running, don't let this admin overlay stuff on top of the screen.
final int uid = mDeviceAdmin.getActivityInfo().applicationInfo.uid;
final String pkg = mDeviceAdmin.getActivityInfo().applicationInfo.packageName;
mCurSysAppOpMode = mAppOps.checkOp(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, uid, pkg);
mCurToastAppOpMode = mAppOps.checkOp(AppOpsManager.OP_TOAST_WINDOW, uid, pkg);
mAppOps.setMode(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, uid, pkg, AppOpsManager.MODE_IGNORED);
mAppOps.setMode(AppOpsManager.OP_TOAST_WINDOW, uid, pkg, AppOpsManager.MODE_IGNORED);
} }
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
// As long as we are running, don't let this admin overlay stuff on top of the screen. mActionButton.setEnabled(false);
final int uid = mDeviceAdmin.getActivityInfo().applicationInfo.uid;
final String pkg = mDeviceAdmin.getActivityInfo().applicationInfo.packageName;
mAppOps.setMode(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, uid, pkg, mCurSysAppOpMode);
mAppOps.setMode(AppOpsManager.OP_TOAST_WINDOW, uid, pkg, mCurToastAppOpMode);
try { try {
ActivityManagerNative.getDefault().resumeAppSwitches(); ActivityManagerNative.getDefault().resumeAppSwitches();
} catch (RemoteException e) { } catch (RemoteException e) {
......
...@@ -292,6 +292,7 @@ public class DeviceAdminSettings extends ListFragment { ...@@ -292,6 +292,7 @@ public class DeviceAdminSettings extends ListFragment {
} }
vh.checkbox.setEnabled(enabled); vh.checkbox.setEnabled(enabled);
vh.name.setEnabled(enabled); vh.name.setEnabled(enabled);
vh.name.setSelected(true);
vh.description.setEnabled(enabled); vh.description.setEnabled(enabled);
vh.icon.setEnabled(enabled); vh.icon.setEnabled(enabled);
} }
......
...@@ -43,6 +43,8 @@ import com.android.settings.search.Index; ...@@ -43,6 +43,8 @@ import com.android.settings.search.Index;
import com.android.settings.search.Indexable; import com.android.settings.search.Indexable;
import com.android.settingslib.DeviceInfoUtils; import com.android.settingslib.DeviceInfoUtils;
import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedLockUtils;
import com.android.internal.os.RegionalizationEnvironment;
import com.android.internal.os.IRegionalizationService;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
...@@ -62,6 +64,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In ...@@ -62,6 +64,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
private static final String KEY_KERNEL_VERSION = "kernel_version"; private static final String KEY_KERNEL_VERSION = "kernel_version";
private static final String KEY_BUILD_NUMBER = "build_number"; private static final String KEY_BUILD_NUMBER = "build_number";
private static final String KEY_DEVICE_MODEL = "device_model"; private static final String KEY_DEVICE_MODEL = "device_model";
private static final String KEY_DEVICE_NAME = "device_name";
private static final String KEY_SELINUX_STATUS = "selinux_status"; private static final String KEY_SELINUX_STATUS = "selinux_status";
private static final String KEY_BASEBAND_VERSION = "baseband_version"; private static final String KEY_BASEBAND_VERSION = "baseband_version";
private static final String KEY_FIRMWARE_VERSION = "firmware_version"; private static final String KEY_FIRMWARE_VERSION = "firmware_version";
...@@ -71,6 +74,15 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In ...@@ -71,6 +74,15 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
private static final String PROPERTY_EQUIPMENT_ID = "ro.ril.fccid"; private static final String PROPERTY_EQUIPMENT_ID = "ro.ril.fccid";
private static final String KEY_DEVICE_FEEDBACK = "device_feedback"; private static final String KEY_DEVICE_FEEDBACK = "device_feedback";
private static final String KEY_SAFETY_LEGAL = "safetylegal"; private static final String KEY_SAFETY_LEGAL = "safetylegal";
private static final String KEY_MBN_VERSION = "mbn_version";
private static final String PROPERTY_MBN_VERSION = "persist.mbn.version";
private static final String KEY_QGP_VERSION = "qgp_version";
private static final String PROPERTY_QGP_VERSION = "persist.qgp.version";
private static final String MBN_VERSION_PATH = "/persist/speccfg/mbnversion";
private static final String QGP_VERSION_PATH = "/persist/speccfg/qgpversion";
private static final String KEY_MOD_VERSION = "mod_version";
private static final String KEY_MOD_BUILD_DATE = "build_date";
private static final String KEY_MOD_API_LEVEL = "mod_api_level";
static final int TAPS_TO_BE_A_DEVELOPER = 7; static final int TAPS_TO_BE_A_DEVELOPER = 7;
...@@ -84,6 +96,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In ...@@ -84,6 +96,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
private boolean mFunDisallowedBySystem; private boolean mFunDisallowedBySystem;
private EnforcedAdmin mDebuggingFeaturesDisallowedAdmin; private EnforcedAdmin mDebuggingFeaturesDisallowedAdmin;
private boolean mDebuggingFeaturesDisallowedBySystem; private boolean mDebuggingFeaturesDisallowedBySystem;
private IRegionalizationService mRegionalizationService = null;
@Override @Override
protected int getMetricsCategory() { protected int getMetricsCategory() {
...@@ -113,12 +126,32 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In ...@@ -113,12 +126,32 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
} }
setValueSummary(KEY_BASEBAND_VERSION, "gsm.version.baseband"); setValueSummary(KEY_BASEBAND_VERSION, "gsm.version.baseband");
setStringSummary(KEY_DEVICE_MODEL, Build.MODEL + DeviceInfoUtils.getMsvSuffix());
setValueSummary(KEY_EQUIPMENT_ID, PROPERTY_EQUIPMENT_ID); setValueSummary(KEY_EQUIPMENT_ID, PROPERTY_EQUIPMENT_ID);
setStringSummary(KEY_DEVICE_MODEL, Build.MODEL); setStringSummary(KEY_DEVICE_MODEL, Build.MODEL);
setStringSummary(KEY_BUILD_NUMBER, Build.DISPLAY); setStringSummary(KEY_BUILD_NUMBER, Build.DISPLAY);
findPreference(KEY_BUILD_NUMBER).setEnabled(true); findPreference(KEY_BUILD_NUMBER).setEnabled(true);
findPreference(KEY_KERNEL_VERSION).setSummary(DeviceInfoUtils.getFormattedKernelVersion()); //setValueSummary(KEY_QGP_VERSION, PROPERTY_QGP_VERSION);
// Remove QGP Version if property is not present
//removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_QGP_VERSION,
// PROPERTY_QGP_VERSION);
String mQGPVersion = getQGPVersionValue();
setStringSummary(KEY_QGP_VERSION, mQGPVersion);
if(mQGPVersion == null){
getPreferenceScreen().removePreference(findPreference(KEY_QGP_VERSION));
}
findPreference(KEY_KERNEL_VERSION).setSummary(DeviceInfoUtils.customizeFormatKernelVersion(
getResources().getBoolean(R.bool.def_hide_kernel_version_name)));
String mMbnVersion = getMBNVersionValue();
setStringSummary(KEY_MBN_VERSION, mMbnVersion);
if(mMbnVersion == null){
getPreferenceScreen().removePreference(findPreference(KEY_MBN_VERSION));
}
findPreference(KEY_MOD_VERSION).setSummary(
cyanogenmod.os.Build.CYANOGENMOD_DISPLAY_VERSION);
findPreference(KEY_MOD_VERSION).setEnabled(true);
setValueSummary(KEY_MOD_BUILD_DATE, "ro.build.date");
setExplicitValueSummary(KEY_MOD_API_LEVEL, constructApiLevelString());
findPreference(KEY_MOD_API_LEVEL).setEnabled(true);
if (!SELinux.isSELinuxEnabled()) { if (!SELinux.isSELinuxEnabled()) {
String status = getResources().getString(R.string.selinux_status_disabled); String status = getResources().getString(R.string.selinux_status_disabled);
...@@ -128,6 +161,9 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In ...@@ -128,6 +161,9 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
setStringSummary(KEY_SELINUX_STATUS, status); setStringSummary(KEY_SELINUX_STATUS, status);
} }
setStringSummary(KEY_DEVICE_NAME, Build.PRODUCT);
removePreferenceIfBoolFalse(KEY_DEVICE_NAME, R.bool.config_displayDeviceName);
// Remove selinux information if property is not present // Remove selinux information if property is not present
removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_SELINUX_STATUS, removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_SELINUX_STATUS,
PROPERTY_SELINUX_STATUS); PROPERTY_SELINUX_STATUS);
...@@ -175,6 +211,15 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In ...@@ -175,6 +211,15 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
// Remove manual entry if none present. // Remove manual entry if none present.
removePreferenceIfBoolFalse(KEY_MANUAL, R.bool.config_show_manual); removePreferenceIfBoolFalse(KEY_MANUAL, R.bool.config_show_manual);
// Remove regulatory information if none present or config_show_regulatory_info is disabled
final Intent intent = new Intent(Settings.ACTION_SHOW_REGULATORY_INFO);
if (getPackageManager().queryIntentActivities(intent, 0).isEmpty()
|| !getResources().getBoolean(R.bool.config_show_regulatory_info)) {
Preference pref = findPreference(KEY_REGULATORY_INFO);
if (pref != null) {
getPreferenceScreen().removePreference(pref);
}
}
// Remove regulatory labels if no activity present to handle intent. // Remove regulatory labels if no activity present to handle intent.
removePreferenceIfActivityMissing( removePreferenceIfActivityMissing(
KEY_REGULATORY_INFO, Settings.ACTION_SHOW_REGULATORY_INFO); KEY_REGULATORY_INFO, Settings.ACTION_SHOW_REGULATORY_INFO);
...@@ -202,7 +247,8 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In ...@@ -202,7 +247,8 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
@Override @Override
public boolean onPreferenceTreeClick(Preference preference) { public boolean onPreferenceTreeClick(Preference preference) {
if (preference.getKey().equals(KEY_FIRMWARE_VERSION)) { if (preference.getKey().equals(KEY_FIRMWARE_VERSION)
|| preference.getKey().equals(KEY_MOD_VERSION)) {
System.arraycopy(mHits, 1, mHits, 0, mHits.length-1); System.arraycopy(mHits, 1, mHits, 0, mHits.length-1);
mHits[mHits.length-1] = SystemClock.uptimeMillis(); mHits[mHits.length-1] = SystemClock.uptimeMillis();
if (mHits[0] >= (SystemClock.uptimeMillis()-500)) { if (mHits[0] >= (SystemClock.uptimeMillis()-500)) {
...@@ -216,6 +262,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In ...@@ -216,6 +262,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
} }
Intent intent = new Intent(Intent.ACTION_MAIN); Intent intent = new Intent(Intent.ACTION_MAIN);
intent.putExtra("is_lineage", preference.getKey().equals(KEY_MOD_VERSION));
intent.setClassName("android", intent.setClassName("android",
com.android.internal.app.PlatLogoActivity.class.getName()); com.android.internal.app.PlatLogoActivity.class.getName());
try { try {
...@@ -251,7 +298,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In ...@@ -251,7 +298,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
if (mDevHitToast != null) { if (mDevHitToast != null) {
mDevHitToast.cancel(); mDevHitToast.cancel();
} }
mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_on, mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_on_cm,
Toast.LENGTH_LONG); Toast.LENGTH_LONG);
mDevHitToast.show(); mDevHitToast.show();
// This is good time to index the Developer Options // This is good time to index the Developer Options
...@@ -265,7 +312,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In ...@@ -265,7 +312,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
mDevHitToast.cancel(); mDevHitToast.cancel();
} }
mDevHitToast = Toast.makeText(getActivity(), getResources().getQuantityString( mDevHitToast = Toast.makeText(getActivity(), getResources().getQuantityString(
R.plurals.show_dev_countdown, mDevHitCountdown, mDevHitCountdown), R.plurals.show_dev_countdown_cm, mDevHitCountdown, mDevHitCountdown),
Toast.LENGTH_SHORT); Toast.LENGTH_SHORT);
mDevHitToast.show(); mDevHitToast.show();
} }
...@@ -273,7 +320,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In ...@@ -273,7 +320,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
if (mDevHitToast != null) { if (mDevHitToast != null) {
mDevHitToast.cancel(); mDevHitToast.cancel();
} }
mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_already, mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_already_cm,
Toast.LENGTH_LONG); Toast.LENGTH_LONG);
mDevHitToast.show(); mDevHitToast.show();
} }
...@@ -360,6 +407,47 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In ...@@ -360,6 +407,47 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
} }
} }
private String getMBNVersionValue() {
String mVersion = null;
if (RegionalizationEnvironment.isSupported()) {
mRegionalizationService = RegionalizationEnvironment.getRegionalizationService();
}
if(mRegionalizationService != null){
try{
if(!mRegionalizationService.checkFileExists(MBN_VERSION_PATH))
return null;
if(mRegionalizationService.readFile(MBN_VERSION_PATH, "").size() > 0){
mVersion = mRegionalizationService.readFile(MBN_VERSION_PATH, "").get(0);
}
Log.d(LOG_TAG,"read MBNVersion="+mVersion);
}catch (Exception e) {
Log.e(LOG_TAG, "IOException:"+ e.getMessage());
}
}
return mVersion;
}
private String getQGPVersionValue() {
String mVersion = null;
if (RegionalizationEnvironment.isSupported()) {
mRegionalizationService = RegionalizationEnvironment.getRegionalizationService();
}
if(mRegionalizationService != null){
try{
if(!mRegionalizationService.checkFileExists(QGP_VERSION_PATH))
return null;
if(mRegionalizationService.readFile(QGP_VERSION_PATH, "").size() > 0){
mVersion = mRegionalizationService.readFile(QGP_VERSION_PATH, "").get(0);
}
Log.d(LOG_TAG,"read QGPVersion="+mVersion);
}catch (Exception e) {
Log.e(LOG_TAG, "IOException:"+ e.getMessage());
}
}
return mVersion;
}
private void setValueSummary(String preference, String property) { private void setValueSummary(String preference, String property) {
try { try {
findPreference(preference).setSummary( findPreference(preference).setSummary(
...@@ -370,6 +458,14 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In ...@@ -370,6 +458,14 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
} }
} }
private void setExplicitValueSummary(String preference, String value) {
try {
findPreference(preference).setSummary(value);
} catch (RuntimeException e) {
// No recovery
}
}
private void sendFeedback() { private void sendFeedback() {
String reporterPackage = DeviceInfoUtils.getFeedbackReporterPackage(getActivity()); String reporterPackage = DeviceInfoUtils.getFeedbackReporterPackage(getActivity());
if (TextUtils.isEmpty(reporterPackage)) { if (TextUtils.isEmpty(reporterPackage)) {
...@@ -380,6 +476,14 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In ...@@ -380,6 +476,14 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
startActivityForResult(intent, 0); startActivityForResult(intent, 0);
} }
private static String constructApiLevelString() {
int sdkInt = cyanogenmod.os.Build.CM_VERSION.SDK_INT;
StringBuilder builder = new StringBuilder();
builder.append(cyanogenmod.os.Build.getNameForSDKInt(sdkInt))
.append(" (" + sdkInt + ")");
return builder.toString();
}
private static class SummaryProvider implements SummaryLoader.SummaryProvider { private static class SummaryProvider implements SummaryLoader.SummaryProvider {
private final Context mContext; private final Context mContext;
......
...@@ -41,6 +41,12 @@ public class DimmableIconPreference extends RestrictedPreference { ...@@ -41,6 +41,12 @@ public class DimmableIconPreference extends RestrictedPreference {
this(context, (AttributeSet) null); this(context, (AttributeSet) null);
} }
public DimmableIconPreference(Context context, AttributeSet attrs, int defStyleAttr,
@Nullable CharSequence contentDescription) {
super(context, attrs, defStyleAttr);
mContentDescription = contentDescription;
}
public DimmableIconPreference(Context context, AttributeSet attrs) { public DimmableIconPreference(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
mContentDescription = null; mContentDescription = null;
...@@ -53,7 +59,7 @@ public class DimmableIconPreference extends RestrictedPreference { ...@@ -53,7 +59,7 @@ public class DimmableIconPreference extends RestrictedPreference {
useAdminDisabledSummary(true); useAdminDisabledSummary(true);
} }
private void dimIcon(boolean dimmed) { protected void dimIcon(boolean dimmed) {
Drawable icon = getIcon(); Drawable icon = getIcon();
if (icon != null) { if (icon != null) {
icon.mutate().setAlpha(dimmed ? ICON_ALPHA_DISABLED : ICON_ALPHA_ENABLED); icon.mutate().setAlpha(dimmed ? ICON_ALPHA_DISABLED : ICON_ALPHA_ENABLED);
......
...@@ -41,6 +41,7 @@ import android.support.v7.preference.DropDownPreference; ...@@ -41,6 +41,7 @@ import android.support.v7.preference.DropDownPreference;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceChangeListener; import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.PreferenceCategory;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
...@@ -69,6 +70,8 @@ import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; ...@@ -69,6 +70,8 @@ import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import cyanogenmod.hardware.CMHardwareManager;
public class DisplaySettings extends SettingsPreferenceFragment implements public class DisplaySettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener, Indexable { Preference.OnPreferenceChangeListener, Indexable {
private static final String TAG = "DisplaySettings"; private static final String TAG = "DisplaySettings";
...@@ -76,6 +79,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements ...@@ -76,6 +79,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
/** If there is no setting in the provider, use this. */ /** If there is no setting in the provider, use this. */
private static final int FALLBACK_SCREEN_TIMEOUT_VALUE = 30000; private static final int FALLBACK_SCREEN_TIMEOUT_VALUE = 30000;
private static final String KEY_CATEGORY_DISPLAY = "display";
private static final String KEY_SCREEN_TIMEOUT = "screen_timeout"; private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
private static final String KEY_FONT_SIZE = "font_size"; private static final String KEY_FONT_SIZE = "font_size";
private static final String KEY_SCREEN_SAVER = "screensaver"; private static final String KEY_SCREEN_SAVER = "screensaver";
...@@ -87,6 +91,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements ...@@ -87,6 +91,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
private static final String KEY_NIGHT_DISPLAY = "night_display"; private static final String KEY_NIGHT_DISPLAY = "night_display";
private static final String KEY_NIGHT_MODE = "night_mode"; private static final String KEY_NIGHT_MODE = "night_mode";
private static final String KEY_CAMERA_GESTURE = "camera_gesture"; private static final String KEY_CAMERA_GESTURE = "camera_gesture";
private static final String KEY_WALLPAPER = "wallpaper"; private static final String KEY_WALLPAPER = "wallpaper";
private static final String KEY_VR_DISPLAY_PREF = "vr_display_pref"; private static final String KEY_VR_DISPLAY_PREF = "vr_display_pref";
...@@ -114,6 +119,9 @@ public class DisplaySettings extends SettingsPreferenceFragment implements ...@@ -114,6 +119,9 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
addPreferencesFromResource(R.xml.display_settings); addPreferencesFromResource(R.xml.display_settings);
PreferenceCategory displayPrefs = (PreferenceCategory)
findPreference(KEY_CATEGORY_DISPLAY);
mScreenSaverPreference = findPreference(KEY_SCREEN_SAVER); mScreenSaverPreference = findPreference(KEY_SCREEN_SAVER);
if (mScreenSaverPreference != null if (mScreenSaverPreference != null
&& getResources().getBoolean( && getResources().getBoolean(
...@@ -122,120 +130,135 @@ public class DisplaySettings extends SettingsPreferenceFragment implements ...@@ -122,120 +130,135 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
} }
mScreenTimeoutPreference = (TimeoutListPreference) findPreference(KEY_SCREEN_TIMEOUT); mScreenTimeoutPreference = (TimeoutListPreference) findPreference(KEY_SCREEN_TIMEOUT);
mFontSizePref = findPreference(KEY_FONT_SIZE); mFontSizePref = findPreference(KEY_FONT_SIZE);
if (isAutomaticBrightnessAvailable(getResources())) { if (displayPrefs != null) {
mAutoBrightnessPreference = (SwitchPreference) findPreference(KEY_AUTO_BRIGHTNESS); mAutoBrightnessPreference = (SwitchPreference) findPreference(KEY_AUTO_BRIGHTNESS);
mAutoBrightnessPreference.setOnPreferenceChangeListener(this); if (mAutoBrightnessPreference != null) {
} else { if (isAutomaticBrightnessAvailable(getResources())) {
removePreference(KEY_AUTO_BRIGHTNESS); mAutoBrightnessPreference.setOnPreferenceChangeListener(this);
} } else {
displayPrefs.removePreference(mAutoBrightnessPreference);
}
}
if (!NightDisplayController.isAvailable(activity)) { if (!NightDisplayController.isAvailable(activity)) {
removePreference(KEY_NIGHT_DISPLAY); removePreference(KEY_NIGHT_DISPLAY);
} }
if (isLiftToWakeAvailable(activity)) {
mLiftToWakePreference = (SwitchPreference) findPreference(KEY_LIFT_TO_WAKE); mLiftToWakePreference = (SwitchPreference) findPreference(KEY_LIFT_TO_WAKE);
mLiftToWakePreference.setOnPreferenceChangeListener(this); if (mLiftToWakePreference != null) {
} else { if (isLiftToWakeAvailable(activity)) {
removePreference(KEY_LIFT_TO_WAKE); mLiftToWakePreference.setOnPreferenceChangeListener(this);
} } else {
displayPrefs.removePreference(mLiftToWakePreference);
}
}
if (isDozeAvailable(activity)) {
mDozePreference = (SwitchPreference) findPreference(KEY_DOZE); mDozePreference = (SwitchPreference) findPreference(KEY_DOZE);
mDozePreference.setOnPreferenceChangeListener(this); if (mDozePreference != null) {
} else { if (isDozeAvailable(activity)) {
removePreference(KEY_DOZE); mDozePreference.setOnPreferenceChangeListener(this);
} } else {
displayPrefs.removePreference(mDozePreference);
}
}
if (isTapToWakeAvailable(getResources())) {
mTapToWakePreference = (SwitchPreference) findPreference(KEY_TAP_TO_WAKE); mTapToWakePreference = (SwitchPreference) findPreference(KEY_TAP_TO_WAKE);
mTapToWakePreference.setOnPreferenceChangeListener(this); if (mTapToWakePreference != null) {
} else { if (isTapToWakeAvailable(getResources())) {
removePreference(KEY_TAP_TO_WAKE); mTapToWakePreference.setOnPreferenceChangeListener(this);
} } else {
displayPrefs.removePreference(mTapToWakePreference);
}
}
if (isCameraGestureAvailable(getResources())) {
mCameraGesturePreference = (SwitchPreference) findPreference(KEY_CAMERA_GESTURE); mCameraGesturePreference = (SwitchPreference) findPreference(KEY_CAMERA_GESTURE);
mCameraGesturePreference.setOnPreferenceChangeListener(this); if (mCameraGesturePreference != null) {
} else { if (isCameraGestureAvailable(getResources())) {
removePreference(KEY_CAMERA_GESTURE); mCameraGesturePreference.setOnPreferenceChangeListener(this);
} } else {
displayPrefs.removePreference(mCameraGesturePreference);
}
}
if (RotationPolicy.isRotationLockToggleVisible(activity)) {
DropDownPreference rotatePreference = DropDownPreference rotatePreference =
(DropDownPreference) findPreference(KEY_AUTO_ROTATE); (DropDownPreference) findPreference(KEY_AUTO_ROTATE);
int rotateLockedResourceId; if (rotatePreference != null) {
// The following block sets the string used when rotation is locked. if (RotationPolicy.isRotationLockToggleVisible(activity)) {
// If the device locks specifically to portrait or landscape (rather than current int rotateLockedResourceId;
// rotation), then we use a different string to include this information. // The following block sets the string used when rotation is locked.
if (allowAllRotations(activity)) { // If the device locks specifically to portrait or landscape (rather than current
rotateLockedResourceId = R.string.display_auto_rotate_stay_in_current; // rotation), then we use a different string to include this information.
} else { if (allowAllRotations(activity)) {
if (RotationPolicy.getRotationLockOrientation(activity) rotateLockedResourceId = R.string.display_auto_rotate_stay_in_current;
== Configuration.ORIENTATION_PORTRAIT) { } else {
rotateLockedResourceId = if (RotationPolicy.getRotationLockOrientation(activity)
R.string.display_auto_rotate_stay_in_portrait; == Configuration.ORIENTATION_PORTRAIT) {
rotateLockedResourceId =
R.string.display_auto_rotate_stay_in_portrait;
} else {
rotateLockedResourceId =
R.string.display_auto_rotate_stay_in_landscape;
}
}
rotatePreference.setEntries(new CharSequence[] {
activity.getString(R.string.display_auto_rotate_rotate),
activity.getString(rotateLockedResourceId),
});
rotatePreference.setEntryValues(new CharSequence[] { "0", "1" });
rotatePreference.setValueIndex(RotationPolicy.isRotationLocked(activity) ?
1 : 0);
rotatePreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean locked = Integer.parseInt((String) newValue) != 0;
MetricsLogger.action(getActivity(), MetricsEvent.ACTION_ROTATION_LOCK,
locked);
RotationPolicy.setRotationLock(activity, locked);
return true;
}
});
} else { } else {
rotateLockedResourceId = displayPrefs.removePreference(rotatePreference);
R.string.display_auto_rotate_stay_in_landscape;
} }
} }
rotatePreference.setEntries(new CharSequence[] {
activity.getString(R.string.display_auto_rotate_rotate),
activity.getString(rotateLockedResourceId),
});
rotatePreference.setEntryValues(new CharSequence[] { "0", "1" });
rotatePreference.setValueIndex(RotationPolicy.isRotationLocked(activity) ?
1 : 0);
rotatePreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean locked = Integer.parseInt((String) newValue) != 0;
MetricsLogger.action(getActivity(), MetricsEvent.ACTION_ROTATION_LOCK,
locked);
RotationPolicy.setRotationLock(activity, locked);
return true;
}
});
} else {
removePreference(KEY_AUTO_ROTATE);
}
if (isVrDisplayModeAvailable(activity)) {
DropDownPreference vrDisplayPref = DropDownPreference vrDisplayPref =
(DropDownPreference) findPreference(KEY_VR_DISPLAY_PREF); (DropDownPreference) findPreference(KEY_VR_DISPLAY_PREF);
vrDisplayPref.setEntries(new CharSequence[] { if (vrDisplayPref != null) {
activity.getString(R.string.display_vr_pref_low_persistence), if (isVrDisplayModeAvailable(activity)) {
activity.getString(R.string.display_vr_pref_off), vrDisplayPref.setEntries(new CharSequence[] {
}); activity.getString(R.string.display_vr_pref_low_persistence),
vrDisplayPref.setEntryValues(new CharSequence[] { "0", "1" }); activity.getString(R.string.display_vr_pref_off),
});
final Context c = activity; vrDisplayPref.setEntryValues(new CharSequence[] { "0", "1" });
int currentUser = ActivityManager.getCurrentUser();
int current = Settings.Secure.getIntForUser(c.getContentResolver(), final Context c = activity;
Settings.Secure.VR_DISPLAY_MODE, int currentUser = ActivityManager.getCurrentUser();
/*default*/Settings.Secure.VR_DISPLAY_MODE_LOW_PERSISTENCE, int current = Settings.Secure.getIntForUser(c.getContentResolver(),
currentUser); Settings.Secure.VR_DISPLAY_MODE,
vrDisplayPref.setValueIndex(current); /*default*/Settings.Secure.VR_DISPLAY_MODE_LOW_PERSISTENCE,
vrDisplayPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { currentUser);
@Override vrDisplayPref.setValueIndex(current);
public boolean onPreferenceChange(Preference preference, Object newValue) { vrDisplayPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
int i = Integer.parseInt((String) newValue); @Override
int u = ActivityManager.getCurrentUser(); public boolean onPreferenceChange(Preference preference, Object newValue) {
if (!Settings.Secure.putIntForUser(c.getContentResolver(), int i = Integer.parseInt((String) newValue);
Settings.Secure.VR_DISPLAY_MODE, int u = ActivityManager.getCurrentUser();
i, u)) { if (!Settings.Secure.putIntForUser(c.getContentResolver(),
Log.e(TAG, "Could not change setting for " + Settings.Secure.VR_DISPLAY_MODE,
Settings.Secure.VR_DISPLAY_MODE); i, u)) {
} Log.e(TAG, "Could not change setting for " +
return true; Settings.Secure.VR_DISPLAY_MODE);
}
return true;
}
});
} else {
displayPrefs.removePreference(vrDisplayPref);
} }
}); }
} else {
removePreference(KEY_VR_DISPLAY_PREF);
} }
mNightModePreference = (ListPreference) findPreference(KEY_NIGHT_MODE); mNightModePreference = (ListPreference) findPreference(KEY_NIGHT_MODE);
...@@ -545,6 +568,14 @@ public class DisplaySettings extends SettingsPreferenceFragment implements ...@@ -545,6 +568,14 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
if (!isVrDisplayModeAvailable(context)) { if (!isVrDisplayModeAvailable(context)) {
result.add(KEY_VR_DISPLAY_PREF); result.add(KEY_VR_DISPLAY_PREF);
} }
if (!context.getResources().getBoolean(
org.cyanogenmod.platform.internal.R.bool.config_proximityCheckOnWake)) {
result.add("proximity_on_wake");
}
if (!CMHardwareManager.getInstance(context).
isSupported(CMHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)) {
result.add("high_touch_sensitivity_enable");
}
return result; return result;
} }
}; };
......
/*
* Copyright (C) 2013 The CyanogenMod 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.settings;
import android.content.Context;
import android.os.SystemProperties;
import android.provider.Settings;
import android.support.v7.preference.EditTextPreference;
import android.util.AttributeSet;
import android.util.Log;
import cyanogenmod.providers.CMSettings;
public class HostnamePreference extends EditTextPreference {
private static final String TAG = "HostnamePreference";
private static final String PROP_HOSTNAME = "net.hostname";
public HostnamePreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setSummary(getText());
}
public HostnamePreference(Context context, AttributeSet attrs) {
this(context, attrs, com.android.internal.R.attr.editTextPreferenceStyle);
}
public HostnamePreference(Context context) {
this(context, null);
}
@Override
public void setText(String text) {
if (text == null) {
Log.e(TAG, "tried to set null hostname, request ignored");
return;
}
// remove any character that is not alphanumeric, period, or hyphen
text = text.replaceAll("[^-.a-zA-Z0-9]", "");
if (text.length() == 0) {
Log.w(TAG, "setting empty hostname");
} else {
Log.i(TAG, "hostname has been set: " + text);
}
SystemProperties.set(PROP_HOSTNAME, text);
persistHostname(text);
setSummary(text);
}
@Override
public String getText() {
return SystemProperties.get(PROP_HOSTNAME);
}
@Override
public void onSetInitialValue(boolean restoreValue, Object defaultValue) {
persistHostname(getText());
}
public void persistHostname(String hostname) {
CMSettings.Secure.putString(getContext().getContentResolver(),
CMSettings.Secure.DEVICE_HOSTNAME, hostname);
}
}
/*
Copyright (c) 2015, The Linux Foundation. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of The Linux Foundation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.android.settings;
import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Switch;
import android.widget.TextView;
public class HotspotPreference extends Preference implements OnCheckedChangeListener {
private Switch mSwitch;
private TextView mSubSummary;
private Context mContext;
private boolean mSwitchEnabled;
private CharSequence mSummary;
public HotspotPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mContext = context;
}
public HotspotPreference(Context context, AttributeSet attrs) {
this(context, attrs, com.android.internal.R.attr.switchPreferenceStyle);
mContext = context;
}
public HotspotPreference(Context context) {
this(context, null);
mContext = context;
}
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
if (mSubSummary == null) {
mSubSummary = (TextView) view.findViewById(R.id.subsummary);
if (mSummary != null && !mSummary.toString().isEmpty()) {
mSubSummary.setVisibility(View.VISIBLE);
} else {
mSubSummary.setVisibility(View.GONE);
}
mSubSummary.setText(mSummary);
}
if (mSwitch == null) {
mSwitch = (Switch) view.findViewById(R.id.switchWidget);
mSwitch.setOnCheckedChangeListener(this);
setChecked(mSwitchEnabled);
}
}
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
callChangeListener(isChecked);
mSwitchEnabled = isChecked;
}
public void setSummary(CharSequence summary) {
mSummary = summary;
if (mSubSummary == null) {
return;
}
mSubSummary.setVisibility(summary != null ? View.VISIBLE : View.GONE);
mSubSummary.setText(summary);
}
public void setChecked(boolean state) {
if (mSwitch != null) {
mSwitch.setOnCheckedChangeListener(null);
mSwitch.setChecked(state);
mSwitch.setOnCheckedChangeListener(this);
}
mSwitchEnabled = state;
}
}
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.android.settings; package com.android.settings;
import android.app.ActionBar;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
...@@ -35,13 +36,9 @@ import android.view.LayoutInflater; ...@@ -35,13 +36,9 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabContentFactory;
import android.widget.TabHost.TabSpec;
import android.widget.TabWidget;
import android.widget.Toast; import android.widget.Toast;
import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.internal.telephony.IccCardConstants.State;
import com.android.internal.telephony.Phone; import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory; import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.TelephonyIntents; import com.android.internal.telephony.TelephonyIntents;
...@@ -70,6 +67,9 @@ public class IccLockSettings extends SettingsPreferenceFragment ...@@ -70,6 +67,9 @@ public class IccLockSettings extends SettingsPreferenceFragment
// State when entering the new pin - second time // State when entering the new pin - second time
private static final int ICC_REENTER_MODE = 4; private static final int ICC_REENTER_MODE = 4;
static final String EXTRA_SUB_ID = "slot_id";
static final String EXTRA_SUB_DISPLAY_NAME = "sub_display_name";
// Keys in xml file // Keys in xml file
private static final String PIN_DIALOG = "sim_pin"; private static final String PIN_DIALOG = "sim_pin";
private static final String PIN_TOGGLE = "sim_toggle"; private static final String PIN_TOGGLE = "sim_toggle";
...@@ -96,10 +96,6 @@ public class IccLockSettings extends SettingsPreferenceFragment ...@@ -96,10 +96,6 @@ public class IccLockSettings extends SettingsPreferenceFragment
// Are we trying to enable or disable ICC lock? // Are we trying to enable or disable ICC lock?
private boolean mToState; private boolean mToState;
private TabHost mTabHost;
private TabWidget mTabWidget;
private ListView mListView;
private Phone mPhone; private Phone mPhone;
private EditPinPreference mPinDialog; private EditPinPreference mPinDialog;
...@@ -200,44 +196,20 @@ public class IccLockSettings extends SettingsPreferenceFragment ...@@ -200,44 +196,20 @@ public class IccLockSettings extends SettingsPreferenceFragment
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public void onActivityCreated(Bundle savedInstanceState) {
Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState);
final TelephonyManager tm =
(TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
final int numSims = tm.getSimCount();
if (numSims > 1) {
View view = inflater.inflate(R.layout.icc_lock_tabs, container, false);
final ViewGroup prefs_container = (ViewGroup) view.findViewById(R.id.prefs_container);
Utils.prepareCustomPreferencesList(container, view, prefs_container, false);
View prefs = super.onCreateView(inflater, prefs_container, savedInstanceState);
prefs_container.addView(prefs);
mTabHost = (TabHost) view.findViewById(android.R.id.tabhost);
mTabWidget = (TabWidget) view.findViewById(android.R.id.tabs);
mListView = (ListView) view.findViewById(android.R.id.list);
mTabHost.setup();
mTabHost.setOnTabChangedListener(mTabListener);
mTabHost.clearAllTabs();
SubscriptionManager sm = SubscriptionManager.from(getContext());
for (int i = 0; i < numSims; ++i) {
final SubscriptionInfo subInfo = sm.getActiveSubscriptionInfoForSimSlotIndex(i);
mTabHost.addTab(buildTabSpec(String.valueOf(i),
String.valueOf(subInfo == null
? getContext().getString(R.string.sim_editor_title, i + 1)
: subInfo.getDisplayName())));
}
final SubscriptionInfo sir = sm.getActiveSubscriptionInfoForSimSlotIndex(0);
mPhone = (sir == null) ? null Intent intent = getActivity().getIntent();
: PhoneFactory.getPhone(SubscriptionManager.getPhoneId(sir.getSubscriptionId())); ActionBar actionBar = getActivity().getActionBar();
return view; if (actionBar != null) {
} else { actionBar.setSubtitle(intent.getStringExtra(EXTRA_SUB_DISPLAY_NAME));
mPhone = PhoneFactory.getDefaultPhone();
return super.onCreateView(inflater, container, savedInstanceState);
} }
int subId = intent.getIntExtra(EXTRA_SUB_ID,
SubscriptionManager.getDefaultSubscriptionId());
int phoneId = SubscriptionManager.getPhoneId(subId);
mPhone = PhoneFactory.getPhone(phoneId);
} }
@Override @Override
...@@ -247,11 +219,22 @@ public class IccLockSettings extends SettingsPreferenceFragment ...@@ -247,11 +219,22 @@ public class IccLockSettings extends SettingsPreferenceFragment
} }
private void updatePreferences() { private void updatePreferences() {
mPinDialog.setEnabled(mPhone != null); if (mPinDialog == null || mPinToggle == null)
mPinToggle.setEnabled(mPhone != null); return;
if (mPhone != null) { if (mPhone != null) {
if (mPhone.getIccCard().getState() != State.READY) {
// if SIM State is NOT READY, it is not possible to interact with UICC app
// for enabling/disabling PIN so greyout PIN options.
mPinToggle.setEnabled(false);
mPinDialog.setEnabled(false);
} else {
mPinToggle.setEnabled(true);
mPinDialog.setEnabled(true);
}
mPinToggle.setChecked(mPhone.getIccCard().getIccLockEnabled()); mPinToggle.setChecked(mPhone.getIccCard().getIccLockEnabled());
} else {
mPinDialog.setEnabled(false);
mPinToggle.setEnabled(false);
} }
} }
...@@ -489,31 +472,4 @@ public class IccLockSettings extends SettingsPreferenceFragment ...@@ -489,31 +472,4 @@ public class IccLockSettings extends SettingsPreferenceFragment
setDialogValues(); setDialogValues();
mDialogState = OFF_MODE; mDialogState = OFF_MODE;
} }
private OnTabChangeListener mTabListener = new OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
final int slotId = Integer.parseInt(tabId);
final SubscriptionInfo sir = SubscriptionManager.from(getActivity().getBaseContext())
.getActiveSubscriptionInfoForSimSlotIndex(slotId);
mPhone = (sir == null) ? null
: PhoneFactory.getPhone(SubscriptionManager.getPhoneId(sir.getSubscriptionId()));
// The User has changed tab; update the body.
updatePreferences();
}
};
private TabContentFactory mEmptyTabContent = new TabContentFactory() {
@Override
public View createTabContent(String tag) {
return new View(mTabHost.getContext());
}
};
private TabSpec buildTabSpec(String tag, String title) {
return mTabHost.newTabSpec(tag).setIndicator(title).setContent(
mEmptyTabContent);
}
} }
...@@ -22,9 +22,14 @@ import android.content.Intent; ...@@ -22,9 +22,14 @@ import android.content.Intent;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.SystemProperties;
import android.provider.SearchIndexableResource; import android.provider.SearchIndexableResource;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;
import android.util.Log;
import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.BaseSearchIndexProvider;
...@@ -36,10 +41,15 @@ import java.util.List; ...@@ -36,10 +41,15 @@ import java.util.List;
public class LegalSettings extends SettingsPreferenceFragment implements Indexable { public class LegalSettings extends SettingsPreferenceFragment implements Indexable {
private static final String LOG_TAG = "LegalSettings";
private static final String KEY_TERMS = "terms"; private static final String KEY_TERMS = "terms";
private static final String KEY_LICENSE = "license"; private static final String KEY_LICENSE = "license";
private static final String KEY_COPYRIGHT = "copyright"; private static final String KEY_COPYRIGHT = "copyright";
private static final String KEY_WEBVIEW_LICENSE = "webview_license"; private static final String KEY_WEBVIEW_LICENSE = "webview_license";
private static final String PROPERTY_CMLICENSE_URL = "ro.cmlegal.url";
private static final String PROPERTY_ELICENSE_URL = "ro.elegal.url";
private static final String KEY_CM_LICENSE = "cmlicense";
private static final String KEY_E_LICENSE = "elicense";
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
...@@ -58,6 +68,34 @@ public class LegalSettings extends SettingsPreferenceFragment implements Indexab ...@@ -58,6 +68,34 @@ public class LegalSettings extends SettingsPreferenceFragment implements Indexab
Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY); Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
} }
@Override
public boolean onPreferenceTreeClick(Preference preference) {
boolean clickOnELicense = preference.getKey().equals(KEY_E_LICENSE);
boolean clickOnCMLicense = preference.getKey().equals(KEY_CM_LICENSE);
if (clickOnELicense || clickOnCMLicense) {
String userLicenseUrl = "";
if (clickOnELicense) {
userLicenseUrl = SystemProperties.get(PROPERTY_ELICENSE_URL);
} else if (clickOnCMLicense) {
userLicenseUrl = SystemProperties.get(PROPERTY_CMLICENSE_URL);
}
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setData(Uri.parse(userLicenseUrl));
try {
startActivity(intent);
} catch (Exception e) {
Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
}
}
return super.onPreferenceTreeClick(preference);
}
@Override @Override
protected int getMetricsCategory() { protected int getMetricsCategory() {
return MetricsEvent.ABOUT_LEGAL_SETTINGS; return MetricsEvent.ABOUT_LEGAL_SETTINGS;
......
...@@ -252,6 +252,10 @@ public class MasterClear extends OptionsMenuFragment ...@@ -252,6 +252,10 @@ public class MasterClear extends OptionsMenuFragment
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
Account account = accounts[i]; Account account = accounts[i];
if (!Utils.showAccount(context, account.type)) {
// If needn't to show the account, skip this account.
continue;
}
AuthenticatorDescription desc = null; AuthenticatorDescription desc = null;
for (int j = 0; j < M; j++) { for (int j = 0; j < M; j++) {
if (account.type.equals(descs[j].type)) { if (account.type.equals(descs[j].type)) {
......
/*
* Copyright (C) 2008 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.settings;
import android.os.Bundle;
import android.content.Intent;
import android.content.ComponentName;
import android.app.Fragment;
import android.app.Activity;
public class MicroGSettings extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent("android.intent.action.MAIN");
intent.setComponent(new ComponentName("com.google.android.gms", "org.microg.gms.ui.SettingsActivity"));
startActivity(intent);
Activity activity = getActivity();
if (activity != null) {
activity.finish();
}
}
}
...@@ -61,6 +61,7 @@ public class PrivacySettings extends SettingsPreferenceFragment implements Index ...@@ -61,6 +61,7 @@ public class PrivacySettings extends SettingsPreferenceFragment implements Index
private static final String CONFIGURE_ACCOUNT = "configure_account"; private static final String CONFIGURE_ACCOUNT = "configure_account";
private static final String DATA_MANAGEMENT = "data_management"; private static final String DATA_MANAGEMENT = "data_management";
private static final String BACKUP_INACTIVE = "backup_inactive"; private static final String BACKUP_INACTIVE = "backup_inactive";
private static final String NETWORK_RESET = "network_reset";
private static final String FACTORY_RESET = "factory_reset"; private static final String FACTORY_RESET = "factory_reset";
private static final String TAG = "PrivacySettings"; private static final String TAG = "PrivacySettings";
private IBackupManager mBackupManager; private IBackupManager mBackupManager;
...@@ -80,7 +81,9 @@ public class PrivacySettings extends SettingsPreferenceFragment implements Index ...@@ -80,7 +81,9 @@ public class PrivacySettings extends SettingsPreferenceFragment implements Index
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Don't allow any access if this is not an admin user. // Don't allow any access if this is not an admin user.
// TODO: backup/restore currently only works with owner user b/22760572 // TODO: backup/restore currently only works with owner user b/22760572
mEnabled = UserManager.get(getActivity()).isAdminUser();
// /e/ Do NOT display Backup & reset item for the moment.
mEnabled = false;//UserManager.get(getActivity()).isAdminUser();
if (!mEnabled) { if (!mEnabled) {
return; return;
} }
...@@ -285,5 +288,10 @@ public class PrivacySettings extends SettingsPreferenceFragment implements Index ...@@ -285,5 +288,10 @@ public class PrivacySettings extends SettingsPreferenceFragment implements Index
UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId())) { UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId())) {
nonVisibleKeys.add(FACTORY_RESET); nonVisibleKeys.add(FACTORY_RESET);
} }
if (RestrictedLockUtils.hasBaseUserRestriction(context,
UserManager.DISALLOW_NETWORK_RESET, UserHandle.myUserId())) {
nonVisibleKeys.add(NETWORK_RESET);
}
} }
} }