com.android.server.LocalServices Java Examples

The following examples show how to use com.android.server.LocalServices. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NotificationRecord.java    From android_9.0.0_r45 with Apache License 2.0 7 votes vote down vote up
public NotificationRecord(Context context, StatusBarNotification sbn,
        NotificationChannel channel) {
    this.sbn = sbn;
    mTargetSdkVersion = LocalServices.getService(PackageManagerInternal.class)
            .getPackageTargetSdkVersion(sbn.getPackageName());
    mAm = ActivityManager.getService();
    mOriginalFlags = sbn.getNotification().flags;
    mRankingTimeMs = calculateRankingTimeMs(0L);
    mCreationTimeMs = sbn.getPostTime();
    mUpdateTimeMs = mCreationTimeMs;
    mInterruptionTimeMs = mCreationTimeMs;
    mContext = context;
    stats = new NotificationUsageStats.SingleNotificationStats();
    mChannel = channel;
    mPreChannelsNotification = isPreChannelsNotification();
    mSound = calculateSound();
    mVibration = calculateVibration();
    mAttributes = calculateAttributes();
    mImportance = calculateImportance();
    mLight = calculateLights();
    mAdjustments = new ArrayList<>();
    mStats = new NotificationStats();
    calculateUserSentiment();
    calculateGrantableUris();
}
 
Example #2
Source File: PackageInstallerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public PackageInstallerService(Context context, PackageManagerService pm) {
    mContext = context;
    mPm = pm;
    mPermissionManager = LocalServices.getService(PermissionManagerInternal.class);

    mInstallThread = new HandlerThread(TAG);
    mInstallThread.start();

    mInstallHandler = new Handler(mInstallThread.getLooper());

    mCallbacks = new Callbacks(mInstallThread.getLooper());

    mSessionsFile = new AtomicFile(
            new File(Environment.getDataSystemDirectory(), "install_sessions.xml"),
            "package-session");
    mSessionsDir = new File(Environment.getDataSystemDirectory(), "install_sessions");
    mSessionsDir.mkdirs();
}
 
Example #3
Source File: BatteryController.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void startTracking() {
    IntentFilter filter = new IntentFilter();

    // Battery health.
    filter.addAction(Intent.ACTION_BATTERY_LOW);
    filter.addAction(Intent.ACTION_BATTERY_OKAY);
    // Charging/not charging.
    filter.addAction(BatteryManager.ACTION_CHARGING);
    filter.addAction(BatteryManager.ACTION_DISCHARGING);
    mContext.registerReceiver(this, filter);

    // Initialise tracker state.
    BatteryManagerInternal batteryManagerInternal =
            LocalServices.getService(BatteryManagerInternal.class);
    mBatteryHealthy = !batteryManagerInternal.getBatteryLevelLow();
    mCharging = batteryManagerInternal.isPowered(BatteryManager.BATTERY_PLUGGED_ANY);
}
 
