Android 添加禁止下拉菜单和实现控制下拉关照栏功能
overlay/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values-zh-rCN/strings.xml<string name="pull_down_switch">禁用关照下拉菜单</string>
<string name="pull_down_switch2">打开:禁止下拉菜单 \n关闭:答应下拉菜单</string>
overlay/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values/strings.xml
<add-resource type="string" name="pull_down_switch"/>
<add-resource type="string" name="pull_down_switch2"/>
<string name="pull_down_switch">Disable notify pull-down menu</string>
<string name="pull_down_switch2">ON:disable pull down \nOFF:allow pull down</string>
【现在添加在显示栏中】
vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/display_settings.xml
<!--add disable pull down menu in systemUI-->
<Preference
android:key="statusbar_switch"
android:title="@string/pull_down_switch">
<intent android:action="com.freeme.intent.action.switch"/>
</Preference>
/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/freeme_qs_switch.xml
<?xml version="1.0" encoding="UTF-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
android:key="switch_preference"
android:title="@string/pull_down_switch"
android:summary="@string/pull_down_switch2"
android:defaultValue="true"/>
</PreferenceScreen>
/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/QsSwitchSetting.java
开关默认1为打开,功能实现默认为1
反之:
开关默认0为关闭 ,功能实现默认为0
<这里为默认打开菜单栏开关>
package com.android.settings;
import android.content.Context;
import android.os.Bundle;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.preference.Preference;
import android.preference.SwitchPreference;
import android.preference.ListPreference;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import android.os.SystemProperties;
import android.preference.PreferenceActivity;
import java.util.ArrayList;
import java.util.List;
import android.util.Log;
import android.preference.Preference.OnPreferenceChangeListener;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
//*/
import android.os.SystemProperties;
//*/
public class QsSwitchSetting extends PreferenceActivity implements
Preference.OnPreferenceChangeListener {
private static final String QS_KEY = "switch_preference";
private SwitchPreference mARPreference;
private Context mContext;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.freeme_qs_switch);
mContext = this;
initializeAllPreferences();
}
private void initializeAllPreferences() {
mARPreference = (SwitchPreference) findPreference(QS_KEY);
mARPreference.setChecked(Settings.System.getInt(getContentResolver(),"qs_switch", 1) == 1);//def 1 open
mARPreference.setOnPreferenceChangeListener(this);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean isChecked = (boolean) newValue;
if (isChecked) {
//SystemProperties.set("disable.qs.switch","1");//disable
Settings.System.putInt(getContentResolver(), "qs_switch", 1);
} else {
//ystemProperties.set("disable.qs.switch","0");//able
Settings.System.putInt(getContentResolver(), "qs_switch", 0);
}
return true;
}
private void writeFile(String path, String content) {
FileWriter fileWriter = null;
try {
fileWriter = new FileWriter(path);
if (fileWriter != null) {
fileWriter.write(content);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (fileWriter != null)
try {
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
四个实现类:包括锁屏状态和未锁屏
return中断或返回值
1./vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
/ TODO: change the method signature to use (boolean inputFocusTransferStarted)
@Override
public void onStatusBarMotionEvent(MotionEvent event) {
//*/,add qs switch
if(1 == android.provider.Settings.System.getInt(mContext.getContentResolver(), "qs_switch", 1)){//1 def open
} else {
verifyCallerAndClearCallingIdentity("onStatusBarMotionEvent", () -> {
// TODO move this logic to message queue
mCentralSurfacesOptionalLazy.get().ifPresent(centralSurfaces -> {
if (event.getActionMasked() == ACTION_DOWN) {
centralSurfaces.getPanelController().startExpandLatencyTracking();
}
mHandler.post(() -> {
int action = event.getActionMasked();
if (action == ACTION_DOWN) {
mInputFocusTransferStarted = true;
mInputFocusTransferStartY = event.getY();
mInputFocusTransferStartMillis = event.getEventTime();
centralSurfaces.onInputFocusTransfer(
mInputFocusTransferStarted, false /* cancel */,
0 /* velocity */);
}
if (action == ACTION_UP || action == ACTION_CANCEL) {
mInputFocusTransferStarted = false;
float velocity = (event.getY() - mInputFocusTransferStartY)
/ (event.getEventTime() - mInputFocusTransferStartMillis);
centralSurfaces.onInputFocusTransfer(mInputFocusTransferStarted,
action == ACTION_CANCEL,
velocity);
}
event.recycle();
});
});
});
}//*/
}
2.
/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
//*/add
private Context mContext;
//*/
public CommandQueue(Context context, ProtoTracer protoTracer, CommandRegistry registry) {
mProtoTracer = protoTracer;
mRegistry = registry;
//*/add
mContext = context;
//*/
context.getSystemService(DisplayManager.class).registerDisplayListener(this, mHandler);
// We always have default display.
setDisabled(DEFAULT_DISPLAY, DISABLE_NONE, DISABLE2_NONE);
}
// TODO(b/118592525): add multi-display support if needed.
public boolean panelsEnabled() {
//*/add qs_switch
if(1 == android.provider.Settings.System.getInt(mContext.getContentResolver(), "qs_switch", 1)){//def open
return false;
} else {
final int disabled1 = getDisabled1(DEFAULT_DISPLAY);
final int disabled2 = getDisabled2(DEFAULT_DISPLAY);
return (disabled1 & StatusBarManager.DISABLE_EXPAND) == 0
&& (disabled2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) == 0
&& !ONLY_CORE_APPS;
}
//*/
}
3. /vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt
class DragDownHelper(
private val falsingManager: FalsingManager,
private val falsingCollector: FalsingCollector,
private val dragDownCallback: LockscreenShadeTransitionController,
context: Context
) : Gefingerpoken {
private var dragDownAmountOnStart = 0.0f
lateinit var expandCallback: ExpandHelper.Callback
lateinit var host: View
private var minDragDistance = 0
private var initialTouchX = 0f
private var initialTouchY = 0f
private var touchSlop = 0f
private var slopMultiplier = 0f
private val temp2 = IntArray(2)
private var draggedFarEnough = false
private var startingChild: ExpandableView? = null
private var lastHeight = 0f
var isDraggingDown = false
private set
//add mContext
var mContext = context
private val isFalseTouch: Boolean
get() {
return if (!dragDownCallback.isFalsingCheckNeeded) {
false
} else {
falsingManager.isFalseTouch(Classifier.NOTIFICATION_DRAG_DOWN) || !draggedFarEnough
}
}
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
val x = event.x
val y = event.y
when (event.actionMasked) {
MotionEvent.ACTION_DOWN -> {
draggedFarEnough = false
isDraggingDown = false
startingChild = null
initialTouchY = y
initialTouchX = x
}
MotionEvent.ACTION_MOVE -> {
val h = y - initialTouchY
// Adjust the touch slop if another gesture may be being performed.
val touchSlop = if (event.classification
== MotionEvent.CLASSIFICATION_AMBIGUOUS_GESTURE)
touchSlop * slopMultiplier
else
touchSlop
if (h > touchSlop && h > Math.abs(x - initialTouchX)) {
//*/add if else qs_switch
if(1 == android.provider.Settings.System.getInt(mContext.getContentResolver(), "qs_switch", 1)){
return true
} else {
falsingCollector.onNotificationStartDraggingDown()
isDraggingDown = true
captureStartingChild(initialTouchX, initialTouchY)
initialTouchY = y
initialTouchX = x
dragDownCallback.onDragDownStarted(startingChild)
dragDownAmountOnStart = dragDownCallback.dragDownAmount
return startingChild != null || dragDownCallback.isDragDownAnywhereEnabled
}
//*/
}
}
}
4./vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
void setQsExpansion(float height) {
//*/add if else qs_switch
if(1 == android.provider.Settings.System.getInt(mView.getContext().getContentResolver(), "qs_switch", 1)){
return;
} else {
height = Math.min(Math.max(height, mQsMinExpansionHeight), mQsMaxExpansionHeight);
mQsFullyExpanded = height == mQsMaxExpansionHeight && mQsMaxExpansionHeight != 0;
boolean qsAnimatingAway = !mQsAnimatorExpand && mAnimatingQS;
if (height > mQsMinExpansionHeight && !mQsExpanded && !mStackScrollerOverscrolling
&& !mDozing && !qsAnimatingAway) {
setQsExpanded(true);
} else if (height <= mQsMinExpansionHeight && mQsExpanded) {
setQsExpanded(false);
}
mQsExpansionHeight = height;
updateQsExpansion();
requestScrollerTopPaddingUpdate(false /* animate */);
mKeyguardStatusBarViewController.updateViewState();
if (mBarState == StatusBarState.SHADE_LOCKED || mBarState == KEYGUARD) {
updateKeyguardBottomAreaAlpha();
positionClockAndNotifications();
}
if (mAccessibilityManager.isEnabled()) {
mView.setAccessibilityPaneTitle(determineAccessibilityPaneTitle());
}
if (!mFalsingManager.isUnlockingDisabled() && mQsFullyExpanded
&& mFalsingCollector.shouldEnforceBouncer()) {
mCentralSurfaces.executeRunnableDismissingKeyguard(null, null /* cancelAction */,
false /* dismissShade */, true /* afterKeyguardGone */, false /* deferred */);
}
if (DEBUG_DRAWABLE) {
mView.invalidate();
}
}//*/
}
假如是仅实现屏蔽下拉栏【完全不用下拉栏】,就可不用增加菜单开关,这样直接实现return这几个类也可!
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]