Methods Summary |
---|
private void | bindService()
if (mConnection == null) {
mConnection = new RemoteServiceConnection();
Intent intent = new Intent();
intent.setClassName(KEYGUARD_PACKAGE, KEYGUARD_CLASS);
Log.v(TAG, "BINDING SERVICE: " + KEYGUARD_CLASS);
if (!bindService(intent, mConnection, Context.BIND_AUTO_CREATE)) {
Log.v(TAG, "FAILED TO BIND TO KEYGUARD!");
}
} else {
Log.v(TAG, "Service already bound");
}
|
public void | onClick(android.view.View v)
try {
switch (v.getId()) {
case R.id.on_screen_turned_on:
mService.onScreenTurnedOn(mKeyguardShowCallback);
break;
case R.id.on_screen_turned_off:
mService.onScreenTurnedOff(WindowManagerPolicy.OFF_BECAUSE_OF_USER);
break;
case R.id.do_keyguard:
if (!mSentSystemReady) {
mSentSystemReady = true;
mService.onSystemReady();
}
mService.doKeyguardTimeout(null);
break;
case R.id.verify_unlock:
mService.doKeyguardTimeout(null);
// Wait for keyguard to lock and then try this...
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
try {
mService.verifyUnlock(mKeyguardExitCallback);
} catch (RemoteException e) {
Log.e(TAG, "Failed verifyUnlock()", e);
}
}
}, 5000);
break;
}
} catch (RemoteException e) {
Log.e(TAG, "onClick(): Failed due to remote exeption", e);
}
|
protected void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.keyguard_test_activity);
final int[] buttons = {
R.id.on_screen_turned_off, R.id.on_screen_turned_on,
R.id.do_keyguard, R.id.verify_unlock
};
for (int i = 0; i < buttons.length; i++) {
findViewById(buttons[i]).setOnClickListener(this);
}
Log.v(TAG, "Binding service...");
bindService();
|
public boolean | onOptionsItemSelected(android.view.MenuItem item)
// Handle item selection
switch (item.getItemId()) {
case R.id.none_menu_item:
setMode(MODE_NONE);
break;
case R.id.pin_menu_item:
setMode(MODE_PIN);
break;
case R.id.password_menu_item:
setMode(MODE_PASSWORD);
break;
case R.id.pattern_menu_item:
setMode(MODE_PATTERN);
break;
case R.id.sim_pin_menu_item:
setMode(MODE_SIM_PIN);
break;
case R.id.sim_puk_menu_item:
setMode(MODE_SIM_PUK);
break;
case R.id.add_widget_item:
startWidgetPicker();
break;
default:
return super.onOptionsItemSelected(item);
}
try {
mService.doKeyguardTimeout(null);
} catch (RemoteException e) {
Log.e(TAG, "Remote service died");
e.printStackTrace();
}
return true;
|
protected void | onPause()
super.onPause();
try {
if (mService != null) {
mService.setHidden(true);
}
} catch (RemoteException e) {
Log.e(TAG, "Remote service died");
e.printStackTrace();
}
|
protected void | onRestoreInstanceState(android.os.Bundle savedInstanceState)
super.onRestoreInstanceState(savedInstanceState);
setMode(savedInstanceState.getInt(SECURITY_MODE));
|
protected void | onResume()
super.onResume();
try {
if (mService != null) {
mService.setHidden(false);
}
} catch (RemoteException e) {
Log.e(TAG, "Remote service died");
e.printStackTrace();
}
|
protected void | onSaveInstanceState(android.os.Bundle outState)
super.onSaveInstanceState(outState);
outState.putInt(SECURITY_MODE, mSecurityMode);
|
private void | setMode(int mode)
mTestSimPin = false;
mTestSimPuk = false;
mLockPasswordEnabled = false;
mLockPatternEnabled = false;
switch(mode) {
case MODE_NONE:
mSecurityModeMock = DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
break;
case MODE_PIN:
mSecurityModeMock = DevicePolicyManager.PASSWORD_QUALITY_NUMERIC;
mLockPasswordEnabled = true;
break;
case MODE_PASSWORD:
mSecurityModeMock = DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC;
mLockPasswordEnabled = true;
break;
case MODE_PATTERN:
mSecurityModeMock = DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
mLockPatternEnabled = true;
break;
case MODE_SIM_PIN:
mTestSimPin = true;
break;
case MODE_SIM_PUK:
mTestSimPuk = true;
break;
}
mSecurityMode = mode;
|
private void | startWidgetPicker()
startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS));
|