Example #4
Source File: StatsCompanionService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void pullWifiBytesTransfer(int tagId, List<StatsLogEventWrapper> pulledData) {
    long token = Binder.clearCallingIdentity();
    try {
        // TODO: Consider caching the following call to get BatteryStatsInternal.
        BatteryStatsInternal bs = LocalServices.getService(BatteryStatsInternal.class);
        String[] ifaces = bs.getWifiIfaces();
        if (ifaces.length == 0) {
            return;
        }
        NetworkStatsFactory nsf = new NetworkStatsFactory();
        // Combine all the metrics per Uid into one record.
        NetworkStats stats =
                nsf.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, null)
                        .groupedByUid();
        addNetworkStats(tagId, pulledData, stats, false);
    } catch (java.io.IOException e) {
        Slog.e(TAG, "Pulling netstats for wifi bytes has error", e);
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
 
Example #5
Source File: BatteryStatsService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
BatteryStatsService(Context context, File systemDir, Handler handler) {
    // BatteryStatsImpl expects the ActivityManagerService handler, so pass that one through.
    mContext = context;
    mUserManagerUserInfoProvider = new BatteryStatsImpl.UserInfoProvider() {
        private UserManagerInternal umi;
        @Override
        public int[] getUserIds() {
            if (umi == null) {
                umi = LocalServices.getService(UserManagerInternal.class);
            }
            return (umi != null) ? umi.getUserIds() : null;
        }
    };
    mStats = new BatteryStatsImpl(systemDir, handler, this, mUserManagerUserInfoProvider);
    mWorker = new BatteryExternalStatsWorker(context, mStats);
    mStats.setExternalStatsSyncLocked(mWorker);
    mStats.setRadioScanningTimeoutLocked(mContext.getResources().getInteger(
            com.android.internal.R.integer.config_radioScanningTimeout) * 1000L);
    mStats.setPowerProfileLocked(new PowerProfile(context));
}
 
Example #6
Source File: JobSchedulerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void onUserInteractionStarted(String packageName, int userId) {
    final int uid = mLocalPM.getPackageUid(packageName,
            PackageManager.MATCH_UNINSTALLED_PACKAGES, userId);
    if (uid < 0) {
        // Quietly ignore; the case is already logged elsewhere
        return;
    }

    long sinceLast = mUsageStats.getTimeSinceLastJobRun(packageName, userId);
    if (sinceLast > 2 * DateUtils.DAY_IN_MILLIS) {
        // Too long ago, not worth logging
        sinceLast = 0L;
    }
    final DeferredJobCounter counter = new DeferredJobCounter();
    synchronized (mLock) {
        mJobs.forEachJobForSourceUid(uid, counter);
    }
    if (counter.numDeferred() > 0 || sinceLast > 0) {
        BatteryStatsInternal mBatteryStatsInternal = LocalServices.getService
                (BatteryStatsInternal.class);
        mBatteryStatsInternal.noteJobsDeferred(uid, counter.numDeferred(), sinceLast);
    }
}
 
Example #7
Source File: DefaultPermissionGrantPolicy.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public DefaultPermissionGrantPolicy(Context context, Looper looper,
        @Nullable DefaultPermissionGrantedCallback callback,
        @NonNull PermissionManagerService permissionManager) {
    mContext = context;
    mHandler = new Handler(looper) {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == MSG_READ_DEFAULT_PERMISSION_EXCEPTIONS) {
                synchronized (mLock) {
                    if (mGrantExceptions == null) {
                        mGrantExceptions = readDefaultPermissionExceptionsLocked();
                    }
                }
            }
        }
    };
    mPermissionGrantedCallback = callback;
    mPermissionManager = permissionManager;
    mServiceInternal = LocalServices.getService(PackageManagerInternal.class);
}
 
Example #8
Source File: LockSettingsService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** Do not hold any of the locks from this service when calling. */
private boolean shouldCacheSpForUser(@UserIdInt int userId) {
    // Before the user setup has completed, an admin could be installed that requires the SP to
    // be cached (see below).
    if (Settings.Secure.getIntForUser(mContext.getContentResolver(),
                Settings.Secure.USER_SETUP_COMPLETE, 0, userId) == 0) {
        return true;
    }

    // If the user has an admin which can perform an untrusted credential reset, the SP needs to
    // be cached. If there isn't a DevicePolicyManager then there can't be an admin in the first
    // place so caching is not necessary.
    final DevicePolicyManagerInternal dpmi = LocalServices.getService(
            DevicePolicyManagerInternal.class);
    if (dpmi == null) {
        return false;
    }
    return dpmi.canUserHaveUntrustedCredentialReset(userId);
}
 
