java - setkeyguarddisabled - process myuserhandle
適用於Android UserManager.isUserAGoat()的用例? (8)
從API 21(第一個Android 5.0 / Lollipop SDK)開始 ,它會檢測是否安裝了Goat Simulator應用程序:
/**
* Used to determine whether the user making this call is subject to
* teleportations.
*
* <p>As of {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method can
* now automatically identify goats using advanced goat recognition technology.</p>
*
* @return Returns true if the user making this call is a goat.
*/
public boolean isUserAGoat() {
return mContext.getPackageManager()
.isPackageAvailable("com.coffeestainstudios.goatsimulator");
}
這應該清楚地表明, djechlin建議將其用作無警告if (false)
是一種潛在的災難性策略。 之前為每個設備返回false
的內容現在返回一個看似隨機的值:如果在代碼中埋藏得足夠深,則可能需要很長時間才能確定新bug的來源。
結論:如果您不控制方法的實現並決定將其用於API文檔中未說明的目的,那麼您將遇到麻煩。
我正在研究Android 4.2中引入的新API。 在查看UserManager
類時,我遇到了以下方法:
public boolean isUserAGoat()
用於確定進行此呼叫的用戶是否受傳送的影響。
返回進行此調用的用戶是否為山羊。
應該如何以及何時使用?
在這個星球上最偏遠的山脈中,有一種先進的山羊種類,它們似乎能夠像我們人類一樣使用手機!
洩露的鏡頭: youtu.be/YJwZMUn7GdQ
谷歌必須已經發現了這一點,並決定為他們提供支持,試圖保持技術進步的前沿。
在語音識別學科中,用戶分為山羊和綿羊 。
例如,請參見第89頁 :
綿羊是語音識別非常好的人,山羊是非常糟糕的人。 只有語音識別器知道它們之間的區別。 人們無法預測誰的聲音將被輕易識別,誰的聲音不會被識別。 最好的策略是設計界面,以便它可以處理各種環境中的各種聲音
也許,計劃在未來將Android用戶標記為山羊,以便能夠配置語音識別引擎以滿足山羊的需求。 ;-)
從它們的source ,用於返回false
的方法直到它在API 21中被更改。
/**
* Used to determine whether the user making this call is subject to
* teleportations.
* @return whether the user making this call is a goat
*/
public boolean isUserAGoat() {
return false;
}
看起來這個方法作為開發人員對我們沒有實際用處。 有人此前曾表示可能是複活節彩蛋 。
在API 21中,實現已更改為檢查是否已安裝包com.coffeestainstudios.goatsimulator
應用程序
/**
* Used to determine whether the user making this call is subject to
* teleportations.
*
* <p>As of {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method can
* now automatically identify goats using advanced goat recognition technology.</p>
*
* @return Returns true if the user making this call is a goat.
*/
public boolean isUserAGoat() {
return mContext.getPackageManager()
.isPackageAvailable("com.coffeestainstudios.goatsimulator");
}
這是源鏈接
有一個類似的調用isUserAMonkey()
,如果使用MonkeyRunner工具則返回true。 SDK解釋和這個一樣好奇。
public static boolean isUserAMonkey(){}
如果用戶界面當前正被猴子搞亂,則返回
true
。
Here是來源。
我希望這是為了預期一個名為山羊的新SDK工具,並且實際上可用於測試該工具的存在。
另請參閱類似的問題, ActivityManager中的Strange函數:isUserAMonkey。 這意味著什麼,它的用途是什麼? 。
有趣的複活節彩蛋
在Ubuntu版本的Chrome中,在任務管理器( shift + esc )中,右鍵單擊可以添加一個科幻列,其意大利語版本為“Capre Teletrasportate”(傳送山羊)。
關於它的一個有趣的理論就在here 。
請參閱以下源代碼:
/**
* Used to determine whether the user making this call is subject to
* teleportations.
*
* <p>As of {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method can
* now automatically identify goats using advanced goat recognition technology.</p>
*
* @return Returns true if the user making this call is a goat.
*/
public boolean isUserAGoat() {
return mContext.getPackageManager()
.isPackageAvailable("com.coffeestainstudios.goatsimulator");
}
谷歌非常喜歡山羊和山羊的複活節彩蛋 。 甚至還有關於它的帖子 。
正如之前的帖子中所提到的,它也存在於Chrome任務管理器中( 它在2009年首次出現 ):
<message name="IDS_TASK_MANAGER_GOATS_TELEPORTED_COLUMN" desc="The goats teleported column">
Goats Teleported
</message>
然後在2010年初的Windows,Linux和Mac版Chrome中 )。 “山羊傳送”的數量實際上是隨機的 :
int TaskManagerModel::GetGoatsTeleported(int index) const {
int seed = goat_salt_ * (index + 1);
return (seed >> 16) & 255;
}
其他谷歌參考山羊包括:
據我所知,山羊和谷歌的最早相關性屬於最初的“割山羊”博客文章。
我們可以安全地假設它只是一個複活節彩蛋,除了返回false
之外沒有現實世界的使用。