M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
# We only want this apk build for tests.
LOCAL_MODULE_TAGS := tests
# Include all test java files.
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_JAVA_LIBRARIES := android.test.runner
LOCAL_PACKAGE_NAME := FrameworkPermissionTests
include $(BUILD_PACKAGE)
+33
View File
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
* Copyright (C) 2009 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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.framework.permission.tests">
<application>
<uses-library android:name="android.test.runner" />
</application>
<!--
The test declared in this instrumentation can be run via this command
"adb shell am instrument -w com.android.framework.permission.tests/android.test.InstrumentationTestRunner"
-->
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.android.framework.permission.tests"
android:label="Tests for private API framework permissions"/>
</manifest>
@@ -0,0 +1,198 @@
/*
* Copyright (C) 2009 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.framework.permission.tests;
import android.app.ActivityManagerNative;
import android.app.IActivityManager;
import android.content.res.Configuration;
import android.os.RemoteException;
import android.test.suitebuilder.annotation.SmallTest;
import junit.framework.TestCase;
/**
* TODO: Remove this. This is only a placeholder, need to implement this.
*/
public class ActivityManagerPermissionTests extends TestCase {
IActivityManager mAm;
@Override
protected void setUp() throws Exception {
super.setUp();
mAm = ActivityManagerNative.getDefault();
}
@SmallTest
public void testREORDER_TASKS() {
try {
mAm.moveTaskToFront(-1);
fail("IActivityManager.moveTaskToFront did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mAm.moveTaskToBack(-1);
fail("IActivityManager.moveTaskToBack did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mAm.moveTaskBackwards(-1);
fail("IActivityManager.moveTaskToFront did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
@SmallTest
public void testCHANGE_CONFIGURATION() {
try {
mAm.updateConfiguration(new Configuration());
fail("IActivityManager.updateConfiguration did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
@SmallTest
public void testSET_DEBUG_APP() {
try {
mAm.setDebugApp(null, false, false);
fail("IActivityManager.setDebugApp did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
@SmallTest
public void testSET_PROCESS_LIMIT() {
try {
mAm.setProcessLimit(10);
fail("IActivityManager.setProcessLimit did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
@SmallTest
public void testALWAYS_FINISH() {
try {
mAm.setAlwaysFinish(false);
fail("IActivityManager.setAlwaysFinish did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
@SmallTest
public void testSIGNAL_PERSISTENT_PROCESSES() {
try {
mAm.signalPersistentProcesses(-1);
fail("IActivityManager.signalPersistentProcesses did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
@SmallTest
public void testFORCE_BACK() {
try {
mAm.unhandledBack();
fail("IActivityManager.unhandledBack did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
@SmallTest
public void testSET_ACTIVITY_WATCHER() {
try {
mAm.setActivityController(null);
fail("IActivityManager.setActivityController did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
@SmallTest
public void testSHUTDOWN() {
try {
mAm.shutdown(0);
fail("IActivityManager.shutdown did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
@SmallTest
public void testSTOP_APP_SWITCHES() {
try {
mAm.stopAppSwitches();
fail("IActivityManager.stopAppSwitches did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mAm.resumeAppSwitches();
fail("IActivityManager.resumeAppSwitches did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
}
@@ -0,0 +1,141 @@
/*
* Copyright (C) 2006 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.framework.permission.tests;
import junit.framework.TestCase;
import android.content.pm.PackageManager;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
/**
* Verify PackageManager api's that require specific permissions.
*/
public class PmPermissionsTests extends AndroidTestCase {
private PackageManager mPm;
private String mPkgName = "com.android.framework.permission.tests";
@Override
protected void setUp() throws Exception {
super.setUp();
mPm = getContext().getPackageManager();
}
/*
* This test verifies that PackageManger.getPackageSizeInfo enforces permission
* android.permission.GET_PACKAGE_SIZE
*/
@SmallTest
public void testGetPackageSize() {
try {
mPm.getPackageSizeInfo(mPkgName, null);
fail("PackageManager.getPackageSizeInfo" +
"did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
/*
* This test verifies that PackageManger.DeleteApplicationCacheFiles enforces permission
* android.permission.DELETE_CACHE_FILES
*/
@SmallTest
public void testDeleteApplicationCacheFiles() {
try {
mPm.deleteApplicationCacheFiles(mPkgName, null);
fail("PackageManager.deleteApplicationCacheFiles" +
"did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
/*
* This test verifies that PackageManger.installPackage enforces permission
* android.permission.INSTALL_PACKAGES
*/
@SmallTest
public void testInstallPackage() {
try {
mPm.installPackage(null, null, 0, null);
fail("PackageManager.installPackage" +
"did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
/*
* This test verifies that PackageManger.freeStorage
* enforces permission android.permission.CLEAR_APP_CACHE
*/
@SmallTest
public void testFreeStorage1() {
try {
mPm.freeStorage(100000, null);
fail("PackageManager.freeStorage " +
"did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
/*
* This test verifies that PackageManger.freeStorageAndNotify
* enforces permission android.permission.CLEAR_APP_CACHE
*/
@SmallTest
public void testFreeStorage2() {
try {
mPm.freeStorageAndNotify(100000, null);
fail("PackageManager.freeStorageAndNotify" +
" did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
/*
* This test verifies that PackageManger.clearApplicationUserData
* enforces permission android.permission.CLEAR_APP_USER_DATA
*/
@SmallTest
public void testClearApplicationUserData() {
try {
mPm.clearApplicationUserData(mPkgName, null);
fail("PackageManager.clearApplicationUserData" +
"did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
/*
* This test verifies that PackageManger.deletePackage
* enforces permission android.permission.DELETE_PACKAGES
*/
@SmallTest
public void testDeletePackage() {
try {
mPm.deletePackage(mPkgName, null, 0);
fail("PackageManager.deletePackage" +
"did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
}
@@ -0,0 +1,66 @@
/*
* Copyright (C) 2009 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.framework.permission.tests;
import com.android.internal.os.BinderInternal;
import android.os.Binder;
import android.os.IPermissionController;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManagerNative;
import android.test.suitebuilder.annotation.SmallTest;
import junit.framework.TestCase;
/**
* TODO: Remove this. This is only a placeholder, need to implement this.
*/
public class ServiceManagerPermissionTests extends TestCase {
@SmallTest
public void testAddService() {
try {
// The security in the service manager is that you can't replace
// a service that is already published.
Binder binder = new Binder();
ServiceManager.addService("activity", binder);
fail("ServiceManager.addService did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
}
}
@SmallTest
public void testSetPermissionController() {
try {
IPermissionController pc = new IPermissionController.Stub() {
public boolean checkPermission(java.lang.String permission, int pid, int uid) {
return true;
}
};
ServiceManagerNative.asInterface(BinderInternal.getContextObject())
.setPermissionController(pc);
fail("IServiceManager.setPermissionController did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
}
@@ -0,0 +1,85 @@
/*
* Copyright (C) 2009 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.framework.permission.tests;
import java.util.ArrayList;
import android.telephony.SmsManager;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
/**
* Verify that SmsManager apis cannot be called without required permissions.
*/
public class SmsManagerPermissionTest extends AndroidTestCase {
private static final String MSG_CONTENTS = "hi";
private static final short DEST_PORT = (short)1004;
private static final String DEST_NUMBER = "4567";
private static final String SRC_NUMBER = "1234";
/**
* Verify that SmsManager.sendTextMessage requires permissions.
* <p>Tests Permission:
* {@link android.Manifest.permission#SEND_SMS}.
*/
@SmallTest
public void testSendTextMessage() {
try {
SmsManager.getDefault().sendTextMessage(SRC_NUMBER, DEST_NUMBER, MSG_CONTENTS, null,
null);
fail("SmsManager.sendTextMessage did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
/**
* Verify that SmsManager.sendDataMessage requires permissions.
* <p>Tests Permission:
* {@link android.Manifest.permission#SEND_SMS}.
*/
@SmallTest
public void testSendDataMessage() {
try {
SmsManager.getDefault().sendDataMessage(SRC_NUMBER, DEST_NUMBER, DEST_PORT,
MSG_CONTENTS.getBytes(), null, null);
fail("SmsManager.sendDataMessage did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
/**
* Verify that SmsManager.sendMultipartMessage requires permissions.
* <p>Tests Permission:
* {@link android.Manifest.permission#SEND_MMS}.
*/
@SmallTest
public void testSendMultipartMessage() {
try {
ArrayList<String> msgParts = new ArrayList<String>(2);
msgParts.add(MSG_CONTENTS);
msgParts.add("foo");
SmsManager.getDefault().sendMultipartTextMessage(SRC_NUMBER, DEST_NUMBER, msgParts,
null, null);
fail("SmsManager.sendMultipartTextMessage did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
}
@@ -0,0 +1,86 @@
/*
* Copyright (C) 2009 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.framework.permission.tests;
import junit.framework.TestCase;
import android.os.Binder;
import android.os.IVibratorService;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.test.suitebuilder.annotation.SmallTest;
/**
* Verify that Hardware apis cannot be called without required permissions.
*/
@SmallTest
public class VibratorServicePermissionTest extends TestCase {
private IVibratorService mVibratorService;
@Override
protected void setUp() throws Exception {
mVibratorService = IVibratorService.Stub.asInterface(
ServiceManager.getService("vibrator"));
}
/**
* Test that calling {@link android.os.IVibratorService#vibrate(long)} requires permissions.
* <p>Tests permission:
* {@link android.Manifest.permission#VIBRATE}
* @throws RemoteException
*/
public void testVibrate() throws RemoteException {
try {
mVibratorService.vibrate(2000, new Binder());
fail("vibrate did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
/**
* Test that calling {@link android.os.IVibratorService#vibratePattern(long[],
* int, android.os.IBinder)} requires permissions.
* <p>Tests permission:
* {@link android.Manifest.permission#VIBRATE}
* @throws RemoteException
*/
public void testVibratePattern() throws RemoteException {
try {
mVibratorService.vibratePattern(new long[] {0}, 0, new Binder());
fail("vibratePattern did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
/**
* Test that calling {@link android.os.IVibratorService#cancelVibrate()} requires permissions.
* <p>Tests permission:
* {@link android.Manifest.permission#VIBRATE}
* @throws RemoteException
*/
public void testCancelVibrate() throws RemoteException {
try {
mVibratorService.cancelVibrate(new Binder());
fail("cancelVibrate did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
}
@@ -0,0 +1,425 @@
/*
* Copyright (C) 2009 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.framework.permission.tests;
import android.content.res.Configuration;
import android.os.Binder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.test.suitebuilder.annotation.SmallTest;
import android.view.IWindowManager;
import android.view.KeyEvent;
import android.view.MotionEvent;
import junit.framework.TestCase;
/**
* TODO: Remove this. This is only a placeholder, need to implement this.
*/
public class WindowManagerPermissionTests extends TestCase {
IWindowManager mWm;
@Override
protected void setUp() throws Exception {
super.setUp();
mWm = IWindowManager.Stub.asInterface(
ServiceManager.getService("window"));
}
@SmallTest
public void testMANAGE_APP_TOKENS() {
try {
mWm.pauseKeyDispatching(null);
fail("IWindowManager.pauseKeyDispatching did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.resumeKeyDispatching(null);
fail("IWindowManager.resumeKeyDispatching did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.setEventDispatching(true);
fail("IWindowManager.setEventDispatching did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.addWindowToken(null, 0);
fail("IWindowManager.addWindowToken did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.removeWindowToken(null);
fail("IWindowManager.removeWindowToken did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.addAppToken(0, null, 0, 0, false);
fail("IWindowManager.addAppToken did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.setAppGroupId(null, 0);
fail("IWindowManager.setAppGroupId did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.updateOrientationFromAppTokens(new Configuration(), null);
fail("IWindowManager.updateOrientationFromAppTokens did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.setAppOrientation(null, 0);
mWm.addWindowToken(null, 0);
fail("IWindowManager.setAppOrientation did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.setFocusedApp(null, false);
fail("IWindowManager.setFocusedApp did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.prepareAppTransition(0);
fail("IWindowManager.prepareAppTransition did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.executeAppTransition();
fail("IWindowManager.executeAppTransition did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.setAppStartingWindow(null, "foo", 0, null, 0, 0, null, false);
fail("IWindowManager.setAppStartingWindow did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.setAppWillBeHidden(null);
fail("IWindowManager.setAppWillBeHidden did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.setAppVisibility(null, false);
fail("IWindowManager.setAppVisibility did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.startAppFreezingScreen(null, 0);
fail("IWindowManager.startAppFreezingScreen did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.stopAppFreezingScreen(null, false);
fail("IWindowManager.stopAppFreezingScreen did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.removeAppToken(null);
fail("IWindowManager.removeAppToken did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.moveAppToken(0, null);
fail("IWindowManager.moveAppToken did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.moveAppTokensToTop(null);
fail("IWindowManager.moveAppTokensToTop did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.moveAppTokensToBottom(null);
fail("IWindowManager.moveAppTokensToBottom did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
@SmallTest
public void testINJECT_EVENTS() {
try {
mWm.injectKeyEvent(new KeyEvent(0, 0), false);
fail("IWindowManager.injectKeyEvent did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.injectPointerEvent(MotionEvent.obtain(0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0), false);
fail("IWindowManager.injectPointerEvent did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.injectTrackballEvent(MotionEvent.obtain(0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0), false);
fail("IWindowManager.injectTrackballEvent did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
@SmallTest
public void testDISABLE_KEYGUARD() {
Binder token = new Binder();
try {
mWm.disableKeyguard(token, "foo");
fail("IWindowManager.disableKeyguard did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.reenableKeyguard(token);
fail("IWindowManager.reenableKeyguard did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.exitKeyguardSecurely(null);
fail("IWindowManager.exitKeyguardSecurely did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
@SmallTest
public void testSET_ANIMATION_SCALE() {
try {
mWm.setAnimationScale(0, 1);
fail("IWindowManager.setAnimationScale did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.setAnimationScales(new float[1]);
fail("IWindowManager.setAnimationScales did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
@SmallTest
public void testREAD_INPUT_STATE() {
try {
mWm.getSwitchState(0);
fail("IWindowManager.getSwitchState did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.getSwitchStateForDevice(0, 0);
fail("IWindowManager.getSwitchStateForDevice did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.getScancodeState(0);
fail("IWindowManager.getScancodeState did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.getScancodeStateForDevice(0, 0);
fail("IWindowManager.getScancodeStateForDevice did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.getKeycodeState(0);
fail("IWindowManager.getKeycodeState did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.getKeycodeStateForDevice(0, 0);
fail("IWindowManager.getKeycodeStateForDevice did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
@SmallTest
public void testSET_ORIENTATION() {
try {
mWm.setRotation(0, true, 0);
mWm.getSwitchState(0);
fail("IWindowManager.setRotation did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
}
}