Example #9
Source File: UserManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private UserManagerService(Context context, PackageManagerService pm,
        UserDataPreparer userDataPreparer, Object packagesLock, File dataDir) {
    mContext = context;
    mPm = pm;
    mPackagesLock = packagesLock;
    mHandler = new MainHandler();
    mUserDataPreparer = userDataPreparer;
    synchronized (mPackagesLock) {
        mUsersDir = new File(dataDir, USER_INFO_DIR);
        mUsersDir.mkdirs();
        // Make zeroth user directory, for services to migrate their files to that location
        File userZeroDir = new File(mUsersDir, String.valueOf(UserHandle.USER_SYSTEM));
        userZeroDir.mkdirs();
        FileUtils.setPermissions(mUsersDir.toString(),
                FileUtils.S_IRWXU | FileUtils.S_IRWXG | FileUtils.S_IROTH | FileUtils.S_IXOTH,
                -1, -1);
        mUserListFile = new File(mUsersDir, USER_LIST_FILENAME);
        initDefaultGuestRestrictions();
        readUserListLP();
        sInstance = this;
    }
    mLocalService = new LocalService();
    LocalServices.addService(UserManagerInternal.class, mLocalService);
    mLockPatternUtils = new LockPatternUtils(mContext);
    mUserStates.put(UserHandle.USER_SYSTEM, UserState.STATE_BOOTING);
}
 
Example #10
Source File: DragState.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
void broadcastDragStartedLocked(final float touchX, final float touchY) {
    mOriginalX = mCurrentX = touchX;
    mOriginalY = mCurrentY = touchY;

    // Cache a base-class instance of the clip metadata so that parceling
    // works correctly in calling out to the apps.
    mDataDescription = (mData != null) ? mData.getDescription() : null;
    mNotifiedWindows.clear();
    mDragInProgress = true;

    mSourceUserId = UserHandle.getUserId(mUid);

    final UserManagerInternal userManager = LocalServices.getService(UserManagerInternal.class);
    mCrossProfileCopyAllowed = !userManager.getUserRestriction(
            mSourceUserId, UserManager.DISALLOW_CROSS_PROFILE_COPY_PASTE);

    if (DEBUG_DRAG) {
        Slog.d(TAG_WM, "broadcasting DRAG_STARTED at (" + touchX + ", " + touchY + ")");
    }

    mDisplayContent.forAllWindows(w -> {
        sendDragStartedLocked(w, touchX, touchY, mDataDescription);
    }, false /* traverseTopToBottom */ );
}
 
Example #11
Source File: LockTaskController.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Method to start lock task mode on a given task.
 *
 * @param task the task that should be locked.
 * @param isSystemCaller indicates whether this request was initiated by the system via
 *                       {@link ActivityManagerService#startSystemLockTaskMode(int)}. If
 *                       {@code true}, this intends to start pinned mode; otherwise, we look
 *                       at the calling task's mLockTaskAuth to decide which mode to start.
 * @param callingUid the caller that requested the launch of lock task mode.
 */
void startLockTaskMode(@NonNull TaskRecord task, boolean isSystemCaller, int callingUid) {
    if (!isSystemCaller) {
        task.mLockTaskUid = callingUid;
        if (task.mLockTaskAuth == LOCK_TASK_AUTH_PINNABLE) {
            // startLockTask() called by app, but app is not part of lock task whitelist. Show
            // app pinning request. We will come back here with isSystemCaller true.
            if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK, "Mode default, asking user");
            StatusBarManagerInternal statusBarManager = LocalServices.getService(
                    StatusBarManagerInternal.class);
            if (statusBarManager != null) {
                statusBarManager.showScreenPinningRequest(task.taskId);
            }
            return;
        }
    }

    // System can only initiate screen pinning, not full lock task mode
    if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK,
            isSystemCaller ? "Locking pinned" : "Locking fully");
    setLockTaskMode(task, isSystemCaller ? LOCK_TASK_MODE_PINNED : LOCK_TASK_MODE_LOCKED,
            "startLockTask", true);
}
 
