use of android.content.BroadcastReceiver in project android_frameworks_base by ParanoidAndroid.
the class BroadcastTest method testRemoteReceivePermissionDenied.
public void testRemoteReceivePermissionDenied() throws Exception {
setExpectedReceivers(new String[] { RECEIVER_RESULTS });
BroadcastReceiver finish = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
gotReceive(RECEIVER_RESULTS, intent);
}
};
getContext().sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_REMOTE_DENIED), null, finish, null, Activity.RESULT_CANCELED, null, null);
waitForResultOrThrow(BROADCAST_TIMEOUT);
}
use of android.content.BroadcastReceiver in project android_frameworks_base by ParanoidAndroid.
the class SettingsProvider method onCreate.
@Override
public boolean onCreate() {
mBackupManager = new BackupManager(getContext());
mUserManager = UserManager.get(getContext());
setAppOps(AppOpsManager.OP_NONE, AppOpsManager.OP_WRITE_SETTINGS);
establishDbTracking(UserHandle.USER_OWNER);
IntentFilter userFilter = new IntentFilter();
userFilter.addAction(Intent.ACTION_USER_REMOVED);
getContext().registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_USER_REMOVED)) {
final int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_OWNER);
if (userHandle != UserHandle.USER_OWNER) {
onUserRemoved(userHandle);
}
}
}
}, userFilter);
return true;
}
use of android.content.BroadcastReceiver in project android_frameworks_base by ParanoidAndroid.
the class BaseStatusBar method start.
public void start() {
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
mWindowManagerService = WindowManagerGlobal.getWindowManagerService();
mDisplay = mWindowManager.getDefaultDisplay();
// set up
mProvisioningObserver.onChange(false);
mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true, mProvisioningObserver);
mBarService = IStatusBarService.Stub.asInterface(ServiceManager.getService(Context.STATUS_BAR_SERVICE));
mStatusBarContainer = new FrameLayout(mContext);
mLocale = mContext.getResources().getConfiguration().locale;
mLayoutDirection = TextUtils.getLayoutDirectionFromLocale(mLocale);
// Connect in to the status bar manager service
StatusBarIconList iconList = new StatusBarIconList();
ArrayList<IBinder> notificationKeys = new ArrayList<IBinder>();
ArrayList<StatusBarNotification> notifications = new ArrayList<StatusBarNotification>();
mCommandQueue = new CommandQueue(this, iconList);
int[] switches = new int[7];
ArrayList<IBinder> binders = new ArrayList<IBinder>();
try {
mBarService.registerStatusBar(mCommandQueue, iconList, notificationKeys, notifications, switches, binders);
} catch (RemoteException ex) {
// If the system process isn't there we're doomed anyway.
}
mHaloActive = Settings.System.getInt(mContext.getContentResolver(), Settings.System.HALO_ACTIVE, 0) == 1;
createAndAddWindows();
disable(switches[0]);
setSystemUiVisibility(switches[1], 0xffffffff);
topAppWindowChanged(switches[2] != 0);
// StatusBarManagerService has a back up of IME token and it's restored here.
setImeWindowStatus(binders.get(0), switches[3], switches[4]);
setHardKeyboardStatus(switches[5] != 0, switches[6] != 0);
// Set up the initial icon state
int N = iconList.size();
int viewIndex = 0;
for (int i = 0; i < N; i++) {
StatusBarIcon icon = iconList.getIcon(i);
if (icon != null) {
addIcon(iconList.getSlot(i), i, viewIndex, icon);
viewIndex++;
}
}
// Set up the initial notification state
N = notificationKeys.size();
if (N == notifications.size()) {
for (int i = 0; i < N; i++) {
addNotification(notificationKeys.get(i), notifications.get(i));
}
} else {
Log.wtf(TAG, "Notification list length mismatch: keys=" + N + " notifications=" + notifications.size());
}
if (DEBUG) {
Slog.d(TAG, String.format("init: icons=%d disabled=0x%08x lights=0x%08x menu=0x%08x imeButton=0x%08x", iconList.size(), switches[0], switches[1], switches[2], switches[3]));
}
mCurrentUserId = ActivityManager.getCurrentUser();
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_USER_SWITCHED);
mContext.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_USER_SWITCHED.equals(action)) {
mCurrentUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
if (true)
Slog.v(TAG, "userId " + mCurrentUserId + " is in the house");
userSwitched(mCurrentUserId);
}
}
}, filter);
// Only watch for per app color changes when the setting is in check
if (ColorUtils.getPerAppColorState(mContext)) {
// Reset all colors
Bitmap currentBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
mCurrentCanvas = new Canvas(currentBitmap);
mCurrentCanvas.drawColor(0xFF000000);
BitmapDrawable currentBitmapDrawable = new BitmapDrawable(currentBitmap);
Bitmap newBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
mNewCanvas = new Canvas(newBitmap);
mNewCanvas.drawColor(0xFF000000);
BitmapDrawable newBitmapDrawable = new BitmapDrawable(newBitmap);
mTransition = new TransitionDrawable(new Drawable[] { currentBitmapDrawable, newBitmapDrawable });
mBarView.setBackground(mTransition);
mLastIconColor = ColorUtils.getColorSettingInfo(mContext, Settings.System.STATUS_ICON_COLOR);
mLastBackgroundColor = ColorUtils.getColorSettingInfo(mContext, ExtendedPropertiesUtils.isTablet() ? Settings.System.NAV_BAR_COLOR : Settings.System.STATUS_BAR_COLOR);
updateIconColor();
updateBackgroundColor();
// Listen for status bar icon color changes
mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.STATUS_ICON_COLOR), false, new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
updateIconColor();
}
});
// Listen for status bar background color changes
mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(ExtendedPropertiesUtils.isTablet() ? Settings.System.NAV_BAR_COLOR : Settings.System.STATUS_BAR_COLOR), false, new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
updateBackgroundColor();
}
});
// Listen for per-app-color state changes, this one will revert to stock colors all over
mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.PER_APP_COLOR), false, new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
if (!ColorUtils.getPerAppColorState(mContext)) {
for (int i = 0; i < ExtendedPropertiesUtils.PARANOID_COLORS_COUNT; i++) {
ColorUtils.ColorSettingInfo colorInfo = ColorUtils.getColorSettingInfo(mContext, Settings.System.STATUS_ICON_COLOR);
ColorUtils.setColor(mContext, ExtendedPropertiesUtils.PARANOID_COLORS_SETTINGS[i], colorInfo.systemColorString, "NULL", 1, 250);
}
}
}
});
}
attachPie();
// Listen for PIE gravity
mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.PIE_GRAVITY), false, new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
updatePieControls();
}
});
// Listen for HALO state
mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.HALO_ACTIVE), false, new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
updateHalo();
}
});
mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.HALO_SIZE), false, new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
restartHalo();
}
});
updateHalo();
SettingsObserver settingsObserver = new SettingsObserver(new Handler());
settingsObserver.observe();
}
use of android.content.BroadcastReceiver in project android_frameworks_base by ParanoidAndroid.
the class VibratorService method systemReady.
public void systemReady() {
mIm = (InputManager) mContext.getSystemService(Context.INPUT_SERVICE);
mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.VIBRATE_INPUT_DEVICES), true, new ContentObserver(mH) {
@Override
public void onChange(boolean selfChange) {
updateInputDeviceVibrators();
}
}, UserHandle.USER_ALL);
mContext.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
updateInputDeviceVibrators();
}
}, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mH);
updateInputDeviceVibrators();
}
use of android.content.BroadcastReceiver in project android_frameworks_base by ParanoidAndroid.
the class ActivityManagerService method finishBooting.
final void finishBooting() {
IntentFilter pkgFilter = new IntentFilter();
pkgFilter.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART);
pkgFilter.addDataScheme("package");
mContext.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String[] pkgs = intent.getStringArrayExtra(Intent.EXTRA_PACKAGES);
if (pkgs != null) {
for (String pkg : pkgs) {
synchronized (ActivityManagerService.this) {
if (forceStopPackageLocked(pkg, -1, false, false, false, false, 0)) {
setResultCode(Activity.RESULT_OK);
return;
}
}
}
}
}
}, pkgFilter);
ThemeUtils.registerThemeChangeReceiver(mContext, new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
mUiContext = null;
}
});
synchronized (this) {
// Ensure that any processes we had put on hold are now started
// up.
final int NP = mProcessesOnHold.size();
if (NP > 0) {
ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>(mProcessesOnHold);
for (int ip = 0; ip < NP; ip++) {
if (DEBUG_PROCESSES)
Slog.v(TAG, "Starting process on hold: " + procs.get(ip));
startProcessLocked(procs.get(ip), "on-hold", null);
}
}
if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
// Start looking for apps that are abusing wake locks.
Message nmsg = mHandler.obtainMessage(CHECK_EXCESSIVE_WAKE_LOCKS_MSG);
mHandler.sendMessageDelayed(nmsg, POWER_CHECK_DELAY);
// Tell anyone interested that we are done booting!
SystemProperties.set("sys.boot_completed", "1");
SystemProperties.set("dev.bootcomplete", "1");
for (int i = 0; i < mStartedUsers.size(); i++) {
UserStartedState uss = mStartedUsers.valueAt(i);
if (uss.mState == UserStartedState.STATE_BOOTING) {
uss.mState = UserStartedState.STATE_RUNNING;
final int userId = mStartedUsers.keyAt(i);
Intent intent = new Intent(Intent.ACTION_BOOT_COMPLETED, null);
intent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
broadcastIntentLocked(null, null, intent, null, null, 0, null, null, android.Manifest.permission.RECEIVE_BOOT_COMPLETED, AppOpsManager.OP_NONE, false, false, MY_PID, Process.SYSTEM_UID, userId);
}
}
}
}
}
Aggregations