emptyFunction

emptyFunction模块包含不同类型的空函数。

 

"use strict";

function makeEmptyFunction(arg) {
  return function () {
    return arg;
  };
}

// 返回undefined
var emptyFunction = function emptyFunction() {};

// 返回将参数作为返回值的函数
emptyFunction.thatReturns = makeEmptyFunction;

// 返回false
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);

// 返回true
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);

// 返回null
emptyFunction.thatReturnsNull = makeEmptyFunction(null);

// 返回this
emptyFunction.thatReturnsThis = function () {
  return this;
};

// 参数原路返回
emptyFunction.thatReturnsArgument = function (arg) {
  return arg;
};

module.exports = emptyFunction;

 

protected void setEnabledFunctions(long usbFunctions, 2052 boolean forceRestart, int operationId) { 2053 boolean usbDataUnlocked = isUsbDataTransferActive(usbFunctions); 2054 //#ifndef OPLUS_FEATURE_CHG_BASIC 2055 if (DEBUG) { 2056 Slog.d(TAG, "setEnabledFunctions [" + 2057 "functions=" + UsbManager.usbFunctionsToString(usbFunctions) + 2058 " ,forceRestart=" + forceRestart + 2059 " ,usbDataUnlocked=" + usbDataUnlocked + 2060 " ,mUsbDataUnlocked=" + mUsbDataUnlocked + 2061 " ,operationId=" + operationId + 2062 "]" 2063 ); 2064 } 2065 //else 2066 //if (DEBUG) { 2067 // Slog.d(TAG, "setEnabledFunctions functions=" + usbFunctions + 2068 // " ,forceRestart=" + forceRestart + 2069 // " ,usbDataUnlocked=" + usbDataUnlocked + 2070 // " ,operationId=" + operationId); 2071 //} 2072 //#endif 2073 if (usbDataUnlocked != mUsbDataUnlocked) { 2074 mUsbDataUnlocked = usbDataUnlocked; 2075 updateUsbNotification(false); 2076 forceRestart = true; 2077 } 2078 2079 /** 2080 * Try to set the enabled functions. 2081 */ 2082 final long oldFunctions = mCurrentFunctions; 2083 final boolean oldFunctionsApplied = mCurrentFunctionsApplied; 2084 if (trySetEnabledFunctions(usbFunctions, forceRestart)) { 2085 return; 2086 } 2087 2088 /** 2089 * Didn't work. Try to revert changes. 2090 * We always reapply the policy in case certain constraints changed such as 2091 * user restrictions independently of any other new functions we were 2092 * trying to activate. 2093 */ 2094 if (oldFunctionsApplied && oldFunctions != usbFunctions) { 2095 Slog.e(TAG, "Failsafe 1: Restoring previous USB functions."); 2096 if (trySetEnabledFunctions(oldFunctions, false)) { 2097 return; 2098 } 2099 } 2100 2101 /** 2102 * Still didn't work. Try to restore the default functions. 2103 */ 2104 Slog.e(TAG, "Failsafe 2: Restoring default USB functions."); 2105 if (trySetEnabledFunctions(UsbManager.FUNCTION_NONE, false)) { 2106 return; 2107 } 2108 2109 /** 2110 * Now we're desperate. Ignore the default functions. 2111 * Try to get ADB working if enabled. 2112 */ 2113 Slog.e(TAG, "Failsafe 3: Restoring empty function list (with ADB if enabled)."); 2114 if (trySetEnabledFunctions(UsbManager.FUNCTION_NONE, false)) { 2115 return; 2116 } 2117 2118 /** 2119 * Ouch. 2120 */ 2121 Slog.e(TAG, "Unable to set any USB functions!"); 2122 }这个是setEnabledFunctions 方法
最新发布
09-16
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值