Example #12
Source File: LauncherAppsService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public ActivityInfo resolveActivity(
        String callingPackage, ComponentName component, UserHandle user)
        throws RemoteException {
    if (!canAccessProfile(user.getIdentifier(), "Cannot resolve activity")) {
        return null;
    }

    final int callingUid = injectBinderCallingUid();
    long ident = Binder.clearCallingIdentity();
    try {
        final PackageManagerInternal pmInt =
                LocalServices.getService(PackageManagerInternal.class);
        return pmInt.getActivityInfo(component,
                PackageManager.MATCH_DIRECT_BOOT_AWARE
                        | PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
                callingUid, user.getIdentifier());
    } finally {
        Binder.restoreCallingIdentity(ident);
    }
}
 
Example #13
Source File: LauncherAppsService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private ParceledListSlice<ResolveInfo> queryActivitiesForUser(String callingPackage,
        Intent intent, UserHandle user) {
    if (!canAccessProfile(user.getIdentifier(), "Cannot retrieve activities")) {
        return null;
    }

    final int callingUid = injectBinderCallingUid();
    long ident = injectClearCallingIdentity();
    try {
        final PackageManagerInternal pmInt =
                LocalServices.getService(PackageManagerInternal.class);
        List<ResolveInfo> apps = pmInt.queryIntentActivities(intent,
                PackageManager.MATCH_DIRECT_BOOT_AWARE
                        | PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
                callingUid, user.getIdentifier());
        return new ParceledListSlice<>(apps);
    } finally {
        injectRestoreCallingIdentity(ident);
    }
}
 
