diff options
Diffstat (limited to 'src')
10 files changed, 293 insertions, 44 deletions
diff --git a/src/com/android/settings/ChooseLockSettingsHelper.java b/src/com/android/settings/ChooseLockSettingsHelper.java index 327e622..665bffe 100644 --- a/src/com/android/settings/ChooseLockSettingsHelper.java +++ b/src/com/android/settings/ChooseLockSettingsHelper.java @@ -158,10 +158,19 @@ public final class ChooseLockSettingsHelper { intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, hasChallenge); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge); intent.setClassName(ConfirmDeviceCredentialBaseFragment.PACKAGE, activityClass.getName()); - if (mFragment != null) { - mFragment.startActivityForResult(intent, request); + if (external) { + intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); + if (mFragment != null) { + mFragment.startActivity(intent); + } else { + mActivity.startActivity(intent); + } } else { - mActivity.startActivityForResult(intent, request); + if (mFragment != null) { + mFragment.startActivityForResult(intent, request); + } else { + mActivity.startActivityForResult(intent, request); + } } return true; } diff --git a/src/com/android/settings/ColorModePreference.java b/src/com/android/settings/ColorModePreference.java new file mode 100644 index 0000000..e1f00fd --- /dev/null +++ b/src/com/android/settings/ColorModePreference.java @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2015 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.app.AlertDialog.Builder; +import android.content.Context; +import android.content.res.Resources; +import android.hardware.display.DisplayManager; +import android.hardware.display.DisplayManager.DisplayListener; +import android.os.Handler; +import android.os.Looper; +import android.preference.DialogPreference; +import android.util.AttributeSet; +import android.view.Display; +import android.view.Display.ColorTransform; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Checkable; +import android.widget.LinearLayout; +import android.widget.TextView; + +import java.util.ArrayList; + +public class ColorModePreference extends DialogPreference implements + OnClickListener, DisplayListener { + + private DisplayManager mDisplayManager; + private Display mDisplay; + + private int mCurrentIndex; + private ArrayList<ColorTransformDescription> mDescriptions; + + public ColorModePreference(Context context, AttributeSet attrs) { + super(context, attrs); + mDisplayManager = getContext().getSystemService(DisplayManager.class); + } + + public int getTransformsCount() { + return mDescriptions.size(); + } + + public void startListening() { + mDisplayManager.registerDisplayListener(this, new Handler(Looper.getMainLooper())); + } + + public void stopListening() { + mDisplayManager.unregisterDisplayListener(this); + } + + @Override + public void onDisplayAdded(int displayId) { + if (displayId == Display.DEFAULT_DISPLAY) { + updateCurrentAndSupported(); + } + } + + @Override + public void onDisplayChanged(int displayId) { + if (displayId == Display.DEFAULT_DISPLAY) { + updateCurrentAndSupported(); + } + } + + @Override + public void onDisplayRemoved(int displayId) { + } + + public void updateCurrentAndSupported() { + mDisplay = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY); + + mDescriptions = new ArrayList<>(); + + Resources resources = getContext().getResources(); + int[] transforms = resources.getIntArray( + com.android.internal.R.array.config_colorTransforms); + String[] titles = resources.getStringArray(R.array.color_mode_names); + String[] descriptions = resources.getStringArray(R.array.color_mode_descriptions); + // Map the resource information describing color transforms. + for (int i = 0; i < transforms.length; i++) { + if (transforms[i] != -1) { + ColorTransformDescription desc = new ColorTransformDescription(); + desc.colorTransform = transforms[i]; + desc.title = titles[i]; + desc.summary = descriptions[i]; + mDescriptions.add(desc); + } + } + // Match up a ColorTransform to every description. + ColorTransform[] supportedColorTransforms = mDisplay.getSupportedColorTransforms(); + for (int i = 0; i < supportedColorTransforms.length; i++) { + for (int j = 0; j < mDescriptions.size(); j++) { + if (mDescriptions.get(j).colorTransform + == supportedColorTransforms[i].getColorTransform() + && mDescriptions.get(j).transform == null) { + mDescriptions.get(j).transform = supportedColorTransforms[i]; + break; + } + } + } + // Remove any extras that don't have a transform for some reason. + for (int i = 0; i < mDescriptions.size(); i++) { + if (mDescriptions.get(i).transform == null) { + mDescriptions.remove(i--); + } + } + + ColorTransform currentTransform = mDisplay.getColorTransform(); + mCurrentIndex = -1; + for (int i = 0; i < mDescriptions.size(); i++) { + if (mDescriptions.get(i).colorTransform == currentTransform.getColorTransform()) { + mCurrentIndex = i; + break; + } + } + if (mCurrentIndex != -1) { + setSummary(mDescriptions.get(mCurrentIndex).title); + } else { + setSummary(null); + } + } + + @Override + protected View onCreateDialogView() { + LayoutInflater inflater = LayoutInflater.from(getContext()); + LinearLayout v = (LinearLayout) inflater.inflate(R.layout.radio_list_container, null); + for (int i = 0; i < mDescriptions.size(); i++) { + View child = inflater.inflate(R.layout.radio_with_summary, v, false); + ColorTransformDescription desc = mDescriptions.get(i); + child.setTag(desc); + ((TextView) child.findViewById(android.R.id.title)).setText(desc.title); + ((TextView) child.findViewById(android.R.id.summary)).setText(desc.summary); + ((Checkable) child).setChecked(i == mCurrentIndex); + child.setClickable(true); + child.setOnClickListener(this); + v.addView(child); + } + return v; + } + + @Override + protected void onPrepareDialogBuilder(Builder builder) { + super.onPrepareDialogBuilder(builder); + builder.setPositiveButton(null, null); + } + + @Override + public void onClick(View v) { + ColorTransformDescription desc = (ColorTransformDescription) v.getTag(); + + mDisplay.requestColorTransform(desc.transform); + mCurrentIndex = mDescriptions.indexOf(desc); + + setSummary(desc.title); + getDialog().dismiss(); + } + + private static class ColorTransformDescription { + private int colorTransform; + private String title; + private String summary; + private ColorTransform transform; + } +} diff --git a/src/com/android/settings/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/ConfirmDeviceCredentialActivity.java index da39a0f..86935c3 100644 --- a/src/com/android/settings/ConfirmDeviceCredentialActivity.java +++ b/src/com/android/settings/ConfirmDeviceCredentialActivity.java @@ -58,23 +58,12 @@ public class ConfirmDeviceCredentialActivity extends Activity { String title = intent.getStringExtra(KeyguardManager.EXTRA_TITLE); String details = intent.getStringExtra(KeyguardManager.EXTRA_DESCRIPTION); - // Ignore rotates and ensure we only launch this once - if (savedInstanceState == null) { - ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this); - if (!helper.launchConfirmationActivity(0 /* request code */, null /* title */, title, - details, false /* returnCredentials */, true /* isExternal */)) { - Log.d(TAG, "No pattern, password or PIN set."); - setResult(Activity.RESULT_OK); - finish(); - } + ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this); + if (!helper.launchConfirmationActivity(0 /* request code */, null /* title */, title, + details, false /* returnCredentials */, true /* isExternal */)) { + Log.d(TAG, "No pattern, password or PIN set."); + setResult(Activity.RESULT_OK); } - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - boolean credentialsConfirmed = (resultCode == Activity.RESULT_OK); - Log.d(TAG, "Device credentials confirmed: " + credentialsConfirmed); - setResult(credentialsConfirmed ? Activity.RESULT_OK : Activity.RESULT_CANCELED); finish(); } } diff --git a/src/com/android/settings/ConfirmDeviceCredentialBaseActivity.java b/src/com/android/settings/ConfirmDeviceCredentialBaseActivity.java index 176efbc..d9af800 100644 --- a/src/com/android/settings/ConfirmDeviceCredentialBaseActivity.java +++ b/src/com/android/settings/ConfirmDeviceCredentialBaseActivity.java @@ -19,6 +19,7 @@ package com.android.settings; import android.app.Fragment; import android.app.KeyguardManager; import android.os.Bundle; +import android.os.Handler; import android.view.MenuItem; import android.view.WindowManager; @@ -28,6 +29,7 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi private boolean mDark; private boolean mEnterAnimationPending; private boolean mFirstTimeVisible = true; + private final Handler mHandler = new Handler(); @Override protected void onCreate(Bundle savedState) { @@ -67,6 +69,7 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi mFirstTimeVisible = false; prepareEnterAnimation(); mEnterAnimationPending = true; + mHandler.postDelayed(mEnterAnimationCompleteTimeoutRunnable, 1000); } } @@ -82,6 +85,7 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi public void onEnterAnimationComplete() { super.onEnterAnimationComplete(); if (mEnterAnimationPending) { + mHandler.removeCallbacks(mEnterAnimationCompleteTimeoutRunnable); startEnterAnimation(); mEnterAnimationPending = false; } @@ -94,4 +98,15 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi public void startEnterAnimation() { getFragment().startEnterAnimation(); } + + /** + * Workaround for a bug in window manager which results that onEnterAnimationComplete doesn't + * get called in all cases. + */ + private final Runnable mEnterAnimationCompleteTimeoutRunnable = new Runnable() { + @Override + public void run() { + onEnterAnimationComplete(); + } + }; } diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java index de15d4c..536a30e 100644 --- a/src/com/android/settings/DisplaySettings.java +++ b/src/com/android/settings/DisplaySettings.java @@ -79,6 +79,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements private static final String KEY_CAMERA_GESTURE = "camera_gesture"; private static final String KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE = "camera_double_tap_power_gesture"; + private static final String KEY_COLOR_MODE = "color_mode"; private static final int DLG_GLOBAL_CHANGE_WARNING = 1; @@ -96,6 +97,8 @@ public class DisplaySettings extends SettingsPreferenceFragment implements private SwitchPreference mCameraGesturePreference; private SwitchPreference mCameraDoubleTapPowerGesturePreference; + private ColorModePreference mColorModePreference; + @Override protected int getMetricsCategory() { return MetricsLogger.DISPLAY; @@ -171,6 +174,13 @@ public class DisplaySettings extends SettingsPreferenceFragment implements removePreference(KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE); } + mColorModePreference = (ColorModePreference) findPreference(KEY_COLOR_MODE); + mColorModePreference.updateCurrentAndSupported(); + if (mColorModePreference.getTransformsCount() < 2) { + removePreference(KEY_COLOR_MODE); + mColorModePreference = null; + } + if (RotationPolicy.isRotationLockToggleVisible(activity)) { DropDownPreference rotatePreference = (DropDownPreference) findPreference(KEY_AUTO_ROTATE); @@ -360,6 +370,17 @@ public class DisplaySettings extends SettingsPreferenceFragment implements public void onResume() { super.onResume(); updateState(); + if (mColorModePreference != null) { + mColorModePreference.startListening(); + } + } + + @Override + public void onPause() { + super.onPause(); + if (mColorModePreference != null) { + mColorModePreference.stopListening(); + } } @Override @@ -417,6 +438,10 @@ public class DisplaySettings extends SettingsPreferenceFragment implements getContentResolver(), CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0); mCameraDoubleTapPowerGesturePreference.setChecked(value == 0); } + + if (mColorModePreference != null) { + mColorModePreference.updateCurrentAndSupported(); + } } private void updateScreenSaverSummary() { @@ -556,6 +581,11 @@ public class DisplaySettings extends SettingsPreferenceFragment implements if (!isCameraDoubleTapPowerGestureAvailable(context.getResources())) { result.add(KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE); } + ColorModePreference pref = new ColorModePreference(context, null); + pref.updateCurrentAndSupported(); + if (pref.getTransformsCount() < 2) { + result.add(KEY_COLOR_MODE); + } return result; } }; diff --git a/src/com/android/settings/HotspotOffReceiver.java b/src/com/android/settings/HotspotOffReceiver.java index 06ced1f..f3c3fee 100644 --- a/src/com/android/settings/HotspotOffReceiver.java +++ b/src/com/android/settings/HotspotOffReceiver.java @@ -5,6 +5,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.net.wifi.WifiManager; +import android.util.Log; import com.android.settingslib.TetherUtil; @@ -14,11 +15,15 @@ import com.android.settingslib.TetherUtil; */ public class HotspotOffReceiver extends BroadcastReceiver { + private static final String TAG = "HotspotOffReceiver"; + private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); + @Override public void onReceive(Context context, Intent intent) { if (WifiManager.WIFI_AP_STATE_CHANGED_ACTION.equals(intent.getAction())) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (wifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_DISABLED) { + if (DEBUG) Log.d(TAG, "TetherService.cancelRecheckAlarmIfNecessary called"); // The hotspot has been turned off, we don't need to recheck tethering. TetherService.cancelRecheckAlarmIfNecessary(context, TetherUtil.TETHERING_WIFI); } diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java index 6e679b6..840a393 100644 --- a/src/com/android/settings/SecuritySettings.java +++ b/src/com/android/settings/SecuritySettings.java @@ -361,6 +361,8 @@ public class SecuritySettings extends SettingsPreferenceFragment fingerprintCount, fingerprintCount)); clazz = FingerprintSettings.class.getName(); } else { + fingerprintPreference.setSummary( + R.string.security_settings_fingerprint_preference_summary_none); clazz = FingerprintEnrollIntroduction.class.getName(); } intent.setClassName("com.android.settings", clazz); diff --git a/src/com/android/settings/TetherService.java b/src/com/android/settings/TetherService.java index b6effad..346a175 100644 --- a/src/com/android/settings/TetherService.java +++ b/src/com/android/settings/TetherService.java @@ -89,21 +89,28 @@ public class TetherService extends Service { mCurrentTethers.add(type); } } + if (intent.hasExtra(TetherUtil.EXTRA_REM_TETHER_TYPE)) { - int type = intent.getIntExtra(TetherUtil.EXTRA_REM_TETHER_TYPE, - TetherUtil.TETHERING_INVALID); - if (DEBUG) Log.d(TAG, "Removing tether " + type); - int index = mCurrentTethers.indexOf(type); - if (index >= 0) { - mCurrentTethers.remove(index); - // If we are currently in the middle of a check, we may need to adjust the - // index accordingly. - if (index <= mCurrentTypeIndex && mCurrentTypeIndex > 0) { - mCurrentTypeIndex--; + if (!mInProvisionCheck) { + int type = intent.getIntExtra(TetherUtil.EXTRA_REM_TETHER_TYPE, + TetherUtil.TETHERING_INVALID); + int index = mCurrentTethers.indexOf(type); + if (DEBUG) Log.d(TAG, "Removing tether " + type + ", index " + index); + if (index >= 0) { + mCurrentTethers.remove(index); + // If we are currently in the middle of a check, we may need to adjust the + // index accordingly. + if (DEBUG) Log.d(TAG, "mCurrentTypeIndex: " + mCurrentTypeIndex); + if (index <= mCurrentTypeIndex && mCurrentTypeIndex > 0) { + mCurrentTypeIndex--; + } } + cancelAlarmIfNecessary(); + } else { + if (DEBUG) Log.d(TAG, "Don't cancel alarm during provisioning"); } - cancelAlarmIfNecessary(); } + // Only set the alarm if we have one tether, meaning the one just added, // to avoid setting it when it was already set previously for another // type. @@ -199,15 +206,17 @@ public class TetherService extends Service { } private void startProvisioning(int index) { - String provisionAction = getResources().getString( - com.android.internal.R.string.config_mobile_hotspot_provision_app_no_ui); - if (DEBUG) Log.d(TAG, "Sending provisioning broadcast: " + provisionAction + " type: " - + mCurrentTethers.get(index)); - Intent intent = new Intent(provisionAction); - intent.putExtra(TETHER_CHOICE, mCurrentTethers.get(index)); - intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND); - sendBroadcast(intent); - mInProvisionCheck = true; + if (index < mCurrentTethers.size()) { + String provisionAction = getResources().getString( + com.android.internal.R.string.config_mobile_hotspot_provision_app_no_ui); + if (DEBUG) Log.d(TAG, "Sending provisioning broadcast: " + provisionAction + " type: " + + mCurrentTethers.get(index)); + Intent intent = new Intent(provisionAction); + intent.putExtra(TETHER_CHOICE, mCurrentTethers.get(index)); + intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND); + sendBroadcast(intent); + mInProvisionCheck = true; + } } public static void scheduleRecheckAlarm(Context context, int type) { @@ -261,13 +270,14 @@ public class TetherService extends Service { if (DEBUG) Log.d(TAG, "Got provision result " + intent); String provisionResponse = context.getResources().getString( com.android.internal.R.string.config_mobile_hotspot_provision_response); + if (provisionResponse.equals(intent.getAction())) { if (!mInProvisionCheck) { Log.e(TAG, "Unexpected provision response " + intent); return; } - mInProvisionCheck = false; int checkType = mCurrentTethers.get(mCurrentTypeIndex); + mInProvisionCheck = false; if (intent.getIntExtra(EXTRA_RESULT, RESULT_DEFAULT) == RESULT_OK) { if (checkType == TetherUtil.TETHERING_WIFI && mEnableWifiAfterCheck) { enableWifiTetheringIfNeeded(); @@ -286,7 +296,8 @@ public class TetherService extends Service { break; } } - if (++mCurrentTypeIndex == mCurrentTethers.size()) { + + if (++mCurrentTypeIndex >= mCurrentTethers.size()) { // We are done with all checks, time to die. stopSelf(); } else { diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java index a6b0dca..63d9335 100644 --- a/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java +++ b/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java @@ -16,7 +16,6 @@ package com.android.settings.fingerprint; -import android.content.Context; import android.content.Intent; import android.hardware.fingerprint.FingerprintManager; import android.os.Bundle; @@ -32,15 +31,19 @@ public class FingerprintEnrollFindSensor extends FingerprintEnrollBase { private static final int CONFIRM_REQUEST = 1; private static final int ENROLLING = 2; + public static final String EXTRA_KEY_LAUNCHED_CONFIRM = "launched_confirm_lock"; private FingerprintLocationAnimationView mAnimation; + private boolean mLaunchedConfirmLock; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fingerprint_enroll_find_sensor); setHeaderText(R.string.security_settings_fingerprint_enroll_find_sensor_title); - if (mToken == null) { + mLaunchedConfirmLock = savedInstanceState != null && savedInstanceState.getBoolean( + EXTRA_KEY_LAUNCHED_CONFIRM); + if (mToken == null && !mLaunchedConfirmLock) { launchConfirmLock(); } mAnimation = (FingerprintLocationAnimationView) findViewById( @@ -60,6 +63,12 @@ public class FingerprintEnrollFindSensor extends FingerprintEnrollBase { } @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putBoolean(EXTRA_KEY_LAUNCHED_CONFIRM, mLaunchedConfirmLock); + } + + @Override protected void onNextButtonClick() { startActivityForResult(getEnrollingIntent(), ENROLLING); } @@ -107,6 +116,8 @@ public class FingerprintEnrollFindSensor extends FingerprintEnrollBase { // This shouldn't happen, as we should only end up at this step if a lock thingy is // already set. finish(); + } else { + mLaunchedConfirmLock = true; } } diff --git a/src/com/android/settings/fuelgauge/FakeUid.java b/src/com/android/settings/fuelgauge/FakeUid.java index aaa30a2..7fd66c5 100644 --- a/src/com/android/settings/fuelgauge/FakeUid.java +++ b/src/com/android/settings/fuelgauge/FakeUid.java @@ -246,7 +246,7 @@ public class FakeUid extends Uid { } @Override - public long getTimeAtCpuSpeed(int step, int which) { + public long getTimeAtCpuSpeed(int cluster, int step, int which) { return 0; } |