Loading core/java/android/app/trust/TrustManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.app.trust; import android.Manifest; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SystemService; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; Loading @@ -40,6 +41,15 @@ import java.util.List; @SystemService(Context.TRUST_SERVICE) public class TrustManager { /** * Intent action used to identify services that can serve as significant providers. * * @hide */ @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) public static final String ACTION_BIND_SIGNIFICANT_PLACE_PROVIDER = "com.android.trust.provider.SignificantPlaceProvider.BIND"; private static final int MSG_TRUST_CHANGED = 1; private static final int MSG_TRUST_MANAGED_CHANGED = 2; private static final int MSG_TRUST_ERROR = 3; Loading core/java/android/hardware/location/ISignificantPlaceProvider.aidl 0 → 100644 +10 −0 Original line number Diff line number Diff line package android.hardware.location; import android.hardware.location.ISignificantPlaceProviderManager; /** * @hide */ oneway interface ISignificantPlaceProvider { void setSignificantPlaceProviderManager(in ISignificantPlaceProviderManager manager); } core/java/android/hardware/location/ISignificantPlaceProviderManager.aidl 0 → 100644 +8 −0 Original line number Diff line number Diff line package android.hardware.location; /** * @hide */ interface ISignificantPlaceProviderManager { void setInSignificantPlace(in boolean inSignificantPlace); } location/lib/java/com/android/location/provider/SignificantPlaceProvider.java 0 → 100644 +95 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.location.provider; import android.annotation.Nullable; import android.app.trust.TrustManager; import android.hardware.location.ISignificantPlaceProvider; import android.hardware.location.ISignificantPlaceProviderManager; import android.os.Binder; import android.os.IBinder; import android.os.Process; import android.os.RemoteException; import com.android.internal.annotations.GuardedBy; /** @hide */ public class SignificantPlaceProvider { public static final String ACTION = TrustManager.ACTION_BIND_SIGNIFICANT_PLACE_PROVIDER; private final IBinder mBinder; // write locked on mBinder, read lock is optional depending on atomicity requirements @Nullable private volatile ISignificantPlaceProviderManager mManager; @GuardedBy("mBinder") private boolean mInSignificantPlace = false; public SignificantPlaceProvider() { mBinder = new Service(); mManager = null; } public IBinder getBinder() { return mBinder; } /** Set whether the device is currently in a trusted location. */ public void setInSignificantPlace(boolean inSignificantPlace) { synchronized (mBinder) { if (inSignificantPlace == mInSignificantPlace) { return; } mInSignificantPlace = inSignificantPlace; } ISignificantPlaceProviderManager manager = mManager; if (manager != null) { try { manager.setInSignificantPlace(inSignificantPlace); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } private final class Service extends ISignificantPlaceProvider.Stub { Service() {} @Override public void setSignificantPlaceProviderManager(ISignificantPlaceProviderManager manager) { if (Binder.getCallingUid() != Process.SYSTEM_UID) { return; } synchronized (mBinder) { if (mInSignificantPlace) { try { manager.setInSignificantPlace(true); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } mManager = manager; } } } } Loading
core/java/android/app/trust/TrustManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.app.trust; import android.Manifest; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SystemService; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; Loading @@ -40,6 +41,15 @@ import java.util.List; @SystemService(Context.TRUST_SERVICE) public class TrustManager { /** * Intent action used to identify services that can serve as significant providers. * * @hide */ @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) public static final String ACTION_BIND_SIGNIFICANT_PLACE_PROVIDER = "com.android.trust.provider.SignificantPlaceProvider.BIND"; private static final int MSG_TRUST_CHANGED = 1; private static final int MSG_TRUST_MANAGED_CHANGED = 2; private static final int MSG_TRUST_ERROR = 3; Loading
core/java/android/hardware/location/ISignificantPlaceProvider.aidl 0 → 100644 +10 −0 Original line number Diff line number Diff line package android.hardware.location; import android.hardware.location.ISignificantPlaceProviderManager; /** * @hide */ oneway interface ISignificantPlaceProvider { void setSignificantPlaceProviderManager(in ISignificantPlaceProviderManager manager); }
core/java/android/hardware/location/ISignificantPlaceProviderManager.aidl 0 → 100644 +8 −0 Original line number Diff line number Diff line package android.hardware.location; /** * @hide */ interface ISignificantPlaceProviderManager { void setInSignificantPlace(in boolean inSignificantPlace); }
location/lib/java/com/android/location/provider/SignificantPlaceProvider.java 0 → 100644 +95 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.location.provider; import android.annotation.Nullable; import android.app.trust.TrustManager; import android.hardware.location.ISignificantPlaceProvider; import android.hardware.location.ISignificantPlaceProviderManager; import android.os.Binder; import android.os.IBinder; import android.os.Process; import android.os.RemoteException; import com.android.internal.annotations.GuardedBy; /** @hide */ public class SignificantPlaceProvider { public static final String ACTION = TrustManager.ACTION_BIND_SIGNIFICANT_PLACE_PROVIDER; private final IBinder mBinder; // write locked on mBinder, read lock is optional depending on atomicity requirements @Nullable private volatile ISignificantPlaceProviderManager mManager; @GuardedBy("mBinder") private boolean mInSignificantPlace = false; public SignificantPlaceProvider() { mBinder = new Service(); mManager = null; } public IBinder getBinder() { return mBinder; } /** Set whether the device is currently in a trusted location. */ public void setInSignificantPlace(boolean inSignificantPlace) { synchronized (mBinder) { if (inSignificantPlace == mInSignificantPlace) { return; } mInSignificantPlace = inSignificantPlace; } ISignificantPlaceProviderManager manager = mManager; if (manager != null) { try { manager.setInSignificantPlace(inSignificantPlace); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } private final class Service extends ISignificantPlaceProvider.Stub { Service() {} @Override public void setSignificantPlaceProviderManager(ISignificantPlaceProviderManager manager) { if (Binder.getCallingUid() != Process.SYSTEM_UID) { return; } synchronized (mBinder) { if (mInSignificantPlace) { try { manager.setInSignificantPlace(true); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } mManager = manager; } } } }