Example #14
Source File: StatsCompanionService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void pullMobileBytesTransfer(int tagId, List<StatsLogEventWrapper> pulledData) {
    long token = Binder.clearCallingIdentity();
    try {
        BatteryStatsInternal bs = LocalServices.getService(BatteryStatsInternal.class);
        String[] ifaces = bs.getMobileIfaces();
        if (ifaces.length == 0) {
            return;
        }
        NetworkStatsFactory nsf = new NetworkStatsFactory();
        // Combine all the metrics per Uid into one record.
        NetworkStats stats =
                nsf.readNetworkStatsDetail(NetworkStats.UID_ALL, ifaces, NetworkStats.TAG_NONE, null)
                        .groupedByUid();
        addNetworkStats(tagId, pulledData, stats, false);
    } catch (java.io.IOException e) {
        Slog.e(TAG, "Pulling netstats for mobile bytes has error", e);
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
 
Example #15
Source File: NetworkStatsService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
NetworkStatsService(Context context, INetworkManagementService networkManager,
        AlarmManager alarmManager, PowerManager.WakeLock wakeLock, Clock clock,
        TelephonyManager teleManager, NetworkStatsSettings settings,
        NetworkStatsObservers statsObservers, File systemDir, File baseDir) {
    mContext = checkNotNull(context, "missing Context");
    mNetworkManager = checkNotNull(networkManager, "missing INetworkManagementService");
    mAlarmManager = checkNotNull(alarmManager, "missing AlarmManager");
    mClock = checkNotNull(clock, "missing Clock");
    mSettings = checkNotNull(settings, "missing NetworkStatsSettings");
    mTeleManager = checkNotNull(teleManager, "missing TelephonyManager");
    mWakeLock = checkNotNull(wakeLock, "missing WakeLock");
    mStatsObservers = checkNotNull(statsObservers, "missing NetworkStatsObservers");
    mSystemDir = checkNotNull(systemDir, "missing systemDir");
    mBaseDir = checkNotNull(baseDir, "missing baseDir");
    mUseBpfTrafficStats = new File("/sys/fs/bpf/traffic_uid_stats_map").exists();

    LocalServices.addService(NetworkStatsManagerInternal.class,
            new NetworkStatsManagerInternalImpl());
}
 
Example #16
Source File: GestureLauncherService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * @return true if camera was launched, false otherwise.
 */
@VisibleForTesting
boolean handleCameraGesture(boolean useWakelock, int source) {
    boolean userSetupComplete = Settings.Secure.getIntForUser(mContext.getContentResolver(),
            Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0;
    if (!userSetupComplete) {
        if (DBG) Slog.d(TAG, String.format(
                "userSetupComplete = %s, ignoring camera gesture.",
                userSetupComplete));
        return false;
    }
    if (DBG) Slog.d(TAG, String.format(
            "userSetupComplete = %s, performing camera gesture.",
            userSetupComplete));

    if (useWakelock) {
        // Make sure we don't sleep too early
        mWakeLock.acquire(500L);
    }
    StatusBarManagerInternal service = LocalServices.getService(
            StatusBarManagerInternal.class);
    service.onCameraLaunchGestureDetected(source);
    return true;
}
 
Example #17
Source File: ShortcutPackageInfo.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public int canRestoreTo(ShortcutService s, PackageInfo currentPackage, boolean anyVersionOkay) {
    PackageManagerInternal pmi = LocalServices.getService(PackageManagerInternal.class);
    if (!BackupUtils.signaturesMatch(mSigHashes, currentPackage, pmi)) {
        Slog.w(TAG, "Can't restore: Package signature mismatch");
        return ShortcutInfo.DISABLED_REASON_SIGNATURE_MISMATCH;
    }
    if (!ShortcutService.shouldBackupApp(currentPackage) || !mBackupSourceBackupAllowed) {
        // "allowBackup" was true when backed up, but now false.
        Slog.w(TAG, "Can't restore: package didn't or doesn't allow backup");
        return ShortcutInfo.DISABLED_REASON_BACKUP_NOT_SUPPORTED;
    }
    if (!anyVersionOkay && (currentPackage.getLongVersionCode() < mBackupSourceVersionCode)) {
        Slog.w(TAG, String.format(
                "Can't restore: package current version %d < backed up version %d",
                currentPackage.getLongVersionCode(), mBackupSourceVersionCode));
        return ShortcutInfo.DISABLED_REASON_VERSION_LOWER;
    }
    return ShortcutInfo.DISABLED_REASON_NOT_DISABLED;
}
 
Example #18
Source File: LauncherAppsService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public ApplicationInfo getApplicationInfo(
        String callingPackage, String packageName, int flags, UserHandle user)
        throws RemoteException {
    if (!canAccessProfile(user.getIdentifier(), "Cannot check package")) {
        return null;
    }

    final int callingUid = injectBinderCallingUid();
    long ident = Binder.clearCallingIdentity();
    try {
        final PackageManagerInternal pmInt =
                LocalServices.getService(PackageManagerInternal.class);
        ApplicationInfo info = pmInt.getApplicationInfo(packageName, flags,
                callingUid, user.getIdentifier());
        return info;
    } finally {
        Binder.restoreCallingIdentity(ident);
    }
}
 
Example #19
Source File: LauncherAppsService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isActivityEnabled(
        String callingPackage, ComponentName component, UserHandle user)
        throws RemoteException {
    if (!canAccessProfile(user.getIdentifier(), "Cannot check component")) {
        return false;
    }

    final int callingUid = injectBinderCallingUid();
    long ident = Binder.clearCallingIdentity();
    try {
        final PackageManagerInternal pmInt =
                LocalServices.getService(PackageManagerInternal.class);
        ActivityInfo info = pmInt.getActivityInfo(component,
                PackageManager.MATCH_DIRECT_BOOT_AWARE
                        | PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
                callingUid, user.getIdentifier());
        return info != null;
    } finally {
        Binder.restoreCallingIdentity(ident);
    }
}
 
Example #20
Source File: Searchables.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private ArrayList<ResolveInfo> createFilterdResolveInfoList(List<ResolveInfo> list) {
    if (list == null) {
        return null;
    }
    final ArrayList<ResolveInfo> resultList = new ArrayList<>(list.size());
    final PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class);
    final int callingUid = Binder.getCallingUid();
    final int callingUserId = UserHandle.getCallingUserId();
    for (ResolveInfo info : list) {
        if (pm.canAccessComponent(
                callingUid, info.activityInfo.getComponentName(), callingUserId)) {
            resultList.add(info);
        }
    }
    return resultList;
}
 
Example #21
Source File: ActivityStartInterceptor.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private boolean interceptSuspendedByAdminPackage() {
    DevicePolicyManagerInternal devicePolicyManager = LocalServices
            .getService(DevicePolicyManagerInternal.class);
    if (devicePolicyManager == null) {
        return false;
    }
    mIntent = devicePolicyManager.createShowAdminSupportIntent(mUserId, true);
    mIntent.putExtra(EXTRA_RESTRICTION, POLICY_SUSPEND_PACKAGES);

    mCallingPid = mRealCallingPid;
    mCallingUid = mRealCallingUid;
    mResolvedType = null;

    final UserInfo parent = mUserManager.getProfileParent(mUserId);
    if (parent != null) {
        mRInfo = mSupervisor.resolveIntent(mIntent, mResolvedType, parent.id, 0,
                mRealCallingUid);
    } else {
        mRInfo = mSupervisor.resolveIntent(mIntent, mResolvedType, mUserId, 0,
                mRealCallingUid);
    }
    mAInfo = mSupervisor.resolveActivity(mIntent, mRInfo, mStartFlags, null /*profilerInfo*/);
    return true;
}
 
Example #22
Source File: LauncherAppsService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public LauncherAppsImpl(Context context) {
    mContext = context;
    mUm = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
    mUserManagerInternal = Preconditions.checkNotNull(
            LocalServices.getService(UserManagerInternal.class));
    mActivityManagerInternal = Preconditions.checkNotNull(
            LocalServices.getService(ActivityManagerInternal.class));
    mShortcutServiceInternal = Preconditions.checkNotNull(
            LocalServices.getService(ShortcutServiceInternal.class));
    mShortcutServiceInternal.addListener(mPackageMonitor);
    mCallbackHandler = BackgroundThread.getHandler();
}
 
Example #23
Source File: BurnInProtectionHelper.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public BurnInProtectionHelper(Context context, int minHorizontalOffset,
        int maxHorizontalOffset, int minVerticalOffset, int maxVerticalOffset,
        int maxOffsetRadius) {
    mMinHorizontalBurnInOffset = minHorizontalOffset;
    mMaxHorizontalBurnInOffset = maxHorizontalOffset;
    mMinVerticalBurnInOffset = minVerticalOffset;
    mMaxVerticalBurnInOffset = maxVerticalOffset;
    if (maxOffsetRadius != BURN_IN_MAX_RADIUS_DEFAULT) {
        mBurnInRadiusMaxSquared = maxOffsetRadius * maxOffsetRadius;
    } else {
        mBurnInRadiusMaxSquared = BURN_IN_MAX_RADIUS_DEFAULT;
    }

    mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
    mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    context.registerReceiver(mBurnInProtectionReceiver,
            new IntentFilter(ACTION_BURN_IN_PROTECTION));
    Intent intent = new Intent(ACTION_BURN_IN_PROTECTION);
    intent.setPackage(context.getPackageName());
    intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    mBurnInProtectionIntent = PendingIntent.getBroadcast(context, 0,
            intent, PendingIntent.FLAG_UPDATE_CURRENT);
    DisplayManager displayManager =
            (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
    mDisplay = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
    displayManager.registerDisplayListener(this, null /* handler */);

    mCenteringAnimator = ValueAnimator.ofFloat(1f, 0f);
    mCenteringAnimator.setDuration(CENTERING_ANIMATION_DURATION_MS);
    mCenteringAnimator.setInterpolator(new LinearInterpolator());
    mCenteringAnimator.addListener(this);
    mCenteringAnimator.addUpdateListener(this);
}
 
Example #24
Source File: TimeZoneUpdateIdler.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onStartJob(JobParameters params) {
    RulesManagerService rulesManagerService =
            LocalServices.getService(RulesManagerService.class);

    Slog.d(TAG, "onStartJob() called");

    // Note: notifyIdle() explicitly handles canceling / re-scheduling so no need to reschedule
    // here.
    rulesManagerService.notifyIdle();

    // Everything is handled synchronously. We are done.
    return false;
}
 
Example #25
Source File: LockSettingsStorage.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Nullable
public PersistentDataBlockManagerInternal getPersistentDataBlock() {
    if (mPersistentDataBlockManagerInternal == null) {
        mPersistentDataBlockManagerInternal =
                LocalServices.getService(PersistentDataBlockManagerInternal.class);
    }
    return mPersistentDataBlockManagerInternal;
}
 
Example #26
Source File: Searchables.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the name of the web search activity.
 */
public synchronized ComponentName getWebSearchActivity() {
    final PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class);
    final int callingUid = Binder.getCallingUid();
    final int callingUserId = UserHandle.getCallingUserId();
    if (mWebSearchActivity != null
            && pm.canAccessComponent(callingUid, mWebSearchActivity, callingUserId)) {
        return mWebSearchActivity;
    }
    return null;
}
 
Example #27
Source File: LockSettingsService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void notifySeparateProfileChallengeChanged(int userId) {
    final DevicePolicyManagerInternal dpmi = LocalServices.getService(
            DevicePolicyManagerInternal.class);
    if (dpmi != null) {
        dpmi.reportSeparateProfileChallengeChanged(userId);
    }
}
 
Example #28
Source File: LockSettingsService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
protected LockSettingsService(Injector injector) {
    mInjector = injector;
    mContext = injector.getContext();
    mKeyStore = injector.getKeyStore();
    mRecoverableKeyStoreManager = injector.getRecoverableKeyStoreManager(mKeyStore);
    mHandler = injector.getHandler();
    mStrongAuth = injector.getStrongAuth();
    mActivityManager = injector.getActivityManager();

    mLockPatternUtils = injector.getLockPatternUtils();
    mFirstCallToVold = true;

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_USER_ADDED);
    filter.addAction(Intent.ACTION_USER_STARTING);
    filter.addAction(Intent.ACTION_USER_REMOVED);
    injector.getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter,
            null, null);

    mStorage = injector.getStorage();
    mNotificationManager = injector.getNotificationManager();
    mUserManager = injector.getUserManager();
    mStrongAuthTracker = injector.getStrongAuthTracker();
    mStrongAuthTracker.register(mStrongAuth);

    mSpManager = injector.getSyntheticPasswordManager(mStorage);

    LocalServices.addService(LockSettingsInternal.class, new LocalService());
}
 
Example #29
Source File: StatusBarController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void onAppTransitionFinishedLocked(IBinder token) {
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            StatusBarManagerInternal statusbar = LocalServices.getService(
                    StatusBarManagerInternal.class);
            if (statusbar != null) {
                statusbar.appTransitionFinished();
            }
        }
    });
}
 
Example #30
Source File: GlobalActions.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public GlobalActions(Context context, WindowManagerFuncs windowManagerFuncs) {
    mContext = context;
    mHandler = new Handler();
    mWindowManagerFuncs = windowManagerFuncs;

    mGlobalActionsProvider = LocalServices.getService(GlobalActionsProvider.class);
    if (mGlobalActionsProvider != null) {
        mGlobalActionsProvider.setGlobalActionsListener(this);
    } else {
        Slog.i(TAG, "No GlobalActionsProvider found, defaulting to LegacyGlobalActions");
    }
}