Revert "raphael: parts: Introduce haptic feedback level adjustment"
This reverts commit 83e6e66b64.
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -51,19 +50,6 @@
|
||||
android:permission="PopupCameraService">
|
||||
</service>
|
||||
|
||||
<activity
|
||||
android:name=".haptic.HapticLevelActivity"
|
||||
android:label="@string/haptic_title"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.action.IA_SETTINGS" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.category"
|
||||
android:value="com.android.settings.category.ia.sound" />
|
||||
<meta-data android:name="com.android.settings.summary"
|
||||
android:resource="@string/haptic_summary" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".popupcamera.PopupCameraSettingsActivity"
|
||||
android:exported="false"
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2014, 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"/>
|
||||
@@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 The Android Open Source Project
|
||||
(C) 2018-2020 The LineageOS 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.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@android:id/icon_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@android:id/summary">
|
||||
|
||||
<ImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_gravity="start|center_vertical" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@android:id/icon_frame"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
android:textColor="?android:attr/textColorPrimary" />
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_toEndOf="@android:id/icon_frame"
|
||||
android:maxLines="4"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_below="@android:id/summary"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_toEndOf="@android:id/icon_frame"
|
||||
android:tickMark="@null"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="12dp"
|
||||
style="@android:style/Widget.Material.SeekBar.Discrete" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2022 The LineageOS 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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<!-- Haptic Feedback Levels -->
|
||||
<integer name="haptic_level_default">80</integer>
|
||||
<integer name="haptic_level_max">100</integer>
|
||||
</resources>
|
||||
@@ -39,14 +39,6 @@
|
||||
<string name="popup_camera_calibrate_failed">Couldn\'t calibrate</string>
|
||||
<string name="popup_camera_calibrate_success">Calibrated successfully. You can open the front camera now.</string>
|
||||
|
||||
<!-- Haptic Level Settings -->
|
||||
<string name="haptic_title">Haptic feedback</string>
|
||||
<string name="haptic_warning">Setting-up haptic level too high may cause permanent hardware damage, use at your own risk</string>
|
||||
<string name="haptic_summary">Customize vibration intensity</string>
|
||||
<string name="haptic_level_title">Level</string>
|
||||
<string name="haptic_level_summary">Amount of vibration intensity</string>
|
||||
<string name="haptic_level_summary_incompatible">Feature not supported</string>
|
||||
|
||||
<!-- Clear Speaker -->
|
||||
<string name="clear_speaker_title">Clear speaker</string>
|
||||
<string name="clear_speaker_summary">Play a 30-second audio to clear the speaker</string>
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2018 The LineageOS 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.
|
||||
-->
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/haptic_title">
|
||||
|
||||
<org.lineageos.settings.widget.SeekBarPreference
|
||||
android:key="haptic_level_pref"
|
||||
android:title="@string/haptic_level_title"
|
||||
android:summary="@string/haptic_level_summary"
|
||||
android:layout="@layout/preference_slider"
|
||||
android:defaultValue="@integer/haptic_level_default"
|
||||
android:max="@integer/haptic_level_max" />
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:key="haptic_footer_preference"
|
||||
android:title="@string/haptic_warning"
|
||||
android:selectable="false"
|
||||
android:layout="@layout/preference_footer" />
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -22,7 +22,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import org.lineageos.settings.haptic.HapticUtils;
|
||||
import org.lineageos.settings.popupcamera.PopupCameraUtils;
|
||||
|
||||
public class BootCompletedReceiver extends BroadcastReceiver {
|
||||
@@ -33,7 +32,6 @@ public class BootCompletedReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(final Context context, Intent intent) {
|
||||
if (DEBUG) Log.d(TAG, "Received boot completed intent");
|
||||
HapticUtils.restoreLevel(context);
|
||||
PopupCameraUtils.startService(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2024 The LineageOS 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 org.lineageos.settings.haptic;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
|
||||
|
||||
public class HapticLevelActivity extends CollapsingToolbarBaseActivity {
|
||||
|
||||
private final String TAG_HAPTIC = "haptic_level";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getSupportFragmentManager().beginTransaction().replace(com.android.settingslib.collapsingtoolbar.R.id.content_frame,
|
||||
new HapticLevelFragment(), TAG_HAPTIC).commit();
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2024 The LineageOS 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 org.lineageos.settings.haptic;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import org.lineageos.settings.R;
|
||||
import org.lineageos.settings.utils.FileUtils;
|
||||
import org.lineageos.settings.widget.SeekBarPreference;
|
||||
|
||||
public class HapticLevelFragment extends PreferenceFragmentCompat implements OnPreferenceChangeListener {
|
||||
|
||||
private Vibrator mVibrator;
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.haptic_settings);
|
||||
|
||||
final SeekBarPreference mHapticLevel = (SeekBarPreference) findPreference(HapticUtils.PREF_LEVEL);
|
||||
if (FileUtils.fileExists(HapticUtils.PATH_LEVEL)) {
|
||||
mVibrator = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
|
||||
if (mVibrator == null || !mVibrator.hasVibrator()) {
|
||||
mVibrator = null;
|
||||
}
|
||||
mHapticLevel.setEnabled(true);
|
||||
mHapticLevel.setOnPreferenceChangeListener(this);
|
||||
} else {
|
||||
mHapticLevel.setSummary(R.string.haptic_level_summary_incompatible);
|
||||
mHapticLevel.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
final View view = LayoutInflater.from(getContext()).inflate(R.layout.haptic, container, false);
|
||||
((ViewGroup) view).addView(super.onCreateView(inflater, container, savedInstanceState));
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (HapticUtils.PREF_LEVEL.equals(preference.getKey())) {
|
||||
HapticUtils.applyLevel(getContext(), (int) newValue, true);
|
||||
doHapticFeedback();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void doHapticFeedback() {
|
||||
if (mVibrator == null) {
|
||||
return;
|
||||
}
|
||||
mVibrator.vibrate(VibrationEffect.createOneShot(500,
|
||||
VibrationEffect.DEFAULT_AMPLITUDE));
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The LineageOS 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 org.lineageos.settings.haptic;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.Settings;
|
||||
|
||||
import java.lang.Math;
|
||||
|
||||
import org.lineageos.settings.utils.FileUtils;
|
||||
|
||||
public final class HapticUtils {
|
||||
|
||||
final static String PREF_LEVEL = "haptic_level_pref";
|
||||
final static String PATH_LEVEL = "/sys/module/qti_haptics/parameters/vmax_mv_override";
|
||||
|
||||
final static int MIN_LEVEL = 1;
|
||||
final static int MAX_LEVEL = 3700;
|
||||
|
||||
public static void applyLevel(Context context, int value, boolean test) {
|
||||
if (FileUtils.fileExists(PATH_LEVEL)) {
|
||||
double level = value / 100.0 * (MAX_LEVEL - MIN_LEVEL) + MIN_LEVEL;
|
||||
int newValue = (int) Math.round(level);
|
||||
FileUtils.writeLine(PATH_LEVEL, String.valueOf(newValue));
|
||||
|
||||
if (test) {
|
||||
Vibrator dev = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
if (dev.hasVibrator()) {
|
||||
dev.vibrate(VibrationEffect.createOneShot(15, VibrationEffect.DEFAULT_AMPLITUDE));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void restoreLevel(Context context) {
|
||||
applyLevel(context, Settings.Secure.getInt(
|
||||
context.getContentResolver(), PREF_LEVEL, 80), false);
|
||||
}
|
||||
}
|
||||
@@ -1,280 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
* 2017-2020 The LineageOS 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 org.lineageos.settings.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
|
||||
import org.lineageos.settings.R;
|
||||
|
||||
/**
|
||||
* Based on android.preference.SeekBarPreference, but uses support preference as base.
|
||||
*/
|
||||
public class SeekBarPreference extends RestrictedPreference
|
||||
implements OnSeekBarChangeListener, View.OnKeyListener {
|
||||
|
||||
private int mProgress;
|
||||
private int mMax;
|
||||
private boolean mTrackingTouch;
|
||||
|
||||
private ImageView mIconView;
|
||||
private Drawable mIcon;
|
||||
|
||||
public SeekBarPreference(
|
||||
Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(
|
||||
attrs, com.android.internal.R.styleable.ProgressBar, defStyleAttr, defStyleRes);
|
||||
setMax(a.getInt(com.android.internal.R.styleable.ProgressBar_max, mMax));
|
||||
a.recycle();
|
||||
|
||||
a = context.obtainStyledAttributes(attrs,
|
||||
com.android.internal.R.styleable.SeekBarPreference, defStyleAttr, defStyleRes);
|
||||
final int layoutResId = a.getResourceId(
|
||||
com.android.internal.R.styleable.SeekBarPreference_layout,
|
||||
com.android.internal.R.layout.preference_widget_seekbar);
|
||||
a.recycle();
|
||||
|
||||
setLayoutResource(layoutResId);
|
||||
}
|
||||
|
||||
public SeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
this(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
public SeekBarPreference(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, com.android.internal.R.attr.seekBarPreferenceStyle);
|
||||
}
|
||||
|
||||
public SeekBarPreference(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||
super.onBindViewHolder(view);
|
||||
|
||||
mIconView = (ImageView) view.findViewById(R.id.icon);
|
||||
if (mIcon != null) {
|
||||
mIconView.setImageDrawable(mIcon);
|
||||
}
|
||||
|
||||
view.itemView.setOnKeyListener(this);
|
||||
SeekBar seekBar = (SeekBar) view.findViewById(R.id.seekbar);
|
||||
seekBar.setOnSeekBarChangeListener(this);
|
||||
seekBar.setMax(mMax);
|
||||
seekBar.setProgress(mProgress);
|
||||
seekBar.setEnabled(isEnabled());
|
||||
}
|
||||
|
||||
public ImageView getIconView() {
|
||||
return mIconView;
|
||||
}
|
||||
|
||||
public void setIconDrawable(Drawable drawable) {
|
||||
if (mIconView != null) {
|
||||
mIconView.setImageDrawable(drawable);
|
||||
}
|
||||
mIcon = drawable;
|
||||
}
|
||||
@Override
|
||||
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
|
||||
setProgress(restoreValue ? getPersistedInt(mProgress)
|
||||
: (Integer) defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object onGetDefaultValue(TypedArray a, int index) {
|
||||
return a.getInt(index, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
if (event.getAction() != KeyEvent.ACTION_DOWN) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SeekBar seekBar = (SeekBar) v.findViewById(R.id.seekbar);
|
||||
if (seekBar == null) {
|
||||
return false;
|
||||
}
|
||||
return seekBar.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
public void setMax(int max) {
|
||||
if (max != mMax) {
|
||||
mMax = max;
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
setProgress(progress, true);
|
||||
}
|
||||
|
||||
private void setProgress(int progress, boolean notifyChanged) {
|
||||
if (progress > mMax) {
|
||||
progress = mMax;
|
||||
}
|
||||
if (progress < 0) {
|
||||
progress = 0;
|
||||
}
|
||||
if (progress != mProgress) {
|
||||
mProgress = progress;
|
||||
persistInt(progress);
|
||||
if (notifyChanged) {
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
return mProgress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist the seekBar's progress value if callChangeListener
|
||||
* returns true, otherwise set the seekBar's progress to the stored value
|
||||
*/
|
||||
void syncProgress(SeekBar seekBar) {
|
||||
int progress = seekBar.getProgress();
|
||||
if (progress != mProgress) {
|
||||
if (callChangeListener(progress)) {
|
||||
setProgress(progress, false);
|
||||
} else {
|
||||
seekBar.setProgress(mProgress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(
|
||||
SeekBar seekBar, int progress, boolean fromUser) {
|
||||
if (fromUser && !mTrackingTouch) {
|
||||
syncProgress(seekBar);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
mTrackingTouch = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
mTrackingTouch = false;
|
||||
if (seekBar.getProgress() != mProgress) {
|
||||
syncProgress(seekBar);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
/*
|
||||
* Suppose a client uses this preference type without persisting. We
|
||||
* must save the instance state so it is able to, for example, survive
|
||||
* orientation changes.
|
||||
*/
|
||||
|
||||
final Parcelable superState = super.onSaveInstanceState();
|
||||
if (isPersistent()) {
|
||||
// No need to save instance state since it's persistent
|
||||
return superState;
|
||||
}
|
||||
|
||||
// Save the instance state
|
||||
final SavedState myState = new SavedState(superState);
|
||||
myState.progress = mProgress;
|
||||
myState.max = mMax;
|
||||
return myState;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Parcelable state) {
|
||||
if (!state.getClass().equals(SavedState.class)) {
|
||||
// Didn't save state for us in onSaveInstanceState
|
||||
super.onRestoreInstanceState(state);
|
||||
return;
|
||||
}
|
||||
|
||||
// Restore the instance state
|
||||
SavedState myState = (SavedState) state;
|
||||
super.onRestoreInstanceState(myState.getSuperState());
|
||||
mProgress = myState.progress;
|
||||
mMax = myState.max;
|
||||
notifyChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* SavedState, a subclass of {@link BaseSavedState}, will store the state
|
||||
* of MyPreference, a subclass of Preference.
|
||||
* <p>
|
||||
* It is important to always call through to super methods.
|
||||
*/
|
||||
private static class SavedState extends BaseSavedState {
|
||||
int progress;
|
||||
int max;
|
||||
|
||||
public SavedState(Parcel source) {
|
||||
super(source);
|
||||
|
||||
// Restore the click counter
|
||||
progress = source.readInt();
|
||||
max = source.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
|
||||
// Save the click counter
|
||||
dest.writeInt(progress);
|
||||
dest.writeInt(max);
|
||||
}
|
||||
|
||||
public SavedState(Parcelable superState) {
|
||||
super(superState);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final Parcelable.Creator<SavedState> CREATOR =
|
||||
new Parcelable.Creator<SavedState>() {
|
||||
public SavedState createFromParcel(Parcel in) {
|
||||
return new SavedState(in);
|
||||
}
|
||||
|
||||
public SavedState[] newArray(int size) {
|
||||
return new SavedState[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -67,10 +67,6 @@ on init
|
||||
write /sys/devices/system/cpu/cpu7/cpufreq/schedutil/up_rate_limit_us 500
|
||||
write /sys/devices/system/cpu/cpu7/cpufreq/schedutil/down_rate_limit_us 20000
|
||||
|
||||
# Allow system to adjust haptic level directly
|
||||
chown system system /sys/module/qti_haptics/parameters/vmax_mv_override
|
||||
chmod 0664 /sys/module/qti_haptics/parameters/vmax_mv_override
|
||||
|
||||
# Migrate cpuctl tasks once to cpuctl system
|
||||
copy_per_line /dev/cpuctl/tasks /dev/cpuctl/system/tasks
|
||||
|
||||
|
||||
@@ -37,9 +37,6 @@ allow xiaomiparts_app system_data_file:dir search;
|
||||
|
||||
allow xiaomiparts_app sysfs_leds:dir r_dir_perms;
|
||||
|
||||
allow xiaomiparts_app sysfs_vibrator:dir search;
|
||||
allow xiaomiparts_app sysfs_vibrator:file rw_file_perms;
|
||||
|
||||
allow xiaomiparts_app {
|
||||
cgroup
|
||||
sysfs_leds
|
||||
|
||||
3
sepolicy/vendor/file_contexts
vendored
3
sepolicy/vendor/file_contexts
vendored
@@ -31,9 +31,6 @@
|
||||
/vendor/bin/mlipayd@1\.1 u:object_r:hal_mlipay_default_exec:s0
|
||||
/vendor/bin/sendhint u:object_r:sendhint_vendor_exec:s0
|
||||
|
||||
# Haptic
|
||||
/sys/module/qti_haptics/parameters/vmax_mv_override u:object_r:sysfs_vibrator:s0
|
||||
|
||||
# HBM
|
||||
/sys/devices/platform/soc/soc:qcom,dsi-display-primary/hbm u:object_r:vendor_sysfs_hbm:s0
|
||||
|
||||
|
||||
4
sepolicy/vendor/init.te
vendored
4
sepolicy/vendor/init.te
vendored
@@ -18,10 +18,6 @@ allow init same_process_hal_file:file execute;
|
||||
allow init per_boot_file:file ioctl;
|
||||
allowxperm init per_boot_file:file ioctl { F2FS_IOC_SET_PIN_FILE };
|
||||
|
||||
# Allow init to read and write to sysfs_vibrator
|
||||
allow init sysfs_vibrator:dir search;
|
||||
allow init sysfs_vibrator:file rw_file_perms;
|
||||
|
||||
# /proc/last_kmsg
|
||||
allow init proc_last_kmsg:file r_file_perms;
|
||||
allow init proc_last_kmsg:file setattr;
|
||||
|
||||
Reference in New Issue
Block a user